jojovalenton
17th November 2016, 13:02
hi,

I just need one help on how can i get the result from tdsls4201s000 process. this is a sales order copy, is there a get command to get the result order number which is the destination order?

thanks,
jojo

mark_h
17th November 2016, 14:55
Is it on the form somewhere? I am not familiar with the session myself.

jojovalenton
17th November 2016, 15:07
hi mark,
thanks for reply. this session copy from an existing sales order and generate new sales order and then display a report showing source SO and new SO numbers. what i need is how to get the new SO number by using afs?

regards,
jojo

benito
17th November 2016, 15:28
if you just need the resulting order number, you can probably create a logic in the report to grab "orno.dest" variable.

jojovalenton
17th November 2016, 15:58
hi,
thanks. i will try on this.

regards,
jojo

mark_h
21st November 2016, 01:21
As a backup plan the other thing you can do is write the report to a file and read the file.

jojovalenton
22nd November 2016, 05:54
hi mark,

thanks. thats exactly what i did but i'm thinking of a possibility of putting get command within the copy afs? have u tried this in any of your afs scripts? maybe i just don't know the right way to do it.

regards,
jojo

manish_patel
22nd November 2016, 07:42
hi mark,

thanks. thats exactly what i did but i'm thinking of a possibility of putting get command within the copy afs? have u tried this in any of your afs scripts? maybe i just don't know the right way to do it.

regards,
jojo

I think Get command will not work for this session as on clicking continue button, end.program executed automatically.

You can try to import "tdsls041.orno" or "tdsls040.pono"

mark_h
22nd November 2016, 20:38
In difficult situations I use qkey for the session code. Then I can do things like export and import of variables to get what I need(I use if api.mode then do something). I mean I use the get command on some of the function servers I write to read fields - but if like Manish says the session ends once you save(or continue) and before you execute the get command it will not work. Does it get put in a table you could go read?

below is a quick snippet of code where I create a po and get the po number, but the session stays open in my case. You can also see a quick update that I write directly to a table since putting it on the form did not always work.

rc = stpapi.save( "tdpur4101m000", msg )
if(strip$(msg)<>"") then
msg = sprintf$("Save PO: %s",msg)
stpapi.end.session( "tdpur4101m000" )
return(0)
endif

stpapi.get.field( "tdpur4101m000", "tdpur040.orno", some.field )
created.po = val(some.field)
| IF buyer did not update correctly update it here.
stpapi.get.field( "tdpur4101m000", "tdpur040.ccon", some.field )
buyer = val(some.field)
if buyer = 0 then
db.retry.point()
select tdpur040.*
from tdpur040 for update
where tdpur040._index1 = {:created.po}
as set with 1 rows
selectdo
tdpur040.ccon = po.buyer
db.update(ttdpur040,db.retry)
endselect
commit.transaction()
endif

jojovalenton
23rd November 2016, 16:27
hi mark,
thanks. this is a nice script but i think it works after saving an afs create po.
regards,
jojo

mark_h
27th November 2016, 01:25
That was just an example of a get that I use, showing that if the session stays open you can get form fields after a save. If your session closes before you can execute a get then you have to find another method - be it import/export or reading a table. We do not use the sales module so I don't have sample code for anything using those sessions.

jojovalenton
28th November 2016, 06:37
thanks mark for tip.
regards,
jojo