kmcinc
4th January 2011, 21:42
I have a problem with an AFS for session tfacr4410m000 - Print Sales Invoices in Baan IVc4. It prints the correct invoice but it ignores the set invoice date. However, when I use the session interactively it works just fine. When I debugged the print session I found that the form variable "invd.p" which is an input field on the form, is never set to the value I specified in the AFS. Any ideas why?
mark_h
4th January 2011, 23:42
Post the code - make sure the date format is in correct string format. Below are pieces of code examples.
domain tcdate run.gendate.f,
domain tcdate run.gendate.t,
stpapi.put.field("tdilc4401m000","gendate.f",str$(run.gendate.f))
stpapi.put.field("tdilc4401m000","gendate.t",str$(run.gendate.t))
stpapi.put.field("tdilc4202m000","prdt.t",str$(date.num()+1000))
stpapi.put.field("tdilc4202m000","ddta.f",str$(date.num()-1000))
stpapi.put.field("tdilc4202m000","ddta.t",str$(date.num()+1000))
kmcinc
5th January 2011, 00:20
I checked the afs.log but it doesn't reveal anything as far as I can see; all the provided values are there (note invd.p is set to "12272010"):
10serv<-4gl (add.set+save^A0^A1)
tfacr4100m000(10)-RUNNING:
8dll->serv (start^Atfacr4410m000^A1^A^A0^A0)
12serv<-4gl (api.child.startedtfacr4410m0008)
12serv<-4gl (init.ready)
tfacr4410m000(12)-RUNNING:
>tfacr4410m000(12) put.field:cuno.f 7857
>tfacr4410m000(12) put.field:cuno.t 7857
>tfacr4410m000(12) put.field:ttyp.f R20
>tfacr4410m000(12) put.field:ttyp.t R20
>tfacr4410m000(12) put.field:ninv.f 13
>tfacr4410m000(12) put.field:ninv.t 13
>tfacr4410m000(12) put.field:reprint.posted 2
>tfacr4410m000(12) put.field:reprint 2
>tfacr4410m000(12) put.field:defn 1
>tfacr4410m000(12) put.field:invd.p 12272010
>tfacr4410m000(12) put.field:invoice.rate 1
>tfacr4410m000 set.report
8dll->serv (set.report^Artfacr441011000^AASCIF ^A12)
tfacr4410m000(12)-RUNNING:set.report
12serv<-4gl (set.report^A0)
tfacr4410m000(12)-RUNNING:
<tfacr4410m000
>tfacr4410m000(12) put.field:spool.fileout ${BSE}/tmp/SMPlus.Print.Invoice.txt
>tfacr4410m000 continue.process
8dll->serv (cont.process^A12)
tfacr4410m000(12)-RUNNING:cont.process
13serv<-4gl (api.child.startedttstpsplopen 12)
12serv<-4gl (cont.process^A0)
tfacr4410m000(12)-RUNNING:
<tfacr4410m000
>tfacr4410m000 end.session
8dll->serv (end.program^A12)
tfacr4410m000(12)-RUNNING:end.program
12dll->serv (tfacr4410m000: exit(12))
>tfacr4100m000 end.session
8dll->serv (end.program^A10)
tfacr4100m000(10)-RUNNING:end.program
10dll->serv (tfacr4100m000: exit(10))
8dll->serv (afsscript: exit(8))
$
kmcinc
5th January 2011, 00:26
Mark,
here's the code as requested:
stpapi.put.field( "tfacr4410m000", "cuno.f", smgld901.bcustnum )
stpapi.put.field( "tfacr4410m000", "cuno.t", smgld901.bcustnum )
stpapi.put.field( "tfacr4410m000", "ttyp.f", smgld001.ttyp )
stpapi.put.field( "tfacr4410m000", "ttyp.t", smgld001.ttyp )
stpapi.put.field( "tfacr4410m000", "ninv.f", str.ninv )
stpapi.put.field( "tfacr4410m000", "ninv.t", str.ninv )
stpapi.put.field( "tfacr4410m000", "reprint.posted", STR$( ETOL( tcyesno.no ) ) )
stpapi.put.field( "tfacr4410m000", "reprint", STR$( ETOL( tcyesno.no ) ) )
stpapi.put.field( "tfacr4410m000", "defn", STR$( ETOL( tcyesno.yes ) ) )
stpapi.put.field( "tfacr4410m000", "invd.p", "12272010" )
| stpapi.put.field( "tfacr4410m000", "invd.p", inv.date )
stpapi.put.field( "tfacr4410m000", "invoice.rate", STR$( ETOL( tcyesno.yes ) ) )
stpapi.continue.process( "tfacr4410m000", error.msg )
stpapi.end.session( "tfacr4410m000", error.msg )
mark_h
5th January 2011, 15:46
Wrong format for the date. Below is a snippet of code from one program that reads in the lot date and converts it to tcdate for a bin to bin transfer.
long num.day, num.month, num.year
num.day = val(read.date(4;2))
num.month = val(read.date(1;2))
num.year = val(read.date(7;4))
tdudi020.date = date.to.num(num.year, num.month, num.day)
You could just user inv.date = date.to.num(2010,12,27) - of course declare inv.date as tcdate. Then use stpapi.put.field( "tfacr4410m000", "invd.p", str$(inv.date)).
kmcinc
5th January 2011, 20:06
easy enough, that was it. thanks mark. and i will read the documentation more thoroughly next time :)