baan.tools
7th September 2007, 07:07
Hello All,

I have created a session for writing AFS for the session tfgld1101m000 and facing problem. I am getting an error "Journal not Authorise"

Can anyone help me out.

FYI i am writing AFS in Baan 5.

Thanks in Advance....

Regards,
Baan Tools

george7a
7th September 2007, 10:35
Hi,

I have moved your thread to the right forum.

Can you please post your code?

- George

bigjack
7th September 2007, 13:06
What happens when you actually try and maintain record in session tfgld1101m000(not thru AFS) ? Do you get the same error ? If yes, then the problem is functional than technical .

baan.tools
10th September 2007, 13:11
Sorry for late reply... The problem which i was getting was sloved and i am getting another error mentioned at the end of my code...

Please find below the code

stpapi.put.field("tfgld1101m000","tedt.f",str$(date.num()))
stpapi.put.field("tfgld1101m000","tfgld101.year",str$(2007))
stpapi.put.field( "tfgld1101m000", "tfgld101.btno", str$(00))
stpapi.put.field("tfgld1101m000","bref.f",str$("Test"))
stpapi.put.field("tfgld1101m000","fprd.f",str$(09))
stpapi.put.field("tfgld1101m000","rprd.f",str$(03))
stpapi.put.field("tfgld1101m000","vyer.f",str$(2007))
stpapi.put.field("tfgld1101m000","vprd.f",str$(09))
rc = stpapi.change.view("tfgld1101m000",errmsg)
stpapi.put.field("tfgld1101m000","tfgld101.ttyp","O99")
rc = stpapi.insert("tfgld1101m000", true, errmsg)
stpapi.get.field("tfgld1101m000","tfgld101.btno",errmsg)
batch.number = val(errmsg)
stpapi.end.session("tfgld1101m000",errmsg)
rc = stpapi.browse.set("tfgld1101m000", "last.set", w.err.msg)
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(2007))
stpapi.put.field("tfgld1101m000", "tfgld101.btno", str$(batch.number))
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", str$("O99"))
ret = stpapi.find("tfgld1101m000", error.msg)

if rc <> 0 then
rc = stpapi.mark("tfgld1101m000", w.err.msg)
endif

if rc <> 0 then
stpapi.form.command("tfgld1101m000", 5, "exec.cont.process",error.msg)
endif

if isspace(w.err.msg) then
stpapi.put.field("tfgld1114s000", "tfgld102.docn", str$(123456))
stpapi.put.field("tfgld1114s000", "dcdt.f", str$(date.num()))
stpapi.put.field("tfgld1114s000", "ccur.f", str$("EUR"))
stpapi.put.field("tfgld1114s000", "tfgld102.tcom", str$(360))
stpapi.put.field("tfgld1114s000", "tfgld102.leac", str$("70199999"))
stpapi.put.field("tfgld1114s000", "form.amnt", str$(50))
stpapi.put.field("tfgld1114s000", "dbcr", str$(etol(tfgld.dbcr.debit)))
stpapi.put.field("tfgld1114s000", "refr", str$("Interface Payee"))
rc = stpapi.insert("tfgld1114s000",true, e.msg)
if rc = 0 then
rc = stpapi.recover("tfgld1114s000", w.err.msg)
endif
endif
stpapi.end.session("tfgld1114s000",e.msg)
stpapi.end.session("tfgld1101m000",e.msg)


Here i am getting another error The indicator of counted double for the account general is not authorized here when saving the session tfgld1114s000.

Please help me regarding this..

mojo1980
29th November 2007, 20:53
Hi,

I'm trying to do a very similar thing, and I'm running into a problem. I'm using baanIV. When running the script with debug mode, when reaching stpapi.continue.process, it gets stuck at that point.

Any idea what's going on?

Thanks

if rc <> 0 then │
│ 0068: |stpapi.form.command("tfgld1101m000", 5, "exec.│
│ 0069: stpapi.continue.process("tfgld1101m000", error.│
│ 0070: endif

mark_h
29th November 2007, 21:34
Post your code so we can see what it is doing.

mojo1980
30th November 2007, 15:11
Hi, I actually found some code in another thread, it works, but now I'm trying to create more than 1 transaction withnin the same Batch. The message error (code in RED) gives me: Batch/Transaction Type Already used.

If I change view, I get a new batch number. And that's not what I want.

Sorry if I don't use all the correct terms, I'm a newbie with baan.

Thanks for help.

CODE

| Switch the view
if stpapi.change.view("tfgld1101m000", error.msg) > 0 then
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp" , "JIN")
stpapi.put.field("tfgld1101m000", "tfgld101.amnt" , str$(0.00))
| Insert Transaction
ret = stpapi.insert("tfgld1101m000", 1, error.msg)
if not ret then
message("Insert Error for PM1 = %s ", error.msg)
ret2 = stpapi.recover("tfgld1101m000", error.msg)
endif
ret = stpapi.save("tfgld1101m000", error.msg)
if not ret then
message("Save Error for PM1 = %s ", error.msg)
ret2 = stpapi.recover("tfgld1101m000", error.msg)
endif

stpapi.put.field("tfgld1101m000", "tfgld101.ttyp" , "JEM")
stpapi.put.field("tfgld1101m000", "tfgld101.amnt" , str$(0.00))
ret = stpapi.insert("tfgld1101m000", 1, error.msg)
if not ret then
message("Insert Error for PM1 = %s ", error.msg)
ret2 = stpapi.recover("tfgld1101m000", error.msg)
endif
ret = stpapi.save("tfgld1101m000", error.msg)
if not ret then
message("Save Error for PM1 = %s ", error.msg)
ret2 = stpapi.recover("tfgld1101m000", error.msg)
endif
endif

RET = stpapi.browse.set("tfgld1101m000", "last.set")

ret = stpapi.mark("tfgld1101m000", error.msg)

stpapi.handle.subproc("tfgld1101m000", "tfgld1103s000", "add")
stpapi.continue.process("tfgld1101m000", error.msg)
if stpapi.change.view("tfgld1103s000", error.msg) > 0 then
stpapi.put.field("tfgld1103s000", "tfgld102.ttyp", str$("JIN"))
stpapi.put.field("tfgld1103s000", "tfgld102.docn", str$(28))
stpapi.put.field("tfgld1103s000", "ccur.d", str$("CAD"))
stpapi.put.field("tfgld1103s000", "ccty.f", str$("CAN"))
stpapi.put.field("tfgld1103s000", "dcdt.f", str$(date.num()))
stpapi.put.field("tfgld1103s000", "rate.f", str$(1.000000))
stpapi.put.field("tfgld1103s000", "vyer.f",str$(2008))
stpapi.put.field("tfgld1103s000", "vprd.f",str$(08))
stpapi.put.field("tfgld1103s000", "tfgld102.lino", str$(1))
stpapi.put.field("tfgld1103s000", "tfgld102.tcom", str$(300))
stpapi.put.field("tfgld1103s000", "tfgld102.leac", str$(1234567))
stpapi.put.field("tfgld1103s000", "tfgld102.dim2", str$("1234"))
stpapi.put.field("tfgld1103s000", "form.amnt", str$(150.00))
stpapi.put.field("tfgld1103s000", "tfgld102.dbcr", str$(etol(tfgld.dbcr.debit)))
stpapi.put.field("tfgld1103s000", "tfgld102.refr", str$("TESTER"))
rc = stpapi.insert("tfgld1103s000", 1, e.msg)
if rc = 0 then
rc = stpapi.recover("tfgld1103s000", w.err.msg)
endif
stpapi.put.field("tfgld1103s000", "tfgld102.ttyp", str$("JIN"))
stpapi.put.field("tfgld1103s000", "tfgld102.docn", str$(28))
stpapi.put.field("tfgld1103s000", "ccur.d", str$("CAD"))
stpapi.put.field("tfgld1103s000", "ccty.f", str$("CAN"))
stpapi.put.field("tfgld1103s000", "dcdt.f", str$(date.num()))
stpapi.put.field("tfgld1103s000", "rate.f", str$(1.000000))
stpapi.put.field("tfgld1103s000", "vyer.f",str$(2008))
stpapi.put.field("tfgld1103s000", "vprd.f",str$(08))
stpapi.put.field("tfgld1103s000", "tfgld102.lino", str$(2))
stpapi.put.field("tfgld1103s000", "tfgld102.tcom", str$(300))
stpapi.put.field("tfgld1103s000", "tfgld102.leac", str$(1234567))
stpapi.put.field("tfgld1103s000", "tfgld102.dim2", str$("1234"))
stpapi.put.field("tfgld1103s000", "form.amnt", str$(150.00))
stpapi.put.field("tfgld1103s000", "tfgld102.dbcr", str$(etol(tfgld.dbcr.credit)))
stpapi.put.field("tfgld1103s000", "tfgld102.refr", str$("TESTER"))
rc = stpapi.insert("tfgld1103s000", 1, e.msg)
endif
stpapi.end.session("tfgld1103s000")

RET = stpapi.browse.set("tfgld1101m000", "first.set")
ret = stpapi.mark("tfgld1101m000", error.msg)

stpapi.handle.subproc("tfgld1101m000", "tfgld1103s000", "add")
stpapi.continue.process("tfgld1101m000", error.msg)
if stpapi.change.view("tfgld1103s000", error.msg) > 0 then
stpapi.put.field("tfgld1103s000", "tfgld102.ttyp", str$("JIN"))
stpapi.put.field("tfgld1103s000", "tfgld102.docn", str$(28))
stpapi.put.field("tfgld1103s000", "ccur.d", str$("CAD"))
stpapi.put.field("tfgld1103s000", "ccty.f", str$("CAN"))
stpapi.put.field("tfgld1103s000", "dcdt.f", str$(date.num()))
stpapi.put.field("tfgld1103s000", "rate.f", str$(1.000000))
stpapi.put.field("tfgld1103s000", "vyer.f",str$(2008))
stpapi.put.field("tfgld1103s000", "vprd.f",str$(08))
stpapi.put.field("tfgld1103s000", "tfgld102.lino", str$(1))
stpapi.put.field("tfgld1103s000", "tfgld102.tcom", str$(300))
stpapi.put.field("tfgld1103s000", "tfgld102.leac", str$(1234567))
stpapi.put.field("tfgld1103s000", "tfgld102.dim2", str$("1234"))
stpapi.put.field("tfgld1103s000", "form.amnt", str$(90.00))
stpapi.put.field("tfgld1103s000", "tfgld102.dbcr", str$(etol(tfgld.dbcr.debit)))
stpapi.put.field("tfgld1103s000", "tfgld102.refr", str$("TESTER"))
rc = stpapi.insert("tfgld1103s000", 1, e.msg)
if rc = 0 then
rc = stpapi.recover("tfgld1103s000", w.err.msg)
endif
stpapi.put.field("tfgld1103s000", "tfgld102.ttyp", str$("JIN"))
stpapi.put.field("tfgld1103s000", "tfgld102.docn", str$(28))
stpapi.put.field("tfgld1103s000", "ccur.d", str$("CAD"))
stpapi.put.field("tfgld1103s000", "ccty.f", str$("CAN"))
stpapi.put.field("tfgld1103s000", "dcdt.f", str$(date.num()))
stpapi.put.field("tfgld1103s000", "rate.f", str$(1.000000))
stpapi.put.field("tfgld1103s000", "vyer.f",str$(2008))
stpapi.put.field("tfgld1103s000", "vprd.f",str$(08))
stpapi.put.field("tfgld1103s000", "tfgld102.lino", str$(2))
stpapi.put.field("tfgld1103s000", "tfgld102.tcom", str$(300))
stpapi.put.field("tfgld1103s000", "tfgld102.leac", str$(1234567))
stpapi.put.field("tfgld1103s000", "tfgld102.dim2", str$("1234"))
stpapi.put.field("tfgld1103s000", "form.amnt", str$(90.00))
stpapi.put.field("tfgld1103s000", "tfgld102.dbcr", str$(etol(tfgld.dbcr.credit)))
stpapi.put.field("tfgld1103s000", "tfgld102.refr", str$("TESTER"))
rc = stpapi.insert("tfgld1103s000", 1, e.msg)
if rc = 0 then
rc = stpapi.recover("tfgld1103s000", w.err.msg)
endif
endif
stpapi.end.session("tfgld1103s000")
stpapi.end.session("tfgld1101m000")

mark_h
30th November 2007, 16:01
Have your tried another if stpapi.change.view("tfgld1101m000", error.msg) > 0 then before doing the second insert? I do not think I have ever tried to create two transactions. Another thing is to remove the save between the inserts - just to see what happens. I do not have a save in my code.

mojo1980
30th November 2007, 17:24
Thanks Mark,

my error was related to the type, I actually used the same type twice (not in the present code). Also I did remove the save.

It works fine now.

Thanks again.