Вы находитесь на странице: 1из 26

BOPF- Creating a Business Object

Important Transactions while working with BOPF:

BOB: Business Object Builder.


BOBX: Business Object Builder eXpert.
BOBT: Business Object Builder Test.

Simple step by step example for creating Business Object in BOPF.

1. Start T-code: BOB (Business Object Builder). Click on Custom Business Object. A wizard
opens as below proceed with continue.
2. Provide with a Prefix and Name and continue.
3. Propose a constant interface name and continue.

4. Propose a Persistent structure name, the Root node name is auto filled with ROOT.
The Persistent Structure defines the attributes that are stored in the database.
The Transient Structure defines the attributes calculated at runtime.
Both structures are implemented as regular DDIC structures and are created in the DDIC
transaction SE11. You can simply double click the structure to proceed with the structure
creation.
I have created the following structure.
5. Proceed with Continue in the wizard. The Combined Structure, Table type and the Database
Table is automatically proposed.
6. Proceed with Continue and complete the wizard. You will be prompted for package, which I
have assigned to Local Object.

7. The BO is created as below, by default a Query is created SELECT_ALL:


8. We are now creating ITEM node. Right click ROOT and create a Sub node.

A wizard opens proceed with the ITEM as node name.


9. Provide a Persistent structure which is created in se11 or create it through Forward navigation.

The following Item structure is created.


10. Continuing we get the Combined Structure, Table type and Database Table.

Proceed with continue and complete the wizard. We now have the ITEM node created.

Testing: Let us now proceed with Testing of the BO:


1. Open T-code BOBT (Business Object Builder Test). Provide with your Business Object name.
2. Select the ROOT and click Add node instance. Provide with your input data.

3. Select the record and click Execute Association button and click on ITEM.

4. You can add two item level records.

5. Save your records by clicking the save button.

Thank you.

Creating Delegate Node

I have demonstrated how to create a delegate node (Text Collection in our case), also have
created a test report program to demonstrate usage of helper class and retrieve by associations
to retrieve the text contents, going further we are consuming the Dependent BO in FPM.
Here we are embedding the Dependent Object /BOBF/TEXT_COLLECTION in our BO.

Right click Root node Select Delegate node.


Provide node name, node prefix, under Cross BO Relationship select Ref. Business Object as
/BOBF/TEXT_COLLECTION.
We can choose from the available Dependent Objects:

Node Prefix: The node prefix is used by BOPF at runtime in order to identify the Dependent Object
which is called by the consumer.
When you create the Delegated Node as described above BOPF automatically creates the required
association to the root node of the Dependent Object.

This is possible since the Text Collection Dependent Object supports a standard linkage to a hosting
Business Object. The standard linkage is supported for each Dependent Object that fulfils the
following requirement:
The embedded Dependent Object must have an alternative key on its root node that uses
/BOBF/S_LIB_K_DELEGATION as DATA_TYPE and /BOBF/T_LIB_K_DELEGATION as
DATA_TABLE_TYPE. The Alternative Key must be set to Not-unique to enable one-to-many usages
of it.
We can see that in the Dependent BO for Text Collection.

Activate and regenerate the BOPF constant interface.

Adding Delegate Node instance using T-code BOBT:


Select the BO and provide query select all. Select the Root node and click edit button.

Navigate to ROOT_LONG_TEXT.
Click Create node instance, we may get the error.

Provide with the Test Schema ID as DEFAULT and TEXT_EXISTS_IND = X and click check. Save.
Now Opening the ROOT_LONG_TEXT we see:

Under TEXT create node instance and provide TEXT_TYPE and LANGUAGE_CODE. I have
added as:

Now Select the TEXT_CONTENT and create instance. Provide the Text Demo Text. Save. The
records are now saved.
Testing the BO to get the Text available in TEXT_CONTENT:
The structure and table types used in our program are from ROOT and ITEM nodes:
Add the below code:
*Association to a Delegated node.
DATA: lt_mod TYPE /bobf/t_frw_modification,
ls_mod TYPE /bobf/s_frw_modification,
lo_message TYPE REF TO /bobf/if_frw_message,
lo_chg TYPE REF TO /bobf/if_tra_change,
lr_srv_mgr TYPE REF TO /bobf/if_tra_service_manager,
lt_key TYPE /bobf/t_frw_key,
lt_target_key TYPE /bobf/t_frw_key.

DATA: lv_text_node_key TYPE /bobf/conf_key,


lv_content_node_key TYPE /bobf/conf_key,
lv_text_assoc_key TYPE /bobf/obm_assoc_key,
lt_txc_text_key TYPE /bobf/t_frw_key,
lv_content_assoc_key TYPE /bobf/obm_assoc_key,
lt_txc_content TYPE /bobf/t_txc_con_k.

DATA: lt_root_data TYPE zmay1_t_root,


ls_root_data TYPE zmay1_s_root,
lt_item_data TYPE zmay1_t_item,
ls_item_data TYPE zmay1_s_item.
*Get dependent object keys for retrieve by association calling helper method
*Helper method = /scmtms/cl_common_helper=>get_do_keys_4_rba
*/bobf/if_txc_c = Interface of Dependent BO= /BOBF/TEXT_COLLECTION
*zif_may1_trq_c = Interface of our BO= ZMAY1_TRQ

*Flow:
*ZMAY1_TRQ ->ROOT -> ROOT_LONG_TEXT -> TEXT -> TEXT_CONTENT
*/BOBF/TEXT_COLLECTION -> ROOT -> TEXT -> TEXT_CONTENT

*Helper method to fetch node and keys


/scmtms/cl_common_helper=>get_do_keys_4_rba(
EXPORTING
iv_host_bo_key = zif_may1_trq_c=>sc_bo_key
iv_host_do_node_key = zif_may1_trq_c=>sc_node-root_long_text
iv_do_node_key = /bobf/if_txc_c=>sc_node-text
iv_do_assoc_key = /bobf/if_txc_c=>sc_association-root-text
IMPORTING
ev_node_key = lv_text_node_key
ev_assoc_key = lv_text_assoc_key
).

/scmtms/cl_common_helper=>get_do_keys_4_rba(
EXPORTING
iv_host_bo_key = zif_may1_trq_c=>sc_bo_key
iv_host_do_node_key = zif_may1_trq_c=>sc_node-root_long_text
iv_do_node_key = /bobf/if_txc_c=>sc_node-text_content
iv_do_assoc_key = /bobf/if_txc_c=>sc_association-text-text_content
IMPORTING
ev_node_key = lv_content_node_key
ev_assoc_key = lv_content_assoc_key ).

*Get Service Manager Instance


IF ( lr_srv_mgr IS NOT BOUND ).
lr_srv_mgr = /bobf/cl_tra_serv_mgr_factory=>get_service_manager(
zif_may1_trq_c=>sc_bo_key ).
ENDIF.

lr_srv_mgr->query(
EXPORTING
iv_query_key = zif_may1_trq_c=>sc_query-root-select_all
iv_fill_data = abap_true
IMPORTING
et_data = lt_root_data
et_key = lt_key
).

*RETRIEVE_BY_ASSOCIATION 1. ROOT to ROOT_LONG_TEXT


lr_srv_mgr->retrieve_by_association(
EXPORTING
iv_node_key = zif_may1_trq_c=>sc_node-root
it_key = lt_key Key Table
iv_association = zif_may1_trq_c=>sc_association-root-
root_long_text
IMPORTING
et_target_key = lt_target_key Retrieved key of
root_long_text
).

*RETRIEVE_BY_ASSOCIATION 2. ROOT_LONG_TEXT to TEXT


lr_srv_mgr->retrieve_by_association(
EXPORTING
iv_node_key = zif_may1_trq_c=>sc_node-root_long_text
it_key = lt_target_key ROOT_LONG_TEXT key
iv_association = lv_text_assoc_key
IMPORTING
et_target_key = lt_txc_text_key ).

*RETRIEVE_BY_ASSOCIATION 3. TEXT to TEXT_CONTENT


lr_srv_mgr->retrieve_by_association(
EXPORTING
iv_node_key = lv_text_node_key
it_key = lt_txc_text_key
iv_association = lv_content_assoc_key
iv_fill_data = abap_true
IMPORTING
et_data = lt_txc_content ).

BREAK-POINT.

The Output in Debugger with the text Demo Text:

Consuming the Dependent BO in FPM:


Pre-requisite: Please follow the link to get started with FPM BOPF Integration.
http://scn.sap.com/docs/DOC-45726
Enter T-code: FPM_WB to open the FPM Workbench and proceed with your application.
Create a Tabbed UIBB component.

Search for the Text Collection Config ID and add /BOFU/TEXT_COLLECTION_TAB.


Select the Wire Schema Tab and add a new wire with the below details.
Save and Test the application.

Testing the Delegate Node:


Entering the TRQ ID and click continue.

On the Next screen we see the Text Collection delegate node with the text content.
Thank you..
Alert Moderator

11 Comments

1. Shashank Shivasharan HonakeriDecember 12, 2014 at 7:12 am


Hi Mayur B,
This is working ,but i have trying with Address , is there any further settings for Address DO.
thanks.
Reply Like (0)

1. Matan TarantoDecember 14, 2014 at 10:46 am


Hi Shashank Shivasharan Honakeri,
For DO Address there are more configurations needed in SPRO, besides the regular configuration
of the DO in BOPF.
The configuration view can be found in transaction SPRO:
SAP reference IMG-> cross-application components-> process and tools for enterprise applications->
reusable objects and functions for BOBF environment-> dependent
object for address management.
BR,

Matan.
Reply Like (0)

1. Shashank Shivasharan HonakeriDecember 23, 2014 at 4:27 am


Thanks for reply Matan,
I have gone through
dependent object for address management in SPRO, but im not getting the proper setting to be
made there.
Reply Like (0)

1. Dhivya BaskaranDecember 23, 2014 at 4:33 am


Hi Shashank,
Please find the path flow below for reference.

Thanks,
Dhivya
Reply Like (0)
1. Shashank Shivasharan HonakeriDecember 23, 2014 at 6:33 am
Hi Divya, Thanks for the reply,

Im totally new to these concepts , will u be able to elaborate the settinhgs please.
Reply Like (0)

2. Shashank Shivasharan HonakeriDecember 29, 2014 at 8:12 am


Hi Matan,

I have made the settings by referring from a standard Object TEST_CUSTOMER.


But now its giving an error BO-inconsistency : Configuration not available!
and I cant be able to test it in test_ui
Reply Like (0)

1. Matan TarantoDecember 29, 2014 at 10:54 am


Hi,
You can use the TEST_CUSTOMER as a reference, but you should not copy and paste the same
configurations, as they are BO specific.
Reply Like (0)

1. Shashank Shivasharan HonakeriJanuary 6, 2015 at 4:55 am


Hi Matan,
Address in the business object TEST_CUSTOMER is not working properly.
In my object also there is same kind of problem.
Reply Like (0)

1. Matan TarantoJanuary 6, 2015 at 7:36 am


HI,

can you please decribe what you tryed to do that lead to the error?
in the address DO case, this usally happens if the BAS validations failed, and the address cannot
be saved.
that means that the address was not created properly.
BR,
Matan.
Reply Like (0)

1. Shashank Shivasharan HonakeriJanuary 12, 2015 at 4:41 am


Hi,
It is not accepting the the value of POSTAL_ADDRESS_ID or any of the values in the DO.
When i have tried to save, its giving this dump.
Reply Like (0)

2. rahhaoui mohamedJune 2, 2015 at 1:16 pm


Hi,

The class /scmtms/cl_common_helper doesnt exist.


Is it normal?

Regards,