Skip to Content
author's profile photo Former Member
Former Member

Campaign Id in CRM Order Item

Hi All,

I am using BAPI 'BAPI_SLSTRANSACT_CREATEMULTI' to create a CRM Order from an external system. The requirement is to determine pricing based on the Campaign Id entered. When I fill the DOC_FLOW interface parameters the campaign id gets populated at the header but no corresponding campaign condition gets determined for the product even when I populate the linkage for the item in doc_flow.

I observed that when I go into the created order and manually add the Campaign Id at the item level, the pricing gets adjusted accordingly.

Please let me know what I am missing.

For the Header:

FORM doc_flow_create_bapi USING us_header_handle
                           P_ORDERHEADER STRUCTURE ZZCRMS_ORDERADM_H.

  DATA:
    lv_idx                TYPE i,
    l_campaign            TYPE CGPL_GUID16.               "Campaign GUID

  CHECK NOT P_ORDERHEADER-OFRCODE IS INITIAL.

  SELECT SINGLE PROJECT_GUID
         INTO l_campaign
         FROM CRMD_MKTPL_COUP
         WHERE OFRCODE = P_ORDERHEADER-OFRCODE.

  IF SY-SUBRC = 0.
    PERFORM get_handle_guid32 USING    us_header_handle
                              CHANGING ls_doc_flow-ref_handle
                                       ls_doc_flow-ref_guid.

    ls_doc_flow-OBJKEY_A  = l_campaign.
    ls_doc_flow-OBJTYPE_A = 'BUS2010020'.

    ls_doc_flow-OBJKEY_B  = ls_doc_flow-ref_guid.
    ls_doc_flow-OBJTYPE_B = 'BUS2000115'.
    ls_doc_flow-BREL_KIND = 'A'.
    ls_doc_flow-VONA_KIND = 'F'. "('A')
    ls_doc_flow-reltype   = 'VONA'.
    ls_doc_flow-BREL_MODE = 'A'.

    INSERT ls_doc_flow INTO TABLE lt_doc_flow.

    PERFORM get_handle_guid32 USING    us_header_handle
                              CHANGING ls_input_field-ref_handle
                                       ls_input_field-ref_guid.
    ls_input_field-ref_kind    = 'A'. "'C'
    ls_input_field-objectname  = gc_object_name-doc_flow.
    ls_input_field-logical_key = 'INS'.

    ls_input_field-fieldname = 'OBJKEY_A'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'OBJTYPE_A'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'OBJKEY_B'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'OBJTYPE_B'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'BREL_KIND'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'VONA_KIND'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'BREL_MODE'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'RELTYPE'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.


For the Item (while looping at the items):

FORM doc_flow_itm_bapi USING us_item_handle
                           P_ORDERHEADER STRUCTURE ZZCRMS_ORDERADM_H
                           P_ITEM        STRUCTURE ZZCRMS_ORDERADM_I.

  DATA:
    lv_idx                TYPE i,
    l_campaign            TYPE CGPL_GUID16.               "Campaign GUID

  CHECK NOT P_ORDERHEADER-OFRCODE IS INITIAL.

  SELECT SINGLE PROJECT_GUID
         INTO l_campaign
         FROM CRMD_MKTPL_COUP
         WHERE OFRCODE = P_ORDERHEADER-OFRCODE.

  IF SY-SUBRC = 0.
    PERFORM get_handle_guid32 USING    us_item_handle
                              CHANGING ls_doc_flow-ref_handle
                                       ls_doc_flow-ref_guid.

    ls_doc_flow-REF_KIND  = 'B'.
    ls_doc_flow-OBJKEY_A  = l_campaign.
    ls_doc_flow-OBJTYPE_A = 'BUS2010020'.

    ls_doc_flow-OBJKEY_B  = ls_doc_flow-ref_guid.
    ls_doc_flow-OBJTYPE_B = 'BUS2000115'.
    ls_doc_flow-BREL_KIND = 'D'.
    ls_doc_flow-VONA_KIND = 'F'. "('A')
    ls_doc_flow-reltype   = 'VONA'.
    ls_doc_flow-BREL_MODE = 'B'.

    INSERT ls_doc_flow INTO TABLE lt_doc_flow.

    PERFORM get_handle_guid32 USING    us_item_handle
                              CHANGING ls_input_field-ref_handle
                                       ls_input_field-ref_guid.
    ls_input_field-ref_kind    = 'B'.
    ls_input_field-objectname  = gc_object_name-doc_flow.
    ls_input_field-logical_key = 'INS'.

    ls_input_field-fieldname = 'OBJKEY_A'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'OBJTYPE_A'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'OBJKEY_B'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'OBJTYPE_B'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'BREL_KIND'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'VONA_KIND'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'BREL_MODE'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.
    ls_input_field-fieldname = 'RELTYPE'.
    INSERT ls_input_field  INTO TABLE  lt_input_fields.

  ENDIF.

Thanks in Advance

Shounak

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 23, 2011 at 06:49 PM

    All,

    I figured out the problem. In the DOC_FLOW tables parameter, I was passing VONA_KIND = 'F' ; it should not be filled with any values.

    Thanks

    Shounak

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.