Frank Liu
3rd May 2016, 11:53
Hi,

I am trying to use AFS to run Form-Command “initiate inventory issue…” on session Material to Issue for Production Orders, ticst0101m100, but “stpapi.form.command” always returned an error message “device not found” no matter I set the device display “D” or file “ASCIF”. Could you please help to identify? My Ln version is FP9 and my code is at below,

stpapi.put.field("ticst0101m100","ticst001.pdno","PO2000358")
stpapi.put.field("ticst0101m100","ticst001.pono",str$(20))

if stpapi.find("ticst0101m100",error.msg) = 1 then

if stpapi.synchronize.dialog("ticst0101m100","modify",error.msg) = 1 then

stpapi.put.field("ticst0101m100", "ticst001.issu", str$(1))
stpapi.put.field( "ticst0101m100", "ticst001.dris", str$(tcyesno.yes) )

if stpapi.update("ticst0101m100", true, error.msg) <> 1 then

message("AFS update error ", error.msg)
stpapi.recover( "ticst0101m100",error.msg )

else
printer.device = "ASCIF"
stpapi.enum.answer( "ticst0101m100","ticst01011", tcyesno.yes)
stpapi.set.report("ticst0101m100","tisfc020701000",printer.device, error.msg)

|stpapi.continue.process("ticst0101m100", error.msg)

stpapi.form.command("ticst0101m100", 5, "initiate.inventory", error )

if error <> "" then
message(error&", Error on AFS initiate inventory", error.msg)
else
message(error&" Ok : issued", error.msg)
endif
endif
else
message("synchronize Error : 3", error.msg)
endif
else
message("Find Error : 4", error.msg)
endif

mark_h
3rd May 2016, 13:46
Is this a typo:


stpapi.set.report("ticst0101m100","tisfc020701000",printer.device, error.msg)


if that is the right report it should be rtisfc020701000. That is the first thing I noticed.

Frank Liu
4th May 2016, 04:02
Thanks,Mark

I found the report name "tisfc020701000" on session Slect Device(ttstpsplopen), when I run it manually. I have tried to change the report name to "rtisfc020701000" but it still doesn't work.

frenny
4th May 2016, 06:40
hello ,

try this code .it will work, ( put your production order no and line value )

stpapi.put.field("ticst0101m100","ticst001.pdno","PA0000116")
stpapi.put.field("ticst0101m100","ticst001.pono",str$(10))
ret = stpapi.find("ticst0101m100", ret.err)
if ret = 1 then
ret = stpapi.synchronize.dialog("ticst0101m100", "modify", ret.err)
stpapi.put.field("ticst0101m100", "ticst001.issu", str$(1))
stpapi.put.field( "ticst0101m100", "ticst001.dris", str$(tcyesno.yes))
ret = stpapi.update("ticst0101m100", true, ret.err)
if ret then

stpapi.handle.subproc("ticst0101m100","timfc0101m000","search")
stpapi.form.command( "ticst0101m100", 2, "timfc0101m000", ret.err)
stpapi.form.command("timfc0101m000",5,"initiate.order", ret.err)
if not isspace(ret.err) then
message("Process Fail - Reason:" &ret.err)
endif
stpapi.end.session("timfc0101m000")

endif
else
ret.err = "Position 10 not found for Production Order PA0000116"
endif
stpapi.end.session("ticst0101m100")
stpapi.end.session("ticst0101m100")

Ajesh
4th May 2016, 08:00
First of all you need to put the correct report name.

Secondly, Does your session has a print command or you are sending the records through brp.commands?

If your session is using brp.commands try setting the device name through the predefined variable spool.device.Even if you are not using brp commands try setting the report device in spool.device.

Declare as



string spool.device

spool.device = "ASCIF"

Frank Liu
4th May 2016, 08:53
Hi Frenny,

It is working fine using your code. Thanks a lot!!

Frank Liu
4th May 2016, 08:54
Hi Frenny,

It is working fine using your code. Thanks a lot!!