rohan_rege
12th September 2002, 00:43
I am trying to write an AFs for Maintain transaction , session.

but the problem is that there is no data entry done on this session ,bczo most of the fields transc. date , batch no , etc are defaulted.
we can change all fields except batch no. if desired , of course .
but mostly the default values are taken.

i am trying to simulate the session thru a script where i am putting a value in only the batch no. description .

i am assuming that all the fields shud be populated as they are defaulted when a user tries to create a new record manually.

the foll. compiles but goes in to a loop forever ........

any suggestions


the code goes as follows :


function in.tfgld1100m000()

{

f1100m000.put.Batch_Reference("test batch")

f1100m000.insert(1,err)

if(strip$(err)<>"") then
msg = f1100m000.get.last.message.code()
msg = "tfgld1100m000 insert: "& strip$(err)&" "& strip$(msg)

message(msg)
else
message(" successfull " )


endif


f1100m000.end( )

return

}

NPRao
12th September 2002, 00:54
Hi Rohan,

I had the same issue. You have to remove the defaults for the session before you use the AFS/API calls or else you have to explicitly assign values to each field.

If its your own script use additional programming constructs as -


|****************************** FORM SECTION ******************************
group.1:
init.group:
if not (api.mode or job.process or background) then
get.screen.defaults()
endif


I was mainly dealing with print and process sessions, I am not sure about the maintain sessions, maybe Mark can say more.

rohan_rege
12th September 2002, 01:12
when i ran the session in debug mode...
i see that the session goes for a toss on the very first

stpapi comand that it comes across

any idea , why its so ?

NPRao
12th September 2002, 01:16
Use -- -set AFSLOG=1 in your command option in the BW configuration, which creates the afs log file in your unix home directory.

Go through it to find the problem and ofcourse if you cant figure out, we have to wait for Mr. AFS-Expert (Mark) to appear back on the board here. :D

rohan_rege
12th September 2002, 01:23
whats the afs log file name that gets created ?

NPRao
12th September 2002, 01:30
The file name is afs.log in your home directory

rohan_rege
12th September 2002, 02:56
hi ,

as u told me i put in the values for all the fields , but still its saying .....value cannot be zero

problem is , i dont know which field it is saying that for ...

any idea how to go abt it.

i added stpapi.get commands in the script to debug my cod easily..
i see that all the values are corr. being put in the fields.

pls see if u can help ...

regards
Rohan

**SAT**
12th September 2002, 09:44
Hi Rohan,

Just now I tried to insert a record thru 'Maintain Transaction' session using AFS..

Only for description I put the value only in the Batch description field (tfgld100.bref) as you did... And the rest of the fields are taking the default values...

It is working fine for me..

Here is the Sample code :


#pragma used dll "ottstpapihand"

domain tcmcs.str80 error.mess

function main()
{
stpapi.put.field("tfgld1100m000","tfgld100.bref","My Batch number")

stpapi.insert("tfgld1100m000",1,error.mess)

message(error.mess)
stpapi.end.session("tfgld1100m000")
}


Regards,