Agus Mujtahid
1st June 2010, 11:47
Dear All,
We have problem when we create Payment Advice (source data from Standing Order)with AFS.we have error message like this "Pay to Business partner not allowed".
please help me,how to running new group and new line for this session via AFS.Detail script and error message when we running this script, see attachment.
Regards,

Mujtahid

mark_h
1st June 2010, 19:14
Okay - Where exactly is the error occuring? Does inserting the record manually work?



stpapi.enum.answer("tfcmg1501m000","tfcmg00010",tcyesno.yes)
stpapi.change.view("tfcmg1501m000",error.msg)
stpapi.put.field("tfcmg1510m000","tfcmg101.ifbp",tfcmg912.st.bp)
stpapi.get.field("tfcmg1501m000","tfcmg101.btno",batch.pay.afs)

error.msg=""
if isspace(error.msg) then
stpapi.synchronize.dialog("tfcmg1510m000","add",error.msg)
if isspace(error.msg) then
stpapi.put.field("tfcmg1120s000","tfcmg101.tadv",str$(etol(tfcmg.tadv.standing)))
stpapi.put.field("tfcmg1120s000","tfcmg101.ninv",str$(tfcmg912.st.no))

stpapi.insert("tfcmg1510m000",true,error.msg)
if isspace(error.msg) then

If there error is coming from tcmg1120s000 - what is in the field before the insert? Does this session have session defaults - might need to delete those for you user ID. It might just be that the session is not filling the Business Partner correctly - have you tried doing a put on it?

Agus Mujtahid
2nd June 2010, 04:03
We can do it by manual input.
we think this error caused by this field (tfcmg101.ifbp)is not properly input. we have input this field with this script,

stpapi.put.field("tfcmg1510m000","tfcmg101.ifbp",tfcmg912.st.bp),

but it can't work properly.
please help us.

mark_h
2nd June 2010, 15:35
On 4c4 there is a tfcmg1120m000 or main session - is that session on Baan 5? Better sometimes to use main session that to work through the processes for subsessions.

First in Baan 5 are these 1500 series programs input sessions? On baan 4 they are display sessions. I may not be much help here. Anyway I am very confused by your code.

stpapi.enum.answer("tfcmg1501m000","tfcmg00010",tcyesno.yes)
stpapi.change.view("tfcmg1501m000",error.msg)

These two lines do not do anything but activate tfcmg1501m000. No fields were put on the form, so the change.view would not move to the correct record that you are looking for.

stpapi.put.field("tfcmg1510m000","tfcmg101.ifbp",tfcmg912.st.bp)
stpapi.get.field("tfcmg1501m000","tfcmg101.btno",batch.pay.afs)

Next two lines do not do anything, but start tfcmg1510m000 with the put field. The put on tfcmg1501m000 does nothing.

stpapi.synchronize.dialog("tfcmg1510m000","add",error.msg)
if isspace(error.msg) then
stpapi.put.field("tfcmg1120s000","tfcmg101.tadv",str$(etol(tfcmg.tadv.standing)))
stpapi.put.field("tfcmg1120s000","tfcmg101.ninv",str$(tfcmg912.st.no))
stpapi.insert("tfcmg1510m000",true,error.msg)

Now these lines would start tfcmg1120, but I am not sure if it is a syncronized session or not. There is no link between 1501 to 1510 to 1120s000. The below code is how I would expect something like this to work in 4c4 - which is probably not the same in 5. This code is really how I expect the sessions to flow together and be linked in some fashion.

| Find the batch you want
stpapi.put.field("tfcmg1501m000","tfcmg101.btno",batch.pay.afs)
stpapi.enum.answer("tfcmg1501m000","tfcmg00010",tcyesno.yes)
stpapi.change.view("tfcmg1501m000",error.msg)

| Activate subsession
stpapi.handle.subproc("tfcmg1501m000", "tfcmg1120s000", "add")
stpapi.continue.process("tfcmg1501m000", e.msg)

|Insert payment advice.
stpapi.put.field("tfcmg1120s000","tfcmg101.tadv",str$(etol(tfcmg.tadv.standing)))
stpapi.put.field("tfcmg1120s000","tfcmg101.ninv",str$(tfcmg912.st.no))
stpapi.insert("tfcmg1120s000",true,error.msg)
stpapi.end.session("tfcmg1120s000",error.msg)
stpapi.end.session("tfcmg1501m000",error.msg)

My recommendation is write down each step as you do them manually and what happens at each step. So for example:
(1) Start tfcmg1501m000
(2) Execute find for batch 1234
(3) highlight batch (make batch current record)
(4) Click continue
(5) clicking continue activated tfcmgxxxxm000 session - this is current session.(might even use ps in a shell to see if anyother processes running)
(6) hit insert, put pay advice and tab through other fields
(7) hit save
(8) hit save and exit - this closed tfcmgxxxxm000 and returned to tfcmg1501m000
(9) hit save and exit - all session closed.

A simple little flow like this makes it easier to see where you need to do what. You then program the stpapi commands just like that.

Agus Mujtahid
3rd June 2010, 04:13
Thank mark,

Actually we did fault activities when we run "stpapi.put" script.

yesterday, we tried again with another script, everything is OK.
Thanks for your support.

it's our final script :

function afs.create.payment.advice()
{
|#Create batch baru
stpapi.enum.answer("tfcmg1501m000","tfcmg00010",tcyesno.yes)
stpapi.change.view("tfcmg1501m000",error.msg)
stpapi.get.field("tfcmg1501m000","tfcmg101.btno",batch.pay.afs)

stpapi.end.session("tfcmg1501m000",error.msg)

|#Insert Header
stpapi.put.field("tfcmg1501m000","tfcmg101.btno",batch.pay.afs)
stpapi.put.field("tfcmg1501m000","tfcmg101.ifbp",tfcmg912.st.bp)
stpapi.put.field("tfcmg1501m000","tfcmg101.comp",str$(get.compnr()))
stpapi.put.field("tfcmg1501m000","tfcmg101.tadv",str$(etol(tfcmg.tadv.standing)))
stpapi.put.field("tfcmg1501m000","tfcmg101.ttyp","")
stpapi.put.field("tfcmg1501m000","tfcmg101.ninv",str$(tfcmg912.st.no))
stpapi.put.field("tfcmg1501m000","tfcmg101.srno","0")

stpapi.change.view("tfcmg1501m000",error.msg)
error.msg=""

|#Insert Detail Payment Advice
if isspace(error.msg) then
stpapi.synchronize.dialog("tfcmg1501m000","add",error.msg)
if isspace(error.msg) then
stpapi.put.field("tfcmg1120s000","tfcmg101.comp",str$(get.compnr()))
stpapi.put.field("tfcmg1120s000","tfcmg101.tadv",str$(etol(tfcmg.tadv.standing)))
stpapi.put.field("tfcmg1120s000","tfcmg101.ninv",str$(tfcmg912.st.no))

stpapi.insert("tfcmg1501m000",true,error.msg)
if isspace(error.msg) then
stpapi.get.field("tfcmg1120s000","tfcmg101.ifbp",bp.pay.afs)
stpapi.get.field("tfcmg1120s000","tfcmg101.btno",batch.pay.afs)
stpapi.end.session("tfcmg1110s000",error.msg)
stpapi.end.session("tfcmg1510m000",error.msg)
stpapi.end.session("tfcmg1120s000",error.msg)
stpapi.end.session("tfcmg1501m000",error.msg)
update.tabel.tfcmg912.payment.advice()
print.voucher()
else
stpapi.end.session("tfcmg1110s000",error.msg)
stpapi.end.session("tfcmg1510m000",error.msg)
stpapi.end.session("tfcmg1120s000",error.msg)
stpapi.end.session("tfcmg1501m000",error.msg)
message("Save data payment order, error="&error.msg)
error.msg=""
endif
else
stpapi.end.session("tfcmg1110s000",error.msg)
stpapi.end.session("tfcmg1510m000",error.msg)
stpapi.end.session("tfcmg1501m000",error.msg)
message("Synchronize Error= "&error.msg)
error.msg=""
endif
else
stpapi.end.session("tfcmg1110s000",error.msg)
stpapi.end.session("tfcmg1510m000",error.msg)
message("Error Change View payment Advice= "&error.msg)
error.msg=""
endif
}