Introduction

In most AFS functions where a session is mentioned as a parameter, the session is automatically started if it is not already running. Functions, which require the session to have been started already, return an error if no function is called before that started the session (see Chapter 4). This implies that all subsequent function calls for the same session are sent to the same session instance.

The sessions started by the AFS must be 4GL sessions. 3GL sessions (without a form and a script of type 3GL (Without Std.Prog)) cannot be carried out with the AFS.

Get Field Value from session

SYNTAX

void stpapi.get.field (string session, string field, ref string value, [long element])

ARGUMENTS

session Name of the session this command is executed on.

field Name of the field whose value is desired.

value Upon return, this parameter contains the string representation of the current value of the field specified in field. For fields that contain enum or set values, the string representation of the numeric value is returned, not the text description of this value. Date and UTC fields are not converted, so the Baan internal long values are returned as string. Normal numeric values are also returned as string (for example, -123.45), no conversion based on display formats or language dependent format is performed.

element Array element whose value is to be returned in the case of arrays or repeating fields.


DESCRIPTION

This returns the current value of a particular field from a specified running Baan session. When the field is available in the field buffer, the value is taken from there, otherwise it is extracted directly from the session. See Chapter 4 for the stpapi.* functions, which cause the field buffer to be updated.

RETURN VALUES

None

EXAMPLE

stpapi.put.field(“dtfsa1101s000″, “dtfsa100.seno”, str$(i.seno))

retval = stpapi.find(“dtfsa1101s000″, error.msg)

if retval = 1 then

stpapi.get.field(“dtfsa1101s000″, “dtfsa100.name”, o.name) stpapi.get.field(“dtfsa1101s000″, “balance”, o.balance)

endif

Explanation:

In the session dtfsa1101s000 the record with key ‘i.seno’ is searched. The values of the fields ‘dtfsa100.name’ (table field on the form) and ‘balance’ (calculated field on the form) are retrieved from the session.

USAGE NOTES

BaanERP only: If the AFS calls a synchronized session (multi-occurrence / single-occurrence) the fields must be taken from the session where the field resides. This implies that if a field must be fetched from the single-occurrence dialog box, a synchronize call must have been performed (see stpapi.synchronize.dialog()).

Set Field Value in session

SYNTAX

void stpapi.put.field(string session, string field, string value, [long element])

ARGUMENTS

session Name of the session this command is executed on.

field Name of the field whose value is desired.

value The value of the field specified in field is set to the contents of this parameter. Any necessary type conversion is performed, however, Date and UTC fields must be put in the internal Baan format. Enum fields must be put in the internal byte value. Examples: str$(date.num()), str$(-123.45), str$(etol(tcyesno.yes)).

element Array element whose value is to be set in the case of arrays or repeating fields.

DESCRIPTION

This sets the current value of a particular field in a specified running Baan session. If the field is available in the field buffer, the value is put there till it is processed by the field loop in the session (see Chapter 4). If the field is not available in the field buffer, the field value is directly sent to the session (with the put.var function).

Note that no field sections in the script are executed during the put.field call, so no validation is performed. These sections are called when all fields are processed for an insert or update call.

RETURN VALUES

None

EXAMPLE

stpapi.put.field(“dtfsa1201s000″, “seno.f”, str$(i.seno))

stpapi.put.field(“dtfsa1201s000″, “seno.t”, str$(i.seno))

stpapi.put.field(“dtfsa1201s000″, “proc.date”, str$(date.num()))

stpapi.put.field(“dtfsa1201s000″, “do.update”, str$(etol(dtyesno.no)))

stpapi.continue.process(“dtfsa1201s000″, error.msg)

Explanation:

For a processing session, the input fields are sent to the session, and the continue process function of the session is executed.

USAGE NOTES

The case and alignment of the passed string values is not relevant. The AFS automatically converts the value to the correct domain.

BaanERP only: If fields are sent to a single-occurrence session, which is synchronized with a multi-occurrence session, the values must be put after a stpapi.synchronize.dialog() call is issued to the multi-occurrence session, because otherwise the single-occurrence session is activated without a link to the multi-occurrence session.

Insert Record in session

SYNTAX

long stpapi.insert (string session, long do.save, ref string err.mesg)

ARGUMENTS

session Name of the session this command is executed on.

do.save Flag that specifies whether a database commit must take place within this function. If do.save is set to 1, then the update.db choice section of the session will be executed before this function returns. If do.save is set to 0, then update.db is not executed. In this case, a stpapi.save() function must be called afterwards to update the database.

err.mesg This parameter contains the text of the error message if the function cannot complete normally.

DESCRIPTION

This inserts the current record of the specified session into the database. The values of the fields in the session must be set prior to calling this function.

RETURN VALUES

0 Record not inserted or save failed (err.mesg is filled with the reason)

1 Record inserted (err.mesg is empty)

EXAMPLE

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.seno”, str$(i.seno)) stpapi.put.field(“dtfsa1101s000″, “dtfsa101.name”, name)

retval1 = stpapi.insert(“dtfsa1101s000″, true, error.msg)

if not retval1 then

retval2 = stpapi.recover(“dtfsa1101s000″, recover.msg)

endif

Explanation:

The fields to be filled in the table are sent to the session and the insert function is called.

USAGE NOTES

If err.mesg is filled, stpapi.recover() must be called before any other stpapi.* commands are issued to this session, or the record can be inserted into the database because the stpapi.end.session() call will perform an update.db action.


The error messages returned can be:

n Session not available.

n Command disabled; no insert is possible in the current state of the session.

n Editable synchronized dialog box not started (BaanERP only).

n Any error message from the session.

Only use this function with ‘do.save’ 0 if the calling program must distinguish between errors raised by the insert (for example, check.inputs) and the save (for example, skip.io’s in before.write). Do not use it to buffer inserts, because inserts will not be buffered, as the next stpapi.insert() call will execute an ‘update.db’ for the previously inserted record.

If a record is inserted with a type 3 form, the function stpapi.change.view() must be called to set the correct key field values.

BaanERP only: If a record must be inserted with a synchronized single-occurrence dialog box, the dialog box must be synchronized before the first put.field function is called, because otherwise the field buffer is not present. The stpapi.insert() call must be issued to the multi-occurrence session, but the stpapi.put.field() calls to the single-occurrence session. For multi-occurrence sessions of type 3, make sure you call the stpapi.change.view() before the synchronization.

Update Record in session

SYNTAX

long stpapi.update(string session, long do.save, ref string err.mesg)

ARGUMENTS

session Name of the session this command is executed on.

do.save Flag that specifies whether a database commit must take place within this function. If do.save is set to 1, then the update.db choice section of the session is executed before this function returns. If do.save is set to 0, then update.db is not executed. In this case, a stpapi.save() function must be called afterwards to update the database.

err.mesg This parameter contains the text of the error message if the function cannot complete normally.


DESCRIPTION

This updates the current record of the specified session. The values of the fields in the session must be set prior to calling this function.

RETURN VALUES

0 Record not updated or save failed (err.mesg is filled with the reason)

1 Record updated (err.mesg is empty)

EXAMPLE

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.seno”, str$(i.seno))

ret = stpapi.find(“dtfsa1101s000″, error.msg)

if ret = 1 then

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.name”, name)

retval1 = stpapi.update(“dtfsa1101s000″, true, error.msg)

if not retval1 then

retval2 = stpapi.recover(“dtfsa1101s000″, recover.msg)

endif

endif

Explanation:

The record to be updated is searched in the session and its name field is updated.

USAGE NOTES

A record must be current in the session (for example, by a stpapi.find() call), otherwise the results are unpredictable.

If err.mesg is filled, stpapi.recover() must be called before any other stpapi.* commands are issued to this session, otherwise the record can be updated in the database, because the stpapi.end.session() call performs an update.db action.

The error messages returned can be:

n Command disabled; no update is possible in the current state of the session.

n Editable synchronized dialog box not started (BaanERP only).

n Any error message from the session.

Only use this function with do.save 0 if the calling program must distinguish between errors raised by the update (for example, check.inputs) and the save (for example, skip.io’s in before.rewrite). Do not use it to buffer updates, because updates will not be buffered since the next stpapi.find() call to make another record current will execute an update.db for the previously updated record.


BaanERP only: If a record must be updated with a synchronized single-occurrence dialog box, the dialog box must be synchronized before the first put.field function is called, otherwise the field buffer is not present. The stpapi.update() call must be issued to the multi-occurrence session, but the stpapi.put.field() calls to the single-occurrence session.

Delete Record from session

SYNTAX

long stpapi.delete(string session, long do.save, ref string err.mesg)

ARGUMENTS

session Name of the session this command is executed on.

do.save This option should be true. Do.save = false is not supported for stpapi.delete. The option is in the function for compatibility reasons but the function will act like do.save = true.

err.mesg This parameter contains the text of the error message if the function cannot complete normally.

DESCRIPTION

This deletes the current record of the specified session in the database.

RETURN VALUES

0 Record not deleted or save failed (err.mesg is filled with the reason)

1 Record deleted (err.mesg is empty)

EXAMPLE

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.seno”, str$(i.seno))

ret = stpapi.find(“dtfsa1101s000″, error.msg)

if ret = 1 then

retval1 = stpapi.delete(“dtfsa1101s000″, true, error.msg)

if not retval1 then

retval2 = stpapi.recover(“dtfsa1101s000″, recover.msg)

endif

endif

Explanation:

The record to be deleted is searched in the session and then deleted.

USAGE NOTES

A record must be current in the session (for example, by a stpapi.find() call), otherwise the results are unpredictable.

If err.mesg is filled, stpapi.recover() must be called before any other stpapi.* commands are issued to this session, otherwise the record can be deleted in the database, as the stpapi.end.session() call will perform an update.db action.

The error messages returned can be:

n Command disabled; no update is possible in the current state of the session.

n Any error message from the session.

BaanERP only: If a multi-occurrence session is used with a synchronized dialog box, the delete action must be sent to the multi-occurrence session.

Save Session Updates to database

SYNTAX

long stpapi.save(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 executes the choice section update.db of the specified session. Note that the same effect can be achieved by issuing any of the following functions:

n stpapi.insert()

n stpapi.update()

with the do.save parameter set to 1.


RETURN VALUES

0 Record not saved (err.mesg is filled with the reason)

1 Record saved (err.mesg is empty)

EXAMPLE

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.seno”, str$(i.seno))

ret = stpapi.find(“dtfsa1101s000″, error.msg)

if ret = 1 then

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.name”, name)

retval1 = stpapi.update(“dtfsa1101s000″, false, error.msg)

if retval1 then

retval2 = stpapi.save(“dtfsa1101s000″, false, error.msg) endif

if not retval1 or not retval2 then

retval3 = stpapi.recover(“dtfsa1101s000″, recover.msg)

endif

endif

Explanation:

The record to be updated is searched in the session and its name field is updated. The update function is called without executing update.db directly. The record is saved to the database with the save function.

USAGE NOTES

If err.mesg is filled, stpapi.recover() must be called before any other stpapi.* commands are issued to this session, otherwise the record can be updated in the database as the stpapi.end.session() call will perform an update.db action.

The error messages returned can be:

n Command disabled; no update.db is possible in the current state of the session.

n Any error message from the session.

BaanERP only: If a record must be saved with a synchronized single-occurrence dialog box, the stpapi.save() call must be issued to the single-occurrence session.

Use the stpapi.insert(), and stpapi.update() calls with the do.save flag set to True, as this is better for performance. Buffering inserts or updates and saving one time will not work, as subsequent stpapi.* function calls will call update.db implicitly. In case of errors, the calling program does not know whether the update.db of the previous record failed, or that the current record is rejected due to field values.

Recover Session updates

SYNTAX

long stpapi.recover(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 executes the choice section recover.set in the specified session.

RETURN VALUES

0 Record not recovered (err.mesg is filled with the reason)

1 Record recovered (err.mesg is empty)

EXAMPLE

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.seno”, str$(i.seno))

ret = stpapi.find(“dtfsa1101s000″, error.msg)

if ret = 1 then

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.name”, name)

retval1 = stpapi.update(“dtfsa1101s000″, false, error.msg)

if retval1 then

retval2 = stpapi.save(“dtfsa1101s000″, false, error.msg)

endif

if not retval1 or not retval2 then

retval3 = stpapi.recover(“dtfsa1101s000″, recover.msg)

endif

endif

Explanation:

The record to be updated is searched in the session and its name field is updated. The update function is called without executing ‘update.db’ directly. The record is saved to the database using the save function.

USAGE NOTES

If err.mesg is filled then stpapi.end.session() must be called before you issue any other commands to this session.


The error messages returned can be:

n Command disabled; no update is possible in the current state of the session.

n Any error message from the session.

BaanERP only: If a record must be recovered using a synchronized single-occurrence dialog box, the stpapi.recover() call must be issued to the single-occurrence session.

Use the stpapi.insert(), stpapi.update(), and stpapi.delete() calls with the do.save flag set to True, as this is better for performance. Buffering inserts or updates and saving one time will give problems in case records are rejected, because subsequent calls will call update.db implicitly. The calling program does not know then which records failed.

Set Current Record for session

SYNTAX

long stpapi.find(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 finds the record in the session that corresponds with the current values of the session’s key fields and makes it current. The key field values must be set prior to calling this function.

RETURN VALUES

0 No record found (empty table or error occurred and err.mesg is filled)

1 Record found (err.mesg is empty)

2 A record different to the one requested was found (err.mesg is empty)

EXAMPLE

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.seno”, str$(i.seno))

ret = stpapi.find(“dtfsa1101s000″, error.msg)

if ret <> 1 then

message(“Record not found”)

endif

Explanation:

The key field for the session is put and the record is made current.

USAGE NOTES

The behavior is the same as a find action through BW: if no record exists, no record is shown (return value 0); if the record is found, then it is selected (return value 1); if the record cannot be found, the next record is selected (return value 2), or if there is no record, no records are shown (return value 0).

The error messages returned can be:

n Any error message from the session given during the find action.

Mark Current Record for session

SYNTAX

long stpapi.mark(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 marks the record in the session, which is made current by the stpapi.find() or one of the stpapi.browse.set() functions.

RETURN VALUES

0 Record is not marked (err.mesg is filled)

1 Record marked (err.mesg is empty)

EXAMPLE

stpapi.put.field(“dtfsa1501m000″, “dtfsa101.seno”, str$(i.seno))

ret = stpapi.find(“dtfsa1501m000″, error.msg)

if ret <> 1 then

message(“Record not found”)

else

ret = stpapi.mark(“dtfsa1501m000″, error.msg)

if ret then

stpapi.form.command(“dtfsa1501m000″, 5, “do.something”,

error.msg)

endif

endif

Explanation:

Because the form command needs a record to be marked, the found record is marked before the form command is called.

USAGE NOTES

A record must be current in the session (for example, by a stpapi.find() call), otherwise the results are unpredictable.

The error messages returned can be:

n Any error message from the session given during the mark action.

Only one record can be marked.

Browse Session records

SYNTAX

long stpapi.browse.set(string session, string option [, ref string err.mesg])

ARGUMENTS

session Name of the session this command is executed on.

option This parameter indicates what type of browse action is required. The possible values are first.set, next.set, prev.set, and last.set that correspond with the browse actions first record, next record, previous record, and last record respectively.

err.mesg This parameter will contain the text of the error message if the function cannot complete normally.

DESCRIPTION

This executes the specified browse action against the indicated session. The resulting record is set as current.

RETURN VALUES

0 No record found (empty table, no next or previous record or error occurred and err.mesg is filled)

1 Record found (err.mesg is empty)


EXAMPLE

ret = stpapi.browse.set(“dtfsa1101s000″, “first.set”, error.msg)

while ret

stpapi.get.field(“dtfsa1101s000″, “dtfsa100.name”, o.name)

stpapi.get.field(“dtfsa1101s000″, “balance”, o.balance)

rprt_send()

ret = stpapi.browse.set(“dtfsa1101s000″, “next.set”, error.msg)

endwhile

Explanation:

This piece of code browses through all records of a session and prints the fields.

USAGE NOTES

For next.set and prev.set a record must be current in the session (for example, by a stpapi.find() call), otherwise the results are unpredictable.

The error messages returned can be:

n Any error message from the session given during the browse action

Set Current View for session

SYNTAX

long stpapi.change.view(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 sets the current view for sessions with forms of type 3 (multiple occurrence plus view). The field values of the view fields must be set prior to calling this function.

RETURN VALUES

0 No view found or error occurred and err.mesg is filled

1 View found (err.mesg is empty)

2 Another view found (err.mesg is empty)


EXAMPLE

stpapi.put.field(“dtfsa1501m000″, “dtfsa101.seno”, str$(i.seno))

ret = stpapi.change.view(“dtfsa1501m000″, error.msg)

if not ret then

message(error.msg)

endif

Explanation:

The View field in the session is changed to the given key.

USAGE NOTES

The behavior is the same as a find/new group action through BW: if no records exist, then no record is shown (return value 0); if at least one record in the view exists, then the first record in that view is selected (return value 1); if the view cannot be found, then the first record in the next view selected (return value 2), or if there is no next group, then no records are shown (return value 0).

The error messages returned can be:

n Any error message from the session given during the browse action.

Before a record can be inserted on a type 3 form, the view must have been changed to the desired key fields.

Browse Session Views

SYNTAX

long stpapi.browse.view(string session, string option [, ref string err.mesg])

ARGUMENTS

session Name of the session this command is executed on.

option This parameter indicates what type of browse action is required. The possible values are first.view, next.view, prev.view, and last.view corresponding to the browse actions first view, next view, previous view, and last view respectively.

err.mesg This parameter will contain the text of the error message if the function cannot complete normally.

DESCRIPTION

This executes the specified browse action against the indicated session. The first record of the view being read is set as Current.

RETURN VALUES

0 No view found or error occurred and err.mesg is filled

1 View found (err.mesg is empty)

EXAMPLE

stpapi.put.field(“dtfsa1501m000″, “dtfsa101.seno”, str$(i.seno))

ret = stpapi.change.view(“dtfsa1501m000″, error.msg)

if ret then

ret = stpapi.browse.view(“dtfsa1501m000″, “prev.view”, error.msg)

if ret then

message(“View before ” & str$(i.seno) & ” found”)

endif

Explanation:

A check is performed whether a view is present before a given view.

USAGE NOTES

The error messages returned can be:

n Any error message from the session given during the browse action.

Synchronize Multi-occurrence and Single-occurrence sessions

SYNTAX

long stpapi.synchronize.dialog(string session, string mode, ref string err.mesg)

ARGUMENTS

session Name of the multi-occurrence session this command is executed on.

mode The mode in which the synchronized dialog box must be started. The possible values are:

Add – the dialog box is started and synchronized in Edit mode, view fields are sent from the multi-occurrence session to the single-occurrence session; use this mode before a stpapi.insert() call

Modify – the dialog box is started and synchronized in Edit mode, use this mode before a stpapi.update() call

display – the dialog box is started in Display mode

” ” – no dialog box is synchronized (for future use when multi-occurrence and single-occurrence sessions have the same code, focus is set to the multi-occurrence session)

err.mesg This parameter will contain the text of the error message if the function cannot complete normally.

DESCRIPTION

This function synchronizes a multi-occurrence session with its registered synchronized dialog box. Depending on the mode, the session with the editable window is synchronized or the read-only window.

RETURN VALUES

0 Sessions could not be synchronized (err.mesg is filled)

1 Sessions are synchronized (err.mesg is empty)

EXAMPLE

stpapi.put.field(“dtfsa1501m000″, “dtfsa101.seno”, str$(i.seno))

ret = stpapi.find(“dtfsa1501m000″, error.msg)

if ret then

ret = stpapi.synchronize.dialog(“dtfsa1501m000″, “modify”, error.msg)

if ret then

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.name”, new.name)

ret = stpapi.update(“dtfsa1501m000″, true, error.msg)

endif

endif

Explanation:

The record is searched in the multi-occurrence session. When found, the synchronized dialog box is started, the field changed, and the record updated.

USAGE NOTES

This function is for BaanERP only.

The error messages returned can be:

n Command disabled; no insert/update is possible in the current state of the session.

n Session has no synchronized dialog box.


This function must be used to get the multi-occurrence session synchronized with its connected single-occurrence dialog box. It must be called before an insert or update call. It must also be called before executing a Form command on the single-occurrence session, because the editable and display variants can have different sets of form commands. For retrieving data from the single-occurrence dialog box, the synchronization must also be executed.

Send Start processing command to session

SYNTAX

void stpapi.continue.process(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 cont.process to be executed in the specified session

RETURN VALUES

None

EXAMPLE

stpapi.put.field(“dtfsa1201s000″, “seno.f”, str$(i.seno))

stpapi.put.field(“dtfsa1201s000″, “seno.t”, str$(i.seno))

stpapi.put.field(“dtfsa1201s000″, “proc.date”, str$(date.num()))

stpapi.put.field(“dtfsa1201s000″, “do.update”, str$(etol(dtyesno.no)))

stpapi.continue.process(“dtfsa1201s000″, error.msg)

Explanation:

For a processing session, the input fields are sent to the session, and the continue process function of the session is executed.

USAGE NOTES

This function is for BAAN IV only. For BaanERP, use the stpapi.form.command().

The error messages returned can be:

n Any error message from the session.

When a report is printed, the report specifications must have been set by stpapi.set.report().

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 ValidBaan 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(), stpapi.continue.process(), or stpapi.form.command() is called.

RETURN VALUES

None

EXAMPLE

stpapi.put.field(“dtfsa1401m000″, “seno.f”, str$(i.seno))

stpapi.put.field(“dtfsa1401m000″, “seno.t”, str$(i.seno))

stpapi.set.report(“dtfsa1401m000″, “rdtfsa140111000″, pr.device, error.msg)

if isspace(error.msg) then

stpapi.continue.process(“dtfsa1401m000″, error.msg)

endif

Explanation:

The specified session will print the given report.

USAGE NOTES

The error message that can be returned is for future use. Currently, no errors will be returned by the function. Errors about invalid reports or devices are returned by the subsequent stpapi.print.report(), stpapi.continue.process(), or stpapi.form.command() calls.

Some sessions determine the report to be printed based on the input on the form. When the report code is already known in the session when the report is opened, the value set in the AFS is ignored.

Only one report can be set, so sessions that print more than one report in one execution cannot be executed with the AFS.

To print the report to a file, use a write-file or rewrite file device. To print the data to another file then the default file for the device, you must also set the spool.fileout variable:

stpapi.put.field(“<sessioncode>”, “spool.fileout”, myfile)

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.

RETURN VALUES

None

EXAMPLE

stpapi.put.field(“dtfsa1401m000″, “seno.f”, str$(i.seno))

stpapi.put.field(“dtfsa1401m000″, “seno.t”, str$(i.seno))

stpapi.set.report(“dtfsa1401m000″, “rdtfsa140111000″, pr.device, error.msg)

if isspace(error.msg) then

stpapi.print.report(“dtfsa1401m000″, error.msg)

endif

Explanation:

For a print session, the input fields are sent to the session, and the print.data function of the session is executed.

USAGE NOTES

This function is for BAAN IV only. For BaanERP, use stpapi.form.command().

The error messages returned can be:

n Report not found.

n Device not found.

n Any error message from the session.

The report specifications must have been set by stpapi.set.report().

End session

SYNTAX

void stpapi.end.session(string session [, ref string err.mesg)

ARGUMENTS

session Name of the session this command is executed on.

DESCRIPTION

This ends the specified session.

RETURN VALUES

None

EXAMPLE

stpapi.put.field("dtfsa1101s000", "dtfsa101.seno", str$(i.seno)) stpapi.put.field("dtfsa1101s000", "dtfsa101.name", name)

retval1 = stpapi.insert("dtfsa1101s000", true, error.msg)

if not retval1 then

retval2 = stpapi.recover("dtfsa1101s000", recover.msg)

endif

stpapi.end.session("dtfsa1101s000")

Explanation:

A record is inserted in the session and the session is ended.

USAGE NOTES

The error messages returned can be:

n Any error message from the session.

Although sessions are started implicitly (when used for the first time, see Chapter 4), you must end them explicitly.


When the session has activated another session (see also stpapi.handle.subprocess()), the subsession must be ended first, because the main session may be waiting until the subsession ends. In this case the main session cannot accept the protocol message to end.

Execute session user option

SYNTAX

void stpapi.application.option(string session, long form, long option, ref string err.mesg)

ARGUMENTS

session Name of the session this command is executed on.

form Form number on which user option must be executed. User options (the commands on the Special menu) are defined per form.

option The option number to be executed. User options appear as choice.user.x options in the Baan 4GL code where x is a number that ranges from 0 to 9. The value of x that corresponds to the option that you want to activate is provided as the value of this parameter.

err.mesg This parameter will contain the text of the error message if the function cannot complete normally.

DESCRIPTION

This executes the specified user option in the session.

RETURN VALUES

None

EXAMPLE

stpapi.put.field("dtfsa1501m000", "dtfsa101.seno", str$(i.seno))

ret = stpapi.find("dtfsa1501m000", error.msg)

if ret = 1 then

stpapi.application.option("dtfsa1501m000", 2, 3, error.msg)

endif

Explanation:

For the record found, choice user.3 is executed on the 2nd form.


USAGE NOTES

This function is for BAAN IV only. For BaanERP, use stpapi.form.command().

The error messages returned can be:

n Any error message from the session.

Execute session zoom option

SYNTAX

void stpapi.zoom.option(string session, long form, string zoom.prog, ref string err.mesg)

ARGUMENTS

session Name of the session this command is executed on.

form Form number on which zoom must be executed. This needs to be specified, as some sessions depend on a particular form being active when the zoom is executed.

zoom.prog Baan session for the zoom. This must be the same as the zoom session specified for the choice field of form. If the choice specifies a zoom to a menu, then this session must be one of those mentioned in the menu.

err.mesg This parameter will contain the text of the error message if the function cannot complete normally.

DESCRIPTION

This executes a zoom in the specified session to the program given in zoom.prog.

RETURN VALUES

None

EXAMPLE

stpapi.put.field("dtfsa1501m000", "dtfsa101.seno", str$(i.seno))

ret = stpapi.find("dtfsa1501m000", error.msg)

if ret = 1 then

stpapi.handle.subproc("dtfsa1501m000", "dtfsa1201m000", "add")

stpapi.zoom.option("dtfsa1501m000", 2, "dtfsa1201m000", error.msg)

stpapi.continue.process("dtfsa1201m000", error.msg)

endif


Explanation:

For the record found, the session dtfsa1201m000 is run, which is connected to the Choice field or a menu choice of the menu connected to the Choice field.

USAGE NOTES

This function is for BAAN IV only. For BaanERP, use stpapi.form.command().

The error messages returned can be:

n Any error message from the main session (set in before.choice of choice.zoom).

Execute session form command

SYNTAX

void stpapi.form.command(string session, long command.type, string command.prog, ref string err.mesg)

ARGUMENTS

session Name of the session this command is executed on.

command.type The type of form command to be executed. The following values apply:

2 - session

5 - function

command.prog The code of the session or the name of the function to be executed.

err.mesg This parameter will contain the text of the error message if the function cannot complete normally.

DESCRIPTION

This function causes the specified form command to be executed in the specified session.

RETURN VALUES

None


EXAMPLE

stpapi.put.field("dtfsa1501m000", "dtfsa101.seno", str$(i.seno))

ret = stpapi.find("dtfsa1501m000", error.msg)

if ret = 1 then

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

if ret = 1 then

stpapi.form.command("dtfsa1501m000", 5, "calculate.vat",

error.msg)

endif

endif

Explanation:

For the record found, the function calculate.vat is carried out.

USAGE NOTES

This function is for BaanERP only. For BAAN IV, use stpapi.continue.process(), stpapi.application.option(), or stpapi.zoom.option().

The error messages returned can be:

n Form command not found in session.

n Any error message from the session.

Whether an error message is returned in the function call depends on the way it is coded in the session. See Chapter 4 for more information.

The form command is searched in the session. When it is found in one of the forms it is executed.

If a report is printed, the report specifications must have been set by stpapi.set.report().

If the form command is of type Session, a stpapi.handle.subproc() call must first be issued.


Specify actions for subsessions

SYNTAX

void stpapi.handle.subproc(string session, string sub.prog, string action)

ARGUMENTS

session Name of the session this command is executed on.

sub.prog Baan session code to which the action specified applies. This must be the session code of a valid subsession of the specified session or the menu code of a menu that can be started by the specified session.

action The action to be taken when the subsession starts or which menu choice to be activated when the menu is activated.

Actions for subsessions:

kill - Child process is killed as soon as it starts

ignore - The child process is ignored except for the fact that the parent will wait until the child ends

send - All future stpapi.* function calls that use the name of the parent act on the child instead of the parent

add - The child is added to the list of sessions currently under control. The child can thus be independently controlled by issuing stpapi.* function directly against its session name

Menu choice:

Menu choice of the session to be started converted to a string

DESCRIPTION

This sets the action that is taken when the specified subsession is invoked from the specified session or the menu choice to be activated when the menu is invoked. Note that a stpapi.handle.subproc() must also be called for the session activated by the menu choice.

RETURN VALUES

None


EXAMPLE

stpapi.put.field("dtfsa1501m000", "dtfsa101.seno", str$(i.seno))

ret = stpapi.find("dtfsa1501m000", error.msg)

if ret = 1 then

stpapi.handle.subproc("dtfsa1501m000", "dtfsa1201m000", "add")

stpapi.zoom.option("dtfsa1501m000", 1, "dtfsa1201m000", error.msg)

stpapi.put.field("dtfsa1201m000", "dtfsa101.date", str$(date.num()))

stpapi.continue.process("dtfsa1201m000", error.msg)

stpapi.end.session("dtfsa1201m000")

endif

stpapi.end.session("dtfsa1501m000")

Explanation:

For the record found, the session dtfsa1201m000 is run, which is connected to the Choice field or a menu choice of the menu connected to the Choice field. To also send messages to the subsession, the stpapi.handle.subproc() is called.

USAGE NOTES

When the subprocesses are a session without form, then you cannot communicate with the session through the AFS. In such cases, you cannot define the action for the subsessions of this process.

For this situation, you can define the action for the subprocesses of that session in the group session (session where the pid is the same as the gid of this subsession in the processlist). And the intermediate session must be defined with action Ignore.

This function must always be called when a subprocess is started by the session called through the AFS when the subprocess expects user interaction (such as filling fields or pressing buttons).


Get Messages from session

SYNTAX

string stpapi.get.mess.code(string session [, ref string err.mesg])

ARGUMENTS

session Name of the session this command is executed on.

err.mesg Text of the message.

DESCRIPTION

This retrieves the messages generated by the indicated session as a result of an stpapi.* function call. The messages are returned in the opposite order as generated in the session. Messages generated by the AFS or 4GL-Engine are also returned. These messages are generated when the AFS is not used correctly by the programmer (for example, wrong order of function calls).

RETURN VALUES

String that contains code of error message or the empty string if no error message is found or only the error text is filled.

EXAMPLE

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.seno”, str$(i.seno)) stpapi.put.field(“dtfsa1101s000″, “dtfsa101.name”, name)

retval1 = stpapi.insert(“dtfsa1101s000″, true, error.msg)

if not retval1 then

while true

error.code = stpapi.get.mess.code(“dtfsa1101s000″, true, error.msg)

if isspace(error.msg) then

break

endif

rep.message = error.msg

rprt_send()

endwhile

retval2 = stpapi.recover(“dtfsa1101s000″, recover.msg)

endif

Explanation:

A record is inserted. If an error occurred, all errors raised by the session are retrieved and printed.

USAGE NOTES

See Chapter 4.

Set answers to questions in session

SYNTAX

void stpapi.enum.answer(string session, string question, bset answer)

ARGUMENTS

session Name of the session this command is executed on.

question Baan question code. This question code must be valid within the session, that is, the session must ask this question when the user interface is used.

answer The enum or set answer to be supplied as answer to the question. This must be expressed as the enum value as opposed to the numeric equivalent for example, tcyesno.yes i.s.o. 1.

DESCRIPTION

This sets the answers to questions that occur while the session is executing.

RETURN VALUES

None.

EXAMPLE

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.seno”, str$(i.seno))

stpapi.put.field(“dtfsa1101s000″, “dtfsa101.name”, new.name)

stpapi.enum.answer(“dtfsa1101s000″, “dtfsa1101a”, tcyesno.yes)

ret = stpapi.insert(“dtfsa1101s000″, true, error.msg)

Explanation:

The session asks whether the user wants to continue if a record is already present with the same name. The default answer in the session is No, but you must continue.

USAGE NOTES

This function must only be used for questions for which the default answer in the session must be overruled.

If the same question is used more than once in the same session, you can define only one answer.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Baan Support, One-stop-shop for all Baan Implementation needs, Baan Manual, BAan Help,. Baan ERP LN