How to Create a business Entity with multiple tables.

Posted by ashon shakya on 15-Aug-2017 23:21

@openapi.openedge.entity.primarykey (fields="CustNum").

DEFINE TEMP-TABLE ttCustomer BEFORE-TABLE bttCustomer
FIELD id AS CHARACTER
FIELD seq AS INTEGER INITIAL ?
FIELD CustNum AS INTEGER INITIAL "0" LABEL "Cust Num"
FIELD Country AS CHARACTER INITIAL "USA" LABEL "Country"
.......


@openapi.openedge.entity.primarykey (fields="Ordernum").

DEFINE TEMP-TABLE ttOrder BEFORE-TABLE bttOrder
FIELD Ordernum AS INTEGER INITIAL "0" LABEL "Order Num"
FIELD CustNum AS INTEGER INITIAL "0" LABEL "Cust Num"
FIELD OrderDate AS DATE INITIAL "TODAY" LABEL "Ordered"
.........

DEFINE DATASET dsCustomerOrder FOR ttCustomer,ttOrder
DATA-RELATION drCO for ttCustomer,ttOrder
RELATION-FIELDS (CustNum, CustNum) .

I used the above schema to create a business entity but the datasource-table are not automatically filled.

Also how to create count function for this buisness entity.

All Replies

Posted by maura on 16-Aug-2017 09:06

Hi Ashon,

When you create a BusinessEntity by specifying a schema,  it is left to the developer to fill-in the corresponding data-source tables to be used in your backend resource, since we cannot make an accurate guess as to what table the  developer is intending to use. As an example, if you are using the sports2000 db, you update the following statements as below:

DEFINE DATA-SOURCE srceCustomer FOR <datasource-table>.

DEFINE DATA-SOURCE srceOrder FOR <datasource-table>.

DEFINE DATA-SOURCE srceCustomer FOR Customer.

DEFINE DATA-SOURCE srceOrder FOR Order.

The count function should return the number of records for the parent table. As in the example above, that would be for the customer table. See link below for example BE count function

documentation.progress.com/.../

Maura

Posted by Anil Kumar on 17-Aug-2017 01:18

Hi Ashon,
 
Maura has provided most of the answer(s) for your questions.
 
In addition to that please go through following references for extending/creating Business Entities with multiple tables.
 
 
Thanks and Regards,
Anil Kumar.
 

This thread is closed