VishalMistry
26th October 2017, 15:47
Hi all,

I am trying to change warehouse in production order through AFS. I am passing production order number and project using stpapi.put and checking the return value of stapi.find. I am able to find the record, but when I am trying to update the warehouse by passing new warehouse in stpapi.put, I am getting an error message when I call stpapi.update. The error message is "Item not found".

When I run the session directly and try to update the warehouse in same production order, I am able to do it. I have attached screen that performs warehouse update in tisfc001.

I have attached script for reference.

Shall be grateful if anybody can point out the error.

Vishal

mark_h
26th October 2017, 20:50
Is this 4c4 or LN? I read in one post it would be better to use DAL functionality on LN.

VishalMistry
27th October 2017, 11:12
Hello Mark,

We are on Baan IVc4. In a simple way If I ask, Generally what would be the code to find particular production production order and change warehouse in it.
I would appreciate if any example is given.

Thanks,
Vishal

VishalMistry
27th October 2017, 14:42
The issue is resolved by introducing two variable which are used in QKey layer of tisfc0101. But now, whenever any error occurs, the error.msg in stpapi.update captures only last message (which is not the actual reason for update failure).

The error is "Actual calendar not found when planning for work center 05"

The message following the error is "Estimated BOM and routing will be reset to standard".

And the error.msg captures the second message(Estimated BOM and routing will be reset to standard)

Anybody has any clue how to capture the first error message in error.msg while doing stpapi.update ?

Vishal

mark_h
27th October 2017, 15:03
Glad you found a solution. We have qkey on the session also - but right now in test our third party software is not hooked up. That is causing trigger errors when I tried to run your code (without project, since we do not use it).

As for trapping the first error from the documentation I see this:

Message array
Messages raised by the session are kept in an array, with a maximum of 20 messages. When more messages are raised, the 21st message will be: more than 20 messages raised by the session, other messages are lost.
The function stpapi.get.mess.code() gives access to this array. The array has two fields: error code and error text. The error code can be empty for messages raised by the function message(). In the first call to this function, the last message is returned, then the previous one, and so forth.
Example of message array:
Code Text
dtfsas0002 Price must be filled
dtfsas0001 Note: insufficient inventory

In this example, the session first raised a warning (in check.input of the quantity field) with only a mess() function. In the check.input of the Price field set.input.error(dtfsas0002) was called (or mess(dtfsas0002, 1) followed by set.input.error(“”)). The string “Price must be filled” is also returned in the error argument of the stpapi.insert() call.
When the message array only contains the warning dtfsas0001, no string is returned in the error argument of the stpapi.insert().
See the example code in Chapter 3 how to handle the message array.
Before each stpapi.* call, the array is cleaned up, except stpapi.put.field(), stpapi.get.field() and stpapi.get.mess.code().

So I would think if you stpapi.get.mess.code it would return the estimated bom message the first time. Then the second call to stpapi.get.mess.code would return the Actual calendar error. Never really tried it myself.