Babu N
9th March 2018, 09:07
Hi,
I am writing an AFS to upload price book lines from text file. As for a me my script is fine and throws no error, but the data is not getting processed and the price is not getting uploaded. Also, the report output is not getting generated. I have pasted my script below.
function process.price.book.lines()
{
long ret
effd = utc.num()
stpapi.put.field("tdpcg0131m000","tdpcg031.prbk",pric.book)
stpapi.put.field("tdpcg0131m000","tdpcg031.item",in.item)
stpapi.find("tdpcg0131m000",errm)
stpapi.mark("tdpcg0131m000",errm)
stpapi.handle.subproc("tdpcg0131m000","tdpcg0231m000",errm)
stpapi.put.field("tdpcg0231m000","enum",str$(etol(tdpcg.ampe.amount)))
stpapi.put.field("tdpcg0231m000","prc.valby",str$(valby))
stpapi.put.field("tdpcg0231m000","working.curr",str$(ccur))
stpapi.put.field("tdpcg0231m000","new.effdte",str$(effd))
stpapi.put.field("tdpcg0231m000","new.expdte",str$(0))
stpapi.put.field("tdpcg0231m000","simonl",str$(etol(tcyesno.no)))
stpapi.put.field("tdpcg0231m000","prtchg",str$(etol(tcyesno.yes)))
stpapi.set.report("tdpcg0231m000","rtdpcg023111000","D66",errm)
if isspace(errm) then
stpapi.form.command("tdpcg0231m000",5,"exec.cont.process",errm)
else
stpapi.recover("tdpcg0231m000",errm)
endif
stpapi.end.session("tdpcg0231m000")
stpapi.end.session("tdpcg0131m000")
}
Nothing is happening and no error is poping up.
If any one can throw some light on what I am missing here, it will be much helpful as I am struck for hours on this.
Thanks in advance
Regards
Babu N
mark_h
9th March 2018, 16:48
Not familiar with the session or LN, but does the find work is my first question? And does just doing a find launch the subsession?
stpapi.put.field("tdpcg0131m000","tdpcg031.prbk",pric.book)
stpapi.put.field("tdpcg0131m000","tdpcg031.item",in.item)
stpapi.find("tdpcg0131m000",errm)
stpapi.mark("tdpcg0131m000",errm)
stpapi.handle.subproc("tdpcg0131m000","tdpcg0231m000",errm)
If not then right after the stpapi.handle I would expect to see a command to launch the subsession - a continue or some kind of form command to get the subsession to start.
vinceco252
12th March 2018, 16:11
Is this something you could use an Excel upload for?
Babu N
13th March 2018, 09:34
Hi Vincent,
The idea is to read the price from a text file and upload to the system.
Initially I used the script.
effd = utc.num()
expd = utc.num()
effd.r = utc.num()
effd.r = effd.r + 300
expd.r = utc.num()
expd.r = expd.r + 300
stpapi.put.field("tdpcg0231m000","type.f",str$(etol(tdpcg.mous.so)))
stpapi.put.field("tdpcg0231m000","type.t",str$(etol(tdpcg.mous.so)))
stpapi.put.field("tdpcg0231m000","prbk.f",str$(pric.book))
stpapi.put.field("tdpcg0231m000","prbk.t",str$(pric.book))
stpapi.put.field("tdpcg0231m000","ccur.f",str$(" "))
stpapi.put.field("tdpcg0231m000","ccur.t",str$("ZZZ"))
stpapi.put.field("tdpcg0231m000","otbp.f",str$(" "))
stpapi.put.field("tdpcg0231m000","otbp.t",str$("ZZZZZZZZZ"))
stpapi.put.field("tdpcg0231m000","sfbp.f",str$(" "))
stpapi.put.field("tdpcg0231m000","sfbp.t",str$("ZZZZZZZZZ"))
stpapi.put.field("tdpcg0231m000","qtun.f",str$(" "))
stpapi.put.field("tdpcg0231m000","qtun.t",str$("ZZZ"))
stpapi.put.field("tdpcg0231m000","niqt.f",str$("0.0000"))
stpapi.put.field("tdpcg0231m000","miqt.t",str$("999999999.9999"))
stpapi.put.field("tdpcg0231m000","f.pb.prty.f",str$(etol(tdpcg.prit.not.applicable)))
stpapi.put.field("tdpcg0231m000","f.pb.prty.t",str$(etol(tdpcg.prit.service.subc)))
stpapi.put.field("tdpcg0231m000","efdt.f",str$("0"))
stpapi.put.field("tdpcg0231m000","efdt.t",str$(effd.r))
stpapi.put.field("tdpcg0231m000","exdt.f",str$("0"))
stpapi.put.field("tdpcg0231m000","exdt.t",str$(expd.r))
stpapi.put.field("tdpcg0231m000","item.f",str$(in.item))
stpapi.put.field("tdpcg0231m000","item.t",str$(in.item))
stpapi.put.field("tdpcg0231m000","enum",str$(etol(tdpcg.ampe.amount)))
stpapi.put.field("tdpcg0231m000","prc.valby",str$(valby))
stpapi.put.field("tdpcg0231m000","working.curr",str$(ccur))
stpapi.put.field("tdpcg0231m000","new.effdte",str$(effd))
stpapi.put.field("tdpcg0231m000","new.expdte",str$(expd))
stpapi.put.field("tdpcg0231m000","simonl",str$(etol(tcyesno.no)))
stpapi.set.report("tdpcg0231m000","rtdpcg023111000","D66",errm)
stpapi.form.command("tdpcg0231m000",5,"exec.cont.process",errm)
|stpapi.continue.process("tdpcg0231m000",errm)
if isspace(errm) then
stpapi.form.command("tdpcg0231m000",5,"exec.print.data",errm)
|stpapi.print.report("tdpcg0231m000",errm)
else
stpapi.recover("tdpcg0231m000",errm)
endif
|stpapi.form.command("tdpcg0231m000",5,"exec.cont.process",errm)
|ret = stpapi.save("tdpcg0231m000",errm)
stpapi.end.session("tdpcg0231m000")
It throws no error message but still does not process. Then I changed the script to.
effd = utc.num()
stpapi.put.field("tdpcg0131m000","tdpcg031.prbk",pric.book)
stpapi.put.field("tdpcg0131m000","tdpcg031.item",in.item)
stpapi.find("tdpcg0131m000",errm)
stpapi.mark("tdpcg0131m000",errm)
stpapi.handle.subproc("tdpcg0131m000","tdpcg0231m000",errm)
stpapi.put.field("tdpcg0231m000","enum",str$(etol(tdpcg.ampe.amount)))
stpapi.put.field("tdpcg0231m000","prc.valby",str$(valby))
stpapi.put.field("tdpcg0231m000","working.curr",str$(ccur))
stpapi.put.field("tdpcg0231m000","new.effdte",str$(effd))
stpapi.put.field("tdpcg0231m000","new.expdte",str$(0))
stpapi.put.field("tdpcg0231m000","simonl",str$(etol(tcyesno.no)))
stpapi.put.field("tdpcg0231m000","prtchg",str$(etol(tcyesno.yes)))
stpapi.set.report("tdpcg0231m000","rtdpcg023111000","D66",errm)
if isspace(errm) then
|stpapi.form.command("tdpcg0231m000",5,"exec.print.data",errm)
|stpapi.print.report("tdpcg0231m000",errm)
stpapi.form.command("tdpcg0231m000",5,"exec.cont.process",errm)
else
stpapi.recover("tdpcg0231m000",errm)
endif
stpapi.end.session("tdpcg0231m000")
stpapi.end.session("tdpcg0131m000")
But with same effect. It does not throw any error, but does not process the record. I am clueless about if I am missing some syntax here.
Thanks
Regards
Babu N
mark_h
18th March 2018, 00:52
On this part of the post.
stpapi.mark("tdpcg0131m000",errm)
stpapi.handle.subproc("tdpcg0131m000","tdpcg0231m000",errm)
Even with this code right after the stpapi.handle I expect a command to launch tdpcg0231m000. Some kind of stpapi.form.command for ln. When you run tdpcg0131m000 manually and mark a record what do you do to get tdpcg0231m000 to kick off? You have to replicate every click or button push you use manually when using the api commands.
In 4c4 I can run a shell window and use ps and watch the processes run. To you can see that main session ppid is the parent of the subsession ppid. In your case it looks like a main launching another main session (stpapi.handle.subproc("tdpcg0131m000","tdpcg0231m000",errm)). Which is fine, but I still think the first main should probably show as the parent of the second main session.