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

How to create ST using BAPI_SLSTRANSACT_CREATEMULTI

Hi Friends,

I'm trying to create NEW SalesTransaction(ST) using fm 'BAPI_SLSTRANSACT_CREATEMULTI' in an another new RFC function module. The header is creating but not Partner,Item,product and all. I need to create ST using this BAPI.

The input i'm passing is partner,pro`duct,product description,net price,net value,quantity,PO number,Order number,Quantity,ATP quntity,Date,Address including email and phone.

The problem i'm facing is <b>HOW TO FILL THESE INPUT VALUES IN THE EXACT FILEDS IN THE TABLES OF BAPI.</b>

I'm getting these errors.

<b>1)W CRM_ORDER 004 Referenced object type (PARTNER) not allowed

2)W CRM_ORDER 004 Referenced object type (SALES) not allowed

3)E CRM_ORDERADM_I 006 Item was not found.

4)E CRM_ORDER 005 Incomplete interface data - No reference specified

5)S CRM_MESSAGES 005 A log has been generated for single document </b>

The code i did is:

  TYPES: TYP_HEADER          TYPE BAPIBUS20001_HEADER_INS,
         TYP_ITEM            TYPE BAPIBUS20001_ITEM,
         TYP_SALES           TYPE BAPIBUS20001_SALES,
         TYP_PARTNER         TYPE BAPIBUS20001_PARTNER_INS,
         TYP_SCHEDULELINE    TYPE BAPIBUS20001_SCHEDLIN,
         TYP_CREATED_PROCESS TYPE BAPIBUS20001_HEADER_INS,
         TYP_SAVED_PROCESS   TYPE BAPIBUS20001_OBJECT_ID,
         TYP_INPUT_FIELDS    TYPE BAPIBUS20001_INPUT_FIELDS.

  DATA: IT_HEADER            TYPE TYP_HEADER OCCURS 10
                                  WITH HEADER LINE,
        IT_ITEM              TYPE TYP_ITEM OCCURS 10
                                  WITH HEADER LINE,
        IT_SALES             TYPE TYP_SALES OCCURS 10
                                  WITH HEADER LINE,
        IT_PARTNER           TYPE TYP_PARTNER OCCURS 10
                                  WITH HEADER LINE,
        IT_SCHEDULELINE      TYPE TYP_SCHEDULELINE OCCURS 10
                                  WITH HEADER LINE,
        IT_CREATED_PROCESS   TYPE TYP_CREATED_PROCESS OCCURS 10
                                  WITH HEADER LINE,
        IT_SAVED_PROCESS     TYPE TYP_SAVED_PROCESS OCCURS 10
                                  WITH HEADER LINE,
        IT_INPUT_FIELDS      TYPE TYP_INPUT_FIELDS OCCURS 10
                                  WITH HEADER LINE,
        V_ORDER_DATE(15)     TYPE C,
        V_GUID_H             TYPE BBP_GUID_32,
        V_GUID_I             TYPE BBP_GUID_32,
        V_GUID_P             TYPE BBP_GUID_32,
        V_GUID_SA            TYPE BBP_GUID_32,
        V_GUID_SC            TYPE BBP_GUID_32.

  PERFORM GET_GUID CHANGING V_GUID_H.
  PERFORM GET_GUID CHANGING V_GUID_I.
  PERFORM GET_GUID CHANGING V_GUID_P.  
  PERFORM GET_GUID CHANGING V_GUID_SA.
  PERFORM GET_GUID CHANGING V_GUID_SC.

* Header
  IT_HEADER-GUID 	 = V_GUID_H.
  IT_HEADER-PROCESS_TYPE = PROCESS_TYPE(INPUT).
  IT_HEADER-DESCRIPTION  = DESCRIPTION(INPUT).
  APPEND IT_HEADER.

* Item
  IT_ITEM-GUID = V_GUID_I.
  IT_ITEM-HEADER = V_GUID_H.
  IT_ITEM-ORDERED_PROD = PRODUCT(INPUT).
  IT_ITEM-DESCRIPTION  = PRODUCT_DESCRIPTION(INPUT).
  IT_ITEM-ITM_TYPE     = ITEM_TYPE(INPUT).
  IT_ITEM-MODE         = 'A'.
  APPEND IT_ITEM.

* Sales
  IT_SALES-REF_GUID = V_GUID_SA.
  IT_SALES-PO_NUMBER_SOLD = PO_NUMBER(INPUT).
  APPEND IT_SALES.

* Partner
  IT_PARTNER-REF_GUID    = V_GUID_H.
  IT_PARTNER-PARTNER_FCT = '00000001'.
  IT_PARTNER-REF_KIND    = 'A'.
  IT_PARTNER-REF_PARTNER_HANDLE = '0001'.
  IT_PARTNER-KIND_OF_ENTRY = 'A'.
  IT_PARTNER-NO_TYPE     = 'BP'.
  IT_PARTNER-DISPLAY_TYPE = 'BP'.
  IT_PARTNER-PARTNER_NO  = CUSTOMER(INPUT).
  IT_PARTNER-NAME        = NAME(INPUT).
  IT_PARTNER-HOUSE_NO    = HOUSE_NO(INPUT).
  IT_PARTNER-CITY        = CITY(INPUT).
  IT_PARTNER-STREET      = STREET(INPUT).
  IT_PARTNER-COUNTRY     = COUNTRY(INPUT).
  IT_PARTNER-E_MAIL      = EMAIL(INPUT).
  IT_PARTNER-TEL1_NUMBR  = PHONE(INPUT).
  APPEND IT_PARTNER.

* Schedule line
  IT_SCHEDULELINE-ITEM_GUID = V_GUID_SC.
  IT_SCHEDULELINE-QUANTITY = ATP_QUANTITY(INPUT).
  APPEND IT_SCHEDULELINE.

* Input fields
  IT_INPUT_FIELDS-REF_GUID    = V_GUID_H.
  IT_INPUT_FIELDS-OBJECTNAME  = 'ORDERADM_H'.
  IT_INPUT_FIELDS-LOGICAL_KEY = '1'.
  APPEND IT_INPUT_FIELDS.
*
  IT_INPUT_FIELDS-REF_GUID    = V_GUID_I.
  IT_INPUT_FIELDS-OBJECTNAME  = 'ORDERADM_I'.
  IT_INPUT_FIELDS-LOGICAL_KEY = '1'.
  APPEND IT_INPUT_FIELDS.

  IT_INPUT_FIELDS-REF_GUID    = V_GUID_H.
  IT_INPUT_FIELDS-OBJECTNAME  = 'PARTNER'.
  IT_INPUT_FIELDS-LOGICAL_KEY = '1'.
  APPEND IT_INPUT_FIELDS.

  IT_INPUT_FIELDS-REF_GUID    = V_GUID_SA.
  IT_INPUT_FIELDS-OBJECTNAME  = 'SALES'.
  IT_INPUT_FIELDS-LOGICAL_KEY = '1'.
  APPEND IT_INPUT_FIELDS.

  IT_INPUT_FIELDS-REF_GUID    = V_GUID_SC.
  IT_INPUT_FIELDS-OBJECTNAME  = 'SCHEDLIN'.
  IT_INPUT_FIELDS-LOGICAL_KEY = '1'.
  APPEND IT_INPUT_FIELDS.


  CALL FUNCTION 'BAPI_SLSTRANSACT_CREATEMULTI'
*   EXPORTING
*     TESTRUN                =
    TABLES
      HEADER                 = IT_HEADER
      ITEM                   = IT_ITEM
      RETURN                 = RETURN
      SALES                  = IT_SALES
      PARTNER                = IT_PARTNER
*     ORGANISATION           =
*     SHIPPING               =
*     APPOINTMENT            =
*     TEXT                   =
*     STATUS                 =
      INPUT_FIELDS           = IT_INPUT_FIELDS
*     PRODUCT                =
      SCHEDULELINE           = IT_SCHEDULELINE
*     CUSTOMER_HEAD          =
*     CUSTOMER_ITEM          =
*     PRICING                =
*     PRICING_ITEM           =
*     CONDITION_CREATE       =
*     BILLING                =
*     CONFIG_CFG             =
*     CONFIG_BLB             =
*     CONFIG_INS             =
*     CONFIG_PRT             =
*     CONFIG_VAL             =
*     CONFIG_VK              =
*     CONFIG_REF             =
*     ADDRESS                =
*     BILLPLAN               =
*     BILLPLAN_DATE          =
      CREATED_PROCESS        = IT_CREATED_PROCESS
      SAVED_PROCESS          = IT_SAVED_PROCESS
*     DOC_FLOW               =
*     PAYPLAN                =
*     PAYPLAN_DATE           =
      .
  COMMIT WORK.
  READ TABLE RETURN WITH KEY TYPE = 'E'.
  IF SY-SUBRC NE 0.

     DATA: V_RETURN LIKE  BAPIRET2.
     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
       IMPORTING
         RETURN        = V_RETURN.

     CHECK NOT IT_SAVED_PROCESS[] IS INITIAL.
     READ TABLE IT_SAVED_PROCESS INDEX 1.
     CHECK SY-SUBRC EQ 0.
       SALES_PROCESS = IT_SAVED_PROCESS-OBJECT_ID.

  ENDIF.


ENDFUNCTION.

FORM GET_GUID CHANGING P_GUID TYPE  GUID_32.

  CALL FUNCTION 'GUID_CREATE'
    IMPORTING
      EV_GUID_32       = P_GUID.

ENDFORM.

Can any one help me in this.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Aug 03, 2005 at 03:16 PM

    Hi,

    you do not need to pass a guid when creating an order, the system does that for you. Instead you should fill the handle to reference the data. For example you can use hande 1 for the header and handle 2 for the item. Then you should use handle one for the partner and handle 2 in the scheduel lines and so on.

    Regards, Paul

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 12, 2005 at 01:25 PM

    Srinivas,

    I am facing the same problem. I am not passing the GuId but still the same error. Can you please let me know in detail as to how you could resolve this ASAP?

    Thanks in advance.

    Regards,

    Kumar.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 22, 2006 at 07:59 PM

    Hi Srinivasa,

    Please replace your input field code with the following.

    The concept is to mention all the fields that you have populated, in the input_fields

    <u><b>ORDERADM_H</b></u>

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_H'.

    IT_INPUT_FIELDS-FIELDNAME = 'GUID'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_H'.

    IT_INPUT_FIELDS-FIELDNAME = 'PROCESS_TYPE'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_H'.

    IT_INPUT_FIELDS-FIELDNAME = 'DESCRIPTION'.

    APPEND IT_INPUT_FIELDS.

    <u><b>ORDERADM_I</b></u>

    (Please pass PRODUCT_GUID in the field ORDERADM_I-PRODUCT.)

    IT_INPUT_FIELDS-REF_GUID = V_GUID_I.

    IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_I'.

    IT_INPUT_FIELDS-FIELDNAME = 'GUID'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_I.

    IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_I'.

    IT_INPUT_FIELDS-FIELDNAME = 'HEADER'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_I.

    IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_I'.

    IT_INPUT_FIELDS-FIELDNAME = 'ORDERED_PROD'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_I.

    IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_I'.

    IT_INPUT_FIELDS-FIELDNAME = 'PRODUCT'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_I.

    IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_I'.

    IT_INPUT_FIELDS-FIELDNAME = 'DESCRIPTION'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_I.

    IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_I'.

    IT_INPUT_FIELDS-FIELDNAME = 'ITM_TYPE'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_I.

    IT_INPUT_FIELDS-OBJECTNAME = 'ORDERADM_I'.

    IT_INPUT_FIELDS-FIELDNAME = 'MODE'.

    APPEND IT_INPUT_FIELDS.

    <u><b>SALES</b></u>

    (Do not create new GUID for SALES. Pass Header GUID in the REF_GUID field)

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'SALES'.

    IT_INPUT_FIELDS-FIELDNAME = 'REF_GUID'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'SALES'.

    IT_INPUT_FIELDS-FIELDNAME = 'PO_NUMBER_SOLD'.

    APPEND IT_INPUT_FIELDS.

    <u><b>PARTNER</b></u>

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'REF_GUID'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'PARTNER_FCT'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'REF_KIND'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'REF_PARTNER_HANDLE'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'KIND_OF_ENTRY'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'NO_TYPE'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'DISPLAY_TYPE'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'PARTNER_NO'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'NAME'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'HOUSE_NO'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'CITY'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'STREET'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'COUNTRY'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'E_MAIL'.

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_H.

    IT_INPUT_FIELDS-OBJECTNAME = 'PARTNER'.

    IT_INPUT_FIELDS-LOGICAL_KEY = '00000001' (partner fct to be passed here).

    IT_INPUT_FIELDS-FIELDNAME = 'TEL1_NUMBR'.

    APPEND IT_INPUT_FIELDS.

    <b><u>SCHEDLIN</u></b>

    Do not create new GUID for schedule line. Use IT_SCHEDULELINE-ITEM_GUID = V_GUID_I.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_I.

    IT_INPUT_FIELDS-OBJECTNAME = 'SCHEDLIN'.

    IT_INPUT_FIELDS-FIELDNAME = 'ITEM_GUID'

    APPEND IT_INPUT_FIELDS.

    IT_INPUT_FIELDS-REF_GUID = V_GUID_I.

    IT_INPUT_FIELDS-OBJECTNAME = 'SCHEDLIN'.

    IT_INPUT_FIELDS-FIELDNAME = 'QUANTITY'

    APPEND IT_INPUT_FIELDS.

    PLease let me know if you have any further questions

    Do reward with points if this helps you

    Regards

    Kaushal

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 11, 2007 at 11:06 AM

    Hello Srinivasa,

    I had the same error. It was solved by filling field IT_PARTNER-businesspartnerguid field.

    Field KIND_OF_ENTRY should be 'C' in your case because you are manually entering the adres data.

    Domain CRM_PARTNER_KIND_OF_ENTRY value range

    A = Automatic determination

    B = Selected

    C = Entered manually

    Please reward if this solves your issue,

    Best regards,

    Sander Pol

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hey Varda,

      I generated a sales order in CRM with BAPI_SLSTRANSACT_CREATEMULTI for a single line item...that is it accepts a single product and generates a sales order...but in real time there can be any number of line items for a sales order...

      *1) Now i need to make this code generic such that it can accept any number of materials...line items?

      How can i make the code generic ....such that it works for any number of line items.*

      *2) Also the CRM is currently configured in such a way that , there is a provision to assign ship to party at item level for each material.

      How can i programatically replicate this? I need to assign a diiferent ship to party for each material in the sales order.*

      how can i programatically replicate this?...

      this is my code for cresating a sales order in CRM for a single line item or single material

      *************include constants

      include crm_direct.

      ************// GUIDs

      data: lv_guid_h type GUID_32, "HEADER GUIDE

      lv_guid_i type GUID_32, "ITEM GUIDE

      lv_guid_sl type GUID_32, "SCHEDULE LINE GUIDE

      lv_guid_p type GUID_32. "PARTNER GUIDE

      ***********// Handles

      data: lv_current_handle type crmt_handle, "CURRENT HANDLE

      lv_handle_h type crmt_handle, "HEADER HANDLE

      lv_handle_i type crmt_handle, "ITEM HANDLE

      lv_handle_sl type crmt_handle, "SCHEDULE LINE HANDLE

      lv_handle_p type crmt_handle. "PARTNER HANDLE

      ***********// Administration header + item + etc

      data: lt_salesorder_header type table of bapibus20001_header_ins, "LT_SALESORDER_HEADER

      ls_salesorder_header type bapibus20001_header_ins, "LS_SALESORDER_HEADER

      lt_salesorder_item type table of bapibus20001_item, "LT_SALESORDER_ITEM

      ls_salesorder_item type bapibus20001_item, "LS_SALESORDER_ITEM

      lt_scheduleline type table of BAPIBUS20001_SCHEDLIN, "LT_SCHEDULELINE

      ls_scheduleline type BAPIBUS20001_SCHEDLIN, "LS_SCHEDULELINE

      lt_partner type table of BAPIBUS20001_PARTNER_INS, "LT_PARTNER

      ls_partner type BAPIBUS20001_PARTNER_INS, "LS_PARTNER

      ls_logical_key TYPE crmt_partner_logic_partner_key, "LS_LOGICAL_KEY

      lt_organisation type table of BAPIBUS20001_ORGMAN_INS, "LT_ORGANISATION

      ls_organisation type BAPIBUS20001_ORGMAN_INS. "LS_ORGANISATION

      *********// Saved sales orders

      data: lt_saved_process type table of bapibus20001_object_id, "LT_SAVED_PROCESS

      data:

      ls_saved_process type bapibus20001_object_id, "LS_SAVED_PROCESS

      ls_salesorder type CRMT_RETURN_OBJECTS_STRUC. "LS_SALESORDER

      data: lt_input_fields type table of bapibus20001_input_fields, "LT_INPUT_FIELDS

      ls_input_fields type bapibus20001_input_fields, "LS_INPUT_FIELDS

      ls_return type bapiret2. "LS_RETURN

      data: lt_return type table of bapiret2. "LT_RETURN

      ***********// Macro definition to populate structure and input field This, called as

      *_set_field ls_salesorder_header GUID lv_guid_h

      *is exploded as

      ls_salesorder_header-GUID = lv_guid_h.

      ls_input_fields-fieldname = 'GUID'.

      append ls_input_fields to lt_input_fields.

      *Note 1: &2 (field name) MUST be uppercase

      *Note 2: for the salesorder header, Macro has not been used to show how the code should look like.

      *except for that the macro has been used everywhere else.

      define setfield.

      &1-&2 = &3.

      ls_input_fields-fieldname = '&2'.

      append ls_input_fields to lt_input_fields.

      end-of-definition.

      *****// end of macro definition

      ******// fill order administration header

      perform get_guid changing lv_guid_h.

      add 1 to lv_handle_h.

      ls_salesorder_header-guid = lv_guid_h.

      ls_salesorder_header-handle = lv_handle_h.

      ls_salesorder_header-process_type = 'ZWEB'.

      clear ls_input_fields.

      ls_input_fields-ref_handle = lv_handle_h.

      ls_input_fields-ref_guid = lv_guid_h.

      *ls_input_fields-ref_kind = gc_object_ref_kind-orderadm_h.

      ls_input_fields-objectname = gc_object_name-orderadm_h.

      ls_input_fields-fieldname = 'GUID'.

      append ls_input_fields to lt_input_fields.

      ls_input_fields-fieldname = 'HANDLE'.

      append ls_input_fields to lt_input_fields.

      ls_input_fields-fieldname = 'PROCESS_TYPE'.

      append ls_input_fields to lt_input_fields.

      append ls_salesorder_header to lt_salesorder_header.

      **********// fill organisation data (Interface needs this, some times may rely on sales org determination instead...

      clear ls_input_fields.

      ls_input_fields-ref_handle = lv_handle_h.

      ls_input_fields-ref_guid = lv_guid_h.

      ls_input_fields-ref_kind = gc_object_ref_kind-orderadm_h.

      ls_input_fields-objectname = gc_object_name-orgman.

      setfield ls_organisation REF_GUID lv_guid_h.

      setfield ls_organisation REF_HANDLE lv_handle_h.

      setfield ls_organisation REF_KIND gc_object_ref_kind-orderadm_h.

      setfield ls_organisation SALES_ORG_RESP SO_RESP . "(input).

      setfield ls_organisation SALES_ORG SALES_ORG. "(input).

      setfield ls_organisation DIS_CHANNEL DIS_CHNL. "(input).

      setfield ls_organisation DIVISION DIVISION. "(input).

      append ls_organisation to lt_organisation.

      **********// fill order administration item

      perform get_guid changing lv_guid_i.

      lv_handle_i = lv_handle_h.

      add 1 to lv_handle_i.

      clear ls_input_fields.

      ls_input_fields-ref_guid = lv_guid_i.

      ls_input_fields-ref_handle = lv_handle_i.

      *ls_input_fields-ref_kind = gc_object_ref_kind-orderadm_i.

      ls_input_fields-objectname = gc_object_name-orderadm_i.

      setfield ls_salesorder_item GUID lv_guid_i.

      setfield ls_salesorder_item HEADER lv_guid_h.

      setfield ls_salesorder_item HANDLE lv_handle_i.

      setfield ls_salesorder_item HEADER_HANDLE lv_handle_h.

      setfield ls_salesorder_item ORDERED_PROD PRODUCT . "(input).

      setfield ls_salesorder_item ITM_TYPE 'ZTAN'.

      setfield ls_salesorder_item MODE 'A'.

      *adjustment taken from standard include LCMS_MAPPERF04

      *(see where-used-list for BAPI_SLSTRANSACT_CREATEMULTI, program LCMS_MAPPERU11)

      delete lt_input_fields where fieldname = 'HANDLE'

      OR

      fieldname = 'HEADER_HANDLE'.

      append ls_salesorder_item to lt_salesorder_item.

      ********// fill schedule line for item

      perform get_guid changing lv_guid_sl.

      add 1 to lv_handle_sl.

      clear ls_input_fields.

      ls_input_fields-ref_guid = lv_guid_i.

      ls_input_fields-ref_handle = lv_handle_i.

      ls_input_fields-ref_kind = gc_object_ref_kind-orderadm_i.

      ls_input_fields-objectname = gc_object_name-schedlin.

      setfield ls_scheduleline ITEM_GUID lv_guid_i.

      setfield ls_scheduleline GUID lv_guid_sl.

      setfield ls_scheduleline HANDLE lv_handle_sl.

      setfield ls_scheduleline ITEM_HANDLE lv_handle_i.

      setfield ls_scheduleline QUANTITY quantity. "(input).

      append ls_scheduleline to lt_scheduleline.

      ********// fill partner line

      *perform get_guid changing lv_guid_p.

      *the partner use the logical key as well

      ls_logical_key-ref_partner_handle = '0001'.

      clear ls_input_fields.

      ls_input_fields-ref_guid = lv_guid_h.

      ls_input_fields-ref_handle = lv_handle_h.

      ls_input_fields-ref_kind = gc_object_ref_kind-orderadm_h.

      ls_input_fields-objectname = gc_object_name-partner.

      ls_input_fields-logical_key = ls_logical_key.

      setfield ls_partner REF_GUID lv_guid_h.

      setfield ls_partner REF_HANDLE lv_handle_h.

      setfield ls_partner REF_KIND gc_object_ref_kind-orderadm_h.

      setfield ls_partner REF_PARTNER_HANDLE '0001'.

      setfield ls_partner KIND_OF_ENTRY 'C'.

      setfield ls_partner PARTNER_FCT '00000001'.

      setfield ls_partner PARTNER_NO SOLD_TO. "(input).

      setfield ls_partner NO_TYPE 'BP'.

      setfield ls_partner DISPLAY_TYPE 'BP'.

      move-corresponding ls_partner to ls_logical_key.

      append ls_partner to lt_partner.

      ls_logical_key-ref_partner_handle = '0002'.

      clear ls_input_fields.

      ls_input_fields-ref_guid = lv_guid_h.

      ls_input_fields-ref_handle = lv_handle_h.

      ls_input_fields-ref_kind = gc_object_ref_kind-orderadm_h.

      ls_input_fields-objectname = gc_object_name-partner.

      ls_input_fields-logical_key = ls_logical_key.

      setfield ls_partner REF_GUID lv_guid_h.

      setfield ls_partner REF_HANDLE lv_handle_h.

      setfield ls_partner REF_KIND gc_object_ref_kind-orderadm_h.

      setfield ls_partner REF_PARTNER_HANDLE '0002'.

      setfield ls_partner KIND_OF_ENTRY 'C'.

      setfield ls_partner PARTNER_FCT '00000002'.

      setfield ls_partner PARTNER_NO SHIP_TO . "(input).

      setfield ls_partner NO_TYPE 'BP'.

      setfield ls_partner DISPLAY_TYPE 'BP'.

      move-corresponding ls_partner to ls_logical_key.

      append ls_partner to lt_partner.

      ls_logical_key-ref_partner_handle = '0003'.

      clear ls_input_fields.

      ls_input_fields-ref_guid = lv_guid_h.

      ls_input_fields-ref_handle = lv_handle_h.

      ls_input_fields-ref_kind = gc_object_ref_kind-orderadm_h.

      ls_input_fields-objectname = gc_object_name-partner.

      ls_input_fields-logical_key = ls_logical_key.

      setfield ls_partner REF_GUID lv_guid_h.

      setfield ls_partner REF_HANDLE lv_handle_h.

      setfield ls_partner REF_KIND gc_object_ref_kind-orderadm_h.

      setfield ls_partner REF_PARTNER_HANDLE '0003'.

      setfield ls_partner KIND_OF_ENTRY 'C'.

      setfield ls_partner PARTNER_FCT '00000003'.

      setfield ls_partner PARTNER_NO BILL_TO ."(input).

      setfield ls_partner NO_TYPE 'BP'.

      setfield ls_partner DISPLAY_TYPE 'BP'.

      move-corresponding ls_partner to ls_logical_key.

      append ls_partner to lt_partner.

      ls_logical_key-ref_partner_handle = '0004'.

      clear ls_input_fields.

      ls_input_fields-ref_guid = lv_guid_h.

      ls_input_fields-ref_handle = lv_handle_h.

      ls_input_fields-ref_kind = gc_object_ref_kind-orderadm_h.

      ls_input_fields-objectname = gc_object_name-partner.

      ls_input_fields-logical_key = ls_logical_key.

      setfield ls_partner REF_GUID lv_guid_h.

      setfield ls_partner REF_HANDLE lv_handle_h.

      setfield ls_partner REF_KIND gc_object_ref_kind-orderadm_h.

      setfield ls_partner REF_PARTNER_HANDLE '0004'.

      setfield ls_partner KIND_OF_ENTRY 'C'.

      setfield ls_partner PARTNER_FCT '00000004'.

      setfield ls_partner PARTNER_NO PAYER ."(input).

      setfield ls_partner NO_TYPE 'BP'.

      setfield ls_partner DISPLAY_TYPE 'BP'.

      move-corresponding ls_partner to ls_logical_key.

      append ls_partner to lt_partner.

      *******// example of a second partner function (custom) with data override

      *ls_logical_key-ref_partner_handle = '0002'.

      *clear ls_input_fields.

      *ls_input_fields-ref_guid = lv_guid_h.

      *ls_input_fields-ref_handle = lv_handle_h.

      *ls_input_fields-ref_kind = gc_object_ref_kind-orderadm_h.

      *ls_input_fields-objectname = gc_object_name-partner.

      *ls_input_fields-logical_key = ls_logical_key.

      *_set_field ls_partner REF_GUID lv_guid_h.

      *_set_field ls_partner REF_HANDLE lv_handle_h.

      *_set_field ls_partner REF_KIND gc_object_ref_kind-orderadm_h.

      *_set_field ls_partner REF_PARTNER_HANDLE '0002'.

      *_set_field ls_partner KIND_OF_ENTRY 'B'. "manual entry...

      *_set_field ls_partner PARTNER_FCT customFct(input).

      *_set_field ls_partner PARTNER_NO bpNumber(input).

      *_set_field ls_partner NO_TYPE 'BP'.

      *_set_field ls_partner DISPLAY_TYPE 'BP'.

      *_set_field ls_partner TITLE 'Mr.'.

      *_set_field ls_partner FIRSTNAME 'John'.

      *_set_field ls_partner LASTNAME 'Smith'.

      *_set_field ls_partner STR_SUPPL1 'John Smith and Co'.

      *_set_field ls_partner STREET 'Street1'.

      *_set_field ls_partner STR_SUPPL3 'Street4'.

      *_set_field ls_partner HOUSE_NO '42'.

      *_set_field ls_partner CITY 'Townville'.

      *_set_field ls_partner DISTRICT 'Districtshire'.

      *_set_field ls_partner POSTL_COD1 'AA1 2BB'.

      *note now ...

      *adjustment taken from standard include LCMS_MAPPERF04

      *(see where-used-list for BAPI_SLSTRANSACT_CREATEMULTI, program LCMS_MAPPERU11)

      *I don't use macro because name of the field in input_table is different

      *_set_field ls_partner COUNTRYISO 'GB'.

      *instead

      ls_partner-COUNTRYISO = 'GB'.

      ls_input_fields-fieldname = 'COUNTRY'.

      append ls_input_fields to lt_input_fields.

      *_set_field ls_partner LANGU_ISO 'EN'.

      ls_partner-LANGU_ISO = 'EN'.

      ls_input_fields-fieldname = 'LANGU'.

      append ls_input_fields to lt_input_fields.

      move-corresponding ls_partner to ls_logical_key.

      append ls_partner to lt_partner.

      *----


      *Create sales orders *

      *----


      call function 'BAPI_SLSTRANSACT_CREATEMULTI'

      EXPORTING

      testrun = false

      TABLES

      header = lt_salesorder_header[]

      item = lt_salesorder_item[]

      partner = lt_partner[]

      organisation = lt_organisation[]

      input_fields = lt_input_fields[]

      scheduleline = lt_scheduleline[]

      saved_process = lt_saved_process[]

      return = lt_return[].

      *************// get the GUID of the created object

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

      EXPORTING

      WAIT = 'X'

      IMPORTING

      RETURN = lt_return1.

      INCLUDE ZZGVBAPISALESORDER_GET_GUIDF01.

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.