Beas Common Interface, using Script

  • Updated

Article Type: Tips & Tricks

Product AREA: Beas

TOPIC / SYSTEM AREA: Beas script

System Functionality: Beas Script for Beas Common Interface

 

Scenario description

With the Beas Common Interface you can simply perform asynchronous tasks.

The Beas Common Interface contains among other things the table BEAS_COMMON_INPUT for inserting the Beas script, which is then executed via the running Beas Sever Manager. Another table BEAS_COMMON_OUTPUT can be used for the output of the script result (e. g. error code, error text).

 

Solution

For working with Beas Script via the Beas Common Interface the following fields of the table BEAS_COMMON_INPUT are to be filled:

 

COMMONTYP:                                 script

TEXTPARAMETER:                            the Beas Script which is to be executed

 

Further following variables can be used in the Beas Script:

IS_REQUESTED:                                Reply to this ID (is preallocated)

IS_STATIONID:                                  Reply to this station-ID (is preallocated)

IS_ANSWERID:                                  Answer ID (only numbers)

IS_ANSWERTEXT:                              Answer text, will only be written if IS_ANSWERID was set

IS_COMMONTYP:                             The COMMONTYP which should be written

                                                         (default from BEAS_COMMON_INPUT)

IS_PARAMETER1:                              Any text you want (max. 255 characters)

 

Example:

Creating a work worder

The Beas Script, which is entered into the table BEAS_COMMON_INPUT, is identical to the standard Beas Script syntax.

A simple Beas Script for creating a work order with the Beas API object look like:

 

// Create Workorder

declare=mywo=ue_api_wo

mywo=line=itemcode=A118f96

mywo=line=quantity=10

mywo=kndname=Smith

mywo=add

if <global:errortext> <>  then

   message=error$**$<global:errortext>

end if

destroy=mywo

 

Now variables are added to get a line in the table BEAS_COMMON_OUTPUT:

// Create Workorder

declare=mywo=ue_api_wo

mywo=line=itemcode=A118f96

mywo=line=quantity=10

mywo=kndname=Added by scan

mywo=add

setvar=is_answerid=0

setvar=is_requestid=11111

setvar=is_answertext=workorder created

if <global:errortext> <>  then

   setvar=is_answerid=1

   setvar=is_answertext=<global:errortext>

end if

destroy=mywo

 

This Beas Script is now inserted into field textparameter of the table BEAS_COMMON_INPUT via a SQL INPUT Statement in the following way:

 

insert into “BEAS_COMMON_INPUT” (“COMMONTYP”, “PARAMETER1”, ”TEXTPARAMETER”)

values

('script','',

'// clear last errormessage '+char(13)+char(10)+

'setglobal=errortext='+char(13)+char(10)+

'// Create Workorder'+char(13)+char(10)+

'declare=mywo=ue_api_wo'+char(13)+char(10)+

'mywo=line=itemcode=A118f96'+char(13)+char(10)+

'mywo=line=quantity=10'+char(13)+char(10)+

'mywo=kndname=Added by scan'+char(13)+char(10)+

'mywo=add'+char(13)+char(10)+

'setvar=is_answerid=0'+char(13)+char(10)+

'setvar=is_requestid=11111'+char(13)+char(10)+

'setvar=is_answertext=workorder created'+char(13)+char(10)+

'if <global:errortext> <>  then'+char(13)+char(10)+

'   setvar=is_answerid=1'+char(13)+char(10)+

'   setvar=is_answertext=<global:errortext>'+char(13)+char(10)+

'end if'+char(13)+char(10)+

'destroy=mywo')

 

Beware that you have no CRLF in the insert statement. So the Insert Statement should be in one line.

 

The Beas server process will take this entry and execute it. The output of the task (error code and error text) will be entered as a new line in the table BEAS_COMMON_OUTPUT.

 

Important:

If the variable is_answerid is NOT set in the Beas script, no entry is inserted in table BEAS_COMMON_OUTPUT.

 

 

 

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.