pralash
10th October 2018, 11:02
Hi,

Can anybody explain how to create an new AFS please?
Thanks in Advance...
Regards,
Pralash

VishalMistry
10th October 2018, 11:30
Hi Pralash,

In Baan IV, go to File->Run, then in the run dialogue box provide ttstpcreatdll as session name.

It will open a session where you can provide the session name for which you want to create dll (AFS). See attached screen shot for ref. I think process is same for Infor Ln.

After following the above steps, you can open Libraries session to view dll (in this case, tcmcsf0123m000).

Hope this helps.
Vishal

pralash
10th October 2018, 14:33
Hi Vishal Mistry,

Thanks a lot for your guidance... As you suggested, I've created an AFS...
Regards,
Pralash

pralash
10th October 2018, 15:06
Hi Vishalmistry,
As you suggested, I've created the following AFS for a particular session...
But I got an error while compiling the AFS. Please advise me that what is the exact issue by referring the attachment...
Thanks in advance,
Regards,
Pralash
|------------------------------------------------------------------------------
| File created by ttstpcreatdll, Date: 03/10/18
| Created for session: tcemp1503m000
|------------------------------------------------------------------------------

#pragma used dll ottstpapihand

function extern void tcempf1503m000.put.Roll_No( const domain tcncmp value )
{
DLLUSAGE
Function to set Roll No ( tcemp103.roll ) in session tcemp1503m000
arg: - value to put in Roll No
ENDDLLUSAGE
stpapi.put.field( "tcemp1503m000", "tcemp103.roll", str$(value) )
}

function extern domain tcncmp tcempf1503m000.get.Roll_No( )
{
DLLUSAGE
Function to get Roll No ( tcemp103.roll ) from session tcemp1503m000
return: - value of Roll No
ENDDLLUSAGE
string value(5)
stpapi.get.field( "tcemp1503m000", "tcemp103.roll", "1000" )
return( lval(value) )
}

function extern void tcempf1503m000.put.Mark_1( const domain tcncmp value )
{
DLLUSAGE
Function to set Mark 1 ( tcemp103.mar1 ) in session tcemp1503m000
arg: - value to put in Mark 1
ENDDLLUSAGE
stpapi.put.field( "tcemp1503m000", "tcemp103.mar1", str$(value) )
}

function extern domain tcncmp tcempf1503m000.get.Mark_1( )
{
DLLUSAGE
Function to get Mark 1 ( tcemp103.mar1 ) from session tcemp1503m000
return: - value of Mark 1
ENDDLLUSAGE
string value(5)
stpapi.get.field( "tcemp1503m000", "tcemp103.mar1", "200")
return( lval(value) )
}

function extern void tcempf1503m000.put.Mark_2( const domain tcncmp value )
{
DLLUSAGE
Function to set Mark 2 ( tcemp103.mar2 ) in session tcemp1503m000
arg: - value to put in Mark 2
ENDDLLUSAGE
stpapi.put.field( "tcemp1503m000", "tcemp103.mar2", str$(value) )
}

function extern domain tcncmp tcempf1503m000.get.Mark_2( )
{
DLLUSAGE
Function to get Mark 2 ( tcemp103.mar2 ) from session tcemp1503m000
return: - value of Mark 2
ENDDLLUSAGE
string value(5)
stpapi.get.field( "tcemp1503m000", "tcemp103.mar2", "300" )
return( lval(value) )
}

function extern void tcempf1503m000.put.Mark_3( const domain tcncmp value )
{
DLLUSAGE
Function to set Mark 3 ( tcemp103.mar3 ) in session tcemp1503m000
arg: - value to put in Mark 3
ENDDLLUSAGE
stpapi.put.field( "tcemp1503m000", "tcemp103.mar3", str$(value) )
}

function extern domain tcncmp tcempf1503m000.get.Mark_3( )
{
DLLUSAGE
Function to get Mark 3 ( tcemp103.mar3 ) from session tcemp1503m000
return: - value of Mark 3
ENDDLLUSAGE
string value(5)
stpapi.get.field( "tcemp1503m000", "tcemp103.mar3", "400" )
return( lval(value) )
}

function extern void tcempf1503m000.put.Total( const domain tcncmp value )
{
DLLUSAGE
Function to set Total ( tcemp103.tota ) in session tcemp1503m000
arg: - value to put in Total
ENDDLLUSAGE
stpapi.put.field( "tcemp1503m000", "tcemp103.tota", str$(value) )
}

function extern domain tcncmp tcempf1503m000.get.Total( )
{
DLLUSAGE
Function to get Total ( tcemp103.tota ) from session tcemp1503m000
return: - value of Total
ENDDLLUSAGE
string value(5)
stpapi.get.field( "tcemp1503m000", "tcemp103.tota", "900" )
return( lval(value) )
}

function extern void tcempf1503m000.end([string error(500)])
{
DLLUSAGE
Function to end connection to session tcemp1503m000
ENDDLLUSAGE
if get.argc() = 0 then
stpapi.end.session( "tcemp1503m000" )
else
error = get.string.arg(1)
stpapi.end.session( "tcemp1503m000" , error )
put.string.arg(1, error)
endif
}

function extern long tcempf1503m000.insert( long do.update, ref string error )
{
DLLUSAGE
Function to insert a record in session tcemp1503m000
Fields must be put before calling this function
ENDDLLUSAGE
return( stpapi.insert( "tcemp1503m000", do.update, error ) )
}

function extern long tcempf1503m000.update( long do.update, ref string error )
{
DLLUSAGE
Function to update a record in session tcemp1503m000
Record must be made current and fields to be changed before calling
this function
ENDDLLUSAGE
return( stpapi.update( "tcemp1503m000", do.update, error ) )
}

function extern long tcempf1503m000.delete( long do.update, ref string error )
{
DLLUSAGE
Function to delete a record in session tcemp1503m000
Record must be made current before calling this function
ENDDLLUSAGE
return( stpapi.delete( "tcemp1503m000", do.update, error ) )
}

function extern long tcempf1503m000.mark([string error (500)])
{
DLLUSAGE
Function to mark the current record in session tcemp1503m000
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.mark( "tcemp1503m000" ) )
else
error = get.string.arg(1)
ret = stpapi.mark( "tcemp1503m000" , error )
put.string.arg(1, error)
return( ret )
endif
}

function extern long tcempf1503m000.recover( ref string error )
{
DLLUSAGE
Function to undo an update/insert/delete in session tcemp1503m000
ENDDLLUSAGE
return( stpapi.recover( "tcemp1503m000", error ) )
}

function extern long tcempf1503m000.save( ref string error )
{
DLLUSAGE
Function to save an update/insert/delete in session tcemp1503m000
ENDDLLUSAGE
return( stpapi.save( "tcemp1503m000", error ) )
}

function extern long tcempf1503m000.find( [string error(500)] )
{
DLLUSAGE
Function to find a record in session tcemp1503m000
Search fields must be put before calling this function
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.find( "tcemp1503m000" ) )
else
error = get.string.arg(1)
ret = stpapi.find( "tcemp1503m000" , error )
put.string.arg(1, error)
return( ret )
endif
}

function extern long tcempf1503m000.synchronize.dialog( string mode(8), ref string err.mesg)
{
DLLUSAGE
Function to set up a synchronized dialog between multi-occurrence
and single-occurrence session
ENDDLLUSAGE
return( stpapi.synchronize.dialog("tcemp1503m000", mode , err.mesg) )
}

function extern void tcempf1503m000.clear( )
{
DLLUSAGE
Function to clear the current record in session tcemp1503m000
ENDDLLUSAGE
stpapi.clear( "tcemp1503m000" )
}

function extern void tcempf1503m000.print( ref string error )
{
DLLUSAGE
Function to start the print option in session tcemp1503m000
ENDDLLUSAGE
stpapi.print.report( "tcemp1503m000", error )
}

function extern void tcempf1503m000.set.report( const string reportname, const string device, ref string error )
{
DLLUSAGE
Function to set report name and device for a subsequent print action
in session tcemp1503m000
ENDDLLUSAGE
stpapi.set.report( "tcemp1503m000", reportname, device, error )
}

function extern long tcempf1503m000.first([string error(500)] )
{
DLLUSAGE
Function to find the first record in session tcemp1503m000
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.browse.set( "tcemp1503m000", "first.set" ) )
else
error = get.string.arg(1)
ret = stpapi.browse.set( "tcemp1503m000", "first.set" , error )
put.string.arg(1, error)
return( ret )
endif
}

function extern long tcempf1503m000.next([string error(500)] )
{
DLLUSAGE
Function to find the next record in session tcemp1503m000
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.browse.set( "tcemp1503m000", "next.set" ) )
else
error = get.string.arg(1)
ret = stpapi.browse.set( "tcemp1503m000", "next.set" , error )
put.string.arg(1, error)
return( ret )
endif
}

function extern long tcempf1503m000.previous([string error(500)] )
{
DLLUSAGE
Function to find the previous record in session tcemp1503m000
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.browse.set( "tcemp1503m000", "prev.set" ) )
else
error = get.string.arg(1)
ret = stpapi.browse.set( "tcemp1503m000", "prev.set" , error )
put.string.arg(1, error)
return( ret )
endif
}

function extern long tcempf1503m000.last([string error(500)] )
{
DLLUSAGE
Function to find the last record in session tcemp1503m000
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.browse.set( "tcemp1503m000", "last.set" ) )
else
error = get.string.arg(1)
ret = stpapi.browse.set( "tcemp1503m000", "last.set" , error )
put.string.arg(1, error)
return( ret )
endif
}

function extern long tcempf1503m000.set.view( [string error(500)] )
{
DLLUSAGE
Function to define another view in session tcemp1503m000
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.change.view( "tcemp1503m000" ) )
else
error = get.string.arg(1)
ret = stpapi.change.view( "tcemp1503m000", error )
put.string.arg(1, error)
return( ret )
endif
}

function extern long tcempf1503m000.first.view([string error(500)] )
{
DLLUSAGE
Function to read the first view in session tcemp1503m000
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.browse.view( "tcemp1503m000" , "first.view" ) )
else
error = get.string.arg(1)
ret = stpapi.browse.view( "tcemp1503m000", "first.view", error )
put.string.arg(1, error)
return( ret )
endif
}

function extern long tcempf1503m000.next.view([string error(500)] )
{
DLLUSAGE
Function to read the next view in session tcemp1503m000
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.browse.view( "tcemp1503m000" , "next.view" ) )
else
error = get.string.arg(1)
ret = stpapi.browse.view( "tcemp1503m000", "next.view", error )
put.string.arg(1, error)
return( ret )
endif
}

function extern long tcempf1503m000.previous.view([string error(500)] )
{
DLLUSAGE
Function to read the previous view in session tcemp1503m000
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.browse.view( "tcemp1503m000" , "prev.view" ) )
else
error = get.string.arg(1)
ret = stpapi.browse.view( "tcemp1503m000", "prev.view", error )
put.string.arg(1, error)
return( ret )
endif
}

function extern long tcempf1503m000.last.view([string error(500)] )
{
DLLUSAGE
Function to read the last view in session tcemp1503m000
ENDDLLUSAGE
long ret
if get.argc() = 0 then
return( stpapi.browse.view( "tcemp1503m000" , "last.view" ) )
else
error = get.string.arg(1)
ret = stpapi.browse.view( "tcemp1503m000", "last.view", error )
put.string.arg(1, error)
return( ret )
endif
}

function extern string tcempf1503m000.get.last.message.code([string error(500)])
{
DLLUSAGE
Function to get the code of the message which occurred on
the last insert/update/delete/save/recover action in session tcemp1503m000
ENDDLLUSAGE
string ret(20)
if get.argc() = 0 then
return( stpapi.get.mess.code( "tcemp1503m000" ) )
else
error = get.string.arg(1)
ret = stpapi.get.mess.code( "tcemp1503m000", error )
put.string.arg(1, error)
return( ret )
endif
}

function extern string tcempf1503m000.get.last.error( )
{
DLLUSAGE
Function to get the error message which occurred on
the last action in the Function Server
ENDDLLUSAGE
return( stpapi.get.error( ) )
}

function extern void tcempf1503m000.handle.sub.process( const string sub.process, const string action )
{
DLLUSAGE
Function to define an action when a sub process is started.
Possible actions are: add/send/ignore/kill
add - add child session to internal structure,
session dll of child can be used
send - send all api calls to child instead of parent
ignore - child process is ignored, parent will wait
until child exits (for background processes)
kill - child process is killed immediately
ENDDLLUSAGE
stpapi.handle.subproc( "tcemp1503m000", sub.process, action )
}

function extern void tcempf1503m000.define.enum.answer( const string question, bset answer )
{
DLLUSAGE
Function to define an answer on a question, when the default answer should not be taken.
ENDDLLUSAGE
stpapi.enum.answer( "tcemp1503m000", question, answer )
}

VishalMistry
11th October 2018, 08:33
Hello Pralash,

Looking at one of the get function in your attached code:
function extern domain tcncmp tcempf1503m000.get.Roll_No( )
{
DLLUSAGE
Function to get Roll No ( tcemp103.roll ) from session tcemp1503m000
return: - value of Roll No
ENDDLLUSAGE
string value(5)
stpapi.get.field( "tcemp1503m000", "tcemp103.roll", "1000" )
return( lval(value) )
}

The third argument should not be a string constant but a variable as given in the attached AFS DLL for session tcmcs0123m000.
Please replace below statement:
stpapi.get.field( "tcemp1503m000", "tcemp103.roll", "1000" )
with
stpapi.get.field( "tcemp1503m000", "tcemp103.roll", value ) as the function is returning the value of variable "value". Make this change is every get function and it should resolve the issue.

Vishal

pralash
11th October 2018, 14:08
Hi Vishalmistry,

As per your ideas, I resolved the issue and successfully compiled the AFS. But I don't know that how to execute this AFS. Hence pls let me know that how to execute the AFS...

Thanks in advance,
Pralash

mark_h
11th October 2018, 17:01
There is documentation pinned to the top of this forum where I moved this post. It is http://www.baanboard.com/baanboard/showthread.php?t=7251 this post.

So far it looks like all you did was create a library with calls to a session. Now you actually create a new session to call the library to drive the standard baan session. I used to create libraries with ttstpcreate, but no longer do. You might try searching on you session in question to see if someone else has posted code. If you do not find it there are plenty of other examples of what people have to done. Basically a lot of times I take an input file, upload it to the server, process the data using AFS code and generate a report. So poke around and read some in this forum to get started.

pralash
11th October 2018, 17:13
Hi Mark,

Thank so much for your guidance... I will go through the document...

Regards,
Pralash