Quantcast
Channel: SCN: Message List - ABAP Connectivity
Viewing all articles
Browse latest Browse all 3125

Re: /AFS/BAPI_SALESORD_CREATEFDATA

$
0
0

Here is the same code for AFS Sales Order Creation

REPORT ZGL_ALV_SO_CREATE.
Data : i_vbeln type BAPIVBELN-VBELN,
        lt_head        like /AFS/BAPISDHD,                    "S/O Header
        lt_headx       like /AFS/BAPISDHDX,
        lt_partner     like STANDARD TABLE OF BAPIPARNR,      "Partner Function
        wa_partner     like line of lt_partner,
        lt_ser_pritem  type STANDARD TABLE OF BAPI_SRV_SERVICE_LINE, "AFS Material Details
        wa_ser_pritem  like line of lt_ser_pritem,
        lt_item        like STANDARD TABLE OF /AFS/BAPISDITM,
        wa_item        like line of lt_item,
        lt_itemx       like STANDARD TABLE OF /AFS/BAPISDITMX,
        wa_itemx       like line of lt_itemx,
        lt_itemsd      like STANDARD TABLE OF /AFS/BAPISDSCHD,
        wa_itemsd      like line of lt_itemsd,
        lt_itemsdx     like STANDARD TABLE OF /AFS/BAPISDSCHDx,
        wa_itemsdx     like line of lt_itemsdx,
        it_itemcon     like STANDARD TABLE OF /AFS/BAPICOND,
        wa_itemcon    like line of it_itemcon,
        it_return     like STANDARD TABLE OF BAPIRET2,
        wa_return     like line of it_return.

** Header Data
Move 'GS'          to lt_head-DOC_TYPE,
         '4100'        to lt_head-SALES_ORG,
         '10'          to lt_head-DISTR_CHAN,
         '450000509'   to lt_head-PURCH_NO_C,
         sy-datum      to lt_head-PURCH_DATE,
         '01'          to lt_head-PRICE_GRP,
         '01'          to lt_head-CUST_GROUP,
         'CT30'        TO lt_head-PMNTTRMS,
         'I'           to lt_headx-UPDATEFLAG,
         'X'           TO lt_headx-PMNTTRMS,
         'X'           to lt_headx-DOC_TYPE,
         'X'           to lt_headx-SALES_ORG,
         'X'           to lt_headx-DISTR_CHAN,
         'X'           to lt_headx-PURCH_NO_C,
         'X'           to lt_headx-PURCH_DATE,
         'X'           to lt_headx-PRICE_GRP,
         'X'           to lt_headx-CUST_GROUP.
** Item   data

Move:   '000010'      to wa_item-ITM_NUMBER,
         '000000000000009472' to wa_item-material,
         '4100'        to wa_item-plant,
         '4199'        to wa_item-STORE_LOC,
         '40'          to wa_item-GROSS_WGHT,
         '40'          to wa_item-NET_WEIGHT,
         'EA'          to wa_item-T_UNIT_ISO,
         'EA'          to wa_item-SALES_UNIT,
         'KG'          to wa_item-UNTOF_WGHT,
         'KG'          to wa_item-UNOF_WTISO,
         'TAN'         to wa_item-ITEM_CATEG,
         'Short Text'  to wa_item-SHORT_TEXT,
         '450000509'   to wa_item-PURCH_NO_C,
         '01'          to wa_item-PRICE_GRP,
         '01'          to wa_item-CUST_GROUP,
         'EA'          to wa_item-SALES_UNIT.

Move:   '000010'      to wa_itemx-ITM_NUMBER,
         'X'           to wa_itemx-material,
         'X'           to wa_itemx-plant,
         'X'           to wa_itemx-STORE_LOC,
         'X'           to wa_itemx-NET_WEIGHT,
         'X'           to wa_itemx-T_UNIT_ISO,
         'X'           to wa_itemx-SALES_UNIT,
         'X'           to wa_itemx-UNTOF_WGHT,
         'X'           to wa_itemx-ITEM_CATEG,
         'X'           to wa_itemx-SHORT_TEXT,
         'X'           to wa_itemx-PURCH_NO_C,
         'X'           to wa_itemx-PRICE_GRP,
         'X'           to wa_itemx-CUST_GROUP,
         'X'           to wa_itemx-SALES_UNIT.
         append wa_item   to lt_item.
         append wa_itemx  to lt_itemx.
         clear : wa_item,wa_itemx.
* Schd   data
  Move :   '000010'      to wa_itemsd-ITM_NUMBER,
           '0001'        to wa_itemsd-SCHED_LINE,
           sy-datum      to wa_itemsd-REQ_DATE,
           '20'          to wa_itemsd-REQ_QTY,
           '20'          to wa_itemsd-GROSS_WGHT,
           '20'          to wa_itemsd-NET_WEIGHT,
           'L  16'       to wa_itemsd-GRID_VALUE.

  Move :   '000010'      to wa_itemsdx-ITM_NUMBER,
           '0001'        to wa_itemsdx-SCHED_LINE,
           'X'           to wa_itemsdx-REQ_DATE,
           'X'           to wa_itemsdx-REQ_QTY,
           'X'           to wa_itemsdx-GROSS_WGHT,
           'X'           to wa_itemsdx-NET_WEIGHT,
           'X'           to wa_itemsdx-GRID_VALUE.
        append wa_itemsd to lt_itemsd.
        append wa_itemsdx to lt_itemsdx.
        clear : wa_itemsd,wa_itemsdx.
  Move :   '000010'      to wa_itemsd-ITM_NUMBER,
           '0002'        to wa_itemsd-SCHED_LINE,
           sy-datum      to wa_itemsd-REQ_DATE,
           '20'          to wa_itemsd-REQ_QTY,
           '20'          to wa_itemsd-GROSS_WGHT,
           '20'          to wa_itemsd-NET_WEIGHT,
           'L  32'       to wa_itemsd-GRID_VALUE.

  Move :   '000010'      to wa_itemsdx-ITM_NUMBER,
           '0002'        to wa_itemsdx-SCHED_LINE,
           'X'           to wa_itemsdx-REQ_DATE,
           'X'           to wa_itemsdx-REQ_QTY,
           'X'           to wa_itemsdx-GROSS_WGHT,
           'X'           to wa_itemsdx-NET_WEIGHT,
           'X'           to wa_itemsdx-GRID_VALUE.
        append wa_itemsd to lt_itemsd.
        append wa_itemsdx to lt_itemsdx.


*Partner Function.
  Move : 'AG'           to wa_partner-PARTN_ROLE,
         '0000000216'   to wa_partner-PARTN_NUMB,
         '000000'       to wa_partner-ITM_NUMBER.
         append wa_partner to lt_partner.

         clear : wa_partner.
  Move : 'BP'           to wa_partner-PARTN_ROLE,
         '0000000216'   to wa_partner-PARTN_NUMB,
         '000000'       to wa_partner-ITM_NUMBER.
         append wa_partner to lt_partner.
          clear : wa_partner.
Move : 'PY'           to wa_partner-PARTN_ROLE,
         '0000000216'   to wa_partner-PARTN_NUMB,
         '000000'       to wa_partner-ITM_NUMBER.
          append wa_partner to lt_partner.
          clear : wa_partner.
Move : 'WE'           to wa_partner-PARTN_ROLE,
         '0000000216'   to wa_partner-PARTN_NUMB,
         '000000'       to wa_partner-ITM_NUMBER.
          append wa_partner to lt_partner.
         clear : wa_partner.

**Partner Function.
break abap.
CALL FUNCTION '/AFS/BAPI_SALESORD_CREATEFDATA'
   EXPORTING
     order_header_in               lt_head
     ORDER_HEADER_INX              lt_headx
   IMPORTING
    SALESDOCUMENT                 =   i_vbeln
   tables
    RETURN                        =   it_return
    ORDER_ITEMS_IN                lt_item
    ORDER_ITEMS_INX               lt_itemx
    ORDER_SCHEDULES_IN            = lt_itemsd
    ORDER_SCHEDULES_INX           = lt_itemsdx
    order_partners                = lt_partner
    ORDER_CONDITIONS_IN           it_itemcon.

    if sy-subrc eq 0.
    endif.

    if i_vbeln ne 0.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
            WAIT    = 'X'.
    endif.



Viewing all articles
Browse latest Browse all 3125

Trending Articles