How to create the sales order using BAPI's ....?

Hi Guru's,
could you please provide how to create the sales order using BAPI's .....i need step by step process and please provide the details from scratch....basically  i don't have basic knowledge on this....please provide required inputs ....:)
thanks in advance
Srinivas......

Hi Guru's thanks for your inouts and your valuble time...
please find the program logic below...
*& Report  ZAREPAS30
REPORT  zarepas30.
DATA : gs_vbeln                   TYPE  vbak-vbeln,
       gs_order_header_in         TYPE  bapisdhd1,
       gs_order_header_inx        TYPE  bapisdhd1x,
       gt_order_items_in          TYPE  STANDARD TABLE OF bapisditm,
       gwa_itab1                  TYPE  bapisditm,
       gt_order_items_inx         TYPE  STANDARD TABLE OF bapisditmx,
       gwa_itab2                  TYPE  bapisditmx,
       gt_order_partners          TYPE  STANDARD TABLE OF bapiparnr,
       gwa_itab3                  TYPE  bapiparnr,
       gt_return                  TYPE  STANDARD TABLE OF bapiret2,
       gwa_itab4                  TYPE  bapiret2.
Sales document type
  PARAMETERS: p_auart TYPE auart OBLIGATORY.
Sales organization
  PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.
Distribution channel
  PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.
Division.
  PARAMETERS: p_spart TYPE spart OBLIGATORY.
Requested Delivery Date
  PARAMETERS: p_edatu  TYPE edatu OBLIGATORY.
Sold-to
  PARAMETERS: p_sold  TYPE kunnr OBLIGATORY.
Ship-to
  PARAMETERS: p_ship  TYPE kunnr OBLIGATORY.
Material
  PARAMETERS: p_matnr TYPE matnr   OBLIGATORY.
Quantity.
  PARAMETERS: p_menge TYPE kwmeng  OBLIGATORY.
Plant
  PARAMETERS: p_plant TYPE werks_d OBLIGATORY.
Start-of-selection.
  START-OF-SELECTION.
Header data
Sales document type
  gs_order_header_in-doc_type = p_auart.
  gs_order_header_inx-doc_type = 'X'.
Sales organization
  gs_order_header_in-sales_org = p_vkorg.
  gs_order_header_inx-sales_org = 'X'.
Distribution channel
  gs_order_header_in-distr_chan  = p_vtweg.
  gs_order_header_inx-distr_chan = 'X'.
Division
  gs_order_header_in-division = p_spart.
  gs_order_header_inx-division = 'X'.
Reguested Delivery Date
  gs_order_header_in-req_date_h = p_edatu.
  gs_order_header_inx-req_date_h = 'X'.
  gs_order_header_inx-updateflag = 'I'.
Partner data
Sold to
  gwa_itab3-partn_role = 'AG'.
  gwa_itab3-partn_numb = p_sold.
  APPEND gwa_itab3 TO  gt_order_partners .
ship to
  gwa_itab3-partn_role = 'WE'.
  gwa_itab3-partn_numb = p_ship.
  APPEND gwa_itab3 TO  gt_order_partners .
ITEM DATA
  gwa_itab2-updateflag = 'I'.
Line item number.
  gwa_itab1-itm_number = '000010'.
  gwa_itab2-itm_number = 'X'.
Material
  gwa_itab1-material = p_matnr.
  gwa_itab2-material = 'X'.
Plant
  gwa_itab1-plant    = p_plant.
  gwa_itab2-plant   = 'X'.
Quantity
  gwa_itab1-target_qty = p_menge.
  gwa_itab2-target_qty = 'X'.
  APPEND gwa_itab1 TO gt_order_items_in.
  APPEND gwa_itab2 TO gt_order_items_inx.
Line item number.
  gwa_itab1-itm_number = '000020'.
  gwa_itab2-itm_number = 'X'.
Material
  gwa_itab1-material = p_matnr.
  gwa_itab2-material = 'X'.
Plant
  gwa_itab1-plant    = p_plant.
  gwa_itab2-plant   = 'X'.
Quantity
  gwa_itab1-target_qty = p_menge.
  gwa_itab2-target_qty = 'X'.
  APPEND gwa_itab1 TO gt_order_items_in.
  APPEND gwa_itab2 TO gt_order_items_inx.
CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
  EXPORTING
    order_header_in               = gs_order_header_in
    ORDER_HEADER_INX              = gs_order_header_inx
  IMPORTING
    SALESDOCUMENT                 = gs_vbeln
  tables
    RETURN                        = gt_return
    ORDER_ITEMS_IN                = gt_order_items_in
    ORDER_ITEMS_INX               = gt_order_items_inx
    order_partners                = gt_order_partners.
Check the return table.
  LOOP AT gt_return into gwa_itab4 WHERE type = 'E' OR type = 'A'.
    EXIT.
  ENDLOOP.
  IF sy-subrc = 0.
    WRITE: / 'Error occured while creating sales order '.
  ELSE.
Commit the work.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    WRITE: / 'Document ', gs_vbeln, ' created'.
  ENDIF.

Similar Messages

  • How to create a sales order using bapi

    hi
        i need to create a sales order using bapi.
    can any one help me

    Do NOT USE BAPI_SALESORDER_CREATEFROMDATA, that FM is obsolete!
    Use BAPI_SALESORDER_CREATEFROMDAT1 .
    To build a reference to your contract you have to supply ORDER_HEADER_IN.
    Here´s a sample:
    MOVE:
    gs_vbak-vbeln TO ls_bapisdhd1-refobjkey,
    gs_vbak-vbeln TO ls_bapisdhd1-ref_doc,
    gs_vbak-vbtyp TO ls_bapisdhd1-refdoc_cat,
    gs_vbak-auart TO ls_bapisdhd1-refdoctype.
    also gothrouh the links
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2b-%2bsimple%2bprogram%2bto%2bcreate%2bsales%2border%2busing%2bbapi

  • How to create the sales order using excell sheet thru BAPI's?

    Hi Guru's,
    In my excell sheet i had 11 sales order details ..now i wanted to create the sales order's sing BAPI's...?
    could please guide me step by step.....that would be greatly helpfull to me...
    Thanks in advance
    Srinivas....

    Hi,
    follow below steps.
    1. Get the excel data into internal table,  Build a internal table whcih fields are in bapi same order
    2. call the Bapi and pass the table data to the bapi
    3. after calling the  bapi,  call the commit bapi.
        then only it will careates.
    Regards
    Ganesh

  • How to create open sales order using BAPI....?

    Hi Guru's,
    please help me how to create open sales order and which BAPI i have to use for open sales order.
    please provide any program logic related to this or step by step process.....
    that would be helpful to me.
    thanks in advance...
    Srinivas....

    Hi sreenu,
    Open PO or Open sales order means that the complete cycle is not complete. That means the Sales order is not completely delievered or is not billed or is not paid for. Only once the cycle is completed the order status shows as complete untill then its Open.
    You can use VA05 to find open sales orders.
    Similarlry open PO's are those PO's whos inbound delivery is not complete or whos goods receipt is not complete and whos payment is not done to the vendor
    U cannot directly find the open PO and open SO from any table.
    That u have to calculate from the status of the PO and SO and then check wheteher that is complete or not.
    U have table VBUP for SO status.Check out the fields in that table
    pls see the below link.
    http://abaplovers.blogspot.com/2008/02/bapi-sales-order-create-code.html
    http://msdn.microsoft.com/en-us/library/cc185190.aspx
    thjanks
    karthik

  • Sale Order Item Quantity Not Populating When Create A Sale Order Using BAPI

    I am having a problem when creating a sale order using BAPI
    BAPI_SALESORDER_CREATEFROMDAT2
    Problem is that sale order item quantity field is not populating
    code is as follows
    ORDER_ITEMS_IN-ITM_NUMBER = '0010'.
    ORDER_ITEMS_IN-MATERIAL = '000000000010000262'.
    ORDER_ITEMS_IN-TARGET_QU = 'LB'.
    ORDER_ITEMS_IN-TARGET_QTY = 1.

    Hi,
    Try populating ORDER_SCHEDULES_IN table in the bapi field REQ_QTY.
    Regds,
    Rudra

  • Uploading the sales order using BAPI

    hi experts,
    i want to upload the sales order using BAPI.
    can you provide the FM.
    it will be much helpful if i have the sample code........
    thanks

    Hi Shyam,
    Use BAPI : BAPI_SALESORDER_CREATEFROMDAT2
    REPORT ZZBAPI_TEST1 .
    *===========================================================
    *** Start of selection
    *===========================================================
    START-OF-SELECTION.
    * test of sales order with BAPI
    PERFORM SALES_ORDER_BAPI.
    *================ End of main program ======================
    *& Form SALES_ORDER_BAPI
    * text
    FORM SALES_ORDER_BAPI.
    DATA : SD_HEADER LIKE BAPISDHEAD.
    DATA : BEGIN OF ITEMIN_IT OCCURS 1.
    INCLUDE STRUCTURE BAPIITEMIN.
    DATA : END OF ITEMIN_IT.
    DATA : BEGIN OF PARTNR_IT OCCURS 1.
    INCLUDE STRUCTURE BAPIPARTNR.
    DATA : END OF PARTNR_IT.
    DATA : WK_SD_DOCNO LIKE VBAK-VBELN.
    DATA: WK_RETURN LIKE BAPIRETURN.
    CLEAR : SD_HEADER , ITEMIN_IT , PARTNR_IT.
    SD_HEADER-DOC_TYPE = 'TA'.
    SD_HEADER-SALES_ORG = '1793'.
    SD_HEADER-DISTR_CHAN = '01'.
    SD_HEADER-DIVISION = '01'.
    SD_HEADER-PURCH_NO = 'Test'.
    * itemin_it-hg_lv_item = '10'.
    ITEMIN_IT-MATERIAL = '000000000000001143'.
    ITEMIN_IT-PLANT = '3018'.
    ITEMIN_IT-REQ_QTY = '1'.
    ITEMIN_IT-SALES_UNIT = 'CS'.
    APPEND ITEMIN_IT.
    * itemin_it-hg_lv_item = '20'.
    ITEMIN_IT-MATERIAL = '000000000000000848'.
    ITEMIN_IT-PLANT = '3018'.
    ITEMIN_IT-REQ_QTY = '1'.
    ITEMIN_IT-SALES_UNIT = 'KG'.
    APPEND ITEMIN_IT.
    * itemin_it-hg_lv_item = '30'.
    ITEMIN_IT-MATERIAL = '000000000000000848'.
    ITEMIN_IT-PLANT = '3018'.
    ITEMIN_IT-REQ_QTY = '1'.
    ITEMIN_IT-SALES_UNIT = 'EA'.
    APPEND ITEMIN_IT.
    LOOP AT ITEMIN_IT.
    WRITE : / SY-TABIX , ITEMIN_IT-MATERIAL , ITEMIN_IT-PLANT
    , ITEMIN_IT-REQ_QTY , ITEMIN_IT-SALES_UNIT.
    ENDLOOP.
    CLEAR : PARTNR_IT.
    PARTNR_IT-PARTN_ROLE = TEXT-001.
    PARTNR_IT-PARTN_NUMB = '0000000004'.
    APPEND PARTNR_IT.
    CLEAR : PARTNR_IT.
    PARTNR_IT-PARTN_ROLE = 'WE'.
    PARTNR_IT-PARTN_NUMB = '0000000051'.
    APPEND PARTNR_IT.
    LOOP AT PARTNR_IT.
    WRITE : / SY-TABIX , PARTNR_IT-PARTN_ROLE , PARTNR_IT-PARTN_NUMB.
    ENDLOOP.
    CLEAR : ITEMIN_IT , PARTNR_IT , WK_RETURN..
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDATA'
    EXPORTING
    ORDER_HEADER_IN = SD_HEADER
    IMPORTING
    SALESDOCUMENT = WK_SD_DOCNO
    * SOLD_TO_PARTY =
    * SHIP_TO_PARTY =
    * BILLING_PARTY =
    RETURN = WK_RETURN
    TABLES
    ORDER_ITEMS_IN = ITEMIN_IT
    ORDER_PARTNERS = PARTNR_IT
    * ORDER_ITEMS_OUT =
    * ORDER_CFGS_REF =
    * ORDER_CFGS_INST =
    * ORDER_CFGS_PART_OF =
    * ORDER_CFGS_VALUE =
    * ORDER_CCARD =
    EXCEPTIONS
    OTHERS = 1.
    WRITE : / 'sy-subrc = ' , SY-SUBRC.
    IF NOT WK_SD_DOCNO IS INITIAL.
    WRITE : / WK_SD_DOCNO , 'registerd'.
    ELSE.
    WRITE : / 'incorrect'.
    WRITE : / WK_RETURN-TYPE , WK_RETURN-CODE , WK_RETURN-MESSAGE.
    WRITE : / WK_RETURN-LOG_NO, WK_RETURN-LOG_MSG_NO,
    WK_RETURN-MESSAGE_V1.
    ENDIF.
    ENDFORM. " SALES_ORDER_BAPI
    Hope that helps.
    Regards
    Kapadia
    ***Assigning points is the way to say thanks in SDN.***
    Message was edited by:
            Mr Kapadia

  • Error while creating the sales order using Proxy

    Hi Folks,
    I am trying to create a Sales Order using Proxy via BAPI "BAPI_SALESORDER_CREATEFROMDAT2" :
    and i got this type of standard error message
    <Message>FB call: insufficient parameters</Message>
    few days back only i used the same bapi for creating the Sales Order and did it successfully...using the same parameters
    I don't have any clue about this type error .
    Kindly guide .
    Regards,

    Hi Nikhil,
    How refreshing the cache and restart the server will help ?
    basically i am testing the scenario at R/3 end only by generating XML template in SPROXY.
    My ECC 6.0 is on sp 12....I am not sure is it configuration related error or a bug ? as i have used the same code in ECC 6.0 with sp 09.
    regards,

  • How to Change a Sales Order using BAPI

    Hi All
    How can we change the sales document using BAPI as the requirement is
    --> First we create a Sales order using a BAPI.
    --> If the sales order is changed then we get the changed order information alonge with the old order data in a CSV file.
    here i have the problem that we are uncertain which fields will be changed some times we may get the item changes or some times we may get the quantity changed information and some times the condition type may be changed . So how to handle this ?
    Thanks,
    Chindam

    Hi,
    try this
    DATA: IT_MESSAGE TYPE STANDARD TABLE OF BAPIRET2,
          WA_VBELN TYPE BAPIVBELN-VBELN.
    DATA: WA_BAPIHEAD TYPE BAPISDH1,
          WA_BAPIHEADX TYPE BAPISDH1X,
          WA_HEADDATA TYPE BAPISDH1.
    DATA: I_BAPIITEM TYPE STANDARD TABLE OF BAPISDITM,
          WA_BAPIITEM TYPE BAPISDITM,
            WA_DATA TYPE BAPISDITM,
          I_BAPIITEMX TYPE STANDARD TABLE OF BAPISDITMX,
          WA_BAPIITEMX TYPE BAPISDITMX.
    CHANGE ITEM DATA
    WA_BAPIITEM-ITM_NUMBER =WA_DATA-ITM_NUMBER.
    WA_BAPIITEM-REASON_REJ = WA_DATA-REASON_REJ. "(REASON FOR REJECTION)
    WA_BAPIITEMX-ITM_NUMBER = WA_DATA-ITM_NUMBER. "(ITEM NUMBER)
    WA_BAPIITEMX-UPDATEFLAG = 'X'.
    WA_BAPIITEMX-REASON_REJ = 'X'.
    APPEND WA_BAPIITEM TO I_BAPIITEM.
    APPEND WA_BAPIITEMX TO I_BAPIITEMX.
    TO CHANGE HEADER DATA
    WA_BAPIHEADX-UPDATEFLAG = 'U'.
    WA_BAPIHEADX-DLV_BLOCK = 'X'.
    WA_BAPIHEAD-SALES_ORG = WA_HEADDATA-SALES_ORG. "(COMPANY CODE)
    WA_BAPIHEAD-DLV_BLOCK = WA_HEADDATA-DLV_BLOCK. "(DELIVERY BLOCK)
    WA_VBELN = '0000000168'.
    CALL BAPI AND PASS THE VALUE
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
       EXPORTING
         SALESDOCUMENT               = WA_VBELN " (SALES AND DOCUMENT NO)
        ORDER_HEADER_IN             = WA_BAPIHEAD
         ORDER_HEADER_INX           = WA_BAPIHEADX
       TABLES
         RETURN                     = IT_MESSAGE
        ORDER_ITEM_IN               = I_BAPIITEM
        ORDER_ITEM_INX              = I_BAPIITEMX
    CLEAR IT_MESSAGE.

  • How to create a sales order using a catlog numer

    hi,
        is it possible to create a sales order using a catlog number of the material .. did  any one work on this type ... and how to maintain catalog number for a material?
    thank you
    mmn

    Do NOT USE BAPI_SALESORDER_CREATEFROMDATA, that FM is obsolete!
    Use BAPI_SALESORDER_CREATEFROMDAT1 .
    To build a reference to your contract you have to supply ORDER_HEADER_IN.
    Here´s a sample:
    MOVE:
    gs_vbak-vbeln TO ls_bapisdhd1-refobjkey,
    gs_vbak-vbeln TO ls_bapisdhd1-ref_doc,
    gs_vbak-vbtyp TO ls_bapisdhd1-refdoc_cat,
    gs_vbak-auart TO ls_bapisdhd1-refdoctype.
    also gothrouh the links
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2b-%2bsimple%2bprogram%2bto%2bcreate%2bsales%2border%2busing%2bbapi

  • How to create a sales order using PO ALE Idoc

    Hi,
    I  have a purchase order in my ECC6 system, and output for this PO is ALE idoc.
    Now I want to create a Sales order using that Idoc in the same system,
    can anbody please tell the procedure
    sreeram

    Do NOT USE BAPI_SALESORDER_CREATEFROMDATA, that FM is obsolete!
    Use BAPI_SALESORDER_CREATEFROMDAT1 .
    To build a reference to your contract you have to supply ORDER_HEADER_IN.
    Here´s a sample:
    MOVE:
    gs_vbak-vbeln TO ls_bapisdhd1-refobjkey,
    gs_vbak-vbeln TO ls_bapisdhd1-ref_doc,
    gs_vbak-vbtyp TO ls_bapisdhd1-refdoc_cat,
    gs_vbak-auart TO ls_bapisdhd1-refdoctype.
    also gothrouh the links
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/abap%2b-%2bsimple%2bprogram%2bto%2bcreate%2bsales%2border%2busing%2bbapi

  • Creating the Sales Order using the bapi BAPI_SALESORDER_CREATEFROMDAT2

    Hi,
    My problem is , i have created one module pool program for accelerating the Sales Order creation.
    I am using the bapi BAPI_SALESORDER_CREATEFROMDAT2 for sales order creation. After executing the program
    bapi is given an errot that, incomplete sales order document is saved.
    Can any body tell me plz what are the necessary fields i need to take in the header and item level , so that the complete
    document will be saved through BAPI.
    <removed_by_moderator>
    Thanks
    Edited by: Julius Bussche on Jan 11, 2010 12:09 PM

    TABLES: VBAK,                             "Sales Document: Header Data
            VBAP.                             "Sales Document: Item Data
    *************************************WORK AREA DECELERATION************************
    DATA: BEGIN OF WA_HEADER,
            LI    TYPE I,                      "LINE TYPE
            AUART TYPE VBAK-AUART,             "Sales Document Type
            VKORG TYPE VBAK-VKORG,             "Sales Organization
            VTWEG TYPE VBAK-VTWEG,             "Distribution Channel
            SPART TYPE VBAK-SPART,             "Division
            KUNNR TYPE BAPIPARNR-PARTN_NUMB,   "Customer number
          END OF WA_HEADER.
    DATA: BEGIN OF WA_ITEM,
            LI     TYPE I,
            MATNR  TYPE VBAP-MATNR,            "MATERIAL NUMBER
            ZMENG  TYPE VBAP-ZMENG,           "QUANTITY
          END OF WA_ITEM.
    ***********************************INTERNAL TABLE DECELERATION***************************************
    DATA: IT_HEADER      LIKE TABLE OF WA_HEADER WITH HEADER LINE.                   "IT FOR HEADER
    DATA: IT_ITEM        LIKE TABLE OF WA_ITEM WITH HEADER LINE.                     "IT FOR ITEM
    DATA: IT             LIKE VBAK OCCURS 0 WITH HEADER LINE.
    ***************************SALES ORDER INTERNAL TABLE DECELERATION********************************
    DATA:
          HEADER  TYPE TABLE OF BAPISDHEAD WITH HEADER LINE,        "SALES HEADER DATA
          ITEMS   TYPE TABLE OF BAPIITEMIN WITH HEADER LINE,         "SALES ITEM DATA
          PARTNERS TYPE TABLE OF BAPIPARTNR WITH HEADER LINE.      "SALLES PARTNERS
    ***********************************DYNAMIC FIEL PATH GETTING DECELERATION************************
    DATA : HL_FIELD_NAME TYPE DYNPREAD-FIELDNAME VALUE 'G_P_SPATH',              "SCREEN FIELD NAME
           HL_FILE_NAME  TYPE IBIPPARMS-PATH VALUE 'G_P_SPATH',                  "Local file for upload/download
           IL_FIELD_NAME TYPE DYNPREAD-FIELDNAME VALUE 'G_P_EPATH',              "SCREEN FIELD NAME
           IL_FILE_NAME  TYPE IBIPPARMS-PATH VALUE 'G_P_EPATH',                  "Local file for upload/download
           FL_FIELD_NAME TYPE DYNPREAD-FIELDNAME VALUE 'G_P_EPATH',              "SCREEN FIELD NAME
           FL_FILE_NAME  TYPE IBIPPARMS-PATH VALUE 'G_P_EPATH'.                  "Local file for upload/download
    DATA : CTR TYPE I .
    DATA : CTR2 TYPE STRING.
    DATA : CTR1 TYPE STRING.
    Sales document number
    DATA : L_VBELN LIKE BAPIVBELN-VBELN.
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE T1.
    SELECTION-SCREEN : SKIP.
    PARAMETER        : P_HPATH TYPE STRING.
    PARAMETER        : P_IPATH TYPE STRING.
    SELECTION-SCREEN : SKIP.
    SELECTION-SCREEN : END OF BLOCK B1.
    SELECTION-SCREEN : BEGIN OF BLOCK B2 WITH FRAME TITLE T2.
    SELECTION-SCREEN : SKIP.
    SELECTION-SCREEN : BEGIN OF LINE.
    SELECTION-SCREEN : PUSHBUTTON 10(14) UPLOAD USER-COMMAND CLICK1.
    SELECTION-SCREEN : END OF LINE.
    SELECTION-SCREEN   END OF BLOCK B2.
    ******************************************INITIALIZATION.***************************************************
    INITIALIZATION.
      T1       = 'Putchase Order Source File Path'.
      T2       = 'Push Button'.
      UPLOAD   = 'Upload'.
    *******************************************AT SELECTION SCREE EVENT********************************************
    AT SELECTION-SCREEN.
      CASE SY-UCOMM.
        WHEN 'CLICK1'.
          IF P_HPATH IS INITIAL AND P_IPATH IS INITIAL.      "CHECKING BTHE THE TEXT BOX
            MESSAGE I009.
          ELSE.
            PERFORM SELECT.                                  "CALLING THE SELECT SUBROUTINE
          ENDIF.
        WHEN OTHERS.
          MESSAGE 'PRESS FORM BUTTON' TYPE 'I'.      "WHEN EXECUTE BUTTON IS PRESSED
      ENDCASE.
    ***********************************GETTING HEADER FIEL PATH*******************************************
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_HPATH.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
          FIELD_NAME    = HL_FIELD_NAME
        IMPORTING
          FILE_NAME     = HL_FILE_NAME.
      P_HPATH = HL_FILE_NAME.
    ***********************************GETTING ITEM FIEL PATH*******************************************
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_IPATH.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
          FIELD_NAME    = IL_FIELD_NAME
        IMPORTING
          FILE_NAME     = IL_FILE_NAME.
      P_IPATH = IL_FILE_NAME.
    START-OF-SELECTION.
    *&      Form  SELECT
          text
    -->  p1        text
    <--  p2        text
    FORM SELECT .
      CALL FUNCTION 'GUI_UPLOAD'             " function resposible to get the local flat
          EXPORTING                          " and upload it in a internal table
            FILENAME            = P_HPATH
            FILETYPE            = 'ASC'
            HAS_FIELD_SEPARATOR = '#'
          TABLES
            DATA_TAB            = IT_HEADER.
      CALL FUNCTION 'GUI_UPLOAD'             " function resposible to get the local flat
          EXPORTING                          " and upload it in a internal table
            FILENAME            = P_IPATH
            FILETYPE            = 'ASC'
            HAS_FIELD_SEPARATOR = '#'
          TABLES
            DATA_TAB            = IT_ITEM.
      LOOP AT IT_HEADER.
        Initialize Header values
        HEADER-DOC_TYPE     =  IT_HEADER-AUART.
        HEADER-SALES_ORG    =  IT_HEADER-VKORG.
        HEADER-DISTR_CHAN   =  IT_HEADER-VTWEG.
        HEADER-DIVISION     =  IT_HEADER-SPART.
        APPEND HEADER.
        PARTNERS-PARTN_ROLE = 'WE'.
        PARTNERS-PARTN_NUMB = IT_HEADER-KUNNR.
        APPEND PARTNERS.
        CTR = 10.
        LOOP AT IT_ITEM WHERE LI = IT_HEADER-LI.
          CTR2 = CTR.
          CONCATENATE '0000' CTR2 INTO CTR1.
    ***Initialize Item values
         ITEMS-ITM_NUMBER   = IT_ITEM-ITEM.
          ITEMS-ITM_NUMBER   = CTR1.
          ITEMS-MATERIAL     = IT_ITEM-MATNR.
          ITEMS-REQ_QTY   = IT_ITEM-ZMENG.
          APPEND ITEMS.
          CTR = CTR + 10.
        ENDLOOP.
        CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
          EXPORTING
            ORDER_HEADER_IN = HEADER                      "SALES HEADER DATA
          IMPORTING
            SALESDOCUMENT   = L_VBELN                        "RETRIEVED SALES DOCUMENT NUMBER
          TABLES
            ORDER_ITEMS_IN  = ITEMS                       "SALES ITEM LEVEL DATA
            ORDER_PARTNERS  = PARTNERS.                    "SAKES PARTNERS
        APPEND L_VBELN TO IT.
        COMMIT WORK AND WAIT.
        CLEAR : HEADER , ITEMS[] ,PARTNERS,CTR,CTR1,CTR2.
        REFRESH : ITEMS.
      ENDLOOP.
      IF IT[] IS NOT INITIAL.
        LOOP AT IT.
          WRITE: / 'SALES ORDER', IT-VBELN , 'CREATED'.
        ENDLOOP.
        LEAVE TO LIST-PROCESSING.
        SET PF-STATUS SPACE.
      ELSE.
        MESSAGE I044.
      ENDIF .
    ENDFORM.                    " SELECT

  • How to create a Sales Order using BAPI_SALESORDER_CREATEFROMDAT1 in VC

    I am new to Visual Composer.
    I read the tutorial and created a Model which fetches the Sales Orders from the R/3 using <b>BAPI_SALESORDER_GETLIST</b>, every thing worked fine.
    I am trying to create a sales order in R/3 using <b>BAPI_SALESORDER_CREATEFROMDAT1</b>, following are the steps I did:
    1)Create a model
    2)Drag a model element(iView) on to the designer
    3)Double click the iView and Drag the function <b>BAPI_SALESORDER_CREATEFROMDAT1</b> on to the iView Designer
    Now my question is, for <b>BAPI_SALESORDER_CREATEFROMDAT1</b> there are some mandatory fields as mentioned in the document.
    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 functions, SP sold-to party
    PARTN_NUMB   Customer number
    ORDER_ITEMS_IN..:
    MATERIAL     Material number
    REQ_QTY      Order quantity in sales unit
    I can pass the values of structure <b>ORDER_HEADER_IN</b> from a input form but how should I pass mandatory values for tables <b>ORDER_PARTNERS</b> and <b>ORDER_ITEMS_IN</b>.
    Ideally I should have one form where I can send all the mandatory items in the form.
    Thank you,
    Vamsi

    Hi,
    how did you return the materials in the Table View. I tried to do it, but it only returns one material?
    Regards,
    Matthias

  • Need to Create a Sales Order Using BAPI....

    Hello Gurus,
    I have called 'BAPI_SALESORDER_CREATEFROMDAT2' n a FM and trying to create a Sales Order. I have passed the header (auart, vkorg, vtweg, spart) and partner (nmbr and role). I passed the parameters to BAPI but in the return messages it says 'Sales Document was not changed V4 E'.
    I hope I am clear, if not please ask...
    Suggestions would be rewarded....
    Regards
    Leo

    Hi Leo,
    Check out the following codes:
    Even I have worked in ECC 5.0.These are the mandatory parametersthat u need to pass to create a Sales Order successfully...
    REPORT  Z6SKS_HERSHEYS2.
    data : order_header_in1 type BAPISDHD1.
    data: order_partners1 type BAPIPARNR occurs 0 with header line.
    data: ORDER_ITEMS_IN1 type BAPISDITM occurs 0 with header line.
    DATA : SALESDOCUMENT1 TYPE BAPIVBELN-VBELN.
    DATA : RETURN1 TYPE BAPIRET2 OCCURS 0.
    DATA : RETURN2 TYPE BAPIRET2.
       order_header_in1-doc_type = 'TA'.
       order_header_in1-sales_org = '0001'.
       order_header_in1-distr_chan = '01'.
       order_header_in1-division = '01'.
       ORDER_ITEMS_IN1-material = '000000000000000013'.
       append ORDER_ITEMS_IN1.
       order_partners1-PARTN_ROLE = 'WE'.
       order_partners1-PARTN_NUMB = '0000000017'.
       APPEND order_partners1.
    Perform call_function.
    *&      Form  call_function
          text
    -->  p1        text
    <--  p2        text
    form call_function .
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
      EXPORTING
      SALESDOCUMENTIN               =
        order_header_in               = order_header_in1
      ORDER_HEADER_INX              =
      SENDER                        =
      BINARY_RELATIONSHIPTYPE       =
      INT_NUMBER_ASSIGNMENT         =
      BEHAVE_WHEN_ERROR             =
      LOGIC_SWITCH                  =
      TESTRUN                       =
      CONVERT                       = ' '
    IMPORTING
       SALESDOCUMENT                 = SALESDOCUMENT1
      tables
       RETURN                        = RETURN1
       ORDER_ITEMS_IN                = ORDER_ITEMS_IN1
      ORDER_ITEMS_INX               =
        order_partners                = order_partners1
      ORDER_SCHEDULES_IN            =
      ORDER_SCHEDULES_INX           =
      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              =
      IF NOT SALESDOCUMENT1 IS INITIAL.
              CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
              EXPORTING
                WAIT          =
               IMPORTING
                 RETURN        = RETURN2
       ELSE.
              CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
              IMPORTING
                RETURN        =
       ENDIF.
    endform.                    " call_function
    This should help u...
    Please reward points if found useful...

  • How to create a sales order using a quatation reference

    Hi,
      I have a created a quatation.Now i want to create sales order using that quatation as a reference.will u pls tell me the way of doing it.send me the sample code if any and send me the related information and links.
    Regards,
    Kiran

    Go to VA01, enter the order type and then click on 'Create with Reference' and enter your quotation number there in the subsequent popup.

  • Create / Change Sales Order using BAPI - Populating Enhanced Fields

    Hi,
    I am using BAPI: BAPI_SALESORDER_CHANGE to change the Sales Order and want to update the Enhanced Screen Field (Screen Exit Fields) in the Sales Order. Where to populate these enhanced screen fields in the BAPI Structure?
    Appreciate Your Help!.
    Thanks,
    Kannan

    Hi,
    MV45AFZZ   BAPI_SALESORDER_CHANGE
    Regards,
    Padmam.

Maybe you are looking for

  • How can I find the dimensions of an object?

    Is there a way to view the height and width of an object in Photoshop without having to measure it with the ruler tule or eyeball it?

  • Why can't I change the font size on the menu bars for my mac book air?

    The text is just too small sometimes. Are there any third party apps that can help with this, apparently apple is under the impression everyone has perfect vision? Is this some crazy request? I was reading through the forums and this has been a probl

  • PDF font error

    Getting a Font Error when opening a pdf file with Adobe Reader. All the newest versions of Reader, OSX etc. The error says missing font Univers-Light Sometimes Reader crashes. It turns out this is an Adobe font that I have to pay for???

  • ORA-00900 when there is huge quantity access to Data Base

    Hi I have some Java programs which access to the same Data Base Oracle 11gR2 from diferent computers and diferent Operative System. in a normal execution everything is working but when I want to test the 'stress' in the data base I execute many concu

  • Can't add photos to a shared album in Photos

    I created a shared album in Photos with 59 photos. Only 15 were uploaded to the album and when I try to add the others, nothing happens. I highlight them, click "add" and.... nothing.