Paul P
10th October 2002, 07:54
Dear all,
Following are the steps for registering receipt (whinh3520m000) in BaanERP
whinh3520m000
-start.set will automatically fill the receipt number field
-add.set will execute expected inbound movement*
whinh3820m000
-Mark an occurence in list of expected inbound movement*
-Execute a user option in expected inbound movement will record the new receipt number field in inbound order lines table and end.program, resulting in the line appearing in receipt session*
whinh3520m000
-mark occurence*
-synchronize*
whinh3120s000
-modify fields as needed*
-update db*
-end.program*
whinh3520m000
- execute a user option to confirm receipt
I'm a newbie to AFS and don't even know how to get past the first step above. I don't know where to place start.set command in the list of AFS command. If you guys have time, just an explanation of how to do this will be fine, I'm not asking for ready made scripts. I know you guys are all busy. BTW, the steps marked by * represent ones that can be repeated between first and last step, as receipt from multiple orders is possible so long as the supplier is the same
Thank you very much
Rgds,
Paul
mark_h
10th October 2002, 16:28
Have you read the AFS documentation? It has some really good examples. If not the documentation is attached in one of the threads and I will try to attach a link when I find it.
There are examples in this forum that should help you get started. I work on 4c3 so I am not very knowledgable about BaanErp or its sessions. I usually recommend picking something easy to start with just to get a feel for how they work.
Mark
Paul P
11th November 2002, 07:47
Dear all,
Finished coding receipt using API in our B5 sys. Few hints:
In normal new group addition procedure, you'll press new group button and fill up the view fields. This can be modelled using stpapi.put.field() on view fields than calling stpapi.change.view(). However, in this session, the procedure is different. Here, you press new group button and view field whinh210.rcno is filled automatically by a function in the script. Hence, in here, perform stpapi.change.view() without setting view field first. Then issue stpapi.get.field() on view field, the receipt number, because you'll need it
Execute whinh3820m000 using stpapi.handle.subproc(). You'd have to put the value of whinh210.rcno field into whinh3820m000 for it to be able to link order line to a receipt number correctly
Make sure you issue stpapi.end.session("whinh3820m000") even though linking lines to receipt automatically terminate whinh3820m000
Use intelligent prev.view and next.view combo in whinh3520m000 just to make sure the whinh3520m000 screen are refreshed. Don't use stpapi.change.view() because it will create new receipt number (see first point)
Use stpapi.browse.set() to find the correct record in whinh3520m000. stpapi.find() is not reliable here (it's quite reliable in whinh3820m000). Pls be careful as failure to do next.set will stupidly reset the current record to the first record
Rgds,
Paul
alibaba
15th September 2005, 11:12
Dear all,
Finished coding receipt using API in our B5 sys. Few hints:
In normal new group addition procedure, you'll press new group button and fill up the view fields. This can be modelled using stpapi.put.field() on view fields than calling stpapi.change.view(). However, in this session, the procedure is different. Here, you press new group button and view field whinh210.rcno is filled automatically by a function in the script. Hence, in here, perform stpapi.change.view() without setting view field first. Then issue stpapi.get.field() on view field, the receipt number, because you'll need it
Execute whinh3820m000 using stpapi.handle.subproc(). You'd have to put the value of whinh210.rcno field into whinh3820m000 for it to be able to link order line to a receipt number correctly
Make sure you issue stpapi.end.session("whinh3820m000") even though linking lines to receipt automatically terminate whinh3820m000
Use intelligent prev.view and next.view combo in whinh3520m000 just to make sure the whinh3520m000 screen are refreshed. Don't use stpapi.change.view() because it will create new receipt number (see first point)
Use stpapi.browse.set() to find the correct record in whinh3520m000. stpapi.find() is not reliable here (it's quite reliable in whinh3820m000). Pls be careful as failure to do next.set will stupidly reset the current record to the first record
Rgds,
Paul
how to mimic action add.set of whinh3520m000 and synchronization with whinh3820m000. I was tried stpapi.insert() but an error appear.
and i dont understand what meaning of "You'd have to put the value of whinh210.rcno field into whinh3820m000 for it to be able to link order line to a receipt number correctly"....
can you tell me more?
thank you !
Paul P
15th September 2005, 11:46
Normally we use stpapi.synchronize.dialog() with "add" mode to mimic add.set standard command. However, I found that it doesn't work here in whinh3520m000 and I had to resort to using stpapi.handle.subproc() on whinh3820m000 instead. Right after that use stpapi.put.field() to send the receipt number (whinh210.rcno) to whinh3820m000
Rgds,
Paul
alibaba
15th September 2005, 12:09
ret = stpapi.change.view("whinh3520m000", error.msg)
if ret then
stpapi.get.field("whinh3520m000", "whinh210.rcno", recpit.number)
endif
stpapi.handle.subproc("whinh3520m000","whinh3820m000","add")
if not isspace(recpit.number) then
stpapi.put.field("whinh3820m000", "whinh210.rcno", recpit.number)
stpapi.put.field("whinh3820m000", "whinh210.oorg", "2")
stpapi.put.field("whinh3820m000", "whinh210.orno", "100000049")
stpapi.put.field("whinh3820m000", "whinh210.pono", "10")
stpapi.put.field("whinh3820m000", "whinh210.seqn", "0")
ret = stpapi.find("whinh3820m000", error.msg)
if ret then
stpapi.get.field("whinh3820m000", "expected.qty", number.1)
ret = stpapi.mark("whinh3820m000", error.msg)
if ret = 1 then
stpapi.form.command("whinh3820m000", 5, "exec.user.1",error.msg)
endif
endif
stpapi.end.session("whinh3820m000")
stpapi.end.session("whinh3520m000")
else
stpapi.end.session("whinh3820m000")
stpapi.end.session("whinh3520m000")
endif
_________________________________________________________
some field of whinh3820m000 is constant because of that a test section, that script can be execute normally,but run whinh3520m000 again, I cant found any order link to recipt number and no any record found in whinh3520m000.
why ?
Paul P
15th September 2005, 12:29
When you execute form command exec.user.1 in whinh3820m000, BaanERP will ask question whinh3009. Answer tcyesno.yes to it using stpapi.enum.answer() (and place it before stpapi.form.command() on whinh3820m000)
Rgds,
Paul
alibaba
15th September 2005, 12:50
I was place "ret = stpapi.enum.answer("whinh3820m000", "whinh3009", tcyesno.yes)" before stpapi.form.command().but results not changed.....
why ?
thank you paul.again....
Paul P
16th September 2005, 07:47
2 things:
Try to see if removing stpapi.handle.subproc() altogether helps
You did try to do the receipt manually (not through API) using exactly the same data, did you? And it ran well?
Rgds,
Paul
alibaba
16th September 2005, 11:22
I think the command "stpapi.form.command("whinh3820m000", 5, "exec.user.1",error.msg)" are ran. beacuse of I debug Bshell on runtiom, I found If setp to that command,the BaaN will called some process in background.like
new process: session whinh3820m000, object otccomdll0001, pid 11
Object d:/baan/application/whB50U_c_stnd/owhwmd/owmddll0003 load from disk
---------------------------OBJECT HEADER--------------------------------
Object = owhwmddll0003
Pathname = d:/baan/application/whB50U_c_stnd/owhwmd/owmddll0003
Magic = [_bic_dll_]
relno = 61
obj_revision = 1
object_flags = 10
I think that touch off by form command,the session aleady process record. but because of no link with whinh3520,so no record link to 3520.like open whinh3820 only and dont via whinh3520,at that time , any action on whinh3820 not in fact result....
Is this reason?
Paul P
16th September 2005, 12:26
I checked my script again. Use stpapi.get.field() on whinh3520m000 to get whinh210.rcno but pass it to whinh3820m000 as receipt.number (not as whinh210.rcno)
Rgds,
Paul
alibaba
19th September 2005, 12:26
Thanks a lot paul!thanks for you help!
you right ! ,that Extern Variable is switch and communication between sessions.
I read script of 3820 section, when press that choice,system will import that variable.
so....it worked! I think if not read script of program or somebody made some hints for that program ,it hard tooooooooo....:)
thanks again!
alibaba
21st September 2005, 17:58
Im test my script again, But I found some problem appear...
If the record of whinh3820m000 must answer question whinh3009, that record cant be link to receipt. but if the record dont need answer question whinh3009, the record can be link! why ? I was set stpapi.enum.answer("whinh3820m000", "whinh3009", tcyesno.yes) before choice.user.1 already.
I found that question generate in DLL whinhdll2210 is not in whinh3820m000. the function "stpapi.enum.answer" cant answer question out of current session ???? It's a bug or limit?
Paul,Did you test your script with some record that must answer question whinh3009? Is correct ?
Paul P
22nd September 2005, 05:43
My script is part of a larger MES-WMS-ERP integration program and it has been working flawlessly for the last 2 years. It was run on BaanERP 5.0c SP7 with STP updated to around July 2003. You might have been in a newer installation than mine, so some things might differ
Rgds,
Paul
lakoon
25th October 2005, 16:56
Hello
´
I have automated the whinh3520m000.
But at the moment I facing the following problem which I´m not able to solve.
I have open the session an the program is browsing through the records with stpapi.browse.
For each record i get the correct position and sequence number displayed.
If i try to mark the current record, stpapi.mark returns o.k. If I then use the stpapi.form.command for this marked record the function is executed on the first record and not of the (in my opinion) marked record.
Have you got a workaround or solution for it?
/lakoon
Attached my script:
ret.brow = stpapi.browse.set(MAT.MAIN, "first.set", err.msg)
while ret.brow
stpapi.get.field(MAT.MAIN, "whinh210.orno", get.orno)
stpapi.get.field(MAT.MAIN, "whinh210.oset", get.oset.str)
stpapi.get.field(MAT.MAIN, "whinh210.pono", get.pono.str)
stpapi.get.field(MAT.MAIN, "whinh210.seqn", seqn_str)
seqn_lng = lval(seqn_str)
no.delete = false
for i = 1 to rec.count
if a.iseqn(i) = seqn_lng then
|Datensatz nicht löschen
no.delete = true
endif
endfor
if no.delete = false then
ret.mark = stpapi.mark(MAT.MAIN, err.msg)
if ret.mark then
rec.deleted = true
stpapi.form.command(MAT.MAIN,
5,
"exec.user.3",
err.msg)
if not isspace(err.msg) then
get.api.messages(MAT.MAIN, "")
endif
endif
api.action = "first.set"
else
api.action = "next.set"
endif
ret.brow = stpapi.browse.set(MAT.MAIN, strip$(api.action), err.msg)
endwhile
Paul P
26th October 2005, 06:36
Hi lakoon,
Your code looks alright. And as from my side, I was able to remove specific receipt line from a receipt number if it failed to be confirmed (i.e. my script can remove any receipt line at any particular position in the receipt). And I didn't use any workaround to do it, just standard API commands and procedure
Rgds,
Paul
Andy..
3rd July 2006, 18:10
having set whinh3520m000 to add receipt header OK
then whinh3820m000 to link to order OK I can see a receipt line has been added, however when I try and alter the delivered qty - nothing happens. See below for the part of code that I think should do this...
stpapi.handle.subproc("whinh3520m000","whinh3120s000","add")
stpapi.put.field( "whinh3120s000", "whinh210.rstk", str$(98) ) |rec.qty
|save
ret=stpapi.update( "whinh3120s000", do.update, error )
ret=stpapi.save( "whinh3120s000", error )
stpapi.end.session( "whinh3120s000" , error )
I put an update and a save in there to see if that helped - but it didn't! I've tried marking the record in inh3520 before calling subsession that hasn't helped
I have been using the same test data and it still works via the Baan session. Hopefully i'm making a stupid mistake - Help!
mark_h
5th July 2006, 15:32
Maybe if you post all of your code someone will see a problem. I do not have any knowledge of ln, but you never know I might see a problem.
Paul P
6th July 2006, 05:02
Hi Andy,
As per manual, for BaanERP you use stpapi.synchronize.dialog() and not stpapi.handle.subproc()
Rgds,
Paul
Andy..
6th July 2006, 14:13
Paul, thanks for the suggestion - since the original post I had tried sync dialog but it doesn't seem to work at all! In fact, when compiling in debug mode and I try and set a breakpoint on the sync line it says 'no command on this line' and when you step through the code it skips the line as though it were blank or a comment line!!
Here's the story so far...
First I tried tried the 'obvious' way of coding based on the API code generated:
stpapi.handle.subproc("whinh3520m000","whinh3820m000","add")
stpapi.put.field("whinh3820m000", "receipt.number", recnum)
stpapi.put.field("whinh3820m000", "whinh210.oorg", "1")
stpapi.put.field("whinh3820m000", "whinh210.orno", "211000499")
stpapi.put.field("whinh3820m000", "whinh210.pono", "10")
stpapi.put.field("whinh3820m000", "whinh210.seqn", "0")
stpapi.form.command("whinh3820m000", 5, "exec.user.1",error)
stpapi.handle.subproc("whinh3520m000","whinh3120s000","add")
stpapi.put.field( "whinh3120s000", "whinh210.rstk", str$(98) ) |rec.qty
ret=stpapi.update( "whinh3120s000", do.update, error )
ret=stpapi.save( "whinh3120s000", error )
Having created the receipt line, this links fine but doesn't allow the change of receipt qty . Then I tried to update main session (this works with some sessions, but not this one!):
stpapi.put.field( "whinh3520m000", "whinh210.rstk", str$(98))
ret=stpapi.update( "whinh3520m000", do.update, error )
ret=stpapi.save( "whinh3520m000", error )
but that gives the 'synchronized dialog not started' error
so I tried:
ret=stpapi.synchronize.dialog("whinh3520m000", "modify", error)
stpapi.put.field( "whinh3120s000", "whinh210.rstk", str$(98) ) |rec.qty
ret=stpapi.update( "whinh3120s000", do.update, error )
ret=stpapi.save( "whinh3120s000", error )
this is where is gets weird and the sync line is not even recognised at runtime - ie line is skipped in debug mode! I thought maybe there's a bug with the API handler, but I have another session for picking that requires stpapi.synchronize.dialog and that works fine!
I am totally confused now, someone must have got this to work! I am on the verge of having to use a SQL update to change the values in the table, but that's a poor solution. HELP!
Cheers, Andy
Paul P
6th July 2006, 14:42
Hi Andy,
Just like how users normally use the system, you need to mark the record to modify first (press space bar) before you are able to open up the record for modifying (press enter). So, you need to issue stpapi.mark() command before doing stpapi.synchronize.dialog()
Rgds,
Paul
Andy..
6th July 2006, 14:55
i missed the following line from the code I posted above -
ret=stpapi.mark("whinh3520m000", error)
so I was marking before the sync, but I just noticed, am I supposed to have the main or subsession? Will try with the subsession instead...
Andy
Andy..
6th July 2006, 18:33
I did an end session on the 'link order' subsession, then made sure I had marked the receipt line by returning the order number - now its working!
thanks for the suggestions Paul
kathuria
25th October 2006, 09:32
Hi,
I am trying to write AFS of Maintain Receipt as per logic given by Mr. Paul. But getting error message Command Cancelled. I am also giving code. Kindly resolve this problem.
Source Code :
function afs.to.generate.automatic.receipt()
{
extern domain whinh.shpm rec.no
extern long ret
extern domain tcmcs.str50 error.msg
ret = stpapi.change.view("whinh3512m000", error.msg)
if ret then
stpapi.get.field("whinh3512m000", "whinh312.rcno", rec.no)
endif
stpapi.handle.subproc("whinh3512m000","whinh3820m000","add")
if not isspace(rec.no) then
endif
}
Regards,
Sanjay Kathuria
Paul P
30th October 2006, 04:02
Sanjay,
First of all, why are you using whinh3512m000? This thread is discussing receipt on BaanERP (ie version 5). On BaanERP, the built-in session for receipt is whinh3520m000 as you can see above. If you're in SSA ERP LN, then this thread might not be applicable to you
Rgds,
Paul
kathuria
30th October 2006, 06:24
Hi,
Any way I have solved problem with script which is earlier attached. In this session giving error message but doing everythingh which is mandotary for Maintain Receipt (WHINH3512m000).
Regards,
Sanjay Kathuria
zakir_h
24th June 2009, 17:33
Hello ,
Can somebody pls. help in figuring out why i am getting the error "Command Cancelled.
My code looks like something below.
ret = stpapi.change.view("whinh3520m000", error.msg)
stpapi.get.field("whinh3520m000", "whinh210.rcno", temp.rcno)
stpapi.handle.subproc("whinh3520m000","whinh3822m000","add")
if ret and not isspace(temp.rcno) then
stpapi.form.command("whinh3822m000", 5, "view.not.linked",error.msg)
stpapi.enum.answer("whinh3822m000","whinh0009",tcyesno.yes)
stpapi.put.field("whinh3822m000", "receipt.number", temp.rcno)
stpapi.put.field("whinh3822m000", "whinh210.oorg", "2")
stpapi.put.field("whinh3822m000", "whinh210.orno", str$(tdafi018.orno))
stpapi.put.field("whinh3822m000", "whinh210.pono", "0")
stpapi.put.field("whinh3822m000", "whinh210.seqn", "0")
ret = stpapi.find("whinh3822m000", error.msg)
while ret
if ret then
| stpapi.get.field("whinh3822m000", "expected.qty", number.1)
ret = stpapi.mark("whinh3822m000", error.msg)
if ret = 1 then
stpapi.form.command("whinh3822m000", 5, "exec.user.2",error.msg)
endif
endif
stpapi.form.command("whinh3822m000", 5, "view.not.linked",error.msg)
stpapi.enum.answer("whinh3822m000","whinh0009",tcyesno.yes)
stpapi.put.field("whinh3822m000", "receipt.number", temp.rcno)
stpapi.put.field("whinh3822m000", "whinh210.oorg", "2")
stpapi.put.field("whinh3822m000", "whinh210.orno", str$(tdafi018.orno))
stpapi.put.field("whinh3822m000", "whinh210.pono", "0")
stpapi.put.field("whinh3822m000", "whinh210.seqn", "0")
ret = stpapi.find("whinh3822m000", error.msg)
endwhile
stpapi.end.session("whinh3820m000")
stpapi.end.session("whinh3520m000")
else
stpapi.end.session("whinh3820m000")
stpapi.end.session("whinh3520m000")
endif
The reason for while loop is for going thru all the records for the PO and and view.not.linked to narrow down the records.
regards
zakir
mark_h
24th June 2009, 23:45
There can be several reasons for the command cancelled - you might need newer libraries, portingset or even new session objects. Next I see this
ret = stpapi.change.view("whinh3520m000", error.msg)
stpapi.get.field("whinh3520m000", "whinh210.rcno", temp.rcno)
stpapi.handle.subproc("whinh3520m000","whinh3822m000","add")
if ret and not isspace(temp.rcno) then
stpapi.form.command("whinh3822m000", , "view.not.linked",error.msg)
I would expect to see an action on the whinh3520m000 session that would activate the 2whinh2822m000 session after the stpapi.handle.subproc command. Not an expert on 5, but that was the first thing I noticed.
zakir_h
7th July 2009, 12:50
Hello Mark,
Thanks... could get the script working as below... didnot have to upgrade the porting set ...etc.
stpapi.form.command("whinh3520m000", 5, "exec.user.1",error.msg)
stpapi.get.field("whinh3520m000", "whinh210.rcno", temp.rcno)
stpapi.handle.subproc("whinh3520m000","whinh3822m000","add")
stpapi.form.command("whinh3520m000", 5, "option.add.order",error.msg)
stpapi.put.field("whinh3822m000", "receipt.number", temp.rcno)
ret = stpapi.change.view("whinh3822m000", error.msg)
if ret and not isspace(temp.rcno) then
stpapi.enum.answer("whinh3822m000","whinh3009",tcyesno.yes)
stpapi.put.field("whinh3822m000", "whinh210.orno", str$(tdafi018.orno))
stpapi.form.command("whinh3822m000", 5, "exec.user.1",error.msg)
stpapi.form.command("whinh3822m000", 5, "view.not.linked",error.msg)
stpapi.put.field("whinh3822m000", "whinh210.oorg", "2")
stpapi.put.field("whinh3822m000", "whinh210.orno", str$(tdafi018.orno))
stpapi.put.field("whinh3822m000", "whinh210.pono", "0")
ret = stpapi.find("whinh3822m000", error.msg)
stpapi.get.field("whinh3822m000", "whinh210.orno", temp.orno)
stpapi.get.field("whinh3822m000", "whinh210.pono", number.1)
while ret
if temp.orno <> tdafi018.orno then
break
endif
ret = stpapi.mark("whinh3822m000", error.msg)
error.code = ""
stpapi.form.command("whinh3822m000", 5, "exec.user.2",error.msg)
error.code = stpapi.get.mess.code("whinh3822m000", error.msg)
if NOT ISSPACE(error.msg) then
flag = tcyesno.no
message(error.msg)
endif
flag = tcyesno.yes
if NOT ISSPACE(error.code) then
flag = tcyesno.no
ret = stpapi.recover("whinh3822m000", error.msg)
message("Please delete %s to avoid confusion.",temp.rcno)
break
endif
stpapi.put.field("whinh3822m000", "whinh210.oorg", "2")
stpapi.put.field("whinh3822m000", "whinh210.orno", str$(tdafi018.orno))
stpapi.put.field("whinh3822m000", "whinh210.pono", "0")
ret = stpapi.find("whinh3822m000", error.msg)
stpapi.get.field("whinh3822m000", "whinh210.orno", temp.orno)
stpapi.get.field("whinh3822m000", "whinh210.pono", number.1)
endwhile
if flag = tcyesno.no then
message("Please delete %s to avoid confusion. Could not Confirm Receipt Successfully.",temp.rcno)
endif
stpapi.end.session("whinh3822m000")
stpapi.end.session("whinh3520m000")
else
stpapi.end.session("whinh3822m000")
stpapi.end.session("whinh3520m000")
endif
regards
zakir