guilmor
3rd January 2003, 11:28
Hi Baanboard,
I'm trying to copy items using afs from session tiitm0101m000.
I haven't found any "stpapi.dupl.occur("...")" command to do this.
I guess I should do something like this:
stpapi.put.field("tiitm0101m000","tiitm001.item","TEMPLATEITEM")
ret = stpapi.find("tiitm0101m000")
if ret = 1 then
stpapi.handle.subproc("tiitm0101m000","tiitm0202s000","add")
stpapi.dupl.occur("tiitm0101m000") (this is what I can't find in manual)
stpapi.put.field("tiitm0202s000","copy.item","NEWITEM")
stpapi.continue.process("tiitm0202s000")
stpapi.end.session("tiitm0202s000")
endif
anyone can help?
Thanks, Guilmor.
mark_h
3rd January 2003, 16:54
I have never seen a stpapi command to duplicate or copy a record. Have you tried just doing a find of the item you want to copy, then put the new item, then just do a save or insert. Not sure what would happen to all of the other fields, but it is something to try.
Mark
cherokee
29th September 2005, 20:28
Hello there,
I just tried this suggestion. When I try the insert it, it gives me "Item Type Not allowed"... I think is validating every field again. I do not know if when I put the new item code it blanks out all other fields.
stpapi.put.field("tppdm0110m000","tiitm001.item",i.item)
if stpapi.find("tppdm0110m000") = 1
stpapi.put.field("tppdm0110m000","tiitm001.item",copy.item)
stpapi.insert("tppdm0110m000",true,err.mesg)
if not isspace(err.mesg) then
stpapi.recover("tppdm0110m000", err.mesg)
stpapi.end.session("tppdm0110m000")
return(false)
endif
stpapi.end.session("tppdm0110m000")
return(true)
endif
cherokee
29th September 2005, 20:52
Hello again,
Actually it works only if you enter the item type and Item group, then It only creates the Item based on the Default Item Data. The down side of this is that, you are not copying all data from your source Item, you are just creating new item with a different code. The rest of the data isn't copied over to the new item.
stpapi.put.field("tppdm0110m000","tiitm001.item",i.item)
if stpapi.find("tppdm0110m000") = 1 then
stpapi.put.field("tppdm0110m000","tiitm001.item",copy.item)
stpapi.put.field("tppdm0110m000","tiitm001.kitm",str$(tiitm001.kitm))
stpapi.put.field("tppdm0110m000","tiitm001.citg",tiitm001.citg)
stpapi.insert("tppdm0110m000",true,err.mesg)
if not isspace(err.mesg) then
stpapi.recover("tppdm0110m000", err.mesg)
stpapi.end.session("tppdm0110m000")
return(false)
endif
stpapi.end.session("tppdm0110m000")
return(true)
endif
return(false)
It is a step forward for me at least.
:rolleyes: