jojovalenton
5th May 2014, 21:59
hello,

pls advise why this afs is inserting to the next prod. order number not to the current prod. order inside ticst001. i debug this and all variables are reading correctly from the source espc. the pdno and pono, both modify and add works the same in this script. thanks.

|* AFS Script
stpapi.put.field("ticst0101m100","ticst001.pdno",i.pdno)
stpapi.put.field("ticst0101m100","ticst001.pono",str$(i.pono))
ret = stpapi.find("ticst0101m100",error.msg)

if ret <> 1 then |not found
add = stpapi.synchronize.dialog("ticst0101m100","add",error.msg)
if add = 1 then

stpapi.put.field("ticst0101m100","ticst001.pdno",i.pdno)
stpapi.put.field("ticst0101m100","ticst001.pono",str$(i.pono))
stpapi.put.field("ticst0101m100","ticst001.sitm.segment.1","")
stpapi.put.field("ticst0101m100","ticst001.sitm.segment.2",i.sitm)
stpapi.put.field("ticst0101m100","ticst001.lsel",str$(etol(tclsel.any)))
stpapi.put.field("ticst0101m100","ticst001.qune",str$(qune.qty))
stpapi.put.field("ticst0101m100","ticst001.ques",str$(ques.qty))
stpapi.put.field("ticst0101m100","ticst001.ccur","SAR")
stpapi.put.field("ticst0101m100","ticst001.cwar","PP02")
stpapi.put.field("ticst0101m100","ticst001.cpes(1)",str$(cpes.pric))
stpapi.put.field("ticst0101m100","ticst001.qucs","0")
stpapi.put.field("ticst0101m100","ticst001.cpcs(1)","0")
stpapi.put.field("ticst0101m100","ticst001.issu",str$(i.qucs))
stpapi.put.field("ticst0101m100","ticst001.iswh","0")
stpapi.put.field("ticst0101m100","ticst001.opno","10")
stpapi.put.field("ticst0101m100","ticst001.aldt",str$(utc.num()))
stpapi.put.field("ticst0101m100","ticst001.bfls",str$(o.bfcp1))
stpapi.put.field("ticst0101m100","ticst001.drin",str$(etol(tcyesno.no)))
stpapi.put.field("ticst0101m100","ticst001.dris",str$(etol(tcyesno.yes)))
stpapi.put.field("ticst0101m100","ticst001.revn","0")
stpapi.put.field("ticst0101m100","ticst001.mcmd",str$(etol(tisfc.mcmd.print.and.alloc)))
stpapi.put.field("ticst0101m100","ticst001.preq","0.00")
stpapi.put.field("ticst0101m100","ticst001.cctt",str$(etol(ticst.updm.no.action)))
stpapi.put.field("ticst0101m100","ticst001.alty",str$(etol(tialty.input)))
stpapi.put.field("ticst0101m100","ticst001.owns",str$(etol(tcowns.comp.owned)))
stpapi.put.field("ticst0101m100","ticst001.aamt(1)","0.0000")
stpapi.put.field("ticst0101m100","ticst001.bwar","PP02")

|saving
retval = stpapi.insert("ticst0101m100", true, error.msg)
if retval = 1 then
message("save")
posting.to.orders(i.inno, i.pono, i.sitm)
else
message(error.msg)
endif
endif
endif
stpapi.end.session("ticst0101m100")
}

regards,

jojo

mark_h
5th May 2014, 23:22
Are you saying if you do stpapi.update and stpapi.insert, both work against the next production order? If you can insert I would not expect to need a find at all. But if something already exists then I would expect to see an stpapi.update. I would also not expect to see the production number and position as part of the input.

jojovalenton
6th May 2014, 08:24
hi mark,

thanks for reply. i will take note of your comments but is there any way that i can mark the line and copy or duplicate it and then put my values and save?

regards,

jojo

bhushanchanda
6th May 2014, 11:19
Hi,

When you see the session, the Production Order no is a view field. So, before inserting or modifying. You have to change the view.
Try this piece of code:-

stpapi.put.field( "ticst0101m100", "ticst001.pdno", tigil002.pdno)
ret = stpapi.change.view( "ticst0101m100", error )
stpapi.put.field( "ticst0101m100", "ticst001.pono", str$(tigil000.pono) )
ret = stpapi.find( "ticst0101m100" , err )
if ret = 1 then
ret = stpapi.mark( "ticst0101m100" , err )
ret = stpapi.synchronize.dialog("ticst0101m100", "modify", err.msg)
stpapi.put.field( "ticst0101m100", "ticst001.issu", str$(tigil005.issu) )
stpapi.put.field( "ticst0101m100", "ticst001.dris", str$(1) )
ret = stpapi.update( "ticst0101m100", TRUE, err )
if ret = 1 and isspace(error) then
stpapi.save( "ticst0101m100", err )
else
stpapi.recover( "ticst0101m100", err )
endif
endif

stpapi.end.session( "ticst0101m100" , err )
stpapi.end.session( "ticst0101m100" , errr1 )

jojovalenton
6th May 2014, 13:33
thanks mark & bhushan. now it's ok and inserting in the right order.

regards,

jojo

bhushanchanda
6th May 2014, 13:37
Hi,

If possible please post your code so that it will help people facing similar issues.

jojovalenton
7th May 2014, 14:31
I only used the same codes i posted above, i noticed only that my i.pono is reading from the wrong source that is why its inserting to diff prod. order.

thanks,

jojo

DDPatel
5th June 2021, 10:21
Hi,

When you see the session, the Production Order no is a view field. So, before inserting or modifying. You have to change the view.
Try this piece of code:-

stpapi.put.field( "ticst0101m100", "ticst001.pdno", tigil002.pdno)
ret = stpapi.change.view( "ticst0101m100", error )
stpapi.put.field( "ticst0101m100", "ticst001.pono", str$(tigil000.pono) )
ret = stpapi.find( "ticst0101m100" , err )
if ret = 1 then
ret = stpapi.mark( "ticst0101m100" , err )
ret = stpapi.synchronize.dialog("ticst0101m100", "modify", err.msg)
stpapi.put.field( "ticst0101m100", "ticst001.issu", str$(tigil005.issu) )
stpapi.put.field( "ticst0101m100", "ticst001.dris", str$(1) )
ret = stpapi.update( "ticst0101m100", TRUE, err )
if ret = 1 and isspace(error) then
stpapi.save( "ticst0101m100", err )
else
stpapi.recover( "ticst0101m100", err )
endif
endif

stpapi.end.session( "ticst0101m100" , err )
stpapi.end.session( "ticst0101m100" , errr1 )



Dear sir,

I have same script for AFS to update "ticst0101m100", Data is updating but i want to do 1 extra step, That is "Initiate inventory issue" (Form command - 'initiate.inventory').

long ret
string error(200)

stpapi.put.field("ticst0101m100","ticst001.pdno",ticsl051.pdno)
stpapi.put.field("ticst0101m100","ticst001.opno","10")

ret = stpapi.find("ticst0101m100",error)
if ret = 1 then
ret = stpapi.mark("ticst0101m100",error)
if ret = 1 then
ret = stpapi.synchronize.dialog("ticst0101m100", "modify", error)
if ret = 1 then
stpapi.put.field("ticst0101m100","ticst001.issu",str$(ticsl051.prqt))
stpapi.put.field("ticst0101m100","ticst001.lsel",str$(3)) |tclsel.specific
stpapi.put.field("ticst0101m100","ticst001.clot",ticsl051.ilot)
ret = stpapi.update("ticst0101m100", true, error)
if ret = 1 then
stpapi.form.command("ticst0101m100", 5, "initiate.inventory", error)
stpapi.set.report("ticst0101m100", "tisfc020701000", "D", error)
if isspace(error) then
|stpapi.print.report("ticst0101m100", error)
stpapi.continue.process("ticst0101m100", error)
endif
else
stpapi.recover("ticst0101m100",error)
endif
endif
endif
endif
stpapi.end.session("ticst0101m100")


Code is working good till "stpapi.update" statement. But after that how can i hit "Initiate inventory issue" option? i tried "stpapi.print.report" and "stpapi.continue.process" statement but no luck.


Regards,
DDPatel