Adding new text types in SAP CRM

...Previous

STEP 13:

Go to the parameters of the method ‘ON_NEW_FOCUS’ and include the below one.

Save and activate the new changes made above:

Click on the method and add this code to implement the event handler that tirggers the addition of text type ‘ZTM8’ in the context node whenever the ui component is triggered. Activate it.

DATA  lv_collection TYPE REF TO if_bol_bo_col,
        entity        
TYPE REF TO cl_crm_bol_entity,
        lr_root       
TYPE REF TO cl_crm_bol_entity,
        lv_guid       
TYPE crmt_object_guid,
        lt_alltext    
TYPE comt_text_cust_struc1_tab.

* Field Symbols
  
FIELD-SYMBOLS: <fs_alltext>  TYPE comt_text_cust_struc1_rec.

*   get collection of dependent nodes
  entity ?= focus_bo.
  
TRY.

      
CALL METHOD entity->get_root
        RECEIVING
          rv_result = lr_root.


      
CALL METHOD lr_root->if_bol_bo_property_access~get_property_as_value
        
EXPORTING
          iv_attr_name = 
'CRM_GUID'
        
IMPORTING
          ev_result    = lv_guid.

* check if the text type is allowed
      
CALL FUNCTION 'CRM_DNO_READ_ORDER_TEXT'
        
EXPORTING
          iv_header_guid = lv_guid
        
IMPORTING
          et_text_cust   = lt_alltext.
    
CATCH cx_crm_genil_model_error.
*       should never happen
      
EXIT.
    
CATCH cx_sy_ref_is_initial.
  
ENDTRY.

  
READ TABLE lt_alltext WITH KEY textid = 'ZTM8' ASSIGNING <fs_alltext>.

  
IF sy-subrc EQ 0.
    
TRY.
        lv_collection = entity->get_related_entities(
               iv_relation_name = 
'BTTextH_ZTM8' ).

        
IF lv_collection IS NOT BOUND OR lv_collection->size( ) = 0.
          
IF entity->is_changeable( ) = abap_true.
            
TRY.
                entity = entity->create_related_entity(
                 iv_relation_name = 
'BTTextH_ZTM8' ).
              
CATCH cx_crm_genil_model_error cx_crm_genil_duplicate_rel.
*               should never happen
            
ENDTRY.
            
IF entity IS BOUND.
              
CREATE OBJECT lv_collection TYPE cl_crm_bol_bo_col.
              lv_collection->add( entity ).
            
ENDIF.
          
ENDIF.
        
ENDIF.

      
CATCH cx_crm_genil_model_error.
*       should never happen
        
EXIT.
      
CATCH cx_sy_ref_is_initial.
    
ENDTRY.

  
ENDIF.
  me->set_collection( lv_collection ).

STEP 14:

Go to the attribute ‘STRUCT.CONC_LINES’ in the node of ‘ZTEXTSUCCESSFACTOR’ and generate the GETTER, SETTER, P_GETTER METHODS. Double click on the P_GETTER method and implement it by including the below code which defines the property of the attribute as a dropdown, textarea, etc. And activate it.

METHOD GET_P_CONC_LINES.

CASE iv_property.
    
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
      rv_value = cl_bsp_dlc_view_descriptor=>field_type_textarea.

ENDCASE.

Goto the implementation class of the context nodes and include the below code in the method ‘CREATE_CONTEXT_NODES’ which holds the context nodes in the component’s view.

 

METHOD ‘CREATE_CONTEXT_NODES’.

  CREATE_ZTEXTSUCCESSFACTOR( ).

STEP 15:

Now implement the above method by including the below piece of code.  

STEP 16:

Now include the text area in the view by adding the view configuration and launch your service. Now the text area looks as below:


Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image