Adding New Text Types in SAP CRM

15
Adding new text types in SAP CRM By Arunmozhivarman Viswanathan, Kaar Technologies This document will explain in detail about creating text types in SAP CRM by means of extending the business transaction with new relations in the SPRO and enhancing the standard service component SRQM_INCIDENT_H to include the new text type added. STEP 1: Click on extending relations in the transaction SPRO in CRM: STEP 2: Click on the new entries and add the text type as below with the necessary details and save it. This will prompt you for a ‘workbench request’.

description

Adding New Text Types in SAP CRM

Transcript of Adding New Text Types in SAP CRM

Page 1: Adding New Text Types in SAP CRM

Adding new text types in SAP CRM

By Arunmozhivarman Viswanathan, Kaar Technologies

This document will explain in detail about creating text types in SAP CRM by means of extending the business transaction with new relations in the SPRO and enhancing the standard service component SRQM_INCIDENT_H to include the new text type added.

STEP 1:

Click on extending relations in the transaction SPRO in CRM:

STEP 2:

Click on the new entries and add the text type as below with the necessary details and save it. This will prompt you for a ‘workbench request’.

Page 2: Adding New Text Types in SAP CRM

STEP 3:

Now the GenIL layer will show the newly added text types:

Page 3: Adding New Text Types in SAP CRM

STEP 4:

Click on dependent object ‘BTTextH’:

The text type ‘ztm8’ will show up in the aggregation part:

Page 4: Adding New Text Types in SAP CRM

STEP 5:

Now we need to include the newly added text type as a context node in the standard service component ‘SRQM_INCIDENT_H’.

Go to the component workbench with the above component and enhancement set.

Page 5: Adding New Text Types in SAP CRM

Click on the below view ‘SRQM_INCIDENT_H/IncidentHeaderEF’.

STEP 6:

Go to the context node:

Page 6: Adding New Text Types in SAP CRM

STEP 7:

Right click on context node and click ‘create’. A pop-up window generates for creating the context nodes.

Page 7: Adding New Text Types in SAP CRM

STEP 8:

Specify the name of the text type and model node as ‘BTText’ in the ‘DEFINE CONTEXT NODE’ option and proceed till complete and finish the process of creating a context node for the text type.

Page 8: Adding New Text Types in SAP CRM

STEP 9:

The new node added will be shown as below in the “CONTEXT NODES”

STEP 10:

Now click on the implementation class of the newly context node added:

STEP 11:

Add the method ‘ON_NEW_FOCUS’ which is an event handler that triggers the context node ‘ZTEXTSUCCESSFACTORE’ of text type ‘ZTM8’.

STEP 12:

Page 9: Adding New Text Types in SAP CRM

Click on the detail view of the on_new_focus and make it as an event handler by including the below standard class ‘CL_BSP_WD_COLLLECTION_WRAPPER’ and method ‘NEW_FOCUS’. Tick the option ‘EVENT HANDLER FOR’ AND SAVE IT.

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:

Page 10: Adding New Text Types in SAP CRM

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>.

Page 11: Adding New Text Types in SAP CRM

  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.

Page 12: Adding New Text Types in SAP CRM

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:

Page 13: Adding New Text Types in SAP CRM