Beas service layer (BSL), register new objects (tables)

  • Updated

It may happen that an own (Custom) object in Beas is needed to perform a specific retrieval or insertion to e. g. a customized table (UDT) 

  

Therefore, it is possible 

  • to create own BSL objects 
  • enter fields/columns to a BSL Object 

 These definitions are stored / registered in the Addon Administration:

blobid0.png

1.1.- Create your own BSL object 

[register collections] 

myBeasUDT=primary=ItemCode/c<tab>description=My Beas UDT 

[/register collections] 

 

[register myBeasUDT] 

table=BEAS_MY_TABLE 

post=true/false // Possibility to insert new entries 

column=name=ItemCode<tab>sql="BEAS_MY_TABLE"."ItemCode"<tab>maxlength=50<tab>fieldtype=c 

column=name=ItemName<tab>sql="BEAS_MY_TABLE"."Description"<tab>maxlength=100<tab>fieldtype=c 

column=name=Color<tab>sql="BEAS_MY_TABLE"."Color"<tab>maxlength=10<tab>fieldtype=c 

column=name=Quantity<tab>sql="BEAS_MY_TABLE"."Quantity"<tab>fieldtype=i 

[/register myBeasUDT] 

 

Table contents of “myBeasUDT” (example): 
blobid1.png

 

1.2.1- Results of own BSL object 

Testing of the results are performed with Postman. It’s also possible to do it via BeasScript. 


1.2.2- Get
 

Therefore your own registered object will be taken: 

blobid2.png

 


1.2.2- Post

If you also want to “post” (insert) data to this table a corresponding definition is necessary. 

It is to be added to the customizing area of the Beas Service Layer 

 

[myBeasUDT/post] 

// check if inserted Item already exist in table 

select count(*) from "BEAS_MY_TABLE" where "ItemCode" =<j.ItemCode,dbstring> 

if <wert1> n> 0 then 

  setvar=result={"error":200,"errormessage":"ItemCode '<j.ItemCode>' already exists"} 

  return success 

end if 

// Insert line into table 

sql=insert into BEAS_MY_TABLE ("ItemCode","Description","Color","Quantity") values (<j.ItemCode,dbstring>,<j.Description,dbstring>,<j.Color,dbstring>,<j.Quantity>) 

if <sqlcode> <> 0 then 

  setvar=result={"error":300,"errormessage":"<sqlerrtext>"} 

  return success 

end if 

// OK message 

setvar=result={"ok":"record inserted"} 

[/myBeasUDT/post] 

 

 

You have to post the following with a data line in the “body”:

blobid3.png

 

The following result is retrieved: 

blobid4.png

 

 1.2.3- Put 

If you also want to “put” (Update) data to this table a corresponding definition is necessary. 

But this is currently not supported by Beas. 

 

1.2.4- Delete 

If you also want to “delete” (Delete) data to this table a corresponding definition is necessary. 

But this is currently not supported by Beas. 

 

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.