SAP MDG: Derive the customer group2 based on change request type

sowmya surekha manukonda's photo
·

1 min read


Scenario:

ERP Customer: Sales Areas

Process:

Code:

METHOD if_ex_usmd_rule_service~derive_entity.

*****Derive the customer group2 based on change request type**********

DATA(lo_crtyp) = cl_fpm_factory=>get_instance( )->mo_app_parameter.

    CONSTANTS : lc_crkey  TYPE string VALUE 'CRTYPE'.

    DATA : lv_crtyp TYPE usmd_crequest_type.

    CALL METHOD lo_crtyp->get_value
      EXPORTING
        iv_key   = lc_crkey
      IMPORTING
        ev_value = lv_crtyp.

    IF  lv_crtyp = 'ZCUST1H1'.

      IF lines( ct_data ) EQ 1.
        LOOP AT ct_data ASSIGNING FIELD-SYMBOL(<fs_data>).

          ASSIGN COMPONENT 'KVGR2' OF STRUCTURE <fs_data> TO FIELD-SYMBOL(<fs_grp2>).
          IF <fs_grp2> IS ASSIGNED.

            <fs_grp2> = '01'.
          ENDIF.
        ENDLOOP.

      ENDIF.
    ENDIF.

    IF  lv_crtyp = 'ZCUST1S1'.

      IF lines( ct_data ) EQ 1.
        LOOP AT ct_data ASSIGNING FIELD-SYMBOL(<fs_cash>).

          ASSIGN COMPONENT 'KVGR2' OF STRUCTURE <fs_cash> TO FIELD-SYMBOL(<fs_cash_gr2>).
          IF <fs_cash_gr2> IS ASSIGNED.
            <fs_cash_gr2> = '02'.
          ENDIF.

        ENDLOOP.

      ENDIF.
    ENDIF.

ENDMETHOD.

Thank You :)