Skip to Content
avatar image
Former Member

Bapi for sales order creation

hi

i want bapi for sales order creation and can you share a program how to create a sales order using bapi.

Thanks

Manohar

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Sep 24, 2008 at 01:48 PM

    Bapi: BAPI_SALESORDER_CREATEFROMDAT1

    BAPI_SALESORDER*

    BAPI_SALESDOCUMENT*

    Regards,

    Gordon

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 24, 2008 at 02:24 PM

    Hi,

    Below is the sample code ....

    Report YTEST_SO_CREATE.

    DATA: HEADER LIKE BAPISDHD1.

    DATA : HEADERX LIKE BAPISDHD1X.

    DATA: I_PARTNERS LIKE BAPIPARNR OCCURS 0 WITH HEADER LINE.

    DATA: I_ITEM LIKE BAPISDITM OCCURS 0 WITH HEADER LINE.

    DATA: I_ITEMX LIKE BAPISDITMX OCCURS 0 WITH HEADER LINE.

    DATA: RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

    DATA: ORD_TEXT LIKE BAPISDTEXT OCCURS 0 WITH HEADER LINE.

    DATA: I_SHLINE LIKE BAPISCHDL OCCURS 0 WITH HEADER LINE.

    DATA: I_SHLINEX LIKE BAPISCHDLX OCCURS 0 WITH HEADER LINE.

    DATA : ORDER LIKE VBAK-VBELN.

    DATA: T_CONDITION LIKE STANDARD TABLE OF BAPICOND WITH HEADER LINE.

    DATA: T_CONDITIONX LIKE STANDARD TABLE

    OF BAPICONDX

    WITH HEADER LINE.

      • order header values

      HEADER-DOC_TYPE = 'ZIMP'.

      HEADER-SALES_ORG = '1000'.

      HEADER-DISTR_CHAN = '10'.

      HEADER-DIVISION = '11'.

      HEADER-REQ_DATE_H = sy-datum.

      HEADER-DATE_TYPE = '1'.

      HEADER-PURCH_NO_C = '3476926'.

      HEADER-CREATED_BY = 'AOAX01_A2'.

      HEADERX-UPDATEFLAG = 'X'.

      HEADERX-DOC_TYPE = 'X'.

      HEADERX-SALES_ORG = 'X'.

      HEADERX-DISTR_CHAN = 'X'.

      HEADERX-DIVISION = 'X'.

      HEADERX-REQ_DATE_H = 'X'.

      HEADERX-DATE_TYPE = 'X'.

      HEADERX-PURCH_NO_C = 'X'.

      *INCLUDE ZITEM.

      I_ITEM-ITM_NUMBER = '000010'.

      I_ITEM-MATERIAL = '971LX'.

      I_ITEM-CUST_MAT22 = 'SD_AA54577'.

      I_ITEM-PLANT = '1000'.

      I_ITEM-STORE_LOC = '0001'.

      I_ITEM-TARGET_QTY = '3.00'.

      I_ITEM-TARGET_QU = 'ST'.

      APPEND I_ITEM.

      CLEAR I_ITEM.

      I_ITEMX-ITM_NUMBER = '000010'.

      I_ITEMX-UPDATEFLAG = 'X'.

      I_ITEMX-MATERIAL = 'X'.

      I_ITEMX-CUST_MAT22 = 'X'.

      I_ITEMX-PLANT = 'X'.

      I_ITEMX-STORE_LOC = 'X'.

      I_ITEMX-TARGET_QTY = 'X'.

      I_ITEMX-TARGET_QU = 'X'.

      APPEND I_ITEMX.

      CLEAR I_ITEMX.

      I_ITEM-ITM_NUMBER = '000020'.

      I_ITEM-MATERIAL = '971LX'.

      I_ITEM-CUST_MAT22 = 'SD_AA54577'.

      I_ITEM-PLANT = '1000'.

      I_ITEM-STORE_LOC = '0001'.

      I_ITEM-TARGET_QTY = '3.00'.

      I_ITEM-TARGET_QU = 'ST'.

      APPEND I_ITEM.

      CLEAR I_ITEM.

      I_ITEMX-ITM_NUMBER = '000020'.

      I_ITEMX-UPDATEFLAG = 'X'.

      I_ITEMX-MATERIAL = 'X'.

      I_ITEMX-CUST_MAT22 = 'X'.

      I_ITEMX-PLANT = 'X'.

      I_ITEMX-STORE_LOC = 'X'.

      I_ITEMX-TARGET_QTY = 'X'.

      I_ITEMX-TARGET_QU = 'X'.

      APPEND I_ITEMX.

      CLEAR I_ITEMX.

      *INCLUDE ZPARTN.

      I_PARTNERS-PARTN_ROLE = 'SP'. " Soldto

      I_PARTNERS-PARTN_NUMB = '99999S1000'.

      APPEND I_PARTNERS.

      CLEAR I_PARTNERS.

      I_PARTNERS-PARTN_ROLE = 'SH'. " Soldto

      I_PARTNERS-PARTN_NUMB = '99999S1000'.

      APPEND I_PARTNERS.

      CLEAR I_PARTNERS.

      ORD_TEXT-ITM_NUMBER = '10'.

      ORD_TEXT-TEXT_ID = 'Z036'.

      ORD_TEXT-LANGU = 'EN'.

      ORD_TEXT-TEXT_LINE = 'Equipment Serial Number e.g 123456'.

      APPEND ORD_TEXT.

      *INCLUDE ZORD_TEXT.

      I_SHLINE-ITM_NUMBER = '000010'.

      *I_SHLINE-SCHED_LINE = '0001'.

      I_SHLINE-REQ_DATE = SY-DATUM.

      I_SHLINE-REQ_QTY = '3.00'.

      APPEND I_SHLINE.

      I_SHLINEX-ITM_NUMBER = '000010'.

      *I_SHLINEX-SCHED_LINE = '0001'.

      I_SHLINEX-UPDATEFLAG = ''.

      I_SHLINEX-REQ_DATE = 'X'.

      I_SHLINEX-REQ_QTY = 'X'.

      APPEND I_SHLINEX.

      I_SHLINE-ITM_NUMBER = '000020'.

      *I_SHLINE-SCHED_LINE = '0001'.

      I_SHLINE-REQ_DATE = SY-DATUM.

      I_SHLINE-REQ_QTY = '3.00'.

      APPEND I_SHLINE.

      I_SHLINEX-ITM_NUMBER = '000020'.

      *I_SHLINEX-SCHED_LINE = '0001'.

      I_SHLINEX-UPDATEFLAG = ''.

      I_SHLINEX-REQ_DATE = 'X'.

      I_SHLINEX-REQ_QTY = 'X'.

      APPEND I_SHLINEX.

      *INCLUDE ZSHLINE.

      MOVE:

      '000010' TO T_CONDITION-ITM_NUMBER,

      'ZPR0' TO T_CONDITION-COND_TYPE,

      '12345' TO T_CONDITION-COND_VALUE,

      'USD' TO T_CONDITION-CURRENCY.

      APPEND T_CONDITION.

      MOVE:

      '000010' TO T_CONDITIONX-ITM_NUMBER,

      'ZPR0' TO T_CONDITIONX-COND_TYPE,

      'X' TO T_CONDITIONX-COND_VALUE,

      'X' TO T_CONDITIONX-CURRENCY,

      'X' TO T_CONDITIONX-UPDATEFLAG.

      APPEND T_CONDITIONX.

      MOVE:

      '000020' TO T_CONDITION-ITM_NUMBER,

      'ZPR0' TO T_CONDITION-COND_TYPE,

      '130' TO T_CONDITION-COND_VALUE,

      'USD' TO T_CONDITION-CURRENCY.

      APPEND T_CONDITION.

      MOVE:

      '000020' TO T_CONDITIONX-ITM_NUMBER,

      'ZPR0' TO T_CONDITIONX-COND_TYPE,

      'X' TO T_CONDITIONX-COND_VALUE,

      'X' TO T_CONDITIONX-CURRENCY,

      'X' TO T_CONDITIONX-UPDATEFLAG.

      APPEND T_CONDITIONX.

      CLEAR T_CONDITION.

      MOVE:

      'ZWHF' TO T_CONDITION-COND_TYPE,

      '120' TO T_CONDITION-COND_VALUE,

      'USD' TO T_CONDITION-CURRENCY,

      '01' TO T_CONDITION-CONDCOINHD.

      APPEND T_CONDITION.

      CLEAR T_CONDITIONX.

      MOVE:

      'ZWHF' TO T_CONDITIONX-COND_TYPE,

      'X' TO T_CONDITIONX-COND_VALUE,

      'X' TO T_CONDITIONX-CURRENCY,

      'X' TO T_CONDITIONX-UPDATEFLAG.

      APPEND T_CONDITIONX.

      .

      CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

      EXPORTING

      • SALESDOCUMENTIN =

      order_header_in = HEADER

      ORDER_HEADER_INX = HEADERX

      • SENDER =

      • BINARY_RELATIONSHIPTYPE =

      INT_NUMBER_ASSIGNMENT = 'X'

      • BEHAVE_WHEN_ERROR =

      • LOGIC_SWITCH =

      • TESTRUN =

      CONVERT = 'X'

      IMPORTING

      SALESDOCUMENT = W_VBELN

      tables

      RETURN = RETURN

      ORDER_ITEMS_IN = I_ITEM

      ORDER_ITEMS_INX = I_ITEMX

      order_partners = I_PARTNERS

      ORDER_SCHEDULES_IN = I_SHLINE

      ORDER_SCHEDULES_INX = I_SHLINEX

      ORDER_CONDITIONS_IN = T_CONDITION

      ORDER_CONDITIONS_INX = T_CONDITIONX

      • ORDER_CFGS_REF =

      • ORDER_CFGS_INST =

      • ORDER_CFGS_PART_OF =

      • ORDER_CFGS_VALUE =

      • ORDER_CFGS_BLOB =

      • ORDER_CFGS_VK =

      • ORDER_CFGS_REFINST =

      • ORDER_CCARD =

      ORDER_TEXT = ORD_TEXT

      • ORDER_KEYS =

      • EXTENSIONIN =

      • PARTNERADDRESSES =

      .

      *EXPORT (RETURN) TO MEMORY ID 'EFGH'.

      IF SY-SUBRC = 0.

      WRITE : ORDER.

      LOOP AT RETURN.

      WRITE : / RETURN-TYPE, RETURN-MESSAGE.

      ENDLOOP.

      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .

      Thanks & Regards

      Vijayanand Poreddy

      Add comment
      10|10000 characters needed characters exceeded