FoxZapper
31st October 2005, 14:06
Hello,

I am trying to automate the Collect Order Process.
In this, I managed to:
1. create a new sales order header
2. insert new sales order lines.

And when I save the record, the Maintain Outbound Data session (tdilc4102s000) gets activated immediately as its an order of type "Collect Order" [Note: tcmcs0142m000: Maintain Order Type with Collect Order = Yes]

I have already successfully managed to run the Maintain Outbound Process via the Maintain Outbound Data (tdilc4101m000) and the subsequent occurance of the subsession tdils4102s000.

However, in this case, the program fails as I am assuming there are 2 subsessions (tdsls4105s000 and tdilc4102s000) to be activated from the main session Maintain Sales Order tdsls4101m000

Has someone come across this issue?
Any suggestions are welcome.

Regards,

Arun


function insert.so.lines.and.outbound.data()
{
long ret.val, ret.val1, ret.val2, ret.val3
string so.str(8)
string err.mess(132)
string so.number.str(10)
string position.string(5)

get.max.position.for.order()

stpapi.put.field("tdsls4101m000", "tdsls040.orno", so.number.str)
ret.val1 = stpapi.find("tdsls4101m000", error.msg)

if ret.val1 = 1 then

stpapi.handle.subproc("tdsls4101m000", "tdsls4105s000", "add")
stpapi.continue.process("tdsls4101m000", error.msg)
stpapi.get.field("tdsls4105s000", "tdsls041.orno", so.str)

stpapi.put.field("tdsls4105s000", "tdsls041.orno", so.number.str)
stpapi.put.field("tdsls4105s000", "tdsls041.pono", position.number.str)
stpapi.put.field("tdsls4105s000", "tdsls041.item", "51209")
stpapi.put.field("tdsls4105s000", "tdsls041.cwar", "001")
stpapi.put.field("tdsls4105s000", "tdsls041.oqua", "1")
stpapi.put.field("tdsls4105s000", "tdsls041.pric", "735")
stpapi.put.field("tdsls4105s000", "tdsls041.ldam", "0")
stpapi.put.field("tdsls4105s000", "tdsls041.disc", "0")
ret.val2 = stpapi.insert("tdsls4105s000", true, err.mesg)
if ret.val2 <> 1 then
|* If error, then recover the session
ret.val3 = stpapi.recover("tdsls4105s000", err.mess)
create.so.insert.err.file()
else
success.rec = success.rec + 1
|* Maintain Outbound Data
stpapi.handle.subproc("tdsls4105s000", "tdilc4102s000", "add")
get.next.sequence.number.for.sales.sera.serb.from.tdilc401()
|* Begin the Subsession to maintain the data
stpapi.put.field( "tdilc4102s000", "tdilc401.koor", str$(etol(tdilc.koob.act.sls)))
stpapi.put.field( "tdilc4102s000", "tdilc401.orno", order.no.str)
stpapi.put.field( "tdilc4102s000", "tdilc401.pono", position.number.str)
ret.val3 = stpapi.change.view("tdilc4102s000", error.msg)
stpapi.put.field( "tdilc4102s000", "tdilc401.orno", order.no.str)
stpapi.put.field( "tdilc4102s000", "tdilc401.pono", position.number.str)
stpapi.put.field( "tdilc4102s000", "tdilc401.sera", sera.str)
stpapi.put.field( "tdilc4102s000", "tdilc401.serb", serb.str)
stpapi.put.field( "tdilc4102s000", "tdsls041.item", "51209")
stpapi.put.field( "tdilc4102s000", "tdilc401.loca", "RE")
stpapi.put.field( "tdilc4102s000", "tdilc401.stun", "set")
stpapi.put.field( "tdilc4102s000", "tdilc401.qstr", "1")
stpapi.put.field( "tdilc4102s000", "tdilc401.qsts", "1")

ret.val = stpapi.insert("tdilc4102s000", true, err.mesg )
if ret.val <> 1 then
ret.val2 = stpapi.recover("tdilc4102s000", err.mess)
|create.err.file()
else
success.rec = success.rec + 1
first.time = false
endif
stpapi.end.session( "tdilc4102s000")
stpapi.end.session( "tdilc4513s000")
endif
stpapi.end.session( "tdsls4105s000")
stpapi.end.session( "tdsls4504s000")
else
|* Order Not found
err.mesg = sprintf$("Sales Order:%s could not be found!!", so.number.str)
create.so.insert.err.file()
endif
stpapi.end.session( "tdsls4101m000")
}

mark_h
31st October 2005, 15:25
Just an observation - does ret.val2 = stpapi.insert("tdsls4105s000", true, err.mesg) then launch tdilc4102s000? If so then move your stpapi.handle.subproc up above the insert statement. Just guessing since I can't see the code in get.next.sequence.number.for.sales.sera.serb.from.tdilc401().

Another question - is it possible for you to use the kill option and then run tdilc4102m000? Not sure since I do not understand this whole process.

FoxZapper
31st October 2005, 15:43
Dear Mark,

Thanks for your reply.
Actually from a UI perspective, the moment the user saves the record in tdsls4105s000, the system activates the tdilc4102s000 session internally. Based on your obeservation, I tried moving the
stpapi.handle.subproc( "tdsls4105s000", "tdilc4102s000", "add")
before the
ret.val2 = stpapi.insert("tdsls4105s000", true, err.mesg)

Unfortunately, the moment the focus reaches
stpapi.put.field( "tdilc4102s000", "tdilc401.koor", str$(etol(tdilc.koob.act.sls)))

the code freezes and gets delayed considerably.

Have you ever come across a case where 2 subsessions needed to be activated in sequence.
My process is similar to the one below (where you had posted some answers too!)
afs problem with tdilc4102s000 out of tdsls4105s000 (http://www.baanboard.com/baanboard/showthread.php?t=16198)

Any ideas?


Regards,

Arun

mark_h
31st October 2005, 16:03
Yes - I have one that interacts with tfgld1101m00 and several of the tfacp sessions. Of course that was one of my uglier processes, but it works. Several questions pop into my mind? One when the insert is executed does this activate the tdilc session? If so does the stpapi.put.field( "tdilc4102s000", "tdilc401.koor", str$(etol(tdilc.koob.act.sls) activate another instance of tdilc4102s000 in the background? If yes - then I have this question? When you run it manually can you just cancel out of the tdilc4102s000 session. Then possible activate it again??

Even better would be if you had source code and could put tdsls4105s000 and tdilc4102s000 in debug mode.

FoxZapper
31st October 2005, 17:14
Dear Mark,

This is the flow. The following sessions are activated in sequence.

a. Maintain Sales Order tds4101m000
b. Maintain Sales Order Lines tdsls4105s000
While inserting the lines, it also activates the session tdsls4504s000 in the background.

The moment, we save a record (insert) on this session, the following get activated.
Maintain Outbound Data tdilc4102s000
It also activates the session tdilc4513s000 in the background.

In my script, the AFS successfully inserts the data into the Sales Order Line
stpapi.insert("tdsls4105s000", true, err.mesg)

But the focus is lost from:
stpapi.handle.subproc("tdsls4105s000", "tdilc4102s000", "add")
stpapi.continue.process("tdsls4105s000", err.mess)
stpapi.get.field("tdsls4105s000", "tdsls041.orno", so.str)[U]

Manually, there is no way to cancel this session tdilc4102s000 as at this moment the focus is lost from all other sessions.
The only way to establish that the other sessions are running is via the Bshell.

Having the source code would have made my life a lot easier.... but life isn't always fair.

Regards,

Arun

mark_h
31st October 2005, 17:52
Sent an email to you.

I have done a lot of ugly things to get function servers to work with some sessions. I have posted code to kill a session in the background - but I do not know if it would do you any good. In my case I kill the session (no control like yours), but then I re-launch it with another stpapi command which then gives me code. You can try this by hand - run your function server. Once tdilc4102 launches then use the bsehll and kill both tdilc4102 and tdilc4513. See if control returns to your program. Then run tdilc4101m000 by hand and do the outbound stuff. And then let your code just close. Does this process work?

I had to get this in today - I learned that true is not always equal to true in Baan. I know understand how Baan handles boolean. In service pack 19 I had one program where I had api.mode = true. TSK! TSK! It worked before, but now api.mode=2 which is still true yet not equal to true. I just could not resist. :)

FoxZapper
3rd November 2005, 12:37
Dear Mark,

Thanks for your assistance and suggestions.
Your scripts were useful. Managed to establish that all 'COLLECT' orders activate the ilc subsessions.
But, the issue is not with my script, it's with the session itself. According to BaaN tdsls4105m00 and tdsls4105s000 Maintain Sales Order Lines(Wholesale)are not supported on AFS.

The session “Maintain Sales Order Lines” (tdpur4102s000) is supported for use with API and Application Function Servers while session “Maintain Sales Order Lines (Wholesale)” (tdpur4105s000) is not. Support is dependent on the session and not the program script. A function server generated for session “Maintain Sales Order Lines (Wholesale)” (tdpur4105s000) is used at your own risk and not supported because Baan has not adapted the session logic to be compatible with API and function server requirements.

I should have checked this before attempting this on AFS. My bad!
Surprisingly, even though BaaN does not support these sessions, I was able to insert Sales Order Lines using my AFS script.

I plan to activate this via tdsls4102s000 and try the same. Will let you know how it turns out.

Regards,

Arun

mark_h
3rd November 2005, 15:45
Glad to be of help. I have plenty of function servers for non-supported sessions. So far it has not stopped me and plus I think Baan should make all sessions API friendly.