Jaroslaw
31st March 2006, 19:55
Hi,
I am trying to insert a new lot through AFS using session tdltc0101m000 but every time it fails with message "Manufactured Item not allowed".
When I insert exactly the same item manually it saves without a problem.
Here is the code:

item = "1000-00556"
olot = tdltc.olot.prod
stpapi.put.field("tdltc0101m000", "tdltc001.item", item)
stpapi.put.field("tdltc0101m000", "tdltc001.olot", str$(olot))
stpapi.insert("tdltc0101m000", true, error)

I tried the following:
- using different items
- changing the item type in Maintain Item Data to Purchased
- changing variable olot to tdltc.olot.purch
- filling all fields on the form (using function stpapi.put.field) even though I want to accept the defaults for everything exept tiitm001.item and tiitm001.olot
In all cases, inserting manually works fine but using AFS fails with message "Manufactured Item not allowed":confused:

Any comments would be appreciated,
Jaroslaw

mark_h
31st March 2006, 20:54
Here is my routine to insert a lot:


function extern create_lot( domain tcitem purchase.item,
domain tdltc.clot purchase.lot,
domain tcdate purchaselot.date,
domain tcsuno supplier.number,
ref string msg())
{
msg = ""
stpapi.put.field("tdltc0101m000","tdltc001.item",purchase.item)
stpapi.put.field("tdltc0101m000","tdltc001.clot",purchase.lot)
stpapi.put.field("tdltc0101m000","tdltc001.olot",str$(tdltc.olot.purch))
stpapi.put.field("tdltc0101m000","tdltc001.suno",supplier.number)
stpapi.put.field("tdltc0101m000","tdltc001.oudt",str$(purchaselot.date))
rc = stpapi.insert("tdltc0101m000",1,msg)
stpapi.end.session("tdltc0101m000")
}


We are on 4c4 and service pack 18(I think).

Jaroslaw
31st March 2006, 22:42
Thanks for replying mark_h

I created a function almost exactly the same as your code with hard coded values (just for testing); here it is:

function test()
{
long ret
string error(500)

stpapi.put.field("tdltc0101m000", "tdltc001.item", "2000-00005")
stpapi.put.field("tdltc0101m000", "tdltc001.olot", str$(tdltc.olot.purch))
stpapi.put.field("tdltc0101m000", "tdltc001.suno", "MAKSTE")
stpapi.put.field("tdltc0101m000", "tdltc001.oudt", str$(date.num()))
ret = stpapi.insert("tdltc0101m000", true, error)
if ret <> 1 then
message(error)
endif
stpapi.end.session("tdltc0101m000")
}

The only difference is that I am not filling field tdltc001.clot because in our case it is generated by the system in main.table.io->before.write (of session tdltc0101m000).
When I run this code stpapi.insert comes back with exactly the same error:
"Manufactured Item not allowed"
This makes no sense because this time it is not even a manufactured item.

Any more suggestions ?

Jaroslaw

mark_h
31st March 2006, 23:29
Now I see - we do not create manufactured parts that are lot controlled. At least not on purpose. :)

Do you own source code? If so you can put it in debug and see what is causing the problem.

No promises that these would work for you. In the past sometimes I had to do the following to get some sessions to work:

(a) save followed by insert.
(b) update (can try both 0 and 1 in save parameter) followed by insert.

And sometimes I actually use Qkey to modify the session to get it to behave in the correct fashion.

Jaroslaw
3rd April 2006, 21:21
We have figured out what the problem was:
In the past a third form was attached to this session (by us). This form contained field tibom010.mitm "Manufactured Item" which was of type "input" (obviously wrong). As soon as I removed the form from the session, everything worked as expected.

Thanks for your help mark_h

Jaroslaw