Amit_Jain
28th February 2010, 07:35
Dear Board Members

I am writing an AFS on session Direct Debit Advice "tfcmg4501m000" and "tfcmg4120s000" (LN). when I try to insert a new batch I get an error "Business Partner not found". I checked the value while debuging, the value seems to be ok.
Also I am able to create batches manually with the same Business partner. I am not able to figure out what actual problem is? Kindly find my code as attachment.

Thanks in anticipation

Amit Jain

manish_patel
1st March 2010, 13:29
Attachment is missing...

Amit_Jain
2nd March 2010, 05:58
here it is

manish_patel
2nd March 2010, 13:55
ret = stpapi.synchronize.dialog("tfcmg4120s000", "Add", err.msg)

What is the return value of this function?

I did not get chance to use this function. But from help I can say that, here first argument must be name of the multi-occurrence session this command is executed on.

(Assumption: Multi-occurrence session=tfcmg4501m000, Single-occurrence session=tfcmg4120s000)

Amit_Jain
3rd March 2010, 06:40
Hi Manish

The ret value contains '1', the problem in the code not occurs at synchronisation, The problem occurs at insert statement where it gives message "Business partner not found".

I am not very good at AFS but what I observed is that this is the same message which occurs if you directly run session "tfcmg4120s000". this not any conclusion this is just a pointer to you.

I think if we are able to create batch using AFS all other things would fall in to place.

Regards

mark_h
3rd March 2010, 17:40
A few questions:

(1) What happens when you do this: ret = stpapi.insert("tfcmg4501m000",true,err.msg). Does this kick off the subsession tfcmg4120s000? If yes see the next question.
(2) Is this really single occurence multi-occurence situation? If not the you would use the the stpapi.handle.subproc and not the stpapi.sync command.
(3) If it is a true single occurence and multi-occurence situation I would expect the code to look like this:

function Insert.direct.debit.advice()
{
trans.refr =(tfecl900.refr)
curr.date = date.num()
ret = stpapi.synchronize.dialog("tfcmg4501m000", "Add", err.msg)
stpapi.put.field("tfcmg4120s000","tfcmg401.btno",str$(batch))
stpapi.put.field("tfcmg4120s000","tfcmg401.itbp",tfecl900.bpid) | temporary table field
stpapi.put.field("tfcmg4120s000","tfcmg401.ttyp","O")
stpapi.put.field("tfcmg4120s000","tfcmg401.ninv",str$(tfecl900.ninv))
stpapi.put.field("tfcmg4120s000","tfcmg401.comp","100")
stpapi.put.field("tfcmg4120s000","tfcmg401.tadv",str$(3))
stpapi.put.field("tfcmg4120s000","tfcmg401.pbbp",tfecl900.bpid)
stpapi.put.field("tfcmg4120s000","tfcmg401.ccur","INR")
stpapi.put.field("tfcmg4120s000","tfcmg401.amnt",str$(tfecl900.amnt))
stpapi.put.field("tfcmg4120s000","tfcmg401.disa",str$(tfecl900.damt))
stpapi.put.field("tfcmg4120s000","tfcmg401.paym","RTG")
stpapi.put.field("tfcmg4120s000","tfcmg401.plan", str$(curr.date))
stpapi.put.field("tfcmg4120s000","tfcmg401.refr",trans.refr)
stpapi.put.field("tfcmg4120s000","tfcmg401.bank", "KOT")
stpapi.put.field("tfcmg4120s000","tfcmg401.cfrs","CAS")
ret = stpapi.insert("tfcmg4501m000",true,err.msg)
if not ret then
stpapi.recover("tfcmg4120s000",err.msg)
return
endif
}


Refer to the API document for the sync command there are several examples. I can't confirm this code since we are on 4c4 and even then some of these fields do not exist on our system. But not the sync command is on the main session and so is the insert. BUT the recovery takes place on the subsession - per the documentation.

Amit_Jain
4th March 2010, 09:56
Dear Mark

Thanks for your reply, I was optimistic that you would be there to help when not many are daring to take the issue, The reply to your queries to the best of my understanding are as follows:

1. The return value is 0 and error message variable contains "Editable Synchronised dialog not started". and It did not started the subsession tfcmg4120s000.

I would like to inform you, may be it could be helpful, before applying this insert statement I added few statement which are as under:
stpapi.put.field("tfcmg4501m000","tfcmg401.btno", "21")
stpapi.put.field("tfcmg4501m0000","tfcmg401.itbp","DCU000001")
stpapi.enum.answer("tfcmg4501m000", "tfcmg00010",tcyesno.yes)
stpapi.put.field("tfcmg4501m0000","total.rec","0.0")
the process window showed me 4 different processes for the session "tfcmg4501m000", and the insert statement resulted in above mentioned error.

2. I tried your code, It was perfect to the extent that the process window shows one process each for sessions tfcmg4501m000 and tfcmg4120s000. and the insert statement "stpapi.insert("tfcmg4120s000",true,err.msg)" gives error message "No open balance amount". as the invoice selected is a fresh invoice with no reciept transaction against it. Not able to figure out why it is so.

Thanks in advance

Regards

mark_h
4th March 2010, 16:19
Okay - so it sounds like it is definitely a synchronized session. In your response to me on 2 when trying my code you use the session tfcmg4120s000 for the insert - my code uses the main session tfcmg4501m000 for the insert. Can you confirm you used my code with the insert on the mainsession not the subsession? At least from the documentation that is what should be used.

If the above does not work do you own source code? It would probably help debug what the problems are.


As for responding - well probably not many people use this functionality with LN since it is recommended that DAL2 be used. I can't speak to that since we are on 4c4 and will probably never make it to LN.

Amit_Jain
5th March 2010, 06:05
Yes, Probably I was not so attentive while changing my code, I was using tfcmg4120s000 for insert, Now I changed it to tfcmg4501m000 for insert, the problem now is that the session is not creating a new batch, instead it is inserting the record in already existing batch.


One observation regarding DAL2 functionality in LN, Most of finance tables dont have DAL2 implemented on them hence we are left with no option but to use AFS on them (since we dont have the Source Code).

Regards

mark_h
6th March 2010, 02:55
Well lets try combining the two. The first code you posted was creating the batch - right?

So add this

stpapi.put.field("tfcmg4501m000","tfcmg401.btno",str$(batch))
stpapi.put.field("tfcmg4501m000","tfcmg401.itbp",tfecl900.bpid) | temporary table field
ret = stpapi.insert("tfcmg4501m000",true,err.msg)



Before the code that adds the line. I am running out of ideas on this.

Amit_Jain
6th March 2010, 05:07
Mark

I was able to do it during late hours yesterday :) just felt too lazy to apprise the baanboard about it right then. the code is as under:


function Insert.direct.debit.advice()
{
trans.refr =(tfecl900.refr)
curr.date = date.num()


stpapi.put.field("tfcmg4501m000", "tfcmg401.btno", "28")
stpapi.enum.answer("tfcmg4501m000", "tfcmg00010",tcyesno.yes)
stpapi.put.field("tfcmg4501m000", "tfcmg401.itbp", "DCU000001")

ret = stpapi.change.view("tfcmg4501m000", err.msg)
ret = stpapi.synchronize.dialog("tfcmg4501m000", "add", err.msg)

stpapi.put.field("tfcmg4120s000", "tfcmg401.comp", "110")
stpapi.put.field("tfcmg4120s000", "tfcmg401.tadv",str$(3))
stpapi.put.field("tfcmg4120s000", "tfcmg401.ttyp", "SLD")
stpapi.put.field("tfcmg4120s000", "tfcmg401.ninv", "20900015")
stpapi.put.field("tfcmg4120s000", "tfcmg401.srno", "0")
stpapi.put.field("tfcmg4120s000", "tfcmg401.pbbp", "DCU000001")
stpapi.put.field("tfcmg4120s000", "tfcmg401.ccur", "INR")
stpapi.put.field("tfcmg4120s000", "tfcmg401.amnt", "200.00")
stpapi.put.field("tfcmg4120s000", "tfcmg401.disa", "18.30")
stpapi.put.field("tfcmg4120s000", "tfcmg401.paym", "RCH")
stpapi.put.field("tfcmg4120s000", "tfcmg401.plan", str$(curr.date))
stpapi.put.field("tfcmg4120s000", "tfcmg401.bacu", "KOT")
stpapi.put.field("tfcmg4120s000", "tfcmg401.refr",trans.refr)

ret = stpapi.insert("tfcmg4501m000",true,err.msg)
if not ret then

stpapi.recover("tfcmg4120s000",err.msg)
return

endif
stpapi.end.session("tfcmg4120s000",err.msg)
stpapi.end.session("tfcmg4501m000",err.msg)
}


Thanks again to baanboard and Mark (It has been a gr8 learning experience )

Regards