Professional Documents
Culture Documents
Here we will be creating a Z BOL object. In the second part we will use this Z BOL object in our Web component.
Step 1: Create a Ztable with the following fields. You can also structure the table as desired by you but the only prerequisite is - The
user-defined database table should contain a key field with the GUID name and the GUID data type.
CL_CRM_GENIL_GEN_TABLE_OBJ
Step 4: Define Search object definition. This is very important because using this, we will fill the data in the BOL object.
CRMV_TBLOBJ_MAP
Step 6: Click New entries and do the mapping between the object and the table which we have created. Basically maintain the
entries as shown in the screenshot.
Step 7: Simple GenIL objects are assigned to the SO2 component set automatically. Open tcode GENIL_BOL_BROWSER. Enter
field Component Set with SO2 and Click on Execute. Click the button "New Root Object" as shown in the screenshot. In the left
hand side of the screen you will see the BOL object which we have created. Double click it.
Step 8: Click the button "Create Object". The GUID will be automatically created. Enter the other field details and choose the SAVE
button to save the entries.
Step 9: In Tcode Se16 you will be able to see the following entries.
Step 10: Open tcode GENIL_BOL_BROWSER, enter field Component with SO2. Click the button "New Search" as shown in the
screenshot.
Step 11: Enter object ID and click the button find.
Step 12: If the other entries get populated as shown in the screenshot means our BOL object is working fine.
Next we will be using this in our web component. That I will be writing in next step.
02- How to use your custom BOL Object for webclient within assignment block.
In our case we will choose the Delete data option becuse we want to create a new record, you also have to know that if you choose
the Save data option there's no 100 percent guarantee that your data in the table will be saved , so you should consider the use of
Database Utility very careful.
After we perform the adjustment and activated the table we can step forward to the next step which is the creation of a new record
with the details that we want to display on the screen .
First to the record creation we should find the key which is the BP_GUID that will connect us to the account context .
To find the right BP_GUID enter transaction GENIL_BOL_BROWSER and insert the BP_APPL_COND in the component set field.
See the following screen shot.
when you enter to the component set choose the predefined search
named BuilEmpSearch
See the following screen shot.
Now we can look for any partner , in my case i'll choose to search my user and i'll get the compatible BP_GUID which is :
DF21EBC73A26F8F1A2B0001F29644FC0
See the following screen shot.
Now let's create a new record in the DataBase table ZUSR_BOL_TB with user name, BP_GUID , First and last names.
See the following screen shot.
For now we finish with the database side and we wiil go to perform some improvement in our BOL object to support the different
searching options.
So let's go to transaction SE24 and put ZCL_OWN_BOL in the input filed.
click on Local Types button and put the lines inside :
*-------------------------------------------------------------
TYPES: BEGIN OF ty_general_rng ,
sign TYPE bapisign,
option TYPE bapioption,
low TYPE string ,
high TYPE string ,
END OF ty_general_rng .
TYPES:
tt_general_rng TYPE STANDARD TABLE OF ty_general_rng .
See the following screen shot:
We can see now that the component BP_HEAD use the Model BP_APPL_COND and we want that our BOL object will appear in
the repository of the BP_HEAD component so that we can use it for our purpose.
To do that we need to go to the component set definition.
See the following screen shot.
Now choose the appropriate component set which is in our case BP_APPL_COND.
See the following screen shot.
Now click on component assignment make new entry and add our BOL object named ZBOLOB.
See the following screen shot.
After we named the view we need to add 2 model nodes, one for BuilHeader and
one For our Root BOL object.
The first one is for getting the relevant BP_GUID from the custom controller and get the appropriate first name last name and user
name according to our table .
See the following screen shot.
The next step is to add the fields that we might use in our view to context which we working on.
We start with the BuilHeader fields.
See the following screen shot.
Now we finish the view addition with the wizard we will see that our view is listed with the other views in the component.
See the following screen shot.
After we added the view we should create a binding to the custom controller context node BUILHEADER.
So we put the mouse curser on the context node BUILHEADER pressing the right mouse
Click and create the binding.
See the following screen shot.
We will create the binding for our context node to the same context node in the custom controller.
See the following screen shot.
After we create the appropriate binding we need to add the attributes to the view.
So we move to the configuration tab when we working on the view and then we switch to edit mode.
We see that we have the 2 BOL objects that we added when we working with the wizard in time of the view creation.
In our case we will add the attributes from the Root BOL object.
See the following screen shot.
After we add the attributes to our view we need to add our view as an assignment block.
First we need to add our view to the BPHEADOverview viewset , to do this we will go to the
Runtime Repository Editor and we will add our view to the OverviewPage of BPHEADOverview viewset .
See the following screen shot.
After we added the view to the BPHEADOverview viewset we will go to the configuration tab of BPHEADOverview viewset and
switch to edit mode and add our view TestBOLroot to the list of views that appears as an assignment
blocks in the BPHEADOverview viewset by click on the arrow button and moving it from the left side to the right side .
See the following screen shot.
After we handle the addition of adding our view as an assignment block we need to handle some code addtions for the right
treatment in the attributes in our view .
First we will go to the ROOT context node within our view and redefine
the method IF_BSP_MODEL~INIT.
See the following screen shot.
Put the next ilnes into the method save and aactivate the method.
*-------------------------------------------------------------------------------------------
method IF_BSP_MODEL~INIT.
TYPES: BEGIN OF ltype_attr_struct,
mandt TYPE mandt,
bp_guid TYPE bu_partner_guid,
bname TYPE xubname,
name_last TYPE bu_namep_l,
name_first TYPE bu_namep_f,
END OF ltype_attr_struct.
DATA: lrf_data_struct TYPE REF TO ltype_attr_struct,
lrf_value_node TYPE REF TO cl_bsp_wd_value_node,
lrf_bol_collection TYPE REF TO if_bol_bo_col.
super->if_bsp_model~init( id = id owner = owner ).
CREATE DATA lrf_data_struct.
CREATE OBJECT lrf_value_node
EXPORTING
iv_data_ref = lrf_data_struct.
CREATE OBJECT lrf_bol_collection TYPE cl_crm_bol_bo_col.
lrf_bol_collection->add( lrf_value_node ).
me->set_collection( lrf_bol_collection ).
endmethod.
*-------------------------------------------------------------------------------------------
After we add the above lines to the method we will go to the implementation class of our view, which is in our case is
ZL_ZBP_HEAD_TESTBOLROOT_IMPL.
we will double click on the class name and we will move to display mode of the class in a way that all the method could be shown.
The first thing to do is to write our own method for performing the right query when we need to display the attributes on the screen .
After that we will redefine the method DO_PREPARE_OUTPUT.
so let's create a new method named root_query which is an Instance Method , and the visibility of it is Private.
put the next lines to the method .
*------------------------------------------------------------------------------------------
METHOD root_query.
DATA: lrf_advanced_query TYPE REF TO cl_crm_bol_dquery_service,
lrf_root_result_collection TYPE REF TO if_bol_entity_col,
lrf_root_result_bol_entity TYPE REF TO cl_crm_bol_entity,
lrf_current_root TYPE REF TO if_bol_bo_property_access,
lrf_current_builheader TYPE REF TO if_bol_bo_property_access,
lt_params TYPE crmt_name_value_pair_tab,
ls_params TYPE crmt_name_value_pair,
ls_builheader_properties TYPE crmst_header_object_buil,
lv_low_value TYPE string ,
ls_root_properties TYPE zusr_bol_st.
ls_params-name = 'MAX_HITS' .
ls_params-value = '1'. "we don't need in this case more the single record for result
APPEND ls_params TO lt_params.
lrf_current_root ?= me->typed_context->root->collection_wrapper->get_current( ).
CHECK lrf_current_root IS BOUND .
lrf_current_root->get_properties( IMPORTING es_attributes = ls_root_properties ).
CHECK ls_root_properties IS INITIAL .
" means that we don't have any values in our
"fields and therfore wi'll excute the query
lrf_current_builheader ?=
me->typed_context->builheader->collection_wrapper->get_current( ).
CHECK lrf_current_builheader IS BOUND .
lrf_current_builheader->get_properties( IMPORTING es_attributes = ls_builheader_properties ).
CHECK ls_builheader_properties-bp_guid IS NOT INITIAL .
lv_low_value = ls_builheader_properties-bp_guid.
lrf_advanced_query = cl_crm_bol_dquery_service=>get_instance( 'Search' ).
lrf_advanced_query->set_query_parameters( it_parameters = lt_params ).
lrf_advanced_query->add_selection_param( iv_attr_name = 'BP_GUID'
iv_sign = 'I'
iv_option = 'EQ'
iv_low = lv_low_value
iv_high = '' ).
lrf_root_result_collection = lrf_advanced_query->get_query_result( ).
IF lrf_root_result_collection IS BOUND . "if we found something that match our selection
lrf_root_result_bol_entity = lrf_root_result_collection->get_first( ).
lrf_root_result_bol_entity->get_properties( IMPORTING es_attributes = ls_root_properties ).
lrf_current_root->set_properties( is_attributes = ls_root_properties ).
ENDIF.
ENDMETHOD.
*----------------------------------------------------------------------------------------
Save and activate your code .
the next step is to redefine the method DO_PREPARE_OUTPUT.
put the next lines into the method .
*----------------------------------------------------------------------------------------
method DO_PREPARE_OUTPUT.
CALL METHOD SUPER->DO_PREPARE_OUTPUT
EXPORTING
iv_first_time = iv_first_time.
me->ROOT_QUERY( ).
endmethod.
*----------------------------------------------------------------------------------------
save and activate your code .
Now all job is done our BOL object is wroking like a Rolls-Royce and it's time to derive pleasure from .
We will go to the webclient , choose our account and display it .
we can see that we have our attributes shown on the screen .
See the following screen shot.