BSL Customization

It is possible to create your own entities or entity functions.

youtube BSL Customizing

 

1.Go to Administration > AddOns > Addon Manager (beas) > Click Edit on the project folder > Beas Service Layer.

addonconfig_bsl

2.Define the object/s
3.Define columns, tables and functions for an object.
4.Add optional script for all functions.
5.Add optional script for the post command.

 

 

// Define all Columns, Functions, Table and other properties

[register CompanyWorkOrderActivity]

all properties

[/register CompanyWorkOrderActivity]

 

// Define the functions

[CompanyWorkOrderActivity/functionname]

beas script for function

[/CompanyWorkOrderActivity/functionname]

 

// Define post command

[CompanyWorkOrderActivity/post]

beas script  for post command

[/CompanyWorkOrderActivity/post]

 

hmtoggle_plus1Register collections area

In this area you can define the collection / object , for example SAP Activity for work order call. We use the SAP Activity.

 

 

All other properties are defined in [register CompanyWorkOrderActivity] = the object name.

Note: Always insert the company as suffix, otherwise naming conflicts can occur.

hmtoggle_plus1Register details for an entity / object or add columns

In this area you can define all details for a custom collection/object or you can add additional properties / columns to existing entities / objects.

Note: The system does not check, if you entry is correct. You can make the program unstable, if you modify existing objects.

 

The following properties are available:

Property

Description

table={tablename]

Define the table, which is related to this object. This is mandatory.

Example OCLG

post=true/false

Define, if the post command is possible.

If you define this as true you must define an area:

[objectname/post]

mainfilter=[sql filter]

You can define a main filter, which is always active, if you execute a get command.

aliasname

You can define an alias name for the SQL statement. Use this, if you work with join and you  need a table more than once.

column

Add a column with the following properties:

Note: All properties are mandatory

Property

Description

name

The name of object. Only A-Z, a-z, 0-9 and underline are allowed. Do not use any other character.

This property is mandatory.

sql

The sql statement (field name) from table

fieldtype

The field type

c=char

i=integer/numeric

d=date

b=boolean

default=c

maxlength

For type c: the max. length

default=20

description

The description of this object

 

[register CompanyWorkOrderActivity]
(...)

// Define function with parameter
function=name=AddValues<tab>description=Add 2 values<tab>parameter=value1/i,value2/i
[/register CompanyWorkOrderActivity]

 
// Function AddValues
// return sum of both values. 
[CompanyWorkOrderActivity/AddValues]
setvar=result=%numadd(<value1>,<value2>)
[/CompanyWorkOrderActivity/AddValues]

 

 

Example Function: return Work order Customer name

[register Workorder]
function=name=getName<tab>description=Return Customer name from work order<tab>parameter=DocEntry/i
[/register Workorder]
 
[Workorder/getName]
select "KNDNAME" into result from "BEAS_FTHAUPT" where "BELNR_ID"=<DocEntry>
[/Workorder/getName]

 

function

Add a function with the following properties.

Property

Description

name

Function name

description

Function description

parameter

Defines the parameter

ParameterName/type,

ParameterName/type

 

The field type

c=char

i=integer/numeric

d=date

b=boolean
 
Example
Color/c,Width/i

 

Example:

 

 

// Define all Columns, Functions, Table and other properties

[register CompanyWorkOrderActivity]

table=OCLG

post=true

column=name=ActivityCode<tab>sql="OCLG"."ClgCode"<tab>fieldtype=i

column=name=Details<tab>sql="OCLG"."Details"<tab>maxlength=20<tab>fieldtype=c

function=name=CountOfEntries<tab>description=Return count of existing activities

[/register CompanyWorkOrderActivity]

hmtoggle_plus1Script for a registered function

Beas script can be defined to executed, if you call the function.

Call this with

get [entityname][functionname](parameter)

 

All defined parameters are available as Beas script variables.

Additional variables that are available:

result  Write the text, which you want send to the client.

sql Define a SQL statement,iIf you want to return the result of a SQL statement in JSON format (variable result must be empty).

code Returns the code. (The default is 200 = ok. If this is modified, it results in an error.)

messagecode / message (The default is 200 = ok. If this is modified, it results in an error.)

 
[register collections]
CompanyWorkOrderActivity=primary=ClgCode/n<tab>description=Activity for Work order
[/register collections]
// Define all Columns, Functions, Table and other properties
[register CompanyWorkOrderActivity]
table=OCLG
post=true
column=name=ActivityCode<tab>sql="OCLG"."ClgCode"<tab>fieldtype=i
column=name=Details<tab>sql="OCLG"."Details"<tab>maxlength=20
function=name=CountOfEntries<tab>description=Return count of existing activities
// Define function with parameter
function=name=AddValues<tab>description=Add 2 values<tab>parameter=value1/i,value2/i
 
[/register CompanyWorkOrderActivity]
// Define function
[CompanyWorkOrderActivity/CountOfEntries]
sql=select count(*) into result from "OCLG"
[/CompanyWorkOrderActivity/CountOfEntries]
 
// Function AddValues
// return sum of both values
[CompanyWorkOrderActivity/AddValues]
setvar=result=%numadd(<value1>,<value2>)
[/CompanyWorkOrderActivity/AddValues]

 

hmtoggle_plus1Script for a post command

Beas script can be defined to be executed for post command.

Call this with:

post [entityname]

 

The JSON object, which you define in the body is available for Beas script with JSON object.

For example: <j.jsonproperty>

 

Additional variables that are available:

result Write the text, which you want send to the client.

code Return the code (The default is 200 = ok. If this is modified, it results in an error.)

message Define the error code and error message, if the code is not 200.

 

[CompanyWorkOrderActivity/post]

// Add script to AddActivity

[/CompanyWorkOrderActivity/post]

 

 

Example: Create Activity

Body of the post command:

{"DocEntry":[workorder docentry],"ReceiptDocEntry":[ReceiptDocentry]}

 

[CompanyWorkOrderActivity/post]

[/CompanyWorkOrderActivity/post]