BSL and Beas script

The Beas Service Layer has a connection to a HTTP server and to all functionality of the Beas framework.

Beas does not work with services, but function calls. A running service is not required, because the Beas Service Layer is fully integrated in the Beas core.

bsl-overview

youtube Beas Service Layer command GET with beas script

youtube Beas Service Layer command POST with beas script

youtube Beas Service Layer and datastore

 

Working with BSL as a placeholder

You can return the result directly from BSL. Only GET functions are possible.

The syntax is ODATA, UTF8.

Variables: String

Format: bsl

Numbers: num(x)

Default Format is JSON, if you do not define another.

 

messagebox=<bsl.[odata syntax]>

 

Example:

Return the item name of item 0815

beasscript-logo-small

messagebox=<bsl.item("0815")/ItemName/$value>

 

Place holders inside the main placeholder <> must be defined with []
Strings must be formatted with ",bsl"

 

setvar=ls_itemcode=0815
messagebox=<bsl.Item([ls_itemcode,bsl])/ItemName/$value>

 

Example:

Read Bin Management Warehouse Type

if <bsl.WareHouse("SAP-BIN")/WhsBinType/$value> n> 0 then
  messagebox=Bin managed warehouse
end if

 

Note: This is only working with one Parameter. Comma is not allowed in the place holder string

<bsl.Warehouse("SAP-BIN('01')?$select WhsCode,WhsName> <- Wrong, comma not allowed in the <..> place holder string, because after comma you define the format!

 

Error handling

If there is a syntax error, Beas displays this as an error message and returns an empty string.

In a placeholder <object.ret_code> and <object.ret_text> it is possible to read complete text.

 

Example

setvar=ls_itemcode=0815
// Produce an Syntax error
setvar=ls_itemName=<bsl.NotExistCommand([ls_test,bsl])/ItemName/$value>
// Check Result
if <object.ret_code> n<> 0 then
  messagebox=(<object.ret_code>) <object.ret_text> 
end if

 

Note: Comma in placeholder is not supported. Use Pipeline

setvar=ll_DocEntry=6002479
setvar=ll_LineNumber=10

// Note: use Pipeline, becaus comman in place holder not supported
setvar=lc_bookedQty=<bsl.WorkorderPos([ll_DocEntry]|[ll_LineNumber]).QuantityProduced/$Value>
messagebox=booked quantity: <lc_bookedQty>

 

 

See Example:

After work order creation - get WMS Production Line

 

Working with instance object

It is possible to define the service layer as and object. Use this option, if you must work with a body or if you need a fast result for one result line.

 

Fast result line

This option is very fast, because it does not create a datastore.

instance bsl b
b.select=Item("A001")?$select=ItemName,ItemCode
messagebox=<b.ItemName> / <b.ItemCode>

More see ue_besl

 

Return as formatted string

With GetString the result is a string in JSON format or in the format defined in $format.

instance bsl b
b.getstring=Item("A001")?$select=ItemName,ItemCode&$format=xml,linefeed
messagebox=<b.ret_vale>

 

Function calls

Get next Batch Number for a work order

instance bsl b
b.get=WorkorderPos/GetNextBatchNumber(6002478,40) 
messagebox=<b.value>

 

 

Return only one value (best performance)

instance bsl b
b.get=Itemcode("a001")/ItemName/$value

if <b.ret_code> n= 0 then 
  messagebox=<b.ret_value>
end if

 

Work with aggregate functions

Support $sum, $min, $max, $avg and $count

return Stock informations

 

instance bsl b
b.get=WareHouseStock("BW")/OnHand/$sum
messagebox=<b.ret_value>

 

 

 

Return as object

With "get" a JSON object is generated. All properties are readable with the JSON object.

 

instance bsl b
b.body=[define the body (json string...)]
b.get=[beas service layer get command]

 

<b.ret_code> -> 0 = ok, 400 = Syntax error, 404 = not found, all other messages are error messages

<b.ret_text> = Error message

<b.ret_value> = The return value of the Beas Service Layer, but only text information

 

Return the result in a JSON object:

instance json j
instance bsl b
// parse Item 781
b.get=Item("781")
// Return ItemName
messagebox=<b.ItemName>
// copy in a json object - with reference to the bsl object
j.parse=b

 

Working with BSL as datastore

There is a new bsl method in the ue_datastore.

instance datastore d
// Read Data from Beas Service Layer
d.bsl=Item("781")
// Now all functions available from Datastore object
messagebox=<d.ItemCode>

 

In case of the <d.red_code>,<d.ret_text> error, you can read the information.

Example: Userevent time receipt - check booked material positions

 

Working with BSL in the drop-down

item.WhsCode.dropdown.bsl=WareHouse?$filter=Transaction="IncomingGoods"

 

If you do not define select, Beas automatically creates the current drop-down with visual information.

If fields are defined, the Grid information is returned with correct Title Name.

 

The following example create a drop-down list with Bitmap, Warehouse Code and WhsName:

item.WhsCode.dropdown.bsl=Warehouse?$select=WhsBitmapName,WhsCode,WhsName

 

Working with DataWindow

A list of all items.

 

dw_1.bsl=Item

 

This option can be slow, if the DataField in the DataWindow is not the same as the BSL result.

Beas as follows:

Checks if the datastore schema is same as result schema. If yes, it copies the data directly.

If datastore schema is not exactly the same as the result schema, it inserts this field mapping line by line, which is a slow process.