Header Ads

CRM Sample code for mobile application


method IF_EX_CRM_ACT_MOB_SMARTPHONE~CRM_BADI_ACT_MOBILE_CHANGE.
*CT_ACTIVITY_H            Changing  Type  CRMS_ACTIVITY_MOBILE_H        Header Structure for Activity Management of  Mobile Apps
*CT_ACTIVITY_PARTNER      Changing  Type  CRMT_ACTIVITY_MOBILE_PARTNER  CRM Mobile: Activity Partners
*CT_ACTIVITY_NOTES        Changing  Type  CRMT_ACT_MOBILE_NOTES         CRM Mobile: Activity Notes
*CT_ACTIVITY_ATTACH       Changing  Type  CRMT_ACTIVITY_MOBILE_ATTACH   CRM Mobile: Activity Attachment
*CT_CE_ACTIVITY_H         Changing  Type  CRMS_MOBILE_CUST_ENHANCE_1O_T Crm Mobile: Oppt header enhancement
*CT_CE_ACTIVITY_PARTNER   Changing  Type  CRMS_MOBILE_CUST_ENHANCE_1O_T Crm Mobile: Partner Enhancement
*CT_CE_ACTIVITY_NOTES     Changing  Type  CRMS_MOBILE_CUST_ENHANCE_1O_T Crm Mobile: Enhancement note
*CT_CE_ACTIVITY_ATTACH    Changing  Type  CRMS_MOBILE_CUST_ENHANCE_1O_T Crm Mobile: Enhancement for attachments for oppt
*CT_RETURN                Changing  Type  CRMT_MOBILE_CUST_BAPIRET2     Crm Mobile: Return tabletype


  data :
    lt_input_fields      type CRMT_INPUT_FIELD_NAMES_TAB,
    lt_object_tab        type crmt_object_guid_tab.

  data:
    LS_CE_ACTIVITY_H     type CRMS_MOBILE_CUST_ENHANCE_1O,
    ls_activity_h_com    type CRMT_ACTIVITY_H_COM,
    ls_input_fields      type crmt_input_field_names.

data:
      lv_bool           type CRMT_BOOLEAN VALUE 'X'.

    clear ls_activity_h_com.
    ls_activity_h_com-ref_guid     = CT_ACTIVITY_H-object_guid.

** IC Project
    clear LS_CE_ACTIVITY_H.
    read table ct_CE_ACTIVITY_H into LS_CE_ACTIVITY_H with key FIELD_NAME = 'ZZFLD00000K'.
    ls_activity_h_com-zzfld00000k  = ls_ce_ACTIVITY_H-field_value .
** Sales Project
    clear LS_CE_ACTIVITY_H.
    read table Ct_ce_ACTIVITY_H into LS_CE_ACTIVITY_H with key FIELD_NAME = 'ZZFLD00000U'.
    ls_activity_h_com-zzfld00000u  = ls_ce_ACTIVITY_H-field_value .

    refresh lt_input_fields.
    clear ls_input_fields.
    ls_input_fields-fieldname  = 'ZZFLD00000K'.
    ls_input_fields-changeable = 'X'.
    ls_input_fields-inactive = ' '.
    append ls_input_fields to lt_input_fields.

    clear ls_input_fields.
    ls_input_fields-fieldname  = 'ZZFLD00000U'.
    ls_input_fields-changeable = 'X'.
    ls_input_fields-inactive = ' '.
    append ls_input_fields to lt_input_fields.
**
  call function 'CRM_ACTIVITY_H_CHANGE_OW'
    exporting
      IS_ACTIVITY_H_COM          = ls_activity_h_com
      IV_EXTERNAL_CALL           = lv_bool
    CHANGING
      CT_INPUT_FIELD_NAMES       = lt_input_fields
     EXCEPTIONS
       FILL_ERROR                 = 1
       PUT_ERROR                  = 2
       PUBLISH_ERROR              = 3
       READ_ERROR                 = 4
       OTHERS                     = 5.

*** No need double assignment as sample
    refresh lt_object_tab.
    append  ls_activity_h_com-ref_guid to lt_object_tab.
*
    call function 'CRM_ORDER_SAVE'
      exporting
        it_objects_to_save = lt_object_tab
      exceptions
        document_not_saved = 1
        others             = 2.
    if sy-subrc = 0.
    call function 'BAPI_TRANSACTION_COMMIT'
      exporting
        wait = 'X'.
    endif.

endmethod.
 
*****************************************************************************************88
  method IF_EX_CRM_ACT_MOB_SMARTPHONE~CRM_BADI_ACT_MOBILE_GETDETAIL.
  data :
    LT_HEADER       type CRMT_ACTIVITY_MOBILE_H,        "Entity Specific(Header)
    LT_CE_ACTV_HDR  type CRMS_MOBILE_CUST_ENHANCE_1O_T. "Entity Specific(Header Enhancement)

  data:
    LW_HEADER       type CRMS_ACTIVITY_MOBILE_H,     "Entity Specific(Header)
    LW_CE_ACTV_HDR  type CRMS_MOBILE_CUST_ENHANCE_1O,"Entity Specific(Header Enhancement)
    LW_ACTV_H_COM   type CRMT_ACTIVITY_H_COM.

  data:
    lv_raw_guid     type CRMT_OBJECT_GUID. "RAW(16)

  LT_HEADER[] = CT_ACTIVITY_H[].

  loop at LT_HEADER into LW_HEADER.

    clear lv_raw_guid.
    lv_raw_guid = LW_HEADER-OBJECT_GUID.
    call function 'CRM_ACTIVITY_H_READ_OB'
      exporting
        IV_GUID                       = Lv_raw_guid
      importing
        ES_ACTIVITY_H_COM             = LW_ACTV_H_COM
      exceptions
        PARAMETER_ERROR               = 1
        RECORD_NOT_FOUND              = 2
        AT_LEAST_ONE_RECORD_NOT_FOUND = 3
        others                        = 4.
    if SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      else.

    lw_ce_actv_hdr-OBJECT_GUID = LW_HEADER-OBJECT_GUID.
    lw_ce_actv_hdr-field_name = 'ZZFLD00000K'.
    lw_ce_actv_hdr-field_text = 'IC-Project'.
    lw_ce_actv_hdr-data_type = 'CHAR'.
    lw_ce_actv_hdr-data_length = '20'.
    lw_ce_actv_hdr-decimals = '0'.
    lw_ce_actv_hdr-field_value = LW_ACTV_H_COM-ZZFLD00000K.
    append lw_ce_actv_hdr to lt_ce_actv_hdr.
    clear lw_ce_actv_hdr.
*
        lw_ce_actv_hdr-OBJECT_GUID = LW_HEADER-OBJECT_GUID.
    lw_ce_actv_hdr-field_name = 'ZZFLD00000U'.
    lw_ce_actv_hdr-field_text = 'Sales-Project'.
    lw_ce_actv_hdr-data_type = 'CHAR'.
    lw_ce_actv_hdr-data_length = '20'.
    lw_ce_actv_hdr-decimals = '0'.
    lw_ce_actv_hdr-field_value = LW_ACTV_H_COM-ZZFLD00000U.
    append lw_ce_actv_hdr to lt_ce_actv_hdr.
    clear lw_ce_actv_hdr.
    endif.





  endloop.

  CT_CE_ACTIVITY_H[] = LT_CE_ACTV_HDR.
endmethod.
 
**********************************************************************************8
  method IF_EX_CRM_ACT_MOB_SMARTPHONE~CRM_BADI_ACT_MOBILE_CREATE.
*CT_ACTIVITY_H            Changing  Type  CRMS_ACTIVITY_MOBILE_H        Header Structure for Activity Management of  Mobile Apps
*CT_ACTIVITY_PARTNER      Changing  Type  CRMT_ACTIVITY_MOBILE_PARTNER  CRM Mobile: Activity Partners
*CT_ACTIVITY_NOTES        Changing  Type  CRMT_ACT_MOBILE_NOTES         CRM Mobile: Activity Notes
*CT_ACTIVITY_ATTACH       Changing  Type  CRMT_ACTIVITY_MOBILE_ATTACH   CRM Mobile: Activity Attachment
*CT_CE_ACTIVITY_H         Changing  Type  CRMS_MOBILE_CUST_ENHANCE_1O_T Crm Mobile: Oppt header enhancement
*CT_CE_ACTIVITY_PARTNER   Changing  Type  CRMS_MOBILE_CUST_ENHANCE_1O_T Crm Mobile: Partner Enhancement
*CT_CE_ACTIVITY_NOTES     Changing  Type  CRMS_MOBILE_CUST_ENHANCE_1O_T Crm Mobile: Enhancement note
*CT_CE_ACTIVITY_ATTACH    Changing  Type  CRMS_MOBILE_CUST_ENHANCE_1O_T Crm Mobile: Enhancement for attachments for oppt
*CT_RETURN                Changing  Type  CRMT_MOBILE_CUST_BAPIRET2     Crm Mobile: Return tabletype

  data :
    lt_input_fields      type CRMT_INPUT_FIELD_NAMES_TAB,
    lt_object_tab        type crmt_object_guid_tab.

  data:
    LS_CE_ACTIVITY_H     type CRMS_MOBILE_CUST_ENHANCE_1O,
    ls_activity_h_com    type CRMT_ACTIVITY_H_COM,
    ls_input_fields      type crmt_input_field_names.

data:
      lv_bool           type CRMT_BOOLEAN VALUE 'X'.

    clear ls_activity_h_com.
    ls_activity_h_com-ref_guid     = CT_ACTIVITY_H-object_guid.

** IC Project
    clear LS_CE_ACTIVITY_H.
    read table ct_CE_ACTIVITY_H into LS_CE_ACTIVITY_H with key FIELD_NAME = 'ZZFLD00000K'.
    ls_activity_h_com-zzfld00000k  = ls_ce_ACTIVITY_H-field_value .
** Sales Project
    clear LS_CE_ACTIVITY_H.
    read table Ct_ce_ACTIVITY_H into LS_CE_ACTIVITY_H with key FIELD_NAME = 'ZZFLD00000U'.
    ls_activity_h_com-zzfld00000u  = ls_ce_ACTIVITY_H-field_value .

    refresh lt_input_fields.
    clear ls_input_fields.
    ls_input_fields-fieldname  = 'ZZFLD00000K'.
    ls_input_fields-changeable = 'X'.
    ls_input_fields-inactive = ' '.
    append ls_input_fields to lt_input_fields.

    clear ls_input_fields.
    ls_input_fields-fieldname  = 'ZZFLD00000U'.
    ls_input_fields-changeable = 'X'.
    ls_input_fields-inactive = ' '.
    append ls_input_fields to lt_input_fields.
**
  call function 'CRM_ACTIVITY_H_CHANGE_OW'
    exporting
      IS_ACTIVITY_H_COM          = ls_activity_h_com
      IV_EXTERNAL_CALL           = lv_bool
    CHANGING
      CT_INPUT_FIELD_NAMES       = lt_input_fields
     EXCEPTIONS
       FILL_ERROR                 = 1
       PUT_ERROR                  = 2
       PUBLISH_ERROR              = 3
       READ_ERROR                 = 4
       OTHERS                     = 5.

*** No need double assignment as sample
    refresh lt_object_tab.
    append  ls_activity_h_com-ref_guid to lt_object_tab.
*
    call function 'CRM_ORDER_SAVE'
      exporting
        it_objects_to_save = lt_object_tab
      exceptions
        document_not_saved = 1
        others             = 2.
    if sy-subrc = 0.
    call function 'BAPI_TRANSACTION_COMMIT'
      exporting
        wait = 'X'.
    endif.
ENDMETHOD.
Powered by Blogger.