anjunath
26th July 2015, 10:26
Hi,
I am unable to insert values in tfacr1110s000 using AFS .I am using Infor ERPLN . While debugging an error message is coming like :"ttstps0036"
The below is my source code :

******************************************************************************
|* 15-07-21 [14:58]
|******************************************************************************
|* Script Type: 0
|******************************************************************************

|****************************** declaration section ***************************

#pragma used dll ottstpapihand
#pragma nowarnings
#define ERR shiftl$(shiftr$(error)) <> ""
#include <bic_tt>
|****************************** DECLARATION SECTION ***************************
table ttfgld100
table ttfgld101
table ttfgld102
double trans.amnt
long ret, opno,ret1,ret2
string error(256),sess(13),sub.sess1(13),sub.sess2(13),seqn(4),docn(10),lino(10),
str.btno(11),err.str(50),suno(6),suno1(6),ccur(3),isup(30),refa(30),docd(10),error.msg(256)
domain tcbool afs.success,first.record,valid.data
long amnt, line, doc, rp, reof, wp,dbcr
string leac(12),refr(30),file.name(50), buff(1024), err.file(50),ttyp(3)
double line.amnt, inv.amnt

|****************************** PROGRAM SECTION ***************************
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
|****************************** CHOICE SECTION ***************************
|****************************** FIELD SECTION ***************************
|****************************** MAIN TABLE SECTION ***************************
|****************************** FUNCTION SECTION ***************************






function main()
{
clean.mess()
afs.success = false
str.btno = "0"
stpapi.put.field("tfgld1101m000", "tedt.f", str$(date.num()))
stpapi.put.field("tfgld1101m000", "tfgld100.year", str$(2015))
stpapi.put.field("tfgld1101m000", "tfgld100.bref", "test")
stpapi.put.field("tfgld1101m000","tfgld100.fprd","7")


ret = stpapi.insert("tfgld1101m000", true, error)


if ERR then
message("Cannot Create Batch :- ",shiftl$(error))
stpapi.recover("tfgld1101m000", error)
stpapi.end.session("tfgld1101m000", error)


else
stpapi.get.field("tfgld1101m000","tfgld100.btno",str.btno)
afs.success = true
message("Batch %d",str.btno)
endif

if afs.success then

ret = stpapi.find("tfgld1101m000", error)
if ret then
stpapi.handle.subproc("tfgld1101m000","tfgld1101m100","add")
stpapi.put.field("tfgld1101m100", "tfgld101.year", str$(2015))
stpapi.put.field("tfgld1101m100", "tfgld101.btno", str$(str.btno))
stpapi.put.field("tfgld1101m100", "tfgld101.ttyp", str$("EMD"))
ret = stpapi.insert("tfgld1101m100", true, error)
if ret = 1 then

afs.success = true
else
message(" 2 %s",error)
afs.success = false
endif
else
message(" 3 %s",error)
afs.success = false
endif


ret = stpapi.find("tfgld1101m100", error)
if ret = 1 then
ret = stpapi.mark("tfgld1101m100", error)
afs.success = true
else
message(" 1 %s",error)
afs.success = false
endif
message("Batch Created %s",str.btno)




stpapi.browse.set( "tfgld1101m100" ,"last.set" ,error )
stpapi.handle.subproc("tfgld1101m100", "tfacr1110s000", "add")
stpapi.handle.subproc("tfacr1110s000", "tfacr1111s000", "kill")
stpapi.continue.process("tfgld1101m100",error )


stpapi.put.field("tfacr1110s000", "tfacr200.ttyp", "EMD")
stpapi.put.field("tfacr1110s000", "tfacr200.ninv", "615")
stpapi.put.field("tfacr1110s000", "tfacr200.itbp", "EMP100001")
stpapi.put.field("tfacr1110s000", "tfacr200.styp", "SLS")
stpapi.put.field("tfacr1110s000", "tfacr200.pfbp", "EMP100001")
stpapi.put.field("tfacr1110s000", "tfacr200.ccur", "AED")
stpapi.put.field("tfacr1110s000", "tfacr200.docd", "15/07/2015")
stpapi.put.field("tfacr1110s000", "screen.amnt", "1000")
stpapi.put.field("tfacr1110s000", "tfacr200.refr", "test")


ret =stpapi.insert( "tfacr1110s000", false, error)

If ret = 1 then
stpapi.save( "tfacr1110s000", error)
message("Record3 inserted successfully")
else
error.msg = stpapi.get.mess.code("tfacr1110s000", error)
if isspace(error.msg) then
else
message("not inserted :" &error.msg)
endif
stpapi.recover("tfacr1110s000",error)
message("Insert not saved:" &error)
endif

stpapi.handle.subproc("tfacr1110s000", "tfacr1111s000", "add")
stpapi.continue.process("tfacr1110s000" ,error)

stpapi.put.field("tfacr1111s000", "tfgld102.leac", "11900")
stpapi.put.field("tfacr1111s000", "tfgld102.dim1","1000")
stpapi.put.field("tfacr1111s000", "amount", "1000")

ret =stpapi.insert("tfacr1111s000",FALSE, error)
If ret = 1 then

message("Record3 inserted successfully")
else
stpapi.recover( "tfacr1111s000",error)
message("Insert sub:" &error)
endif

stpapi.end.session( "tfacr1111s000", error)
stpapi.end.session( "tfacr1110s000", error)
stpapi.end.session("tfgld1101m100", error)
stpapi.end.session( "tfgld1101m000", error)

endif



}

mark_h
26th July 2015, 21:26
What is the text related to the message? Anw where exactly in the code does the error does the error occur.

anjunath
27th July 2015, 07:26
Batch is created and Transaction type is inserted. But after calling the sub session and insert to sub session (tfacr1110s000) is not working ,it is throwing this error code . 'ttstps0036' .

please refer below for the code portion.

stpapi.browse.set( "tfgld1101m100" ,"last.set" ,error ) stpapi.handle.subproc("tfgld1101m100", "tfacr1110s000", "add") stpapi.handle.subproc("tfacr1110s000", "tfacr1111s000", "kill") stpapi.continue.process("tfgld1101m100",error )


stpapi.put.field("tfacr1110s000", "tfacr200.ttyp", "EMD")
stpapi.put.field("tfacr1110s000", "tfacr200.ninv", "615")
stpapi.put.field("tfacr1110s000", "tfacr200.itbp", "EMP100001")
stpapi.put.field("tfacr1110s000", "tfacr200.styp", "SLS")
stpapi.put.field("tfacr1110s000", "tfacr200.pfbp", "EMP100001")
stpapi.put.field("tfacr1110s000", "tfacr200.ccur", "AED")
stpapi.put.field("tfacr1110s000", "tfacr200.docd", "15/07/2015")
stpapi.put.field("tfacr1110s000", "screen.amnt", "1000")
stpapi.put.field("tfacr1110s000", "tfacr200.refr", "test")


ret =stpapi.insert( "tfacr1110s000", false, error)

If ret = 1 then
stpapi.save( "tfacr1110s000", error)
message("Record3 inserted successfully")
else
error.msg = stpapi.get.mess.code("tfacr1110s000", error)
if isspace(error.msg) then
else
message("not inserted :" &error.msg)
endif
stpapi.recover("tfacr1110s000",error)
message("Insert not saved:" &error)
endif

mark_h
27th July 2015, 15:14
Why do you use false for the insert instead of true? Also try using string stpapi.get.mess.code(string session [, ref string err.mesg]) to get the text of that error message that might help. One of the fields might be empty or something. Other than that your code reminds me of some of mine.


stpapi.put.field("tfacp1110s000", "ref.po", str$(tdudi050.orno))
stpapi.put.field("tfacp1110s000", "tfacp200.isup", strip$(tdudi050.refr) & "a")
stpapi.put.field("tfacp1110s000", "tfacp200.refr", strip$(tdudi050.refr) & "a")
stpapi.put.field("tfacp1110s000", "tfacp200.docd", str$(date.num()))
stpapi.put.field("tfacp1110s000", "screen.amnt", str$(round(tdudi050.amnt, 2, 0)))
stpapi.put.field("tfacp1110s000", "tfacp200.reas", "0")
stpapi.handle.subproc("tfacp1110s000", "tfacp1230s000", "kill")
rc = stpapi.insert("tfacp1110s000", 1, errmsg)

anjunath
28th July 2015, 07:45
I have change the code like this , I got the error message "Transaction type not found. " But when I go for manual entries I am using same transaction type only.


stpapi.put.field("tfacr1110s000", "tfacr200.ttyp", "EMD")
stpapi.put.field("tfacr1110s000", "tfacr200.ninv", "615")
stpapi.put.field("tfacr1110s000", "tfacr200.itbp", "EMP100001")
stpapi.put.field("tfacr1110s000", "tfacr200.styp", "SLS")
stpapi.put.field("tfacr1110s000", "tfacr200.pfbp", "EMP100001")
stpapi.put.field("tfacr1110s000", "tfacr200.ccur", "AED")
stpapi.put.field("tfacr1110s000", "tfacr200.docd", "15/07/2015")
stpapi.put.field("tfacr1110s000", "screen.amnt", "1000")
stpapi.put.field("tfacr1110s000", "tfacr200.refr", "test")

stpapi.put.field("tfacr1110s000", "tfacr200.lvat", "Transaction Line")
stpapi.put.field("tfacr1110s000", "tfacr200.vatc", " ")
stpapi.put.field("tfacr1110s000", "tfacr200.cvat", " ")
stpapi.put.field("tfacr1110s000", "tfacr200.vaty", "2015")
stpapi.put.field("tfacr1110s000", "tfacr200.vatp", "1")
stpapi.put.field("tfacr1110s000", "tfacr200.cpay", "N00")
stpapi.put.field("tfacr1110s000", "tfacr200.ccrs", " ")
stpapi.put.field("tfacr1110s000", "tfacr200.paym", " ")
stpapi.put.field("tfacr1110s000", "tfacr200.pysh", " ")
stpapi.put.field("tfacr1110s000", "tfacr200.prob", " ")
stpapi.put.field("tfacr1110s000", "tfacr200.pref", " ")
stpapi.put.field("tfacr1110s000", "tfacr200.leac", "13040")
stpapi.put.field("tfacr1110s000", "tfacr200.otyp", " ")
stpapi.put.field("tfacr1110s000", "tfacr200.adrs", "EMP100001")

ret =stpapi.insert( "tfacr1110s000", true, error)

If ret = 1 then
stpapi.save( "tfacr1110s000", error)
message("Record3 inserted successfully")
else
error.msg = stpapi.get.mess.code("tfacr1110s000", err.message)
dal.set.error.message("@"&err.message)
show.dal.messages(MSG.ALL)
if isspace(error.msg) then
else
message("not inserted :" &error.msg)

endif
stpapi.recover("tfacr1110s000",error)
message("Insert not saved:" &error)

endif

bhushanchanda
28th July 2015, 09:51
Hi,

Please verify your first part of the program -

stpapi.put.field("tfgld1101m100", "tfgld101.ttyp", str$("EMD"))

Instead of this, you can use the value directly without converting to string. i.e. "EMD". Not sure what you are trying to do.

Also, you don't need an insert after entering the dates and year/period. Just make a change view.
e.g

stpapi.put.field("tfgld1101m000","tedt.f",str$(trdt.f))
ret = stpapi.change.view("tfgld1101m000",w.err.msg)
stpapi.put.field("tfgld1101m000","tfgld101.ttyp",ttyp.f)
ret = stpapi.insert("tfgld1101m000", true, w.err.msg)
if ret then
ret = stpapi.mark("tfgld1101m000",w.err.msg)
if ret then
stpapi.handle.subproc( "tfgld1101m000", "tfacr1110s000", "add")
....
endif
endf

So, you are never going inside the sub-session.

mark_h
28th July 2015, 15:17
The first thing I would try is to remove the str as bhushan has mentioned when creating the batch. Then if that works - great. If it does not work then the second thing I would do is remove putting the transaction type on tfacp1110s000.

Here is a complete copy of one of my functions - you will note I only put the necessary fields on tfacp1110s000 that I have to. The transaction type is already there - so I do not enter it again. Also note I create the batch in another function(included below) - this function server actually creates three transaction types(2 by me 1 by the system). Also keep in mind different systems do different things in some of these sessions.

function create.zrcb()
{
errmsg = ""
errmsg1= ""
stpapi.put.field("tfgld1100m000", "tfgld100.year", str$(c.yyyy))
stpapi.put.field("tfgld1100m000", "tfgld100.btno", str$(s.btno))
rc = stpapi.find("tfgld1100m000", errmsg)
if rc<>1 then
errmsg1 = "6." & "Batch not found"
stpapi.end.session("tfgld1100m000")
return
endif

| Start Session tfgld1101s000
stpapi.handle.subproc("tfgld1100m000", "tfgld1101s000", "add")
stpapi.continue.process("tfgld1100m000",errmsg)
if not isspace(errmsg) then
errmsg1 = "7." & errmsg
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
return
endif

stpapi.put.field("tfgld1101s000", "tfgld101.year", str$(c.yyyy))
stpapi.put.field("tfgld1101s000", "tfgld101.btno", str$(s.btno))
stpapi.put.field("tfgld1101s000", "tfgld101.ttyp", "ZRC")
rc = stpapi.find("tfgld1101s000", errmsg)
if rc<>1 then
errmsg1 = "8." & "ZRC not found"
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
return
endif
stpapi.handle.subproc("tfgld1101s000", "tfacp1110s000", "add")
stpapi.continue.process("tfgld1101s000", errmsg)
stpapi.save("tfacp1110s000",errmsg)

stpapi.put.field("tfacp1110s000", "ref.po", str$(tdudi050.orno))
stpapi.put.field("tfacp1110s000", "tfacp200.isup", strip$(tdudi050.refr) & "b")
stpapi.put.field("tfacp1110s000", "tfacp200.refr", strip$(tdudi050.refr) & "b")
stpapi.put.field("tfacp1110s000", "tfacp200.docd", str$(date.num()))
stpapi.put.field("tfacp1110s000", "screen.amnt", str$(round(tdudi050.amnt*-1.00, 2, 0)))
stpapi.put.field("tfacp1110s000", "tfacp200.reas", "0")
stpapi.handle.subproc("tfacp1110s000", "tfacp1230s000", "add")
rc = stpapi.insert("tfacp1110s000", 1, errmsg)
stpapi.end.session("tfacp1230s000")
if not isspace(errmsg) then
errmsg1 = "8b." & errmsg
stpapi.end.session("tfacp1110s000",errmsg)
stpapi.end.session("tfgld1101s000",errmsg)
stpapi.end.session("tfgld1100m000",errmsg)
return
endif

stpapi.get.field("tfacp1110s000", "tfacp200.ninv", errmsg)
tdudi055.doc2 = val(errmsg)

errmsg = ""
stpapi.end.session("tfacp1110s000",errmsg)
stpapi.end.session("tfgld1101s000",errmsg)
stpapi.end.session("tfgld1100m000",errmsg)
}
function extern domain tfgld.btno create.batch.for.zrc(ref string msg())
{
num.to.date(date.num(), c.yyyy, c.mm, c.dd)

c.btno = get.next.btno(c.yyyy)
c.fprd = get.cur.fiscal.period()
c.rprd = get.cur.report.period()
c.vprd = get.cur.tax.period()


| 1. tfgld1100m000 (Maintain Transactions)
| 1.0 Input Batch data
stpapi.put.field("tfgld1100m000", "tfgld100.tedt", str$(date.num()))
stpapi.put.field("tfgld1100m000", "tfgld100.year", str$(c.yyyy))
stpapi.put.field("tfgld1100m000", "tfgld100.btno", str$(c.btno))
stpapi.put.field("tfgld1100m000", "tfgld100.bref", sprintf$("INVOICE MATCH (%02d/%02d/%02d)", c.mm, c.dd, c.yyyy\100))
stpapi.put.field("tfgld1100m000", "tfgld100.fprd", str$(c.fprd))
stpapi.put.field("tfgld1100m000", "tfgld100.rprd", str$(c.rprd))
stpapi.put.field("tfgld1100m000", "tfgld100.vyer", str$(c.yyyy))
stpapi.put.field("tfgld1100m000", "tfgld100.vprd", str$(c.vprd))
| 1.1 Insert a batch record
rc = stpapi.insert("tfgld1100m000", 1, errmsg)
if not isspace(errmsg) then
stpapi.end.session("tfgld1100m000")
return(0)
endif

| Start Session tfgld1101s000 ... Insert CTR transaction holder
stpapi.handle.subproc("tfgld1100m000", "tfgld1101s000", "add")
| 1.2 Select Continue button
stpapi.continue.process("tfgld1100m000", errmsg)
stpapi.save("tfgld1101s000", errmsg)

| 2. tfgld1101s000 (Maintain Transactions)
| 2.0 Input Batch transaction type
stpapi.put.field("tfgld1101s000", "tfgld101.ttyp", "ZRC")
| 2.1 Insert a ZRC transaction into that batch
rc = stpapi.insert("tfgld1101s000", 1, errmsg)
if not isspace(errmsg) then
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
return(0)
endif

stpapi.put.field("tfgld1101s000", "tfgld101.ttyp", "AP5")
| 2.1 Insert a ZRC transaction into that batch
rc = stpapi.insert("tfgld1101s000", 1, errmsg)
if not isspace(errmsg) then
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
return(0)
endif
stpapi.end.session("tfgld1101s000")
stpapi.end.session("tfgld1100m000")
return(c.btno)

}

anjunath
29th July 2015, 07:21
Thank you so much for the replies. It is working fine. I have formatted the date like this str$(date.num()) and removed the change .view and continue.process from the code .

ret=stpapi.browse.set( "tfgld1101m100" ,"last.set" ,error )
If ret = 1 then

message("Record browse successfully")
endif
stpapi.handle.subproc("tfgld1101m100", "tfacr1110s000", "add")

stpapi.form.command("tfgld1101m100",2, "tfacr1110s000",err.message)
dal.set.error.message("@"&err.message)
show.dal.messages(MSG.ALL)

now it is working fine in LN .

Thank you all .