ranjankool
9th October 2009, 08:07
Hi,

I was trying to write AFS For PO Invoice matching.

I stated with tfgld1101m000 then opened tfacp1110s000 (maintain Purchase Invoice). till here its fine.

It Works all fine if we give Amount full as full PO Receipt amount. It will open tfacp1230s000 and Link receipt, approval receipt will come YES. click on MATCH ... things will go fine.

Now Problem come when i don't give full Po amount in tfacp1110s000. It will open tfacp1230s000 and Link receipt, approval receipt will come NO. click on MATCH ... it will open tfacp1131s000 then say complete Match and close.

It will open tfacp1130s000 session.
Now here i have click on "Approve" in tfacp1130s000 for futher approval where i can give ledger account and dimension.

Approve button is 2nd FORM COMMAND in BaaN C4.

I want to know how to click on "Approve" and continue further....

BaaNovva
9th October 2009, 15:58
Execute session's user option [ stpapi.application.option(string session, long form, long option, ref string err.mesg) ] where form is the form# where the button you wanted to click. So, if you want to hit 'Approve' in 2nd form, you can call the above method.

Executing session's form command [stpapi.form.command()] is limited only to the current form.

Hope this helps you.

Hitesh Shah
9th October 2009, 17:44
I had intentionally left AFS on tfacp1140s000 as it immediately zooms to some other sessions like tfacp1133s000 / tfacp1141s000 for which there is no way write handle.subprog .

If anybody has done afs on tfacp1140s000 , do let us know with a code for the same.

ranjankool
10th October 2009, 11:34
Execute session's user option [ stpapi.application.option(string session, long form, long option, ref string err.mesg) ] where form is the form# where the button you wanted to click. So, if you want to hit 'Approve' in 2nd form, you can call the above method.

Executing session's form command [stpapi.form.command()] is limited only to the current form.

Hope this helps you.

Hi,
Thanx a lot using stpapi.application.option, now i can open that session tfacp1133s000 on click of Approve button.
I thing its going to serve my purpose.

Thank you once again

Thomasm
12th October 2009, 08:44
I had intentionally left AFS on tfacp1140s000 as it immediately zooms to some other sessions like tfacp1133s000 / tfacp1141s000 for which there is no way write handle.subprog .

If anybody has done afs on tfacp1140s000 , do let us know with a code for the same.

I am no expert in finance but I know that I have no problem using tfacp1140s000 in afs (see code below). Could it be related to the main session and next session settings in the transaction type?

Please find my code for example (based on something else from around here of course):
function approveInvoice()
{
| setMessage() calls functions to print...
long rc
string msg(256)

msg = ""

| find this first to make it stop on this batch (group)
stpapi.put.field("tfgld1101m000","tfgld101.year", str$(tfacp200.year) )
stpapi.put.field("tfgld1101m000","tfgld101.btno", str$(tfacp200.btno) )
stpapi.put.field("tfgld1101m000","tfgld101.ttyp", str$(tfacp200.ttyp) )
| find it if it exists
rc = stpapi.find("tfgld1101m000",msg)
if not isspace(msg) or rc<>1 then | this should never happen...
setMessage("Did not find the EDI batch")
setMessage( "Fiscal Year: " & str$(tfacp200.year)
& " Batch Number: " & str$(tfacp200.btno)
& " Transaction Type: " & str$(tfacp200.ttyp)
& " Invoice to approve is: " & str$(tfacp200.ninv) )
setMessage("Message is: " & str$(msg) )
setMessage("")
return
endif

stpapi.put.field("tfgld1101m000","tfgld101.year", str$(tfacp200.year) )
stpapi.put.field("tfgld1101m000","tfgld101.btno", str$(tfacp200.btno) )
stpapi.put.field("tfgld1101m000","tfgld101.ttyp", str$(ttyp.appr) )

| find it if it exists
rc = stpapi.find("tfgld1101m000",msg)
if not isspace(msg) or rc<>1 then
| if not exists insert it
stpapi.put.field("tfgld1101m000","tfgld101.year", str$(tfacp200.year) )
stpapi.put.field("tfgld1101m000","tfgld101.btno", str$(tfacp200.btno) )
stpapi.put.field("tfgld1101m000","tfgld101.ttyp", str$(ttyp.appr) )
if not ( stpapi.insert("tfgld1101m000", true, msg) ) then
| something whent wrong
setMessage("Could not insert new transaction type")
setMessage( "Fiscal Year: " & str$(tfacp200.year)
& " Batch Number: " & str$(tfacp200.btno)
& " Transaction Type: " & str$(tfacp200.ttyp)
& " Insert Transaction Type: " & str$(ttyp.appr)
& " Document: " & str$(tfacp200.ninv) )
setMessage("Message is: " & str$(msg) )
setMessage("")
stpapi.end.session("tfgld1101m000")
return
endif
| make sure it is set to active
stpapi.put.field("tfgld1101m000","tfgld101.year", str$(tfacp200.year) )
stpapi.put.field("tfgld1101m000","tfgld101.btno", str$(tfacp200.btno) )
stpapi.put.field("tfgld1101m000","tfgld101.ttyp", str$(ttyp.appr) )
rc = stpapi.find("tfgld1101m000",msg)
if not isspace(msg) or rc<>1 then
| This should definitely not happen
setMessage( "Did not find the transaction in session tfgld1101m000 as expected" )
setMessage( "Fiscal Year: " & str$(tfacp200.year)
& " Batch Number: " & str$(tfacp200.btno)
& " Transaction Type: " & str$(tfacp200.ttyp)
& " Insert Transaction Type: " & str$(ttyp.appr)
& " Document: " & str$(tfacp200.ninv) )
setMessage("Message is: " & str$(msg) )
setMessage("")
stpapi.end.session("tfgld1101m000")
return
endif
endif

| zoom
stpapi.handle.subproc("tfgld1101m000", "tfacp1140s000", "add")
stpapi.continue.process("tfgld1101m000", msg)
if not ( isspace(msg) ) then
setMessage( "Could not Continue in session tfgld1101m000. Message is: " )
setMessage( msg )
setMessage( "Fiscal Year: " & str$(tfacp200.year)
& " Batch Number: " & str$(tfacp200.btno)
& " Transaction Type: " & str$(tfacp200.ttyp)
& " Insert Transaction Type: " & str$(ttyp.appr)
& " Document: " & str$(tfacp200.ninv) )
setMessage("Message is: " & str$(msg) )
setMessage("")
stpapi.end.session("tfgld1101m000")
return
endif

stpapi.put.field("tfacp1140s000","tfacp200.ttyp", str$(tfacp200.ttyp) )
stpapi.put.field("tfacp1140s000","tfacp200.ninv", str$(tfacp200.ninv) )
rc = stpapi.find("tfacp1140s000",msg)
if not isspace(msg) or rc<>1 then
setMessage( "Did not find the ducoment in session tfacp1140s000 as expected" )
setMessage( "Transaction Type: " & str$(tfacp200.ttyp)
& " Document: " & str$(tfacp200.ninv) )
setMessage("Message is: " & str$(msg) )
setMessage("")
stpapi.end.session("tfacp1140s000")
return
endif

stpapi.handle.subproc("tfacp1140s000", "tfacp1133s000", "ignore")
stpapi.enum.answer("tfacp1140s000", "tfacp00001", tcyesno.yes)
stpapi.continue.process("tfacp1140s000", msg)
if not ( isspace(msg) ) then
setMessage( "Could not Continue in session tfgld1101m000. Message is: " )
setMessage( msg )
setMessage( "Fiscal Year: " & str$(tfacp200.year)
& " Batch Number: " & str$(tfacp200.btno)
& " Transaction Type: " & str$(tfacp200.ttyp)
& " Insert Transaction Type: " & str$(ttyp.appr)
& " Document: " & str$(tfacp200.ninv) )
setMessage("Message is: " & str$(msg) )
setMessage("")
stpapi.end.session("tfacp1140s000")
return
endif


stpapi.end.session("tfacp1133s000")
stpapi.end.session("tfacp1140s000")
stpapi.end.session("tfgld1101m000")
}