It is possible to create your own entities or entity functions.
1. | Go to Administration > AddOns > Addon Manager (beas) > Click Edit on the project folder > Beas Service Layer. |
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. |
[register collections]
CompanyWorkOrderActivity=primary=[primary]<tab>description=[description]
[/register collections]
// 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]
In this area you can define the collection / object , for example SAP Activity for work order call. We use the SAP Activity.
[register collections] CompanyWorkOrderActivity=primary=ClgCode<tab>description=Activity for Work order [/register collections]
All other properties are defined in [register CompanyWorkOrderActivity] = the object name. Note: Always insert the company as suffix, otherwise naming conflicts can occur. |
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:
Example: [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<tab>fieldtype=c function=name=CountOfEntries<tab>description=Return count of existing activities [/register CompanyWorkOrderActivity] |
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.)
|
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] instance bsl b b.Workorder(<DocEntry>)?$select=DocNum,CardCode if <b.Cardcode> = "" then return success end if
declare=di=ue_api_sbo di=getbusinessobject=ocontacts di=CardCode=<b.CardCode> di=DocType=59 di=DocEntry=<docentry> di=details=Receipt item for <b.DocNum> di=add destroy=di [/CompanyWorkOrderActivity/post]
|