Skip to Content
0
Former Member
May 04, 2010 at 09:31 AM

MKT_ELEMENT_CREATE gives Dump during creation of Campaign Element

52 Views

Hi,

I am trying to create campaign element through code and I am getting dump in the following class method.

Class : CL_CRM_MKTPL_OL_MKTPROJECT

Method : SET_ATTRIBUTES

Line No : 15 ->> lr_header_item->get_attributes( EXPORTING iv_get_external_attributes = abap_true

IMPORTING es_attributes = ls_header_attr ).

In above statement LR_HEADER_ITEM comes as Initial.

Below is the code for creating campaign element.


DATA: LR_TASK          TYPE REF TO CL_CGPL_TASK,
        LR_TASKS         TYPE REF TO CL_CGPL_TASKS,
        LR_PROJECT       TYPE REF TO CL_CGPL_PROJECT.

  DATA: WA_PROJECT  TYPE CGPL_PROJECT.
  DATA: WA_TASK     TYPE CGPL_TASK.
  DATA: LIT_TASKS   TYPE CGPLD_ITAB_TASK.

  DATA: WA_MESSAGE TYPE BAPIRET2.
  DATA: LIT_RETURN TYPE TABLE OF BAPIRETURN1.

  DATA: WA_CAMPAIGN TYPE CRM_MKTPL_CAMPAIGN,
        WA_ATTRIBUTES TYPE CRM_MKTPL_MKTELEMENT.

  DATA: LV_GUID TYPE SYSUUID-X."BAPI_MARKETINGELEMENT_GUID-MKTELEMENT_GUID.
  DATA: LV_CAMP_GUID TYPE BAPI_MARKETINGELEMENT_GUID-MKTELEMENT_GUID.

  CALL FUNCTION 'MKT_ELEMENT_READ'
    EXPORTING
      MARKETINGELEMENT = IV_SOURCE_GUID - THIS IS A IMPORT PARAMETER OF FUNCTION MODULE ( CAMPAIGN GUID ).
    IMPORTING
      EX_CAMPAIGN      = WA_CAMPAIGN
      EX_ATTRIBUTES    = WA_ATTRIBUTES.

  CONCATENATE WA_ATTRIBUTES-EXTERNAL_ID '_' SY-DATUM '_' SY-UZEIT INTO WA_ATTRIBUTES-EXTERNAL_ID.
  WA_ATTRIBUTES-OBJECT_TYPE = 'CPT'.

  CALL FUNCTION 'SYSTEM_UUID_CREATE'
    IMPORTING
      UUID = WA_ATTRIBUTES-GUID.

  LV_CAMP_GUID = WA_ATTRIBUTES-GUID.
  WA_ATTRIBUTES-PROJECT_GUID = IV_SOURCE_GUID.
  WA_ATTRIBUTES-PARENT_GUID = IV_SOURCE_GUID.

  CALL FUNCTION 'MKT_ELEMENT_CREATE'
    EXPORTING
      IM_MARKETINGELEMENT = LV_CAMP_GUID
      IM_ATTRIBUTES       = WA_ATTRIBUTES
    TABLES
      RETURN              = LIT_RETURN.

  IF LIT_RETURN[] IS INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        WAIT = 'X'.
  ENDIF.