Header Ads

To Find Child entity using BOL Programming


To Find Child entity using BOL Programming

This wiki help you to find out child entity's of Root object .
These are the following steps to Find out child entity's 
we can run this in ABAP editor in debug mode to check the process
1) Data Declaration 
2) Get the BOL Core Instance 
3) Load the Component set
4) Create Query Instance 
5) Pass the relationship name to get child entity 
6) Get the Parent Entity 
7) Get attributes from child entity 
1) Data Declaration 
*BOL Declarations
data: lr_core type ref to cl_crm_bol_core,
      lr_query type ref to CL_CRM_BOL_QUERY_SERVICE,
      LR_RESULT TYPE REF TO IF_BOL_ENTITY_COL,
      LR_ENTITY TYPE REF TO cl_crm_bol_entity,
      lr_children type ref to IF_BOL_ENTITY_COL,
      lr_child type ref to cl_crm_bol_entity,
      lr_parent type ref to cl_crm_bol_entity,
      LV_STRING TYPE STRING.
 * BOL Declarations
data:  LR_CORE  type ref to cl_crm_bol_core,
          LR_QUERY type ref to CL_CRM_BOL_QUERY_SERVICE,
          LR_RESULT TYPE REF TO IF_BOL_ENTITY_COL,
          LR_ENTITY TYPE REF TO CL_CRM_BOL_ENTITY,
          LR_CHILDREN  TYPE ref to IF_BOL_ENTITY_COL,
          LR_CHILD        TYPE ref to CL_CRM_BOL_ENTITY,
          LR_PARENT TYPE ref to cl_crm_bol_entity.
Data  : IT_PARMS TYPE CRMT_NAME_VALUE_PAIR_TAB,
             WA_PARMS TYPE CRMT_NAME_VALUE_PAIR.
types : begin of ty_tab,
           value1 type string,value2 type string,value3 type string,
end of ty_tab.
data : itab type table of ty_tab with header line.
2) Get the BOL Core Instance 
         LR_CORE = cl_Crm_bol_core=>get_instance( ).
3)  Load the Component set
LR_CORE->LOAD_COMPONENT_SET( 'BP_APPL' ).
4) Create Query Instance by passing search object name  
lr_query = CL_CRM_BOL_QUERY_SERVICE=>get_instance(
                  iv_query_name = 'BuilHeaderSearch' ).
WA_PARMS-NAME = 'PARTNER'.
WA_PARMS-VALUE = '404050'.
Append WA_PARMS to IT_PARMS.
*Add the selection parameters
CALL METHOD LR_QUERY->SET_QUERY_PARAMETERS
   EXPORTING
     IT_PARAMETERS = IT_PARMS.
*Get the result list
LR_RESULT = LR_QUERY->GET_QUERY_RESULT( ).
*Get the first object(entity) in the result list
LR_ENTITY ?= LR_RESULT->GET_FIRST( ).
*If the entity is bound
WHILE LR_ENTITY IS BOUND.
5)  Get the related entities by mentioning the relation ship name
lr_children ?= lr_entity->get_related_entities(
           iv_relation_name = 'BuilSalesArrangementRel' ).
*If there are related entities available
if lr_children is bound.
*Process the entities - one by one
lr_child ?= lr_children->get_first( ).
while lr_child is bound.
6 ) Get the parent entity
lr_parent ?= lr_child->Get_parent( ).
*Process the parent entity for the required data
itab-value1 = LR_parent->GET_PROPERTY_AS_STRING( 'BP_NUMBER' ).
*Get the attributes of the child entity
7) Get attributes from child entity 
itab-value2 = LR_child->GET_PROPERTY_AS_STRING( 'SALES_ORG' ).
itab-value3 = LR_child->GET_PROPERTY_AS_STRING( 'SALES_ORG_TEXT' ).
Append itab.
lr_child ?= lr_children->get_next( ).
endwhile.
endif.
*Go to the next entity
LR_ENTITY ?= LR_RESULT->GET_NEXT( ).
ENDWHILE.
* output
loop at lt_tab .
write :/  lt_tab-value1,lt_tab-value2,lt_tab-value3.
endloop.

Powered by Blogger.