ap2203
1st June 2012, 14:33
I want to upload some data in Item Master...
there are more than 20 000 items that required to be uploaded in Baan IV.
If anyone can help me with AFS script for tiitm0101m000 session....


I make code , but i have a problem with field titim001.citg

stpapi.put.field("tiitm0101m000","tiitm001.citg",zdsim004.citg)|citg
because i dont have data in tiitm0110m000 i put
stpapi.enum.answer("tiitm0101m000","tiitm01014",tcyesno.yes)

stpapi.insert("tiitm0101m000", 0, err.ins) |01.06.2012
after this I have message in err.ins "tiitm01014"

What can I do to insert data
Please help

mark_h
1st June 2012, 15:47
First on our system running tiitm0101m000 actually starts session tppdm0110m000. Then on our system tiitm01014 is only a warning. The stpapi.enum.answer does nothing - it is only used for questions. Are you positive the item is not being inserted anyway?

On my system the warning is "Note: No default item date for this item type and item group combination. There are several ways to handle this:
(1) Go add the item type and item group data in default item data session tppdm0109m000(on our system).
(2) Just print an error and skip the record.
(3) Include code to convert it to a known item type and item group combination. You can always print a report when insert the records and have the users go update it later.
(4) Just insert a record into tiitm002(table on our system).

Looks like there is nothing wrong with your code - but the data needs to be cleaned up. If I was loading 20k items I would send the errors to the customer and ask them how they wanted to handle it. My code to insert an item is pretty basic - but to get to that point I do a lot of converting and prechecking before this function even gets called.

function extern insert_item( domain tcitem baan.item,
domain tcdsca baan.dsca,
domain tckitm baan.kitm,
domain tccitg baan.citg,
domain tcctyp baan.ctyp,
domain tccsig baan.csig,
domain tccuni baan.cuni,
domain tccuni baan.stgu,
domain tccwar baan.cwar,
domain tckltc baan.kltc,
domain tcobpr baan.obpr,
domain tckpsl baan.kpsl,
domain tcqbia baan.npsl,
domain tcemno baan.buyr,
domain tcemno baan.cplb,
domain tcoltm baan.oltm,
domain tiqbm1 baan.unom,
domain tiqro1 baan.runi,
ref string msg())
{

msg = ""
stpapi.put.field( "tppdm0110m000", "tiitm001.item", baan.item ) | Put item again
|stpapi.put.field( "tppdm0110m000", "tiitm001.dscb", str$(baan.dsca) )
stpapi.put.field( "tppdm0110m000", "tiitm001.dsca", baan.dsca )
stpapi.put.field( "tppdm0110m000", "tiitm001.kitm", str$(baan.kitm) )
stpapi.put.field( "tppdm0110m000", "tiitm001.citg", baan.citg )
stpapi.put.field( "tppdm0110m000", "tiitm001.ctyp", baan.ctyp )
stpapi.put.field( "tppdm0110m000", "tiitm001.csig", str$(baan.csig) )
stpapi.put.field( "tppdm0110m000", "tiitm001.uset", " ALL" ) | Must enter unit set
stpapi.put.field( "tppdm0110m000", "tiitm001.cuni", str$(baan.cuni) )
stpapi.put.field( "tppdm0110m000", "tiitm001.stgu", str$(baan.stgu) )
stpapi.put.field( "tppdm0110m000", "tiitm001.cwar", str$(baan.cwar) )
stpapi.put.field( "tppdm0110m000", "tiitm001.kltc", str$(baan.kltc) )
stpapi.put.field( "tppdm0110m000", "tiitm001.obpr", str$(baan.obpr) )
stpapi.put.field( "tppdm0110m000", "tiitm001.kpsl", str$(baan.kpsl) )
stpapi.put.field( "tppdm0110m000", "tiitm001.npsl", str$(baan.npsl) )
stpapi.put.field( "tppdm0110m000", "tiitm001.buyr", str$(baan.buyr) )
stpapi.put.field( "tppdm0110m000", "tiitm001.cplb", str$(baan.cplb) )
stpapi.put.field( "tppdm0110m000", "tiitm001.oltm", str$(baan.oltm) )
stpapi.put.field( "tppdm0110m000", "tiitm001.unom", str$(baan.unom) )
stpapi.put.field( "tppdm0110m000", "tiitm001.runi", str$(baan.runi) )

| Possible questions
stpapi.enum.answer("tppdm0110m000", "tiitm0101s", tcyesno.yes)

rc = stpapi.insert( "tppdm0110m000", 1, msg )
if not isspace(msg) then
| Clear out what was done, do not worry about some.msg yet
rc = stpapi.recover("tppdm0110m000", some.msg)
| End the session.
stpapi.end.session("tppdm0110m000")
return
endif
}

ap2203
1st June 2012, 16:52
I put it my code I dont see the differences from your, except last instruction

| Possible questions
stpapi.enum.answer("tppdm0110m000", "tiitm0101s", tcyesno.yes)

I know that tiitm01014 is only warning means "Note: No default item date for this item type and item group combination.... " , but why I can not insert my item
I am sure that I dont have wanted item in the data base anyway?
I dont see what is wrong in my code
I ll try with your code

Thanks for help
BR

mark_h
1st June 2012, 18:48
I do not know for a fact, but I do not think it is the code. I think it is the data. You can do one of two things - add a valid item type and item group combo to the record and see if it then gets added. But I think what I would do is run the session manually and input the data by hand. See what warnings and messages you get. It may not have anything to do with the warning you see in the AFS code.

ap2203
4th June 2012, 11:53
You are right, problem is not in the code.
Problem is data .
I done what you said , and see it when I put data manually
AFS work correct

Thanks for suggestion
BR