To create shipment order using BAPI

hi,
i know the bapi_shipment_create is the bapi ,i have to useto create shipment order but the structures & the fields inside that bapi is unfamiliar to me.so i need some samples so that i can follow.
1)i want to know which structures , i have to use & what r the fields of that structures, i have to pass so that a shipment order will be created.
that means,  what r the fields of that bapi i have to use to crete a complete shipment order?plz suggest.
can anyone send me some sample code for creating shipment order using bapi?
Thanks & Regards

It will take to provide Examples
First analyse it BAPI Explorer.
Go for the documentation
Go for the test runs in tools tabstrip and in that identify the mandatory fields.
If u know the transaction go for the shipment order creation for test run to identify mandatory fields.
build the structures as it is in the bapi fm

Similar Messages

  • Shipment order using BAPI

    hi all,
      bapi_shipment_create is the bapi ,i want to use for the creation of shipment order but the structures & the fields inside that bapi is unfamiliar to me.so i need some samples so that i can follow.
    1)i want to know which structures , i have to use & what r the fields of that structures, i have to pass so that a shipment order will be created.
    that means, what r the fields of that bapi i have to use to crete a complete shipment order?plz suggest.
    can anyone send me some sample code for creating shipment order using bapi?
    Thanks & Regards

    Hi,
    Check this sample code.
    REPORT ztest_bapi_shipment_create .
    * This report is provided to help understanding the interface *
    * of function module 'BAPI_SHIPMENT_CREATE' with regard to    *
    * its ability to fill the different shipment-deadlines        *
    * With running this report, new shipments are created         *
    * fill the interface for bapi
    DATA: headerdata LIKE bapishipmentheader,
             headerdeadline LIKE bapishipmentheaderdeadline
                        OCCURS 0 WITH HEADER LINE,
             itemdata LIKE bapishipmentitem  OCCURS 0 WITH HEADER LINE,
             stagedata LIKE bapishipmentstage OCCURS 0 WITH HEADER LINE,
             stagedeadline LIKE bapishipmentstagedeadline
                               OCCURS 0 WITH HEADER LINE,
             itemonstage LIKE bapishipmentitemonstage
                              OCCURS 0 WITH HEADER LINE,
             address LIKE bapishipmentaddress
                              OCCURS 0 WITH HEADER LINE,
             hdunheader LIKE bapishipmenthdunheader
                              OCCURS 0 WITH HEADER LINE,
             hdunitem LIKE bapishipmenthdunitem
                              OCCURS 0 WITH HEADER LINE,
             return LIKE bapiret2  OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN COMMENT /1(83) com1.
    SELECTION-SCREEN COMMENT /1(83) com2.
    SELECTION-SCREEN COMMENT /1(83) com3.
    SELECTION-SCREEN COMMENT /1(83) com4.
    SELECTION-SCREEN COMMENT /1(83) com5.
    SELECTION-SCREEN COMMENT /1(83) com6.
    SELECTION-SCREEN COMMENT /1(83) com7.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN ULINE.
    SELECTION-SCREEN BEGIN OF BLOCK header WITH FRAME TITLE text-hrd.
    * Headerdate - obligatory
    SELECTION-SCREEN COMMENT /1(79) com8 FOR FIELD tplst.
    PARAMETER: tplst LIKE vttk-tplst.
    SELECTION-SCREEN COMMENT /1(79) com9 FOR FIELD tplst.
    PARAMETER: shtyp LIKE vttk-shtyp.
    SELECTION-SCREEN END OF BLOCK header.
    SELECTION-SCREEN ULINE.
    SELECTION-SCREEN BEGIN OF BLOCK status WITH FRAME TITLE com10.
    * Plan
    PARAMETER:  plan LIKE  bapishipmentheader-status_plan.
    *checkin
    PARAMETER:  check LIKE  bapishipmentheader-status_checkin.
    *load start
    PARAMETER:  load_s LIKE  bapishipmentheader-status_load_start.
    *load end
    PARAMETER:  load_e LIKE  bapishipmentheader-status_load_end.
    *Completion
    PARAMETER:  compl LIKE  bapishipmentheader-status_compl.
    * tra begin
    PARAMETER:  ship_s LIKE  bapishipmentheader-status_shpmnt_start.
    * tra end
    PARAMETER:  ship_e LIKE  bapishipmentheader-status_shpmnt_end.
    SELECTION-SCREEN END OF BLOCK status.
    * Headerdeadline
    SELECTION-SCREEN BEGIN OF BLOCK h_deadline WITH FRAME TITLE com11.
    PARAMETERS: ttype(10)
                DEFAULT 'HDRSTPLDT', "= End of planning
                utc LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype2(10)
                DEFAULT 'HDRSTCIPDT',"= planned date of check-in
                utc2 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone2 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype3(10)
                DEFAULT 'HDRSTCIADT',"= actual date of check-in
                utc3 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone3 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype4(10)
                DEFAULT 'HDRSTLSPDT',"= planned date f. start loading
                utc4 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone4 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype5(10)
                DEFAULT 'HDRSTLSADT',"= current date f. start loading
                utc5 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone5 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype6(10)
                DEFAULT 'HDRSTLEPDT',"= planned date f. end loading
                utc6 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone6 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype7(10)
                DEFAULT 'HDRSTLEADT',"= actual date f. end loading
                utc7 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone7 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype8(10)
                DEFAULT 'HDRSTCPDT',"= planned date f. shpmnt completion
                utc8 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone8 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype9(10)
                DEFAULT 'HDRSTCADT',"= actual date f. shpmnt completion
                utc9 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone9 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype10(10)
                DEFAULT 'HDRSTSSPDT',"= planned date f. start shpmnt
                utc10 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone10 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype11(10)
                DEFAULT 'HDRSTSSADT',"= actual date f. start shpmnt
                utc11 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone11 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype12(10)
                DEFAULT 'HDRSTSEPDT',"= planned date f. end shpmnt
                utc12 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone12 LIKE bapishipmentheaderdeadline-time_zone.
    PARAMETERS: ttype13(10)
                DEFAULT 'HDRSTSEADT',"= actual date f. end shpmnt
                utc13 LIKE bapishipmentheaderdeadline-time_stamp_utc,
                zone13 LIKE bapishipmentheaderdeadline-time_zone.
    SELECTION-SCREEN END OF BLOCK h_deadline.
    * Format the select-options                                           *
    INITIALIZATION.
      com1 = 'This report was provided to help understanding the behaviour'.
      com2 = 'of function module BAPI_SHIPMENT_CREATE with regard to its '.
      com3 = 'ability to fill the new shipments deadlines: '.
      com4 = 'Planning, Check-In, Loading Start, Loading end, '.
      com5 = 'Shpmnt completion, Shipment start and shipment end.'.
      com6 = 'This report creates new shipments which can be '.
      com7 = 'viewed e.g. with transaction VT03n'.
      com8 = 'Transportation Planning Point (obligatory)'.
      com9 = 'Shipment type (obligatory)'.
      com10 = 'BAPISHIPMENTHEADER-Flags --> see note 531207 '.
      com11 = 'HEADERDEADLINE-Structure --> see note 531207 '.
    START-OF-SELECTION.
    ******************head begin***********************************
      headerdata-trans_plan_pt = tplst.
      headerdata-shipment_type = shtyp.
    * change Plan status
    *  HEADERDATA-SHIPMENT_NUM = tknum.
      IF plan <> space.
        headerdata-status_plan = plan.
      ENDIF.
    * Change Check_in status
      IF check <> space.
        headerdata-status_checkin = check.
      ENDIF.
    *load beginn
      IF load_s <> space .
        headerdata-status_load_start = load_s.
      ENDIF.
    * load end
      IF load_e <> space .
        headerdata-status_load_end = load_e.
      ENDIF.
    * completion
      IF compl <> space.
        headerdata-status_compl = compl.
      ENDIF.
    *tra beginn
      IF ship_s <> space.
        headerdata-status_shpmnt_start = ship_s.
      ENDIF.
    *tra beginn
      IF ship_e <> space.
        headerdata-status_shpmnt_end = ship_e.
      ENDIF.
    ***** HEADERDEADLINE END OF PLANNING
      IF ttype <> space.
        headerdeadline-time_type = ttype.
        headerdeadline-time_stamp_utc = utc.
        headerdeadline-time_zone = zone.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE PLANNED DATE OF CHECK-IN
      IF ttype2 <> space.
        headerdeadline-time_type = ttype2.
        headerdeadline-time_stamp_utc = utc2.
        headerdeadline-time_zone = zone2.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE ACTUAL DATE OF CHECK-IN
      IF ttype3 <> space.
        headerdeadline-time_type = ttype3.
        headerdeadline-time_stamp_utc = utc3.
        headerdeadline-time_zone = zone3.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE PLANNED D START OF LOADING
      IF ttype4 <> space.
        headerdeadline-time_type = ttype4.
        headerdeadline-time_stamp_utc = utc4.
        headerdeadline-time_zone = zone4.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE CURRENT D START OF LOADING
      IF ttype5 <> space.
        headerdeadline-time_type = ttype5.
        headerdeadline-time_stamp_utc = utc5.
        headerdeadline-time_zone = zone5.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE PLANNED D END OF LOADING
      IF ttype6 <> space.
        headerdeadline-time_type = ttype6.
        headerdeadline-time_stamp_utc = utc6.
        headerdeadline-time_zone = zone6.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE ACTUAL D END OF LOADING
      IF ttype7 <> space.
        headerdeadline-time_type = ttype7.
        headerdeadline-time_stamp_utc = utc7.
        headerdeadline-time_zone = zone7.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE PLANNED D SHIPMENT COMPLETION
      IF ttype8 <> space.
        headerdeadline-time_type = ttype8.
        headerdeadline-time_stamp_utc = utc8.
        headerdeadline-time_zone = zone8.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE ACTUAL D SHIPMENT COMPLETION
      IF ttype9 <> space.
        headerdeadline-time_type = ttype9.
        headerdeadline-time_stamp_utc = utc9.
        headerdeadline-time_zone = zone9.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE PLANNED D START OF SHIPMENT
      IF ttype10 <> space.
        headerdeadline-time_type = ttype10.
        headerdeadline-time_stamp_utc = utc10.
        headerdeadline-time_zone = zone10.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE ACTUAL D START OF SHIPMENT
      IF ttype11 <> space.
        headerdeadline-time_type = ttype11.
        headerdeadline-time_stamp_utc = utc11.
        headerdeadline-time_zone = zone11.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE PLANNED D END OF SHIPMENT
      IF ttype12 <> space.
        headerdeadline-time_type = ttype12.
        headerdeadline-time_stamp_utc = utc12.
        headerdeadline-time_zone = zone12.
        APPEND headerdeadline.
      ENDIF.
    ***** HEADERDEADLINE CURRENT D END OF SHIPMENT
      IF ttype13 <> space.
        headerdeadline-time_type = ttype13.
        headerdeadline-time_stamp_utc = utc13.
        headerdeadline-time_zone = zone13.
        APPEND headerdeadline.
      ENDIF.
    itemdata-DELIVERY  = '0080000028'.
    itemdata-ITENERARY = '0001'.
    append itemdata.
      CALL FUNCTION 'BAPI_SHIPMENT_CREATE'
           EXPORTING
                headerdata     = headerdata
           TABLES
                headerdeadline = headerdeadline
                itemdata       = itemdata
                stagedata      = stagedata
                stagedeadline  = stagedeadline
                itemonstage    = itemonstage
                address        = address
                hdunheader     = hdunheader
                hdunitem       = hdunitem
                return         = return.
      LOOP AT return.
       WRITE:/ return-message.
      ENDLOOP.
    Regards
    vijay

  • Setting user specific contract data while creating sales order using BAPI

    Hi all,
    I am creating sales order using BAPI - BAPI_SALESORDER_CREATEFROMDAT2.
    Now my problem is that there is no structure for contract data (i.e. VEDA), system automatically set contract data using customization values.
    I am doing some validations on cotract data in MV45AFZZ which fails, because these validations are performed on standard values, user specific values r not set.
    How to handle this issue, your small clue may help a lot.
    Regards,
    S@meer

    HI
      Pricing will be carried basing on the pricing
    procedure.
    Case1: Prices will be carried out automatically if
    necessary condition records are maintained for the
    condition type.
      For this you can go to Sales Order-> Item Conditions
    In the screen you can click on command button Analysis,
    which gives you the list of condition types associated
    to the pricing procedure. By clicking on the condition
    type you can know the action that has taken place.
    Case2: Manually forcing prices for Items.
      To do this, you have to populate ORDER_CONDITIONS_IN &
    ORDER_CONDITIONS_INX. Also note to identify the item
    numbers, you manually pass the item number for each item
    in the sales order, use the same item number for
    populating conditions.
      Parameters required:
    ORDER_CONDITIONS_IN:
      ITM_NUMBER, COND_TYPE, COND_VALUE, CURRENCY
    ORDER_CONDITIONS_INX:
      ITM_NUMBER, COND_TYPE, UPDATEFLAG, COND_VALUE,CURRENCY.
       Hope the above info helps you. Do revert back if you
    need more info.
    Kind Regards
    Eswar

  • Creating sales order using bapi

    while creating sales order using bapi serial no is added in dat but its not saving.
    plz reply

    Hi
    See tha sample code for sales order creation
    SALES ORDER INPUT CREATION.
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    PARAMETERS: p_spart TYPE vtweg OBLIGATORY.
    PARAMETERS: p_sold TYPE kunnr OBLIGATORY.
    PARAMETERS: p_ship TYPE kunnr OBLIGATORY.
    *ITEM
    PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
    PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.
    PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.
    DATA DECLARATIONS.
    DATA: v_vbeln LIKE vbak-vbeln.
    DATA: header LIKE bapisdhead1.
    DATA: headerx LIKE bapisdhead1x.
    DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
    DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
    DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
    DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
    DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
    WITH HEADER LINE.
    DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
    WITH HEADER LINE.
    HEADER DATA
    header-doc_type = p_auart.
    headerx-doc_type = 'X'.
    header-sales_org = p_vkorg.
    headerx-sales_org = 'X'.
    header-distr_chan = p_vtweg.
    headerx-distr_chan = 'X'.
    header-division = p_spart.
    headerx-division = 'X'.
    headerx-updateflag = 'I'.
    PARTNER DATA
    partner-partn_role = 'AG'.
    partner-partn_numb = p_sold.
    APPEND partner.
    partner-partn_role = 'WE'.
    partner-partn_numb = p_ship.
    APPEND partner.
    ITEM DATA
    itemx-updateflag = 'I'.
    item-itm_number = '000010'.
    itemx-itm_number = 'X'.
    item-material = p_matnr.
    itemx-material = 'X'.
    item-plant = p_plant.
    itemx-plant = 'X'.
    item-target_qty = p_menge.
    itemx-target_qty = 'X'.
    item-target_qu = 'EA'.
    itemx-target_qu = 'X'.
    item-item_categ = p_itcat.
    itemx-item_categ = 'X'.
    APPEND item.
    APPEND itemx.
    Fill schedule lines
    lt_schedules_in-itm_number = '000010'.
    lt_schedules_in-sched_line = '0001'.
    lt_schedules_in-req_qty = p_menge.
    APPEND lt_schedules_in.
    Fill schedule line flags
    lt_schedules_inx-itm_number = '000010'.
    lt_schedules_inx-sched_line = '0001'.
    lt_schedules_inx-updateflag = 'X'.
    lt_schedules_inx-req_qty = 'X'.
    APPEND lt_schedules_inx.
    Call the BAPI
    CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
    EXPORTING
    sales_header_in = header
    sales_header_inx = headerx
    IMPORTING
    salesdocument_ex = v_vbeln
    TABLES
    return = return
    sales_items_in = item
    sales_items_inx = itemx
    sales_schedules_in = lt_schedules_in
    sales_schedules_inx = lt_schedules_inx
    sales_partners = partner.
    Check the return table.
    LOOP AT return WHERE type = 'E' OR type = 'A'.
    EXIT.
    ENDLOOP.
    IF sy-subrc = 0.
    WRITE: / 'Error in creating document'.
    ELSE.
    COMMIT WORK AND WAIT.
    WRITE: / 'Document ', v_vbeln, ' created'.
    ENDIF.
    after that check in the table VBAP whether serial number is cretaed or not
    Reward points if useful
    Regards
    Anji

  • HOW TO CREATE PURCHASE ORDER USING BAPI

    HI FRIENDS,
    I HAVE URGENT REQUIREMNT ,TO CREATE PURCHASE ORDER USING BAPI.PLS HELP ON THIS.
    UR'S
    RAVI

    Hi
    See the sample code and do accordingly
    REPORT zpo_bapi_purchord_tej.
    DATA DECLARATIONS *
    TYPE-POOLS slis.
    TYPES: BEGIN OF ty_table,
    v_legacy(8),
    vendor TYPE bapimepoheader-vendor,
    purch_org TYPE bapimepoheader-purch_org,
    pur_group TYPE bapimepoheader-pur_group,
    material TYPE bapimepoitem-material,
    quantity(13),
    delivery_date TYPE bapimeposchedule-delivery_date,
    net_price(23),
    plant TYPE bapimepoitem-plant,
    END OF ty_table.
    TYPES: BEGIN OF ty_alv,
    v_legs(8),
    success(10),
    v_legf(8),
    END OF ty_alv.
    TYPES: BEGIN OF ty_alv1,
    v_legf1(8),
    v_msg(500),
    END OF ty_alv1.
    *-----Work area declarations.
    DATA: x_table TYPE ty_table,
    x_header TYPE bapimepoheader,
    x_headerx TYPE bapimepoheaderx,
    x_item TYPE bapimepoitem,
    x_itemx TYPE bapimepoitemx,
    x_sched TYPE bapimeposchedule,
    x_schedx TYPE bapimeposchedulx,
    x_commatable(255),
    x_alv TYPE ty_alv,
    x_alv1 TYPE ty_alv1,
    x_alv2 TYPE ty_alv1.
    *-----Internal table declarations.
    DATA: it_table TYPE TABLE OF ty_table,
    it_commatable LIKE TABLE OF x_commatable,
    it_item TYPE TABLE OF bapimepoitem,
    it_itemx TYPE TABLE OF bapimepoitemx,
    it_sched TYPE TABLE OF bapimeposchedule,
    it_schedx TYPE TABLE OF bapimeposchedulx,
    it_alv TYPE TABLE OF ty_alv,
    it_alv1 TYPE TABLE OF ty_alv1,
    it_alv2 TYPE TABLE OF ty_alv1.
    DATA: po_number TYPE bapimepoheader-po_number,
    x_return TYPE bapiret2,
    it_return TYPE TABLE OF bapiret2,
    v_file TYPE string,
    v_temp(8),
    v_succsount TYPE i VALUE 0,
    v_failcount TYPE i VALUE 0,
    v_total TYPE i.
    DATA: v_temp1(5) TYPE n VALUE 0.
    DATA: x_event TYPE slis_t_event,
    x_fieldcat TYPE slis_t_fieldcat_alv,
    x_list_header TYPE slis_t_listheader,
    x_event1 LIKE LINE OF x_event,
    x_layout1 TYPE slis_layout_alv,
    x_variant1 TYPE disvariant,
    x_repid2 LIKE sy-repid.
    DATA : it_fieldcat TYPE TABLE OF slis_t_fieldcat_alv.
    SELECTION-SCREEN *
    SELECTION-SCREEN BEGIN OF BLOCK v_b1 WITH FRAME.
    *-----To fetch the flat file.
    PARAMETERS: p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF BLOCK v_b1.
    AT SELECTION-SCREEN *
    AT SELECTION-SCREEN.
    IF p_file IS INITIAL.
    MESSAGE text-001 TYPE 'E'.
    ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    *-----To use F4 help to find file path.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    program_name = syst-cprog
    dynpro_number = syst-dynnr
    IMPORTING
    file_name = p_file.
    v_file = p_file.
    START-OF-SELECTION *
    START-OF-SELECTION.
    PERFORM gui_upload.
    LOOP AT it_table INTO x_table.
    PERFORM header_details.
    v_temp = x_table-v_legacy.
    LOOP AT it_table INTO x_table WHERE v_legacy = v_temp.
    PERFORM lineitem.
    PERFORM schedule.
    ENDLOOP.
    DELETE it_table WHERE v_legacy = v_temp.
    PERFORM bapicall.
    MOVE po_number TO x_alv-success.
    APPEND x_alv TO it_alv.
    CLEAR x_alv.
    *-----To clear the item details in internal table after the operation for a header.
    REFRESH: it_item,
    it_itemx,
    it_sched,
    it_schedx.
    CLEAR: v_temp1.
    ENDLOOP.
    v_total = v_succsount + v_failcount.
    PERFORM display_alv.
    FORM GUI_UPLOAD *
    FORM gui_upload .
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = v_file
    filetype = 'ASC'
    TABLES
    data_tab = it_commatable
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17
    IF sy-subrc = 0.
    *-----To fetch the comma seperated flat file into an internal table.
    LOOP AT it_commatable INTO x_commatable.
    IF x_commatable IS NOT INITIAL.
    SPLIT x_commatable AT ',' INTO
    x_table-v_legacy
    x_table-vendor
    x_table-purch_org
    x_table-pur_group
    x_table-material
    x_table-quantity
    x_table-delivery_date
    x_table-net_price
    x_table-plant.
    APPEND x_table TO it_table.
    ENDIF.
    CLEAR x_table.
    ENDLOOP.
    ENDIF.
    ENDFORM. " gui_upload
    FORM HEADER_DETAILS *
    FORM header_details .
    MOVE 'NB' TO x_header-doc_type.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = x_table-vendor
    IMPORTING
    output = x_table-vendor
    MOVE x_table-vendor TO x_header-vendor.
    MOVE x_table-purch_org TO x_header-purch_org.
    MOVE x_table-pur_group TO x_header-pur_group.
    x_headerx-doc_type = 'X'.
    x_headerx-vendor = 'X'.
    x_headerx-purch_org = 'X'.
    x_headerx-pur_group = 'X'.
    ENDFORM. " header_details
    FORM LINEITEM *
    FORM lineitem .
    v_temp1 = v_temp1 + 10.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = v_temp1
    IMPORTING
    output = v_temp1.
    MOVE v_temp1 TO x_item-po_item.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
    input = x_table-material
    IMPORTING
    output = x_table-material.
    MOVE x_table-material TO x_item-material.
    MOVE x_table-quantity TO x_item-quantity.
    MOVE x_table-net_price TO x_item-net_price.
    MOVE x_table-plant TO x_item-plant.
    x_itemx-po_item = v_temp1.
    x_itemx-material = 'X'.
    x_itemx-quantity = 'X'.
    x_itemx-net_price = 'X'.
    x_itemx-plant = 'X'.
    APPEND x_item TO it_item.
    APPEND x_itemx TO it_itemx.
    CLEAR: x_item, x_itemx.
    ENDFORM. " lineitem1
    FORM SCHEDULE *
    FORM schedule .
    MOVE x_table-delivery_date TO x_sched-delivery_date.
    MOVE v_temp1 TO x_sched-po_item.
    x_schedx-delivery_date = 'X'.
    x_schedx-po_item = v_temp1.
    APPEND x_sched TO it_sched.
    APPEND x_schedx TO it_schedx.
    CLEAR: x_sched, x_schedx.
    ENDFORM. " schedule
    FORM BAPICALL *
    FORM bapicall .
    CALL FUNCTION 'BAPI_PO_CREATE1'
    EXPORTING
    poheader = x_header
    poheaderx = x_headerx
    IMPORTING
    exppurchaseorder = po_number
    TABLES
    return = it_return
    poitem = it_item
    poitemx = it_itemx
    poschedule = it_sched
    poschedulex = it_schedx.
    IF po_number IS NOT INITIAL.
    v_succsount = v_succsount + 1.
    MOVE x_table-v_legacy TO x_alv-v_legs.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ELSE.
    v_failcount = v_failcount + 1.
    MOVE x_table-v_legacy TO x_alv-v_legf.
    MOVE x_table-v_legacy TO x_alv1-v_legf1.
    LOOP AT it_return INTO x_return.
    IF x_alv1-v_msg IS INITIAL.
    MOVE x_return-message TO x_alv1-v_msg.
    ELSE.
    CONCATENATE x_alv1-v_msg x_return-message INTO x_alv1-v_msg SEPARATED BY space.
    ENDIF.
    ENDLOOP.
    APPEND x_alv1 TO it_alv1.
    CLEAR x_alv1.
    ENDIF.
    ENDFORM. " bapicall
    FORM DISPLAY_ALV *
    FORM display_alv .
    PERFORM x_list_header.
    PERFORM build_fieldcat CHANGING x_fieldcat.
    x_repid2 = sy-repid.
    x_event1-name = 'TOP_OF_PAGE'.
    x_event1-form = 'TOP_OF_PAGE'.
    APPEND x_event1 TO x_event.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = x_repid2
    is_layout = x_layout1
    it_fieldcat = x_fieldcat
    i_callback_user_command = 'USER_COMMAND'
    i_callback_top_of_page = 'TOP_OF_PAGE'
    i_save = 'A'
    is_variant = x_variant1
    it_events = x_event
    TABLES
    t_outtab = it_alv
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM. " display_master_data
    FORM USER_COMMAND *
    FORM user_command USING ucomm LIKE sy-ucomm selfield
    TYPE slis_selfield.
    READ TABLE it_alv INTO x_alv INDEX selfield-tabindex.
    CLEAR : x_alv2,it_alv2[].
    LOOP AT it_alv1 INTO x_alv1 WHERE v_legf1 = x_alv-v_legf.
    x_alv2 = x_alv1.
    APPEND x_alv2 TO it_alv2 .
    ENDLOOP.
    DATA : it_fieldcat TYPE slis_t_fieldcat_alv.
    DATA : x3_fieldcat LIKE LINE OF it_fieldcat.
    CLEAR : x3_fieldcat,it_fieldcat[].
    CLEAR x3_fieldcat.
    x3_fieldcat-col_pos = '1'.
    x3_fieldcat-fieldname = 'V_LEGF1'.
    x3_fieldcat-reptext_ddic = text-111.
    x3_fieldcat-ref_tabname = 'IT_ALV2'.
    APPEND x3_fieldcat TO it_fieldcat.
    CLEAR x3_fieldcat.
    CLEAR x3_fieldcat.
    x3_fieldcat-col_pos = '1'.
    x3_fieldcat-fieldname = 'V_MSG'.
    x3_fieldcat-reptext_ddic = text-112.
    x3_fieldcat-ref_tabname = 'IT_ALV2'.
    APPEND x3_fieldcat TO it_fieldcat.
    CLEAR x3_fieldcat.
    x_layout1-colwidth_optimize = 'X'.
    x_layout1-zebra = 'X'.
    IF it_alv2[] IS NOT INITIAL.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    i_callback_program = x_repid2
    is_layout = x_layout1
    it_fieldcat = it_fieldcat
    i_save = 'A'
    i_callback_top_of_page = 'TOP'
    is_variant = x_variant1
    it_events = x_event
    TABLES
    t_outtab = it_alv2
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    ENDIF.
    ENDFORM.
    FORM USER_COMMAND *
    FORM top.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = 'Commentry'.
    ENDFORM.
    FORM BUILD_FIELDCAT *
    FORM build_fieldcat CHANGING et_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: x1_fieldcat TYPE slis_fieldcat_alv.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '1'.
    x1_fieldcat-fieldname = 'V_LEGS'.
    x1_fieldcat-reptext_ddic = text-108.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '2'.
    x1_fieldcat-fieldname = 'SUCCESS'.
    x1_fieldcat-key = 'X'.
    x1_fieldcat-reptext_ddic = text-109.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    x1_fieldcat-col_pos = '3'.
    x1_fieldcat-fieldname = 'V_LEGF'.
    x1_fieldcat-key = 'X'.
    x1_fieldcat-reptext_ddic = text-110.
    x1_fieldcat-ref_tabname = 'IT_ALV'.
    APPEND x1_fieldcat TO et_fieldcat.
    CLEAR x1_fieldcat.
    ENDFORM. " build_fieldcat
    FORM BUILD_LIST_HEADER *
    FORM x_list_header.
    DATA: x_list_header1 TYPE slis_listheader.
    *-----List Header: type H
    CLEAR x_list_header1 .
    x_list_header1-typ = 'H'.
    x_list_header1-info = text-105.
    APPEND x_list_header1 TO x_list_header.
    *-----List Key: type S
    x_list_header1-typ = 'S'.
    x_list_header1-key = text-106.
    x_list_header1-info = v_total.
    APPEND x_list_header1 TO x_list_header.
    *-----List Key: Type S
    CLEAR x_list_header1 .
    x_list_header1-typ = 'S'.
    x_list_header1-key = text-107.
    x_list_header1-info = v_succsount.
    APPEND x_list_header1 TO x_list_header.
    ENDFORM. " build_list_header
    FORM TOP_OF_PAGE *
    FORM top_of_page.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    it_list_commentary = x_list_header.
    ENDFORM. " TOP_OF_PAGE
    Reward points if useful
    Anji

  • How can i create slaes order using BAPI

    hi all,
    i didnt work on BAPIS .how can i create sales order using BAPI here i should pass Z values.
    Moderator message : FAQ, search for available information. Thread locked.
    Edited by: Vinod Kumar on Sep 13, 2011 12:22 PM

    Hi!
    There are a lot of answered threads regarding your question. Try searching first. Below is a sample link.
    BAPI_SALESORDER_CREATEFROMDAT2
    Regards,
    Steph
    Edited by: stephquion on Sep 13, 2011 8:25 AM

  • TO CREATE SALES ORDER USING BAPI PROBLEM

    I am trying to create Sales Order using bapi function, this is giving me error as mentioned below
    *Please enter SHIP-TO-PARTY OR SOLD TO PARTY
    *SALES DOCUMENT WAS NOT CHANGED.
    it does not GIVE ME THE SALES DOCUMENT NO .
    The BAPI I am using is BAPI_SALESORDER_CREATEFROMDAT2.
    Would someone know which parameters I have to papulate,or have any other suggestion
    THE INTERNAL TABLES I AM PASSING TO BAPI FUNCTION ARE
    DATA:  IT_BAPI_HEADER LIKE BAPISDHD1.
    DATA:     IT_BAPI_SOLD_TO_PARTY LIKE BAPIPARNR occurs 0 with header line.
    DATA:  SO_NO LIKE BAPIVBELN-VBELN.
    DATA:  IT_BAPI_ITEMS_IN LIKE BAPISDITM occurs 0 with header line.
    DATA: IT_BAPI_RETURN LIKE BAPIRET2 occurs 0 with header line.
    IS THERE ANYTHING ELSE TO POPULATE OTHER THAN THIS STRUCTURES
    HEADER
          Sales-Document type:      
    *     Sales-Organization
    *     Distrubution-Channel: 
    *     Division          
    PARTNER
            Partner Function     
         Customer Number      
    ITEM DETAIL
             Material Number      
    how to accomplish my task?

    Nandan,
    Please go through the documentation of the BAPI. It gives you details of what needs to be filled in in which structure/parmater. Also, read the documentation associated with each structure, that will tell what to fill.
    It is really hard to explain it in simple terms as to what are required. But, you need the header, items and partners at the minimum. Also, with some of these structures there are also 'X' structures(like ORDER_ITEMS_INX for ORDER_ITEMS_IN) which should also be filled based on what fields you filled in the original structure. For example, if you filled 'MATERIAL' field on the ORDER_ITEMS_IN structure, you should also fill in the same field on the ORDER_ITEMS_INX structure with an 'X' in it.
    All this is well documented in the BAPI.
    Srinivas

  • Create Work Order Using BAPI in LSMW

    Hi All,
    I searched in SCN but i dint get the correct idea to create Work Order USING BAPI,
    Im trying to create Work Order Using BAPI in LSWM
    Can any one Give me Brief Idea to create Work Order(Either Component or Operations) (t code - IW31) using BAPI in LSMW
    Regards
    Smitha

    Hi All,
    I searched in SCN but i dint get the correct idea to create Work Order USING BAPI,
    Im trying to create Work Order Using BAPI in LSWM
    Can any one Give me Brief Idea to create Work Order(Either Component or Operations) (t code - IW31) using BAPI in LSMW
    Regards
    Smitha

  • Create sales order using BAPI

    HI,
    I need to create sales orders using BAPI.
    these sales orders are different sales order type and it need to upload from excel file. anyone send me some sample programs for this one.
    kathir.

    use this code to create salesorder using bapi.
    REPORT z_bapi_salesorder_create.
    Parameters
    Sales document type
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Sales organization
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Distribution channel
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Division.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
    PARAMETERS: p_spart TYPE spart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    Sold-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
    PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Ship-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
    PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    Material
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
    PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Quantity.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
    PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Plant
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
    PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Data declarations.
    DATA: v_vbeln            LIKE vbak-vbeln.
    DATA: header             LIKE bapisdhead1.
    DATA: headerx            LIKE bapisdhead1x.
    DATA: item               LIKE bapisditem  OCCURS 0 WITH HEADER LINE.
    DATA: itemx              LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
    DATA: partner            LIKE bapipartnr  OCCURS 0 WITH HEADER LINE.
    DATA: return             LIKE bapiret2    OCCURS 0 WITH HEADER LINE.
    DATA: lt_schedules_inx   TYPE STANDARD TABLE OF bapischdlx
                             WITH HEADER LINE.
    DATA: lt_schedules_in    TYPE STANDARD TABLE OF bapischdl
                             WITH HEADER LINE.
    Initialization.
    INITIALIZATION.
    v_text   = 'Order type'.
    v_text1  = 'Sales Org'.
    v_text2  = 'Distribution channel'.
    v_text3  = 'Division'.
    v_text4  = 'Sold-to'.
    v_text5  = 'Ship-to'.
    v_text6  = 'Material'.
    v_text7  = 'Quantity'.
    v_text9  = 'Plant'.
    Start-of-selection.
    START-OF-SELECTION.
    Header data
    Sales document type
      header-doc_type = p_auart.
      headerx-doc_type = 'X'.
    Sales organization
      header-sales_org = p_vkorg.
      headerx-sales_org = 'X'.
    Distribution channel
      header-distr_chan  = p_vtweg.
      headerx-distr_chan = 'X'.
    Division
      header-division = p_spart.
      headerx-division = 'X'.
      headerx-updateflag = 'I'.
    Partner data
    Sold to
      partner-partn_role = 'AG'.
      partner-partn_numb = p_sold.
      APPEND partner.
    Ship to
      partner-partn_role = 'WE'.
      partner-partn_numb = p_ship.
      APPEND partner.
    ITEM DATA
      itemx-updateflag = 'I'.
    Line item number.
      item-itm_number = '000010'.
      itemx-itm_number = 'X'.
    Material
      item-material = p_matnr.
      itemx-material = 'X'.
    Plant
      item-plant    = p_plant.
      itemx-plant   = 'X'.
    Quantity
      item-target_qty = p_menge.
      itemx-target_qty = 'X'.
      APPEND item.
      APPEND itemx.
      Fill schedule lines
      lt_schedules_in-itm_number = '000010'.
      lt_schedules_in-sched_line = '0001'.
      lt_schedules_in-req_qty    = p_menge.
      APPEND lt_schedules_in.
      Fill schedule line flags
      lt_schedules_inx-itm_number  = '000010'.
      lt_schedules_inx-sched_line  = '0001'.
      lt_schedules_inx-updateflag  = 'X'.
      lt_schedules_inx-req_qty     = 'X'.
      APPEND lt_schedules_inx.
    Call the BAPI to create the sales order.
      CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
           EXPORTING
                sales_header_in     = header
                sales_header_inx    = headerx
           IMPORTING
                salesdocument_ex    = v_vbeln
           TABLES
                return              = return
                sales_items_in      = item
                sales_items_inx     = itemx
                sales_schedules_in  = lt_schedules_in
                sales_schedules_inx = lt_schedules_inx
                sales_partners      = partner.
    Check the return table.
      LOOP AT return WHERE type = 'E' OR type = 'A'.
        EXIT.
      ENDLOOP.
      IF sy-subrc = 0.
        WRITE: / 'Error in creating document'.
      ELSE.
    Commit the work.
        COMMIT WORK AND WAIT.
        WRITE: / 'Document ', v_vbeln, ' created'.
    bye

  • PS Project description when creating sales order using BAPI

    I am trying to create sales orders using BAPI_SALESORDER_CREATE_FROMDAT2.
    Because of the material configuration in table TCN61 the material will trigger a project creation in the project system.
    Now, in order to create a project, we must provide the project description.
    I would like to ask you if anyone knows how to pass the project description in one of the BAPI parameters.
    Thank you for your help.

    Thank you Sreedhar for the answer.
    I tried the CAMPAIGN field but did not work...
    In fact, I am not able to find a field, in any of the of the tables, that could hold the project description (PROJ-POST1).
    An entry is created in PROJ table when we manually create a sales order for materials specified in table TCN61.
    Thanks.

  • ISSUE ON CREATE SALES ORDER USING BAPI

    Hi,
       I am creating a sales order using bapi BAPI_SALESORDER_CREATEFROMDAT2.But it it fails to create a sales order abd below is my code pls check and correct me to create a sales order.
    LOOP AT DATA_TAB.
    clear: l_order_header_in,
           l_salesdocument,
           l_order_partners,
           l_order_items_IN,
           l_order_schedules_IN.
    refresh: l_order_items_in,
             l_order_partners,
             l_order_schedules_IN,
             l_return.
    Order header
    l_order_header_in-DOC_TYPE    = DATA_TAB-AUART.
    l_order_header_IN-SALES_ORG   = DATA_TAB-VKORG.
    l_order_header_IN-DISTR_CHAN  = data_tab-vtweg.
    l_order_header_in-division    = DATA_TAB-SPART.
    l_order_header_in-REF_1_S     = DATA_TAB-IHREZ_E.
    l_order_header_in-PURCH_NO_S  = DATA_TAB-BSTKD_E.
    l_order_header_in-PO_DAT_S    = data_tab-bstdk_e.
    l_order_header_in-PO_METH_S   = DATA_TAB-BSARK_E.
    l_order_header_in-DOC_DATE    = DATA_TAB-AUDAT.
    l_order_header_in-REC_POINT   = DATA_TAB-EMPST.
    l_order_header_inX-DOC_TYPE    = 'X'.
    l_order_header_INX-SALES_ORG   = 'X'.
    l_order_header_INX-DISTR_CHAN  = 'X'.
    l_order_header_inX-division    = 'X'.
    l_order_header_inX-REF_1_S     = 'X'.
    l_order_header_inX-PURCH_NO_S  = 'X'.
    l_order_header_inX-PO_DAT_S    = 'X'.
    l_order_header_inX-PO_METH_S   = 'X'.
    l_order_header_inX-DOC_DATE    = 'X'.
    l_order_header_inX-REC_POINT   = 'X'.
    Partner data SOLD TO PARTY
    l_order_partners-ITM_NUMBER = DATA_TAB-POSNR.
    l_order_partners-partn_role = 'SP'.
    l_order_partners-partn_numb = DATA_TAB-kunnr1.
    append l_ordeR_partners.
    Partner data SHOP TO PARTY
    l_order_partners-ITM_NUMBER = DATA_TAB-POSNR.
    l_order_partners-partn_role = 'SH'.
    l_order_partners-partn_numb = DATA_TAB-kunnr2.
    append l_ordeR_partners.
    Order items
    l_order_items_IN-ITM_NUMBER = DATA_TAB-POSNR.
    l_order_items_IN-material   = DATA_TAB-MABNR.
    l_order_items_IN-BATCH      = DATA_TAB-CHARG.
    l_order_items_IN-REASON_REJ = DATA_TAB-ABGRU.
    append l_order_items_IN.
    l_order_items_INX-ITM_NUMBER = DATA_TAB-POSNR.
    l_order_items_INX-material   = 'X'.
    l_order_items_INX-BATCH      = 'X'.
    l_order_items_INX-REASON_REJ = 'X'.
    append l_order_items_INX.
    Schedules for quantity
    l_order_schedules_IN-itm_number = DATA_TAB-POSNR.
    l_order_schedules_IN-req_qty    = DATA_TAB-KWMENG.
    append l_order_schedules_IN.
    Schedules for quantity
    l_order_schedules_INX-itm_number = data_tab-posnr.
    l_order_schedules_INX-req_qty    =  'X'.
    append l_order_schedules_INX.
    Conditions for value
    l_order_conditions_IN-itm_number = DATA_TAB-POSNR.
    l_order_conditions_IN-cond_type  = DATA_TAB-KSCHL.
    l_order_conditions_IN-cond_value = DATA_TAB-KBETR.
    l_order_conditions_IN-currency   = DATA_TAB-KOEIN.
    append l_order_conditions_IN.
    Conditions for value
    l_order_conditions_INX-itm_number = DATA_TAB-POSNR.
    l_order_conditions_INX-cond_type  = 'X'.
    l_order_conditions_INX-cond_value = 'X'.
    l_order_conditions_INX-currency   = 'X'.
    append l_order_conditions_INX .
    endloop.
    BAPI to create sales order
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
    EXPORTING
    SALESDOCUMENTIN =
      ORDER_HEADER_IN =      l_order_header_IN
      ORDER_HEADER_INX =     l_order_header_INX
    IMPORTING
      SALESDOCUMENT =        l_salesdocument
    TABLES
      RETURN =               l_return
      ORDER_ITEMS_IN =       l_order_items_IN
      ORDER_ITEMS_INX =      l_order_items_INX
      ORDER_PARTNERS =       l_order_partners
      ORDER_SCHEDULES_IN =   l_order_schedules_in
      ORDER_SCHEDULES_INX =  l_order_schedules_inX
      ORDER_CONDITIONS_IN =  l_order_conditions_in
      ORDER_CONDITIONS_INX = l_order_conditions_inX
    IF SY-SUBRC = 0.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
       WAIT           = C_X
    IMPORTING
      RETURN        =
    ENDIF.
      Pls help me to solve the issue.
    Thanks,
    Rajendra.

    Hi Raj
    This is the sameple code which works fine for me,
    REPORT  zkb_sales_order.
    DATA: w_order_header_in TYPE bapisdhd1,
          i_order_partners TYPE TABLE OF bapiparnr,
          w_order_partners TYPE bapiparnr,
          i_return TYPE TABLE OF bapiret2,
          w_return TYPE bapiret2,
         i_order_items_in TYPE TABLE OF bapisditm,
         w_order_items_in TYPE  bapisditm,
         i_order_items_inx TYPE TABLE OF  bapisditmx,
         w_order_items_inx TYPE  bapisditmx,
        i_order_conditions_in TYPE TABLE OF bapicond,
        w_order_conditions_in TYPE bapicond,
        i_order_conditions_inx TYPE TABLE OF bapicondx,
        w_order_conditions_inx TYPE TABLE OF bapicondx.
    CLEAR w_order_header_in.
    w_order_header_in-doc_type  = 'ZSO'.
    w_order_header_in-sales_org =  '1000'.
    w_order_header_in-distr_chan = '01'.
    w_order_header_in-division =  '01'.
    w_order_header_in-req_date_h  = sy-datum.
    w_order_header_in-sales_dist =   '000001'.
    CLEAR: i_order_items_in,w_order_items_in.
    w_order_items_in-material = 77.
    w_order_items_in-salqtynum = 1.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = w_order_items_in-material
      IMPORTING
        output = w_order_items_in-material.
    APPEND w_order_items_in TO i_order_items_in.
    * SP
    CLEAR: i_order_partners,w_order_partners.
    w_order_partners-partn_role = 'AG'.
    w_order_partners-partn_numb = '2000016'.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        input  = w_order_partners-partn_numb
      IMPORTING
        output = w_order_partners-partn_numb.
    APPEND w_order_partners TO i_order_partners.
    CLEAR: i_order_conditions_in,w_order_conditions_in.
    w_order_conditions_in-itm_number =  '000010'.
    w_order_conditions_in-cond_type  =   'PR00'.
    w_order_conditions_in-cond_value =  100.
    APPEND w_order_conditions_in TO i_order_conditions_in.
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
      EXPORTING
    *   SALESDOCUMENTIN               =
        order_header_in               = w_order_header_in
    *   ORDER_HEADER_INX              =
    *   SENDER                        =
    *   BINARY_RELATIONSHIPTYPE       =
    *   INT_NUMBER_ASSIGNMENT         =
    *   BEHAVE_WHEN_ERROR             =
    *   LOGIC_SWITCH                  =
    *   TESTRUN                       =
    *   CONVERT                       = ' '
    * IMPORTING
    *   SALESDOCUMENT                 =
      TABLES
       return                        = i_return
       order_items_in                = i_order_items_in
    *   ORDER_ITEMS_INX               =
        order_partners                = i_order_partners
    *   ORDER_SCHEDULES_IN            =
    *   ORDER_SCHEDULES_INX           =
       order_conditions_in           = i_order_conditions_in
    *   ORDER_CONDITIONS_INX          =
    *   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                    =
    *   ORDER_KEYS                    =
    *   EXTENSIONIN                   =
    *   PARTNERADDRESSES              =
    READ TABLE i_return INTO w_return WITH KEY type = 'E'.
    IF sy-subrc NE 0.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    ENDIF.
    LOOP AT i_return INTO w_return .
      WRITE: / w_return-type,
      w_return-id,
      w_return-number,
      w_return-message.
    ENDLOOP.
    Regards
    Kathirvel

  • How to create sales order using BAPI.

    Hi all,
    I am trying to create sales order using standard BAPI
    "BAPI_SALESORDER_CREATEFROMDAT2". But, even I had entered all mandatory fields, I am unable to create sales order sucessfully.
    I had gone through the documentaion of this BAPI and entered these fields.
    These are the mandatory fields that which I had tried to create,
    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
    Do we have anymore fields to give as inputs? I am getting this error message as below :
    Msg: Personal number 00007176 does not exit.
    But, I am not giving any personal number manually. This personal number was having connection with partner role field,
    I had reffered this from the VBPA (Sales Document: Partner Table). Now, please suggest me how to solve this?
    Can anyone tell me how to solve this problem and create sales order sucessfully.
    Thanks in advance,
    Surender Batlanki.

    hi surendra ,
    chech with below code.
    REPORT z_bapi_salesorder_create.
    Parameters
    Sales document type
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text FOR FIELD p_auart.
    PARAMETERS: p_auart TYPE auart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Sales organization
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text1 FOR FIELD p_vkorg.
    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Distribution channel
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text2 FOR FIELD p_vtweg.
    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Division.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text3 FOR FIELD p_spart.
    PARAMETERS: p_spart TYPE spart OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    Sold-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text4 FOR FIELD p_sold.
    PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Ship-to
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text5 FOR FIELD p_ship.
    PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SKIP 1.
    Material
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text6 FOR FIELD p_matnr.
    PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Quantity.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text7 FOR FIELD p_menge.
    PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Plant
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 2(20) v_text9 FOR FIELD p_plant.
    PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    Data declarations.
    DATA: v_vbeln            LIKE vbak-vbeln.
    DATA: header             LIKE bapisdhead1.
    DATA: headerx            LIKE bapisdhead1x.
    DATA: item               LIKE bapisditem  OCCURS 0 WITH HEADER LINE.
    DATA: itemx              LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
    DATA: partner            LIKE bapipartnr  OCCURS 0 WITH HEADER LINE.
    DATA: return             LIKE bapiret2    OCCURS 0 WITH HEADER LINE.
    DATA: lt_schedules_inx   TYPE STANDARD TABLE OF bapischdlx
                             WITH HEADER LINE.
    DATA: lt_schedules_in    TYPE STANDARD TABLE OF bapischdl
                             WITH HEADER LINE.
    Initialization.
    INITIALIZATION.
    v_text   = 'Order type'.
    v_text1  = 'Sales Org'.
    v_text2  = 'Distribution channel'.
    v_text3  = 'Division'.
    v_text4  = 'Sold-to'.
    v_text5  = 'Ship-to'.
    v_text6  = 'Material'.
    v_text7  = 'Quantity'.
    v_text9  = 'Plant'.
    Start-of-selection.
    START-OF-SELECTION.
    Header data
    Sales document type
      header-doc_type = p_auart.
      headerx-doc_type = 'X'.
    Sales organization
      header-sales_org = p_vkorg.
      headerx-sales_org = 'X'.
    Distribution channel
      header-distr_chan  = p_vtweg.
      headerx-distr_chan = 'X'.
    Division
      header-division = p_spart.
      headerx-division = 'X'.
      headerx-updateflag = 'I'.
    Partner data
    Sold to
      partner-partn_role = 'AG'.
      partner-partn_numb = p_sold.
      APPEND partner.
    Ship to
      partner-partn_role = 'WE'.
      partner-partn_numb = p_ship.
      APPEND partner.
    ITEM DATA
      itemx-updateflag = 'I'.
    Line item number.
      item-itm_number = '000010'.
      itemx-itm_number = 'X'.
    Material
      item-material = p_matnr.
      itemx-material = 'X'.
    Plant
      item-plant    = p_plant.
      itemx-plant   = 'X'.
    Quantity
      item-target_qty = p_menge.
      itemx-target_qty = 'X'.
      APPEND item.
      APPEND itemx.
      Fill schedule lines
      lt_schedules_in-itm_number = '000010'.
      lt_schedules_in-sched_line = '0001'.
      lt_schedules_in-req_qty    = p_menge.
      APPEND lt_schedules_in.
      Fill schedule line flags
      lt_schedules_inx-itm_number  = '000010'.
      lt_schedules_inx-sched_line  = '0001'.
      lt_schedules_inx-updateflag  = 'X'.
      lt_schedules_inx-req_qty     = 'X'.
      APPEND lt_schedules_inx.
    Call the BAPI to create the sales order.
      CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
           EXPORTING
                sales_header_in     = header
                sales_header_inx    = headerx
           IMPORTING
                salesdocument_ex    = v_vbeln
           TABLES
                return              = return
                sales_items_in      = item
                sales_items_inx     = itemx
                sales_schedules_in  = lt_schedules_in
                sales_schedules_inx = lt_schedules_inx
                sales_partners      = partner.
    Check the return table.
      LOOP AT return WHERE type = 'E' OR type = 'A'.
        EXIT.
      ENDLOOP.
      IF sy-subrc = 0.
        WRITE: / 'Error in creating document'.
      ELSE.
    Commit the work.
        COMMIT WORK AND WAIT.
        WRITE: / 'Document ', v_vbeln, ' created'.
      ENDIF.
    let us know if you have any qauistions.
    ~linganna

  • How to Create Sales Order using BAPI with Variant configurations

    Hi All,
    I need to create a sales order using BAPI BAPI_SALESORDER_CREATEFROMDAT2 with Varaint confiugartions. I will get Header ITEM and variant configuration items in the flat file. Kindly help me in this regard.
    One more thing, is there any way to findout all the Varaint classifications for a particular Material?
    I have done the below coding. Sales order is getting created but variant configurations are not populating.
    *...Configuration: Reference Data
    DATA: gt_order_cfgs_ref TYPE TABLE OF bapicucfg,
          wa_order_cfgs_ref TYPE bapicucfg.
    *...Configuration: Instances
    DATA: gt_order_cfgs_inst TYPE TABLE OF bapicuins,
          wa_order_cfgs_inst TYPE bapicuins.
    *...Configuration: Part-of Specifications
    DATA: gt_order_cfgs_part_of TYPE TABLE OF bapicuprt,
          wa_order_cfgs_part_of TYPE bapicuprt     .
    *...Configuration: Characteristic Values
    DATA: gt_order_cfgs_value TYPE TABLE OF bapicuval,
          wa_order_cfgs_value TYPE bapicuval.
    *...Configuration: BLOB Internal Data (SCE)
    DATA: gt_order_cfgs_blob TYPE TABLE OF bapicublb  ,
          wa_order_cfgs_blob TYPE bapicublb.
    *...Configuration: Variant Condition Key
    DATA: gt_order_cfgs_vk TYPE TABLE OF bapicuvk,
          wa_order_cfgs_vk TYPE bapicuvk.
    *...Configuration: Reference Item / Instance
    DATA: gt_order_cfgs_refinst TYPE TABLE OF bapicuref,
          wa_order_cfgs_refinst TYPE bapicuref.
    *...Configuration: Reference Data
      wa_order_cfgs_ref-posex = '10'.
      wa_order_cfgs_ref-config_id = '1'.
      wa_order_cfgs_ref-root_id = '1'.
      wa_order_cfgs_ref-SCE = '1'.
      wa_order_cfgs_ref-CBASE_ID_TYPE = 'G'.
      wa_order_cfgs_ref-CONSISTENT = 'T'.
      wa_order_cfgs_ref-COMPLETE = 'T'.
      APPEND wa_order_cfgs_ref TO gt_order_cfgs_ref.
    *..2nd item
      wa_order_cfgs_ref-posex = '20'.
      wa_order_cfgs_ref-config_id = '2'.
      wa_order_cfgs_ref-root_id = '1'.
      wa_order_cfgs_ref-SCE = '1'.
      wa_order_cfgs_ref-CBASE_ID_TYPE = 'G'.
      wa_order_cfgs_ref-CONSISTENT = 'T'.
      wa_order_cfgs_ref-COMPLETE = 'T'.
      APPEND wa_order_cfgs_ref TO gt_order_cfgs_ref.
    *...Configuration: Instances
      wa_order_cfgs_inst-config_id = '1'.
      wa_order_cfgs_inst-inst_id = '1'.
      wa_order_cfgs_inst-obj_type = 'MARA'.
      wa_order_cfgs_inst-class_type = '300'.
      wa_order_cfgs_inst-obj_key = '2021B'.
      wa_order_cfgs_inst-quantity = 1.
      wa_order_cfgs_inst-PERSIST_ID_TYPE = 'G'.
      wa_order_cfgs_inst-CONSISTENT = 'T'.
      wa_order_cfgs_inst-COMPLETE = 'T'.
      APPEND wa_order_cfgs_inst TO gt_order_cfgs_inst.
    *..2nd item
      wa_order_cfgs_inst-config_id = '2'.
      wa_order_cfgs_inst-inst_id = '1'.
      wa_order_cfgs_inst-obj_type = 'MARA'.
      wa_order_cfgs_inst-class_type = '300'.
      wa_order_cfgs_inst-obj_key = '2021B'.
      wa_order_cfgs_inst-quantity = 1.
      wa_order_cfgs_inst-PERSIST_ID_TYPE = 'G'.
      wa_order_cfgs_inst-CONSISTENT = 'T'.
      wa_order_cfgs_inst-COMPLETE = 'T'.
      APPEND wa_order_cfgs_inst TO gt_order_cfgs_inst.
    *...Configuration: Characteristic Values
      wa_order_cfgs_value-config_id = '1'.
      wa_order_cfgs_value-inst_id = '1'.
      wa_order_cfgs_value-charc = 'BASIC_MACHINE'.
      wa_order_cfgs_value-value = 'L28'.
      wa_order_cfgs_value-VALCODE = '1'.
      APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
      wa_order_cfgs_value-config_id = '1'.
      wa_order_cfgs_value-inst_id = '1'.
      wa_order_cfgs_value-charc = 'BUCKET'.
      wa_order_cfgs_value-value = 'PL1001'.
      wa_order_cfgs_value-VALCODE = '1'.
      APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
    *..2nd item
      wa_order_cfgs_value-config_id = '2'.
      wa_order_cfgs_value-inst_id = '1'.
      wa_order_cfgs_value-charc = 'BUCKET_FOC'.
      wa_order_cfgs_value-value = '023OP0049'.
      wa_order_cfgs_value-VALCODE = '1'.
      APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
      wa_order_cfgs_value-config_id = '2'.
      wa_order_cfgs_value-inst_id = '1'.
      wa_order_cfgs_value-charc = 'BUCKET_HOE'.
      wa_order_cfgs_value-value = '028MS0004'.
      wa_order_cfgs_value-VALCODE = '1'.
      APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
    wa_order_cfgs_value-config_id = '2'.
    wa_order_cfgs_value-inst_id = '1'.
    wa_order_cfgs_value-charc = 'TYRE_PRESSURE_GAUGE'.
    wa_order_cfgs_value-value = '81004402'.
    APPEND wa_order_cfgs_value TO gt_order_cfgs_value.
    *...Configuration: Reference Item / Instance
      wa_order_cfgs_refinst-posex = '10'.
      wa_order_cfgs_refinst-config_id = '1'.
      wa_order_cfgs_refinst-inst_id = '1'.
      APPEND wa_order_cfgs_refinst TO gt_order_cfgs_refinst.
    *..2nd item
      wa_order_cfgs_refinst-posex = '20'.
      wa_order_cfgs_refinst-config_id = '2'.
      wa_order_cfgs_refinst-inst_id = '1'.
      APPEND wa_order_cfgs_refinst TO gt_order_cfgs_refinst.
    Regards,
    Rajesh

    Hi all,
    Please help me in solving the issue.
    Rajesh

  • How to create sales order using bapi( test purpose)

    Hi all,
           while i was creating sales order using the BAPI_SALESORDER_CREATEFROMDAT1 it is giving some error,
    version 0 is not defined for the fiscal year ****.
    I have given the fallowing parameters as input
    ORDER_HEADER_IN
         DOC_TYPE     OR
                    SALES_ORG  1000
         DISTR_CHAN  10
                    DIVISION         00
    ORDER_PATNERS
         PARTN_ROLE     SP
         PARTN_NUMB     1000
    ORDER_ITEMSIN
         MATERIAL     M-13
    I need to create sample sales order . Please help me how to create sales order with an example( for test purpose).
    Regards
    Deviprasad.

    Hi Prasad,
    Try using BAPI_SALESORDER_CREATEFROMDAT2.
    While creating sales order using FM: BAPI_SALESORDER_CREATEFROMDAT2, please make sure ORDER_ITEMS_IN, ORDER_ITEMS_INX, ORDER_SCHEDULES_IN, ORDER_SCHEDULES_INX.
    Pricing Conditions will not be mandatory to create a sales order via BAPI.
    As you were saying, you can create a sales order but not with items. Do populate the internal tables that i have specified above.
    Also try to pass the item number internally, this will help you in identifying the schedule lines.
    Regards,
    Priyanka.

  • Problem while creating sales order using BAPI

    Hi all,
    i am creating a sales order from the purchase order data.
    when my client will send a PO in EDI format, my 3rd party edi tool will convert that edi formatted PO to text format. then i will upload that text formatted PO to my program then i will create a SO from those uploaded PO data using BAPI BAPI_SALESORDER_CREATEFROMDAT2.
      but,no sales order is being created.& also i am not getting any return message.by debugging also, i am not getting the error.plz suggest where i am doing mistake.below is the coding.
    DATA:
      gfilename LIKE rlgrap-filename.
    *--Internal tables
    DATA: BEGIN OF i_item OCCURS 50.    "Create Material Document Item
            INCLUDE STRUCTURE BAPISDITM .
    DATA: END OF i_item .
    DATA: BEGIN OF i_partner OCCURS 20.  "Return parameter
            INCLUDE STRUCTURE BAPIPARNR.
    DATA: END OF i_partner.
    DATA: BEGIN OF i_schedule OCCURS 20.  "Return parameter
            INCLUDE STRUCTURE BAPISCHDL .
    DATA: END OF i_schedule.
    DATA: BEGIN OF i_cond OCCURS 20.  "Return parameter
            INCLUDE STRUCTURE BAPICOND .
    DATA: END OF i_cond.
    DATA: BEGIN OF i_part OCCURS 0,     " Internal table for split data
            part(20),
          END OF i_part.
    DATA: BEGIN OF i_return OCCURS 20.  "Return parameter
            INCLUDE STRUCTURE bapiret2.
    DATA: END OF i_return.
    *-- Work areas
    DATA: BEGIN OF wa_header .       "sales Document Header Data
            INCLUDE STRUCTURE BAPISDHD1.
    DATA: END OF wa_header .
    *DATA: BEGIN OF wa_return .       "Output Structure
           INCLUDE STRUCTURE BAPIRET2.
    *DATA: END OF wa_return .
    DATA: begin of sorder.
         INCLUDE STRUCTURE BAPIVBELN.
    DATA: end of sorder.
    data:begin of t_upload,
         ebeln(10),  "PO no(seagate)
         aedat like sy-datum , "PO date
         bsart(4) , "PO type
         vdatu like sy-datum , "requested delivery date
         kunnr(10) , "customer no-sold-to-party
        kunak like vbak-kunnr, "bill-to-party
         name1_s(20), "name1 of sold-to-party
         name2_s(15), "name2 of sold-to-party
         land1_s(3), "country
         ort01_s(10),  "city
         regio_s(3), "region(state/province)
         pstlz_s(10), "postal code
         adrnr_s(10), "address
         bstkd_e(10), "end customer purchase order
         posex(6),     "end customer PO line no(item no)
         kdmat(18),     "end customer material no(part no)
         kunag(10),     "ship-to-party
         name1_c(20),   "name1 of ship-to-party
         name2_c(15),   "name2 of ship-to-party
         land1_c(3),   "country
         ort01_c(10),    "city
         regio_c(3),   "region(state/province)
         pstlz_c(10),   "postal code
         adrnr_c(10),   "address
         posnr(6), "item no(seagate PO line no)
         pstyv(4), "item category
         matnr(18), "material no(seagate 9 digit part no)
         zmeng(13), "Target quantity in sales unit
        vrkme like vbap-vrkme, "sales unit
         meins(3), "UOM
        posnr_tot like vbap-posnr,"Total no. of line items
         werks(4), "plant
        vstel like vbap-vstel, "shipping point
         empst(10), "receiving point
         shtyp(4), "shipment type
         route(6), "route
         vsbed(2), "shipping conds
        rkfkf like vbap-rkfkf, "method of billing for co/ppc orders
         zterm(4), "terms of payment key
         inco1(3), "F.O.B inco term1
         inco2(3), "F.O.B inco term2
         end of t_upload.
    Data: wa_upload like t_upload,
           i_upload like standard table of t_upload.
    Data:v_kunnr like kna1-kunnr,
          v_posnr like vbap-posnr,
          v_matnr like vbap-matnr,
          v_zmeng like vbap-zmeng,
          v_kunag like kna1-kunnr.
    *---Constants
    CONSTANTS: c_comma TYPE c VALUE ',',   " For splitting data at commas
               c_01(2) TYPE c VALUE '01',  " For movement code in Bapi
               c_b     TYPE c VALUE 'B',   " For mvt. Indicator in Bapi
               c_creat(5) TYPE c VALUE 'CREAT', " For button text
               c_clear(5) TYPE c VALUE 'CLEAR', " For clear button
               c_mvmt(4) TYPE c VALUE 'MVMT',
               c_ok(2)   TYPE c VALUE 'OK',
               c_error(5) TYPE c VALUE 'Error'.
    *--SELECTION SCREEN DESIGN--
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
    PARAMETERS:     
                p_auart LIKE vbak-auart, " order type
                p_vkorg LIKE vbak-vkorg, " sales org
                p_vtweg LIKE vbak-vtweg, " dist channel
                p_spart LIKE vbak-spart, " division
                p_vkgrp LIKE vbak-vkgrp, " sales group
                p_vkbur LIKE vbak-vkbur, "sales office
                p_file(256) default 'c:/saleorder.txt'.         "File name
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION-SCREEN PUSHBUTTON 15(10) v_create USER-COMMAND creat.
    SELECTION-SCREEN PUSHBUTTON 40(10) v_clear USER-COMMAND clear.
      INITIALIZATION -
    INITIALIZATION.
      v_create = c_creat .
      v_clear = c_clear.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    PERFORM selectfile USING p_file.
    *--AT SELECTION_SCREEN--
    AT SELECTION-SCREEN .
      IF sy-ucomm = c_clear.
        PERFORM f_clear.
    ELSE.
       IF sy-ucomm <> c_mvmt.
    **--- Validating the input data.
         PERFORM f_check_inputs.
        ELSEif sy-ucomm = c_creat.
    *--- Validating the input data.
          PERFORM f_check_inputs.
    *-- Uploading the PO data.
          PERFORM f_PO_upload.
    *---checking the PO data
         PERFORM f_check_upload_data.
    *---create sales order from PO data
        PERFORM f_Sales_order_create.
        ENDIF.
    FORM f_PO_upload.
    gfilename = p_file.
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                filename                = gfilename
                filetype                = 'DAT'
           TABLES
                data_tab                = i_upload
           EXCEPTIONS
                conversion_error        = 1
                file_open_error         = 2
                file_read_error         = 3
                invalid_type            = 4
                no_batch                = 5
                unknown_error           = 6
                invalid_table_width     = 7
                gui_refuse_filetransfer = 8
                customer_error          = 9
                OTHERS                  = 10.
      IF sy-subrc <> 0.
        MESSAGE i398(00) WITH '(WS_UPLOAD)'
        ' Errors occured with exception '
         sy-subrc.
      ENDIF.
    ENDFORM.                    " f_PO_upload
    *&      Form  selectfile
          text
         -->P_P_FILE  text
    FORM selectfile CHANGING value(filename) TYPE c.
    CALL FUNCTION 'WS_FILENAME_GET'
           EXPORTING
                def_filename     = gfilename
                def_path         = 'C:\'
                mask             = ',*.txt.'
                mode             = 'O'
                title            = 'Select File Name'
           IMPORTING
                filename         = filename
           EXCEPTIONS
                inv_winsys       = 1
                no_batch         = 2
                selection_cancel = 3
                selection_error  = 4
                OTHERS           = 5.
    ENDFORM.                    " selectfile
    FORM f_Sales_order_create.
      PERFORM f_fill_header.
      PERFORM f_fill_partner.
      PERFORM f_fill_item.
      PERFORM f_call_BAPI.
    ENDFORM.                    " f_Sales_order_create
    *&      Form  f_fill_header
          text
    -->  p1        text
    <--  p2        text
    FORM f_fill_header.
    move p_auart to wa_header-doc_type.
    move p_vkorg to wa_header-sales_org.
    move p_vtweg to wa_header-distr_chan.
    move p_spart to wa_header-division.
    move p_vkgrp to wa_header-sales_grp.
    move p_vkbur to wa_header-sales_off.
    Read table i_upload into wa_upload index 1.
    move wa_upload-ebeln to wa_header-purch_no_c.
    move wa_upload-aedat to wa_header-purch_date.
    move wa_upload-bsart to wa_header-po_method.
    move wa_upload-vdatu to wa_header-req_date_h.
    move wa_upload-bstkd_e to wa_header-purch_no_s.
    *move wa_upload-route to wa_header-route.
    move wa_upload-vsbed to wa_header-ship_cond.
    move wa_upload-empst to wa_header-rec_point.
    move wa_upload-shtyp to wa_header-ship_type.
    move wa_upload-zterm to wa_header-pmnttrms.
    move wa_upload-inco1 to wa_header-incoterms1.
    move wa_upload-inco2 to wa_header-incoterms2.
    ENDFORM.                    " f_fill_header
    *&      Form  f_fill_partner
          text
    -->  p1        text
    <--  p2        text
    FORM f_fill_partner.
    if not wa_upload-kunnr is initial.
    select single kunnr from kna1 into v_kunnr
                where kunnr = wa_upload-kunnr.
    if sy-subrc <> 0.
    Message E014 with 'customer does not exist'.
    else.
    move 'AG' to i_partner-partn_role.
    move wa_upload-kunnr to i_partner-partn_numb.
    move wa_upload-land1_s to i_partner-country.
    move wa_upload-name1_s to i_partner-name.
    move wa_upload-name2_s to i_partner-name_2.
    move wa_upload-ort01_s to i_partner-city.
    move wa_upload-regio_s to i_partner-region.
    move wa_upload-pstlz_s to i_partner-postl_code.
    move wa_upload-adrnr_s to i_partner-address.
    append i_partner.
    endif.
    endif.
    if not wa_upload-kunag is initial.
    select single kunnr from kna1 into v_kunag
                where kunnr = wa_upload-kunag.
    if sy-subrc <> 0.
    Message E015 with 'end customer does not exist'.
    else.
    move 'WE' to i_partner-partn_role.
    move wa_upload-kunag to i_partner-partn_numb.
    move wa_upload-land1_c to i_partner-country.
    move wa_upload-name1_c to i_partner-name.
    move wa_upload-name2_c to i_partner-name_2.
    move wa_upload-ort01_c to i_partner-city.
    move wa_upload-regio_c to i_partner-region.
    move wa_upload-pstlz_c to i_partner-postl_code.
    move wa_upload-adrnr_c to i_partner-address.
    append i_partner.
    endif.
    endif.
    ENDFORM.                    " f_fill_partner
    *&      Form  f_fill_item
          text
    -->  p1        text
    <--  p2        text
    FORM f_fill_item.
    loop at i_upload into wa_upload.
    if not wa_upload-matnr is initial.
    select single  maramatnr msegmenge into (v_matnr, v_zmeng) from
                       mara inner join mseg on maramatnr = msegmatnr
                       where mara~matnr = wa_upload-matnr.
    if sy-subrc <> 0.
    Message E016 with 'material no does not exist'.
    elseif v_zmeng LT wa_upload-zmeng.
    Message E017 with 'order quantity is greater than the quantity present'.
      endif.
    endif.
    move wa_upload-posnr to i_item-itm_number.
    move wa_upload-pstyv to i_item-item_categ.
    move wa_upload-matnr to i_item-material.
    move wa_upload-zmeng to i_item-target_qty.
    move wa_upload-meins to i_item-target_qu.
    move wa_upload-werks to i_item-plant.
    *move wa_upload-meins to wa_vbap-meins.
    *move wa_upload-posnr_tot to wa_vbap-posnr_tot.
    move wa_upload-posex to i_item-po_itm_no.
    move wa_upload-kdmat to i_item-cust_mat22.
    move wa_upload-inco1 to i_item-incoterms1.
    move wa_upload-inco2 to i_item-incoterms2.
    move wa_upload-zterm to i_item-pmnttrms.
    move wa_upload-empst to i_item-rec_point.
    move wa_upload-shtyp to i_item-ship_type.
    move wa_upload-route to i_item-route.
    append i_item.
    PERFORM f_fill_schedule_line.
    PERFORM f_fill_conditions.
    ENDLOOP.
    ENDFORM.                    " f_fill_item
    *&      Form  f_fill_schedule_line
          text
    -->  p1        text
    <--  p2        text
    FORM f_fill_schedule_line.
    move wa_upload-matnr to i_schedule-itm_number.
    move sy-datum to i_schedule-req_date.
    move wa_upload-zmeng to i_schedule-req_qty.
    append i_schedule.
    ENDFORM.                    " f_fill_schedule_line
    *&      Form  f_fill_conditions
          text
    -->  p1        text
    <--  p2        text
    FORM f_fill_conditions.
    move wa_upload-matnr to i_cond-itm_number.
    move sy-datum to i_cond-conpricdat.
    append i_cond.
    ENDFORM.                    " f_fill_conditions
    *&      Form  f_clear
          text
    -->  p1        text
    <--  p2        text
    FORM f_clear.
    clear:p_auart,
          p_vkorg,
          p_vtweg,
          p_spart,
          p_vkgrp,
          p_vkbur.
    ENDFORM.                    " f_clear
    *&      Form  f_call_BAPI
          text
    -->  p1        text
    <--  p2        text
    FORM f_call_BAPI.
    clear:i_item,i_partner,i_schedule.
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
      EXPORTING
      SALESDOCUMENTIN               =
        ORDER_HEADER_IN               = wa_header
      ORDER_HEADER_INX              =
      SENDER                        =
      BINARY_RELATIONSHIPTYPE       =
      INT_NUMBER_ASSIGNMENT         =
      BEHAVE_WHEN_ERROR             =
      LOGIC_SWITCH                  =
      TESTRUN                       =
      CONVERT                       = ' '
    IMPORTING
       SALESDOCUMENT                  = sorder
      TABLES
      RETURN                        =
       ORDER_ITEMS_IN                 = i_item
      ORDER_ITEMS_INX               =
        ORDER_PARTNERS                = i_partner
       ORDER_SCHEDULES_IN             = i_schedule
      ORDER_SCHEDULES_INX           =
      ORDER_CONDITIONS_IN            = i_cond.
      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                    =
      ORDER_KEYS                    =
      EXTENSIONIN                   =
      PARTNERADDRESSES              =
    if not ( sorder-vbeln is initial ).
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    write: /'Order number:', sorder.
    else.
    loop at i_return.
    write: / i_return-id, i_return-number, i_return-message(80).
    endloop.
    *write: /'Error'.
    endif.
    *loop at i_return.
    *write: / i_return-id, i_return-number, i_return-message(80).
    *endloop.
    ENDFORM.                    " f_call_BAPI

    HI
      Pricing will be carried basing on the pricing
    procedure.
    Case1: Prices will be carried out automatically if
    necessary condition records are maintained for the
    condition type.
      For this you can go to Sales Order-> Item Conditions
    In the screen you can click on command button Analysis,
    which gives you the list of condition types associated
    to the pricing procedure. By clicking on the condition
    type you can know the action that has taken place.
    Case2: Manually forcing prices for Items.
      To do this, you have to populate ORDER_CONDITIONS_IN &
    ORDER_CONDITIONS_INX. Also note to identify the item
    numbers, you manually pass the item number for each item
    in the sales order, use the same item number for
    populating conditions.
      Parameters required:
    ORDER_CONDITIONS_IN:
      ITM_NUMBER, COND_TYPE, COND_VALUE, CURRENCY
    ORDER_CONDITIONS_INX:
      ITM_NUMBER, COND_TYPE, UPDATEFLAG, COND_VALUE,CURRENCY.
       Hope the above info helps you. Do revert back if you
    need more info.
    Kind Regards
    Eswar

Maybe you are looking for