raikar_raviraj
13th February 2012, 13:33
Hi,

We have written an AFS code in ERP LN for execution of Confirm Receipt(tdpur4106m000) through PO Line Status session (tdpur4534m000).
But we are not able to achieve the end result.

Process executes completely, but it doesnt perform the intended functionality. DAL is not activated on tables, hence AFS is being used.

Find below the piece of code written.


function process()
|Function to call Print PO and Purchase Receipts session
{
long find.ret |Find Ret Value
domain tcmcs.st60m next.step |Next Step

stpapi.put.field("tdpur4534m000", "tdpur401.orno", pord)
stpapi.put.field("tdpur4534m000", "tdpur401.pono", str$(poln))
stpapi.put.field("tdpur4534m000", "tdpur401.sqnb", str$(pops))
find.ret = stpapi.find( "tdpur4534m000" , error)

stpapi.get.field("tdpur4534m000", "next.step", next.step )

if pos(next.step,"Print Purchase Orders") then
execute.Print.Purchase.Orders()
stpapi.get.field("tdpur4534m000", "next.step", next.step )
endif
if pos(next.step,"Purchase Receipts") then
execute.Purchase.Receipts()
endif
stpapi.end.session("tdpur4534m000" , error)
}

function execute.Print.Purchase.Orders()
|Function to execute Print PO
{
stpapi.handle.subproc("tdpur4534m000", "tdpur4401m000", "add")
stpapi.form.command("tdpur4534m000", 5, "execute.next.step", error)
stpapi.set.report("tdpur4401m000", "rtdpur440101000", "D", error)
stpapi.print.report("tdpur4401m000", error)
stpapi.end.session("tdpur4401m000" , error)
}

function execute.Purchase.Receipts()
||Function to execute Purchase Receipts
{
domain tcdate t
domain tcorno orno
domain tcpono pono
domain tcpono seqn
long retval

stpapi.form.command("tdpur4534m000", 5, "execute.next.step", error)
orno = tdpurf4106m000.get.Purchase_Order()
pono = tdpurf4106m000.get.Order_Line_Receipt()
seqn = tdpurf4106m000.get.Sequence()
tdpurf4106m000.put.Purchase_Order(pord)
tdpurf4106m000.put.Order_Line_Receipt(poln)
tdpurf4106m000.put.Sequence(pops)
t = utc.num()
tdpurf4106m000.put.Actual_Receipt_Date(t)
stpapi.put.field("tdpur4106m000", "tdpur406.rcno", "R3")
stpapi.put.field("tdpur4106m000", "tdpur406.fire", "tcyesno.no")
stpapi.put.field("tdpur4106m000", "form.qodl", str$(num_unit))
stpapi.put.field("tdpur4106m000", "tdpur406.qidl", str$(num_unit))
stpapi.form.command("tdpur4106m000", 5, "confirm.receipts", error)
stpapi.end.session("tdpur4106m000" , error)
}

One thing i have observed is values are not being passed in to the child session. Have written get.field function, but that doesnt return any value.

Please help.

mark_h
13th February 2012, 16:02
Does the first step - print work? I also notice on the second step you do not have a stpapi.handle.subproc for tdpur4106m000? Probably need that first. Also why are you getting fields, then turning around and putting them? I mean if the fields are supposed to be already populated then I can see using the get field just to see what they are. And if the fields are supposed to be populated then you don't need the put. BUT if the fields are not filled then you should put them first, then get them to see if they are populated.

I won't be much help since this is LN. So I am not familiar with the sessions and the requirements.

raikar_raviraj
13th February 2012, 21:29
The Print works perfectly fine. I used stpapi.handle.subproc, just before the stpapi.form.command, but that doesnt help either. I used the get functions, just to check if proper values are passed from main session to child session. But null values are returned. Hence put values for mandatory fields of Confirm Receipt are used. This is a peculiar problem. If anyone has worked with similar structure or necessity before, please help.

mark_h
14th February 2012, 00:01
Well usually the stpapi.handle.subproc sets up the communication link for the main session to the called session. I was hoping that was it, but it sounds like you tried it. The only other thing I can think of is - do you have to call it this way - from tdpur4534m000 to tdpur4106m000? I was wondering if you could just call tdpur4106m000 directly since it looks like a main session. Then you would have to put all the fields, do an insert, etc. to get a receipt. Sorry not much help, but never used LN and not sure how it works.

Do you own source code? You might be able to put the sessions in debug mode to see what is happening.

raikar_raviraj
14th February 2012, 09:54
Mark,

The session behaves and opens differently if called from a parent session and if called individually. Refer the attached screenshot. I would like it to be called from tdpur4534m000, as the Receipt Confirmation is done through this session.

Also tdpur4106m000 is a main session in itself, hence handle subproc doesnt work either.

When i manually operate it in the above fashion, it works perfectly fine. But fails to work through AFS. Have debugged the script, but cant trace the problem.
It operates successfully without giving any errors, but doesnt do the intended functionality.

Also find attached the AFS Log.

mark_h
14th February 2012, 16:20
I see what you are talking about in the log file. Once tdpur4106m000 is up those fields should be viewed. I am not sure what might solve it. If you can debug tdpur4106m000 I would pay attention to when and how the session starts. Checking at the start to make sure everything is filled correctly before the form starts coming up. You might have to run it manually and document what happens, then run thru AFS and see what happens. There has to be a difference to account for those fields being empty. YYou might even have to trace it all the way thru. Not an easy task. Sorry not much help, but just not seeing many options.