veyant
4th October 2006, 16:55
Hi,

I am facing problem in tfcmg2120s000 in inserting a transaction thru AFS.

I created one batch in tfgld1101m000 with transaction type and then called session tfcmg2100s000 to insert record with Type as "journal" and populated the fields with required data and called stpapi.insert and saved the document. It is working fine

Now i call tfcmg2120s000 (Enter Transaction) and try to populate data in fields thru AFS but when i send stpapi.insert, i returns back error "Batch Number not Allowed".

Can somebody help me in this. Given below is the source code which i am using for inserting transction thru tfcmg2120s000.

stpapi.handle.subproc("tfcmg2100s000","tfcmg2120s000","add")
stpapi.form.command("tfcmg2100s000",2,"tfcmg2120s000",cmg.error)

stpapi.put.field( "tfcmg2120s000", "tfgld102.cono", str$(comp.no) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.year", str$(fiscal.year) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.btno", str$(batch.no) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.ttyp", ttyp )
stpapi.put.field( "tfcmg2120s000", "tfgld102.docn", str$(docno) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.lino", str$(1) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.serl", str$(1) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.srno", str$(0) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.tcom", str$(comp.no) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.leac", tfsol912.leac )
if not isspace(tfsol912.dim1) then
stpapi.put.field( "tfcmg2120s000", "tfgld102.dim1", tfsol912.dim1 )
endif
if not isspace(tfsol912.dim2) then
stpapi.put.field( "tfcmg2120s000", "tfgld102.dim2", tfsol912.dim2 )
endif
if not isspace(tfsol912.dim3) then
stpapi.put.field( "tfcmg2120s000", "tfgld102.dim3", tfsol912.dim3 )
endif
if not isspace(tfsol912.dim4) then
stpapi.put.field( "tfcmg2120s000", "tfgld102.dim4", tfsol912.dim4 )
endif
if not isspace(tfsol912.dim5) then
stpapi.put.field( "tfcmg2120s000", "tfgld102.dim5", tfsol912.dim5 )
endif
get.country.from.company.data(comp.no)
stpapi.put.field( "tfcmg2120s000", "tfgld102.ccty", tccom000.ccty )
stpapi.put.field( "tfcmg2120s000", "tfgld102.cvat", " ")
stpapi.put.field( "tfcmg2120s000", "form.amount", str$(tfsol912.amnt) )
if tfsol912.tpay = tfacp.tpay.invoice then
stpapi.put.field( "tfcmg2120s000", "tfgld102.dbcr",str$(tfgld.dbcr.debit) )
else
if tfsol912.tpay = tfacp.tpay.sales then
stpapi.put.field( "tfcmg2120s000", "tfgld102.dbcr", str$(tfgld.dbcr.credit) )
endif
endif
stpapi.put.field( "tfcmg2120s000", "tfgld102.qty1", str$(0))
stpapi.put.field( "tfcmg2120s000", "tfgld102.qty2", str$(0))
stpapi.put.field( "tfcmg2120s000", "tfgld102.fyer", str$(fiscal.year) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.fprd", str$(fiscal.prod) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.ryer", str$(fiscal.year) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.rprd", str$(rep.prod) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.vyer", str$(tax.year) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.vprd", str$(tax.prod) )
stpapi.put.field( "tfcmg2120s000", "tfgld102.refr", tfsol912.esdb)
stpapi.insert( "tfcmg2120s000", true, cmg.error )

if isspace(cmg.error) then
stpapi.save( "tfcmg2120s000", cmg.error )
else
stpapi.recover( "tfcmg2120s000", cmg.error )
endif

on stpapi.isert,it returns cmg.error = "batch Number not Allowed".

can somebody help me in this. how i should handle this issue.

thanks
Veyant

mark_h
4th October 2006, 18:27
Question - do you have source code for tfcmg2120s000? This way you could debug the problem and someone might be able to make a recommendation. When running manually do you actually enter those fields or do they come from the calling session?

veyant
5th October 2006, 10:56
Yaah, i have source code for the session. While maintaining transaction manually, Batch No, Year and Company, Transcation type, Document No, Line No, Seq # comes by default. Batch No, Year, Transaction Type and Company are imported from tfcmg2100s000.

i will try to debug session tfcmg2120s000 and will update about things later in forum.

thanks

jatin_sanghi
18th October 2006, 11:03
Hi,

Just a suggesstion as i faced something similar.
As i can see that the session tfcmg2120s000 has view fields.Just try to put the view fields and then find and then set.current.view.

regards,

Jatin Sanghi

lbencic
18th October 2006, 22:42
Also note that there is a standard way to generate Journal Vouchers from an external/coding standpoint. You can fill the tfgld936, tfgld938 and tfgld940 and call the Session "Import Journal Voucher Batches by ID Number" (tfgld2215m000). I use that, we have an extensive set of automated JV transactions. Then I call that Import session via an API, it's MUCH easier to control than the actual input sessions.

There is even a standard, if old, JVIMPORT Exchange scheme which will fill those tables from a flat file, if you are comfortable with those. Some info here on another post:

http://www.baanboard.com/baanboard/showthread.php?t=22732&highlight=Import