You are on page 1of 13

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:

Adding new text types in SAP CRM By Arunmozhivarman Viswanathan, Kaar Technologies This document will explain

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

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

STEP 3:

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

STEP 3: Now the GenIL layer will show the newly added text types:
STEP 4: Click on dependent object ‘BTTextH’: The text type ‘ztm8’ will show up in the

STEP 4:

Click on dependent object ‘BTTextH’:

STEP 4: Click on dependent object ‘BTTextH’: The text type ‘ztm8’ will show up in the

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

STEP 5: Now we need to include the newly added text type as a context node
STEP 5: Now we need to include the newly added text type as a context node

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.

Click on the below view ‘SRQM_INCIDENT_H/IncidentHeaderEF’. STEP 6: Go to the context node:

Click on the below view ‘SRQM_INCIDENT_H/IncidentHeaderEF’.

Click on the below view ‘SRQM_INCIDENT_H/IncidentHeaderEF’. STEP 6: Go to the context node:

STEP 6:

Go to the context node:

STEP 7: Right click on context node and click ‘create’. A pop-up window generates for creating

STEP 7:

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

STEP 7: Right click on context node and click ‘create’. A pop-up window generates for creating

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.

STEP 8: Specify the name of the text type and model node as ‘BTText’ in the
STEP 9: The new node added will be shown as below in the “CONTEXT NODES” STEP

STEP 9:

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

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

STEP 10:

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

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

STEP 11:

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

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.

Click on the detail view of the on_new_focus and make it as an event handler by

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

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.

lv_collection

TYPE REF TO if_bol_bo_col,

* Field Symbols

 
FIELD-SYMBOLS: <fs_alltext> TYPE comt_text_cust_struc1_rec.

FIELD-SYMBOLS:

<fs_alltext>

  • TYPE

comt_text_cust_struc1_rec.

*

get collection of dependent nodes

entity ?= TRY. focus_bo.

entity ?=

entity ?= TRY. focus_bo.

TRY.

focus_bo.

 
CALL
CALL

METHOD

RECEIVING

=

rv_result

entity->get_root

 
 

lr_root.

CALL
CALL

METHOD

EXPORTING

iv_attr_name

IMPORTING

ev_result

=
=

lr_root->if_bol_bo_property_access~get_property_as_value

=

'CRM_GUID'

 
 

lv_guid.

* check if the text type is allowed

  • cx_crm_genil_model_error.

CALL

FUNCTION

EXPORTING

iv_header_guid

IMPORTING

et_text_cust

=
=

CATCH

EXIT.

.
.

CATCH

ENDTRY

 

READ

TABLE

*

should never happen

  • lt_alltext

= lv_guid

lt_alltext.

  • cx_sy_ref_is_initial.

'CRM_DNO_READ_ORDER_TEXT'

WITH KEY textid = 'ZTM8' ASSIGNING <fs_alltext>.

IF sy-subrc EQ 0. TRY. lv_collection =
IF sy-subrc
EQ
0.
TRY.
lv_collection
=

entity->get_related_entities(

 

iv_relation_name

=

'BTTextH_ZTM8'

).

NOT

BOUND OR ) =
BOUND
OR
)
=

lv_collection->size(

) = 0.
)
=
0.
IF lv_collection IS TRY. entity = CATCH
IF lv_collection
IS
TRY.
entity
=
CATCH

IF entity->is_changeable(

abap_true.

entity->create_related_entity(

=

IF lv_collection IS TRY. entity = CATCH IF entity->is_changeable( abap_true. entity->create_related_entity( = 'BTTextH_ZTM8' ). iv_relation_name cx_crm_genil_model_error

'BTTextH_ZTM8'

).

iv_relation_name

cx_crm_genil_model_error

cx_crm_genil_duplicate_rel.

*

should never happen

ENDTRY.

IF

ENDTRY. IF entity IS BOUND. CREATE OBJECT lv_collection entity ). lv_collection->add(

entity

IS BOUND.

CREATE

OBJECT

lv_collection

entity

).

lv_collection->add(

 

TYPE

cl_crm_bol_bo_col.

ENDIF.

ENDIF. ENDIF. ENDIF.

ENDIF.

ENDIF.

CATCH cx_crm_genil_model_error.

CATCH

cx_crm_genil_model_error.

*

should never happen

EXIT.

. CATCH cx_sy_ref_is_initial. ENDTRY
.
.

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.

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

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.
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( ).
METHOD ‘CREATE_CONTEXT_NODES’.
CREATE_ZTEXTSUCCESSFACTOR( ).

STEP 15:

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

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

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: