NPRao
5th March 2002, 00:55
Hi All,

I am trying my hands at the function server and api stuffs.

I use the ttstpcreatdll and got the dll generated. I then made a new 3-gl program which uses that dll and it should start the session with the form fields assigned to it.

I am trying to trace it in debuggers I see that the session is not shown in foreground and also that it seems running forever and I have to kill the processes.

Here is the 3-GL code -
#pragma used dll ozmadm9203m000f
#pragma used dll ottstpapihand

function main()
{
string error(80)

stpapi.put.field("zmadm9203m000", "cpac.f", " ")
stpapi.put.field("zmadm9203m000", "cpac.t", "zz")
stpapi.put.field("zmadm9203m000", "cmod.f", " ")
stpapi.put.field("zmadm9203m000", "cmod.t", "zzz")
stpapi.put.field("zmadm9203m000", "script.f", " ")
stpapi.put.field("zmadm9203m000", "script.t", "zzzzzzzzz")
stpapi.put.field("zmadm9203m000", "vwie.yn", "zmyeno.no")

zmadm9203m000f.exec.cont.process(error)
zmadm9203m000f.end( )
}
Anyone has clues ???

Thanks!

popeye
5th March 2002, 02:26
Hi NPRao,
You are not using the created DLL i.e. ozmadm9203m000f

Instead of using stpapi.put.field ("zmadm9203m000", "cpac.f", " ") use the corresponding function in the created Function Server.

Open the created Function Server (in ur case zmadm9203m000f)
It'll have functions like zmadm9203m000f.put.Package (...) etc
Use them directly.

The standard naming convention for Function Server DLLs is
package + module + "f" + session code
In your case zmadmf9203m000

Also ... if u have your session (zmadm9203m000) in the debug mode, u'll be able to trace it.

Hope this helps.

NPRao
5th March 2002, 02:41
Hi Popeye,

thanks for the tip.

My function server dll name is ozmadm9203m000f

I have 7 form fields but I could not find any put functions in that dll... I dont know why so I used them in my test 3 gl session explicitly as -
stpapi.put.field("zmadm9203m000", "cpac.f", " ")
stpapi.put.field("zmadm9203m000", "cpac.t", "zz")
stpapi.put.field("zmadm9203m000", "cmod.f", " ")
stpapi.put.field("zmadm9203m000", "cmod.t", "zzz")
stpapi.put.field("zmadm9203m000", "script.f", " ")
stpapi.put.field("zmadm9203m000", "script.t", "zzzzzzzzz")
stpapi.put.field("zmadm9203m000", "vwie.yn", "zmyeno.no")
I also added the statement for the api.mode, from the other posting on the board.
group.1:
init.group:
if not api.mode then
get.screen.defaults()
endif

Tracing through the debugger I found why my session was hanging -

|****************************** choice section ********************************

choice.cont.process:
on.choice:

if spool.open("","",1) then
start.process()
spool.close()
else
choice.again()
endif
The spool session did not start and ask me for a device, and it went to the choice.again() section and I guess thats a reason why it seems hanging or showing running.

Do you have an idea how to fix this ?

popeye
5th March 2002, 02:49
Hi NPRao,
I have never used a Function Server for a Print Session.
Here is what I found in the documentation.
Take a look at it.

Just curious .... Why would you want to use Function Servers for print sessions ?

Hope this helps.


3.14 Set Session Report Parameters
SYNTAX
void stpapi.set.report(string session, string reportname, string device, string err.mesg)
ARGUMENTS
session Name of the session this command is executed on.
reportname Valid Baan report code for desired report
device Valid Baan device code for desired device.
err.mesg This parameter will contain the text of the error message if the function cannot complete normally.
DESCRIPTION
This selects the report to be printed and the device to be printed to when the stpapi.print.report() is called.
RETURN VALUES
None
3.15 Send “Print” Command to Session
SYNTAX
void stpapi.print.report(string session, ref string err.mesg)
ARGUMENTS
session Name of the session this command is executed on.
err.mesg This parameter will contain the text of the error message if the function cannot complete normally.
DESCRIPTION
This causes the choice option “print.data” to be executed in the specified session. The function stpapi.set.report() must be called prior to this to configure the report printing.
RETURN VALUES
None

NPRao
5th March 2002, 02:57
Hi Popeye,

the previous session was a process session zmadm9203m000.

I have now tried with a print session with this code -

stpapi.put.field("zmadm9400m000", "user.f", " ")
stpapi.put.field("zmadm9400m000", "user.t", "zzzzzzzzz")
stpapi.put.field("zmadm9400m000", "vwie.yn", "zmyeno.no")
stpapi.set.report("zmadm9400m000", "zmadm940300000", "D", error)
zmadm9400m000f.print( error )
zmadm9400m000f.end( )
Even this seems to be hanging.

I think I am missing something...

also I think that the get.screen.defaults() function might over write the put field values if we do not use
group.1:
init.group:
if not api.mode then
get.screen.defaults()
endif
The documentation you sent describes how to create the function server dll and the functions created by the ttstpcreatdll and an example is provided.

But the actual implementation script example is not provided there.

Any more clues ?

Thanks!

mark_h
5th March 2002, 15:00
"zmadm940300000" should be "rzmadm940300000". It does expect the "r" infront of the report name. Here is a sample from some of my code.
stpapi.set.report("tppss9269m00b","rtppss92690100b",spool.device,errmsg)
f9269m00b.put.cprj.f(first.project)
f9269m00b.put.cprj.t(last.project)
f9269m00b.put.From_Production_Order(0)
f9269m00b.put.orno.t(999999)
f9269m00b.put.Project_Group(project.group)
f9269m00b.put.ccot.t(project.group)
f9269m00b.continue( errmsg)
Notice that I use the continue command, you do not always need the stpapi.print.report command. I did have one case where this locked up the session and another where it did nothing. So try setting the report and using the continue command, that may work.

Good Luck!

Mark

NPRao
6th March 2002, 01:30
Hi Mark,

I have used that r in the beginning of the report code. It didnt still work.

seeing on the processes, i can see the session's debugger, but I wonder why the invoked session is not visible. Do all the sessions, invoked by the ttstpapi and AFS run in background/hidden mode???

mark_h
6th March 2002, 14:20
Yes - they do run in the background, with your FS session as the parent ID. If you compile the FS in debug mode and the source session in debug mode then you can step through the code to see what is going on. The first time you do a stpapi.put.field you should see the session come up. Just so happens I was debugging one this morning. Attached are a few screen prints.

When you do your first put.field on the zmadm9400m000 session, is it coming up in the background? Is this a session you developed? Because I am really suprised the ttstpcreatdll did not create put functions. I use ttstpcreatdll just so I see what functions are available in a session, and for some reason it does not think a put function is available.


Mark

NPRao
26th June 2002, 01:31
Hi Mark,

Its been a long time that I got back on this AFS issue.

I tried to execute my old scripts and suddenly they worked fine. Maybe due to the BaaN-5.2 GA and earlier we were on the Alpha/LA. Thanks for the tips...

Now I made few more AFS dlls now and I am facing this issue -

I found another problem in a process session at these statements -


choice.cont.process:
on.choice:
if spool.open("","",1) then
start.process()
spool.close()
else
choice.again()
endif


Checking in debuggers the error value is "Device not found" in the statement -

zmadm9203m000f.exec.cont.process(error)

Is there a way that I can set the display "D" in the spool functions, I tried spool.device = "D". It still didnt work.

I couldnt find the option in these postings, how can we get the AFS log file? Also, can I generate the AFS on tools sessions and use them ?

Thanks!

trchandra
26th June 2002, 08:52
Hi Prashant,
You can get log file by setting -- -set AFSLOG=1 in the bwc file. A file with name afs.log will be created (in unix it will be user home directory). You can generate AFS on tools sessions using stpapi.* commands directly instead of generating dll using ttstpcreatdll.

good luck

mark_h
26th June 2002, 18:51
According to the help on spool.open command when the device and report are blank it is opening the previous report and device. So even though this is a process session you probably need to do a set report. Which session is it? I have had problems with a couple of sessions when creating function servers on them.

Also I could not create DLL's on tools sessions because the ttstpcreatdll session defaulted to the tt package and as far as I know nobody is allowed to develop there but Baan. So for tools sessions you have to use the actual stpapi commands.


Mark

NPRao
26th June 2002, 19:30
Mark,

I have created a few utilities/tools for system checks etc... which do not need the BaaN standard reports, hence I use the spool functions to shows the results on the display browser, or we can redirect the log file outputs to any device.

To explore more about AFS/API and use them in automated job process, I was trying to make function servers dlls and I trace the problem that I couldnt set the device in that spool.open() functional call.

Any ideas about how to set the device in the spool.open? :confused:

mark_h
26th June 2002, 20:09
I understand now - I was wondering why Baan would have a session with spool.open(), but I put nothing past them. I wonder if stpapi.set.report("sessionname", "", "D", error) would work? Notice the report name is empty. I am not sure if this is possible.

Also if the session is in debug mode and you do spool.device="D" in the DLL, does the session actually have the spool.device set? I guess what I am asking is if you run the DLL and have the session in debug mode can you see that the spool.device is "D"? I think the answer would be yes, but thought I would check.

The only other solutions I could think of would require that the session be modified. For example you could check the api.mode and if it is true then do a spool.open("",spool.device,0). Or maybe try attaching a dummy report to the session and then try stpapi.set.report. Not sure which would work or what is best.

Mark

gfasbender
26th June 2002, 21:00
In the past, I've experienced many problems with API's that call reports. I have found that the API Handler library functions only work with rprt.*() functions found in the 4GL choice.print.data section. I have not been able to get reports to run that are invoked with brp.*() or spool.*() function calls.

In each case, I've worked with Baan Support and they have come back saying that they will have to modify the script, because it was not API compliant.

If you have the source code, you may want to modify the code using the standard rprt.*() calls in the choice.print.data section.

NPRao
26th June 2002, 21:10
Hi Mark ,

Here is my current situation tracing the problems in debugs.

Gordon,

I have created a few utilities/tools for system checks etc... which do not need the BaaN standard reports, hence I use the spool functions to shows the results on the display browser, or we can redirect the log file outputs to any device. I dont see a reason to create a report layouts... with just a line of text of 80-256 characters.

NPRao
26th June 2002, 22:27
More issues when using the AFS/API on the TT sessions -

Any clues ??? :confused:

mark_h
26th June 2002, 23:44
Hi NPR,

I am afraid Gordon may be right. I have not had this exact problem because most of my sessions use rprt_open(). I have not created a FS on one that uses brp.open or spool.open. I can not think of any other solution if something like spool.open("","D",0) did not work. It sounds like Gordon is correct. The only thing else I can think of is to import spool.device into the session from your DLL, but I think even that will fail when it hits the spool.open("",spool.device,0) command. I can not think of any other solution.


Are you sure it is stpapi.form.command or is that the same as stpapi.continue.process? Everything else looks fine. Also could it be a case of something on the form did not change so it does not think it has to create RDD? I have run into this before. Since day one problems crop up in create/convert to rdd, so I am not sure if this is a good session to make a FS on.

Mark

NPRao
27th June 2002, 20:55
Mark,

I am still trying to make an AFS for the session, ttadv5214m000, as thats our requirement.

reading more documentation, exploring, changing code etc,

I used this command -

stpapi.continue.process("ttadv5214m000", error)
|stpapi.form.command( "ttadv5214m000", 5, "exec.cont.process", error )


Checking in debugger the error has the value "Command Disabled". This doesnt give me any clue, whats wrong and how to make it work. :confused:

Here are the contents of the afs.log -

<ttadv5214m000
>ttadv5214m000 continue.process
69->cont.process
69<-cont.process^A1
<ttadv5214m000 Command disabled
>ttadv5214m000 end.session
69->end.program
69<-end.program^A0

mark_h
28th June 2002, 00:23
I am just not sure. It sounds like what you had the first time was the correct(stpapi.form.command). So I am not sure why the create RDD is not working. I am just not sure anymore. I will look at it some more tomorrow, but right now I do not have a clue about the tools session.

Mark

mark_h
2nd July 2002, 21:13
Did you find a solution? I can not think of one that does not involve having the source code to see what happens on the continue. This way you could see what was actually being generated or skipped.

One thing you could try is to delete the data dictionary for the session then run this script to see if the RDD is created. If that does not work then maybe you could try the ttadv5200m000 (Convert RDD Forms and Menus). I am not sure if that is a option. Sorry, but those are the best I can come up with.

Mark

trchandra
2nd July 2002, 23:26
Prashant,
I wrote the AFS for the session you are trying and it is perferctly working for me!.

Here is the code....

#pragma used dll ottstpapihand


function main()
{
string single.sess(15)
string err.mes(1024)
single.sess = "ttadv5214m000"
stpapi.put.field(single.sess,"cpac.f", "cr")
stpapi.put.field(single.sess,"cpac.t", "cr")
stpapi.put.field(single.sess,"vers.f", "B50C")
stpapi.put.field(single.sess,"vers.t", "B50C")
stpapi.put.field(single.sess,"rele.f", "c ")
stpapi.put.field(single.sess,"rele.t", "c ")
stpapi.put.field(single.sess,"cust.f", "prod")
stpapi.put.field(single.sess,"cust.t", "prod")
stpapi.form.command(single.sess,5,"exec.cont.process", err.mes)
if not isspace(err.mes) then
message(err.mes)
endif
stpapi.end.session(single.sess)

}


best of luck!

NPRao
3rd July 2002, 00:10
Ravi,

This is my code, which gave me those error messages -



#pragma used dll ottstpapihand

function main()
{
string error(80)

stpapi.put.field("ttadv5214m000", "cpac.f", "zm")
stpapi.put.field("ttadv5214m000", "cpac.t", "zm")
stpapi.put.field("ttadv5214m000", "vers.f", "B52U")
stpapi.put.field("ttadv5214m000", "vers.t", "B52U")
stpapi.put.field("ttadv5214m000", "rele.f", "a")
stpapi.put.field("ttadv5214m000", "rele.t", "a")
stpapi.put.field("ttadv5214m000", "cust.f", "abcd")
stpapi.put.field("ttadv5214m000", "cust.t", "abcd")
stpapi.put.field("ttadv5214m000", "clan.f", "2")
stpapi.put.field("ttadv5214m000", "clan.t", "2")
stpapi.put.field("ttadv5214m000", "form.f", "adm9203m000d.")
stpapi.put.field("ttadv5214m000", "form.t", "adm9203m000d")
stpapi.put.field("ttadv5214m000", "forms", "ttyeno.yes")
stpapi.put.field("ttadv5214m000", "menus", "ttyeno.no")
stpapi.put.field("ttadv5214m000", "error.report", "ttyeno.no")
stpapi.put.field("ttadv5214m000", "multi.level", "ttyeno.no")
|stpapi.put.field("ttadv5214m000", "flag.dump", "ttadv.create.formmenu")
stpapi.put.field("ttadv5214m000", "flag.dump", "1")
stpapi.set.report("ttadv5214m000", "rttadv521401000", "D", error)
if isspace(error) then
stpapi.continue.process("ttadv5214m000", error)
endif
|stpapi.continue.process("ttadv5214m000", error)
|stpapi.print.report("ttadv5214m000", error)
|stpapi.form.command( "ttadv5214m000", 5, "exec.cont.process", error )
stpapi.end.session("ttadv5214m000")
}


checking in debugger, I found error is "Command Disabled". Any clues :confused:

NPRao
3rd July 2002, 00:16
More findings... I changed my code to similar to yours -


#pragma used dll ottstpapihand
function main()
{
string error(80)
stpapi.put.field("ttadv5214m000", "cpac.f", "zm")
stpapi.put.field("ttadv5214m000", "cpac.t", "zm")
stpapi.put.field("ttadv5214m000", "vers.f", "B52U")
stpapi.put.field("ttadv5214m000", "vers.t", "B52U")
stpapi.put.field("ttadv5214m000", "rele.f", "a")
stpapi.put.field("ttadv5214m000", "rele.t", "a")
stpapi.put.field("ttadv5214m000", "cust.f", "abcd")
stpapi.put.field("ttadv5214m000", "cust.t", "abcd")
stpapi.form.command( "ttadv5214m000", 5, "exec.cont.process", error )
stpapi.end.session("ttadv5214m000")
}


checking in debugger, I found error is "Device not found".

Any clues :confused:

alejandro
3rd July 2002, 00:20
Not sure about this because you are in ERP, I c4.

¿Has your session check fields?
I cannot see in your script stapi.put for these selection fields.

¿So maybe command disabled maybe means nothing to do?

Not sure but...

gfasbender
3rd July 2002, 00:44
NPRao,

From your previous post, I noticed you had coded in the following:
stpapi.put.field("ttadv5214m000", "error.report", "ttyeno.no")

leading me to believe that you have set your user defaults while running this session. You should add this line back into your new script so you don't have to worry about setting the default report device. Careful coding API's where the default session action is defined as "User Defaults", or "User Defaults" is executed in the before.program section. You should supply an stpapi.put.field() call for every input field on the form, making sure you know what's in every field, so this won't occur.

Also, you shouldn't use the device "D", for display, in background API programs. There isn't any user interaction in API's.

NPRao
3rd July 2002, 01:41
Thanks for the tips Ravi and Gordon, :p

I got the session working now.

I guess the tools sessions, calls the init.form/group sections and statements and then pass the variables we are sending with the put functions.

I have my user defaults and it had the print report on, maybe thats why it was expecting the output to be redirected to a device.

So I removed my user defaults using, ttstpdeldeflt and then executing my 3-GL it worked and all the files on the systems have the new time stamping.

I think this can be avoided in the sessions we develop by using -


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

TheBurniou
6th August 2002, 17:11
Hi popeye,

I am very interested in syntax of stpapi functions, can U attach the doc file U talk about ?

Thanks


Originally posted by popeye
Hi NPRao,
I have never used a Function Server for a Print Session.
Here is what I found in the documentation.
Take a look at it.

Just curious .... Why would you want to use Function Servers for print sessions ?

Hope this helps.


3.14 Set Session Report Parameters
SYNTAX
void stpapi.set.report(string session, string reportname, string device, string err.mesg)
ARGUMENTS
session Name of the session this command is executed on.
reportname Valid Baan report code for desired report
device Valid Baan device code for desired device.
err.mesg This parameter will contain the text of the error message if the function cannot complete normally.
DESCRIPTION
This selects the report to be printed and the device to be printed to when the stpapi.print.report() is called.
RETURN VALUES
None
3.15 Send “Print” Command to Session
SYNTAX
void stpapi.print.report(string session, ref string err.mesg)
ARGUMENTS
session Name of the session this command is executed on.
err.mesg This parameter will contain the text of the error message if the function cannot complete normally.
DESCRIPTION
This causes the choice option “print.data” to be executed in the specified session. The function stpapi.set.report() must be called prior to this to configure the report printing.
RETURN VALUES
None

popeye
6th August 2002, 19:39
doc # 1

popeye
6th August 2002, 19:41
doc # 2

BTW ... how do i attach multiple files ?

patvdv
6th August 2002, 20:03
For the moment, you cannot attach multiple files in 1 post. You need to make separate posts for each attachment.

gfasbender
6th August 2002, 23:25
Put them both in a zipped file...

TheBurniou
7th August 2002, 10:49
Thank U popeye. This doc will help a lot !:D

Satish Nandeti
9th August 2002, 11:25
Hi NPRao,

to set the reportname & device name, you try using the following statement.

stpapi.set.report("zmadm9400m000", "rzmadm940300000", "D", error)

It means that there should be 'r' before the report name.

Suppose if your report name is : zmadm940300000 then the way you specify it in the AFS will be like this : rzmadm940300000 i.e there should be 'r' before the report name.

If the device type 'D' does n't work.. then try writing the report into a file like this,

stpapi.set.report("zmadm9400m000","rzmadm940300000", "ASCIF", error)

stpapi.put.field("zmadm9400m000","spool.fileout", "MY_Report_Name")

and then use

stpapi.continue.process("zmadm9400m000",error)

please let me know if this solution works fine..

Regards,
Satish Nandeti

NPRao
9th October 2004, 00:46
Solution: 133995

SITUATION IDENTIFIED IN:
"Select Device" (ttstpsplopen)

SITUATION DESCRIPTION:
Print to display is present in some program scripts. When the sessions using these program scripts are run in the function server, print to display was skipped. This was not only done when no user interface is present, but also when this script was run from another session in the function server.