Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

/AFS/BAPI_SALESORD_CREATEFDATA

Former Member
0 Likes
1,634

Hi Xperts,

I am planning to use the Fm /AFS/BAPI_SALESORD_CREATEFDATA for my AFS related BDC program, I am in need of some test data to test this function module or atleast the documentation for this? Rewards will be awarded..

Thanks in advance

Rajs

2 REPLIES 2
Read only

Former Member
0 Likes
804

Hi,

Use this FM BAPI_SALESORDER_CREATEFROMDAT2 for ur purpose as this is latest. and for info raed the documentation below.

Sales order: Create Sales Order

Functionality

You can use this method to create sales orders.

You must enter at least sales order header data (via ORDER_HEADER_IN structure) and partner data (via the ORDER_PARTNERS table) as input parameters.

Enter the item data via the ORDER_ITEMS_IN table. You can allocate item numbers manually, by filling in the relevant fields, or the system does it, according to the settings for Customizing, by leaving the relevant fields blank.

If you have configurable items, you must enter the configuration data in the ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_PART_OF and ORDER_CFGS_VALUE tables.

Credit cards can be transferred via the BAPICCARD structure, on the one hand, data for card identification, on the other, data for a transaction which has taken place in an external system.

Once you have created the sales order successfully, you will receive the document number (SALESDOCUMENT field). Any errors that may occur will be announced via the RETURN parameter.

If no sales area has been created in the sales order header, then the system creates the sales area from the sold-to party or ship-to party, who has been entered in the partner table. If a clear sales area cannot be created, you will receive a system message, and the sales order will not be created.

Notes

Mandatory entries:

ORDER_HEADER_IN : DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number

ORDER_ITEMS_IN..: MATERIAL Material number

Ship-to party:

If no ship-to party is entered, use the following: Ship-to party =

sold-to party.

Commit control:

The BAPI does not have a database commit. This means that the relevant application must leave the commit, in order that can be carried out on on the database. The BAPI BAPI_TRANSACTION_COMMIT is available for this.

German key words:

The following key words must be entered in German, independantly of

the logon language:

DOC_TYPE Sales document type, for example: TA for standard order

PARTN_ROLE Partner role, for example: WE for ship-to party

<b>Functionality</b>

You can use this method to create sales orders.

You must enter at least sales order header data (via ORDER_HEADER_IN structure) and partner data (via the ORDER_PARTNERS table) as input parameters.

Enter the item data via the ORDER_ITEMS_IN table. You can allocate item numbers manually, by filling in the relevant fields, or the system does it, according to the settings for Customizing, by leaving the relevant fields blank.

If you have configurable items, you must enter the configuration data in the ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_PART_OF and ORDER_CFGS_VALUE tables.

Credit cards can be transferred via the BAPICCARD structure, on the one hand, data for card identification, on the other, data for a transaction which has taken place in an external system.

Once you have created the sales order successfully, you will receive the document number (SALESDOCUMENT field). Any errors that may occur will be announced via the RETURN parameter.

If no sales area has been created in the sales order header, then the system creates the sales area from the sold-to party or ship-to party, who has been entered in the partner table. If a clear sales area cannot be created, you will receive a system message, and the sales order will not be created.

Notes

1. Mandatory entries:

ORDER_HEADER_IN : DOC_TYPE Sales document type

SALES_ORG Sales organization

DISTR_CHAN Distribution channel

DIVISION Division

ORDER_PARTNERS..: PARTN_ROLE Partner role, SP sold-to party

PARTN_NUMB Customer number

ORDER_ITEMS_IN..: MATERIAL Material number

2. Ship-to party:

If no ship-to party is entered, use the following: Ship-to party =

sold-to party.

3. Commit control:

The BAPI does not have a database commit. This means that the relevant application must leave the commit, in order that can be carried out on on the database. The BAPI BAPI_TRANSACTION_COMMIT is available for this.

4. German key words:

The following key words must be entered in German, independantly of

the logon language:

DOC_TYPE Sales document type, for example: TA for standard order

PARTN_ROLE Partner role, for example: WE for ship-to party

For test data you have to create ur own based on the data available in your system.

reagrds,

sasi

Read only

Former Member
0 Likes
804

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.