minadursun
13th March 2015, 15:20
In Infor ERP-LN 10.4 when I created a patch then bank transaction, I want to import lots of advance payment lines from *.csv file to the Transactions (tfgld1101m000) session.
I started the tfgld1101m000 and added a new batch and new transaction type (bank transaction), then run "Transaction Entry -enter.transactions-" form command. Actually this command is on the menu of the tfgld1101m100 Transaction Types session.
After then Bank Transactions (tfcmg2500m000) session is started via this command. I wanna insert my advance payment lines on this session. On the menu, there is a form command that is Insert -insert.in.details.mode-. Via this command, Bank Transactions session (tfcmg2500m000) is running again with different design -On fp3 from tfgld1101m000, I had got tfcmg2100s000 session screen and that looked like tfcmg2500m000-.
Here is my code below:
#pragma used dll ottstpapihand
#define MAIN.SESSION "tfgld1101m100"
#define SUB.SESSION "tfcmg2500m000"
function void doit()
{
boolean tmp.first
long afs.ret
afs.ret = 0
error.msg = ""
stpapi.put.field(MAIN.SESSION, "tfgld101.year", str$(year.f))
stpapi.put.field(MAIN.SESSION, "tfgld101.btno", str$(btno.f))
stpapi.put.field(MAIN.SESSION, "tfgld101.ttyp", ttyp.f)
afs.ret = stpapi.find(MAIN.SESSION, error.msg)
if afs.ret <> 1 then
fp.ret = seq.puts("Error: Could not find the record! ", fp.log)
stpapi.end.session(MAIN.SESSION, error.msg)
return
endif
afs.ret = stpapi.mark(MAIN.SESSION, error.msg)
if afs.ret <> 1 then
fp.ret = seq.puts("Error: Could not mark the record! ", fp.log)
stpapi.end.session(MAIN.SESSION, error.msg)
return
endif
stpapi.handle.subproc(MAIN.SESSION, SUB.SESSION, "add", error.msg)
stpapi.form.command(MAIN.SESSION, 2, "enter.transactions", error.msg)
stpapi.form.command(SUB.SESSION, 2, "insert.in.details.mode", error.msg)
if afs.ret = 0 then
message(error.msg)
stpapi.end.session(MAIN.SESSION, error.msg)
return
endif
tmp.first = true
while seq.gets(buffer, MAX.STR, fp.import) = 0
if process.records.from.file() = NUMBER.OF.FIELDS then
create.record(tmp.first)
tmp.first = false
else
fp.ret = seq.puts(buffer & "Data is corrupt " , fp.log)
endif
endwhile
stop.all.processes()
}
function long process.records.from.file()
{
fields.scanned = string.scan(buffer, "%s,%s,%s,%f", prm.bpid, prm.bpnm, prm.bpac, prm.amnt)
return(fields.scanned)
}
function create.record(boolean first.i)
{
long afs.ret
string tmp.str(MAX.STR) mb
stpapi.put.field(SUB.SESSION, "tfcmg204.year", str$(year.f))
stpapi.put.field(SUB.SESSION, "tfcmg204.btno", str$(btno.f))
stpapi.put.field(SUB.SESSION, "tfcmg204.ttyp", str$(ttyp.f))
stpapi.put.field(SUB.SESSION, "tfcmg204.docd", str$(docd.f))
stpapi.put.field(SUB.SESSION, "tfcmg204.docn", str$(seri.f))
stpapi.put.field(SUB.SESSION, "tfcmg204.lino", "1")
stpapi.put.field(SUB.SESSION, "tfcmg204.tran", str$(tfcmg.tran.advance.paym))
stpapi.put.field(SUB.SESSION, "tfcmg204.bpid", prm.bpid)
stpapi.put.field(SUB.SESSION, "tfcmg204.ccur", ccur.f)
stpapi.put.field(SUB.SESSION, "tfcmg204.amnt", str$(prm.amnt))
prm.bpnm = referance.f & " " & prm.bpnm
stpapi.put.field(SUB.SESSION, "tfcmg204.refr", prm.bpnm)
afs.ret = stpapi.insert(SUB.SESSION, true, error.msg)
if afs.ret = 0 then
tmp.str = "Error: " & buffer & " Message: " & mb.cast.to.str$(error.msg)
fp.ret = seq.puts(tmp.str, fp.log)
afs.ret = stpapi.recover(SUB.SESSION, error.msg)
endif
}
function generate.tmp.file.names()
{
long r_number
r_number = random()
remote.file.name = getenv$("BSE") & "/tmp/import_items_uploaded_" & str$(r_number) & ".txt"
log.file.name = getenv$("BSE") & "/tmp/import_items_log_" & str$(r_number) & ".txt"
}
function stop.all.processes()
{
stpapi.end.session(SUB.SESSION, error.msg)
stpapi.end.session(MAIN.SESSION, error.msg)
}
My *.csv file format is below:
123456,Mark Smith,666666,128.6
654321,Alice Silver,5555555,32.51
First column is Business Partner ID,
Second column is BP name,
Third one is bank account
Fourth one is amount.
My problem is that,
On fp3 my main session was tfgld1101m000 and this program was working very vell. I change it with tfgld1101m100 on 10.4. It works but one line is added, next one is not.
For example if I have 10 lines, the program added only 5 lines and these are 1., 3., 5., 7., 9. ones.
I could not understand why. Please share your experience and thoughts with me.
Thanks in advance.
Mina
I started the tfgld1101m000 and added a new batch and new transaction type (bank transaction), then run "Transaction Entry -enter.transactions-" form command. Actually this command is on the menu of the tfgld1101m100 Transaction Types session.
After then Bank Transactions (tfcmg2500m000) session is started via this command. I wanna insert my advance payment lines on this session. On the menu, there is a form command that is Insert -insert.in.details.mode-. Via this command, Bank Transactions session (tfcmg2500m000) is running again with different design -On fp3 from tfgld1101m000, I had got tfcmg2100s000 session screen and that looked like tfcmg2500m000-.
Here is my code below:
#pragma used dll ottstpapihand
#define MAIN.SESSION "tfgld1101m100"
#define SUB.SESSION "tfcmg2500m000"
function void doit()
{
boolean tmp.first
long afs.ret
afs.ret = 0
error.msg = ""
stpapi.put.field(MAIN.SESSION, "tfgld101.year", str$(year.f))
stpapi.put.field(MAIN.SESSION, "tfgld101.btno", str$(btno.f))
stpapi.put.field(MAIN.SESSION, "tfgld101.ttyp", ttyp.f)
afs.ret = stpapi.find(MAIN.SESSION, error.msg)
if afs.ret <> 1 then
fp.ret = seq.puts("Error: Could not find the record! ", fp.log)
stpapi.end.session(MAIN.SESSION, error.msg)
return
endif
afs.ret = stpapi.mark(MAIN.SESSION, error.msg)
if afs.ret <> 1 then
fp.ret = seq.puts("Error: Could not mark the record! ", fp.log)
stpapi.end.session(MAIN.SESSION, error.msg)
return
endif
stpapi.handle.subproc(MAIN.SESSION, SUB.SESSION, "add", error.msg)
stpapi.form.command(MAIN.SESSION, 2, "enter.transactions", error.msg)
stpapi.form.command(SUB.SESSION, 2, "insert.in.details.mode", error.msg)
if afs.ret = 0 then
message(error.msg)
stpapi.end.session(MAIN.SESSION, error.msg)
return
endif
tmp.first = true
while seq.gets(buffer, MAX.STR, fp.import) = 0
if process.records.from.file() = NUMBER.OF.FIELDS then
create.record(tmp.first)
tmp.first = false
else
fp.ret = seq.puts(buffer & "Data is corrupt " , fp.log)
endif
endwhile
stop.all.processes()
}
function long process.records.from.file()
{
fields.scanned = string.scan(buffer, "%s,%s,%s,%f", prm.bpid, prm.bpnm, prm.bpac, prm.amnt)
return(fields.scanned)
}
function create.record(boolean first.i)
{
long afs.ret
string tmp.str(MAX.STR) mb
stpapi.put.field(SUB.SESSION, "tfcmg204.year", str$(year.f))
stpapi.put.field(SUB.SESSION, "tfcmg204.btno", str$(btno.f))
stpapi.put.field(SUB.SESSION, "tfcmg204.ttyp", str$(ttyp.f))
stpapi.put.field(SUB.SESSION, "tfcmg204.docd", str$(docd.f))
stpapi.put.field(SUB.SESSION, "tfcmg204.docn", str$(seri.f))
stpapi.put.field(SUB.SESSION, "tfcmg204.lino", "1")
stpapi.put.field(SUB.SESSION, "tfcmg204.tran", str$(tfcmg.tran.advance.paym))
stpapi.put.field(SUB.SESSION, "tfcmg204.bpid", prm.bpid)
stpapi.put.field(SUB.SESSION, "tfcmg204.ccur", ccur.f)
stpapi.put.field(SUB.SESSION, "tfcmg204.amnt", str$(prm.amnt))
prm.bpnm = referance.f & " " & prm.bpnm
stpapi.put.field(SUB.SESSION, "tfcmg204.refr", prm.bpnm)
afs.ret = stpapi.insert(SUB.SESSION, true, error.msg)
if afs.ret = 0 then
tmp.str = "Error: " & buffer & " Message: " & mb.cast.to.str$(error.msg)
fp.ret = seq.puts(tmp.str, fp.log)
afs.ret = stpapi.recover(SUB.SESSION, error.msg)
endif
}
function generate.tmp.file.names()
{
long r_number
r_number = random()
remote.file.name = getenv$("BSE") & "/tmp/import_items_uploaded_" & str$(r_number) & ".txt"
log.file.name = getenv$("BSE") & "/tmp/import_items_log_" & str$(r_number) & ".txt"
}
function stop.all.processes()
{
stpapi.end.session(SUB.SESSION, error.msg)
stpapi.end.session(MAIN.SESSION, error.msg)
}
My *.csv file format is below:
123456,Mark Smith,666666,128.6
654321,Alice Silver,5555555,32.51
First column is Business Partner ID,
Second column is BP name,
Third one is bank account
Fourth one is amount.
My problem is that,
On fp3 my main session was tfgld1101m000 and this program was working very vell. I change it with tfgld1101m100 on 10.4. It works but one line is added, next one is not.
For example if I have 10 lines, the program added only 5 lines and these are 1., 3., 5., 7., 9. ones.
I could not understand why. Please share your experience and thoughts with me.
Thanks in advance.
Mina