Creation of sale order using bapi in webdynpro using table control

only first row is getting updated when checked in va03, the line items are not getting replaced, only first row is committed..
Here is the code for table control i used...
http://www.scribd.com/doc/51879492/creation-of-sale-order-using-bapi-in-webdynpro-using-table-control
pls help me out with this..

Duplicate Posting.  Original is here: Sales order creation with bapi in webdynpro using table control

Similar Messages

  • Creation of sales order with reference to Quotation using BAPI

    Hi All,
    I am using BAPI "BAPI_SALESORDER_CREATEFROMDAT2" for creating sales order. Can you please tell how can I create a sales order with reference to a Quotation.

    Vinit,
    In your header structure, set like this:
      hdr-REF_DOC = i_order-vbeln.  "assign quotation # to sales order
      hdr-REFDOC_CAT = 'B'.         "assign Quotation to VBTYP_N.
    For each line item, set as follows:
    Assigning ref doc to create line item entries in VBFA.
        itm-REF_DOC    = i_order-vbeln.  "quote number
        itm-REF_DOC_IT = i_vbap-posnr.   "quote line item #
        itm-REF_DOC_CA = 'B'.
      data: ret_text type BAPIRET2.
      CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
        EXPORTING
          ORDER_HEADER_IN           = hdr
          convert                   = 'X'
        IMPORTING
          SALESDOCUMENT             = salesdoc
        TABLES
          return                    = ret_tbl
          ORDER_ITEMS_IN            = itm
          ORDER_PARTNERS            = prtnr
          ORDER_ITEMS_inx           = itmx
          ORDER_CONDITIONS_IN       = conds
          ORDER_CONDITIONS_INX      = condsx
          order_schedules_in        = schd_lin.
    Don't forget those points.

  • Creation of sales order- screen exit

    Hi all,
    I have a requirement like while creation of sales order need to develop one screen field in additional data B.i developed that field. and now while creation of sales order it will save in vbak table. now the problem is that screen field will be enable in that particular sales order type only otherwise it will be disable. how to do this. screen exit.

    Hi
    See SAP Note 209278 - Display of customer-specific fields in sales doc
    Check also, SAP Note 302497 - Additional cust. fields not displayed in 'Additional data B' and SAP Note 386694 - Additional data not displayed in screen 8459 and 8309
    Regards
    Eduardo

  • Creating sales order using BAPI, through BSP using 2 pages. one for input

    Hi Friends,
    i have a Requirement that....
    i want to create a BSP pages, in first page i have to give input data (in input fields) which is required to create a sales order through BAPI function module (BAPI_SALESORDER_CREATEFROMDAT1).
    in the second page what ever the result given by BAPI FM, that result i want to display on the second page.
    so how i can i proceed with input fields in first page and result in second page. please through some input on this.
    thanks in advance.
    sree

    Hi Sree,
       If you are going to use MVC pattern to do the following steps.
    For example. company code selection...
    In Model class-INIT() method.
    DATA : S_COMP LIKE LINE OF <table>.
    READ TABLE <table> INTO S_COMP INDEX 1.
      IF SY-SUBRC <> 0.
        S_COMP-TEXT = <variable>.
        S_COMP-KEY = '1'.
        APPEND S_COMP TO <i_table>.
        CLEAR S_COMP.
        INSERT S_COMP INTO <i_table> INDEX 1.
      ENDIF.
    HTML View page.
    <htmlb:dropdownListBox id = "comp"
                      table   = "//model/<table>"
                  selection   = "//model/<variable>"
            nameOfKeyColumn   = "text"
            nameOfValueColumn = "text"
            onSelect          = "<Event name>" />
    Thanks,
    Suriya.

  • Getting Error while creating multiple Orders using Sales order Create BAPI

    Hi,
    I am trying to create 2 orders thru the Sales order create BAPI before I commit and save the orders. The Orders are getting created and the BAPI is coming back with success, but it is not setting the system status on the line items of the 1st order. So when I try to cancel the line items on the first order I get the error 'No status object is available for SDI 4924/10' . I would really appreciate if anyone has encountered such error before and could help me out with the reason for this error and the possible solution.
    Thanks in advance,
    David.

    Hi,
    Check the following link:
    http://www.sap-img.com/bapi.htm
    Regards,
    Bhaskar

  • Issue with creation of sales order in CRM system

    Hi Experts,
    Here are the details of the process we followed
    1.     We found a Function Module u201CBAPI_BUSPROCESSND_CREATEMULTIu201D which is used to create a sales order in CRM.
    2.     We have set a Break point in the FM u201CCRM_ORDER_MAINTAINu201D and tried to create a sales order using the transaction u201CCRMD_ORDERu201D. For this the parameters we have given are
    a.     sold-to-party
    b.     ship-to-party
    c.     quantity
    d.     product
    And after this we have saved the order and the order is saved and in the debug mode we have the parameters in u201CCRM_ORDER_MAINTAINu201D and we found all these     parameters in the FM.
    3.     After this we have given all the parameters mentioned above in the FM u201CBAPI_BUSPROCESSND_CREATEMULTIu201D and still the order is not created, gave an error message saying that CRM_ORDER: Incorrect values in the interface object.
    4.     We checked the CRM_ORDER badiu2019s interface and it is having only header guid to be given. We gave this header guid also in the FM u201CBAPI_BUSPROCESSND_CREATEMULTIu201D and then it gave a different error saying that : Document cannot be saved.
    5.     Finally we are not able to know the parameters to be passed to the FM to create an order.
    Any inputs will be highly appreciated.
    Thanks a lot in advance.
    Lakshman.

    Hi Easwar,
    Now i am able to create a sales order by passing the parameters to "BAPI_BUSPROCESSND_CREATEMULTI" and the parameters i am passing are Process_type in the ORDERADM_H, parner_fct (partner function), partner_no , Quantity and prod_ordered (product name) but after creation of sales order using my report program and if i see the sales order uisng transaction crmd_order (using transaction ID) or crmd_orderadm_h(using headerguid) or crm_order_index, only the PROCESS_TYPE is updated but the remaining parameters which i passed like QUANTITY,PRODUCT NAME,PARTNER NUMBER are not present in the sales order. I am providing the code which i have written for creation of the sales order. Can you please look into it and tell me where i might have went wrong??
    *& Report  ZCREATEORDER_TEST
    REPORT  ZCREATEORDER_TEST.
    DATA : LV_HEADER_GUID  TYPE  GUID_32,
    WA_HEADER            TYPE         BAPIBUS20001_HEADER_INS,
    ITAB_HEADER          TYPE STANDARD TABLE OF BAPIBUS20001_HEADER_INS,
    ITAB_CREATED_PROCESS TYPE STANDARD TABLE OF BAPIBUS20001_HEADER_INS,
    ITAB_OBJECTS_TO_SAVE TYPE STANDARD TABLE OF BAPIBUS20001_GUID_DIS,
    ITAB_PARTNER        TYPE STANDARD TABLE OF BAPIBUS20001_PARTNER_INS,
    lt_product_i TYPE STANDARD TABLE OF BAPIBUS20001_ITEM,
    wa_product_i  type BAPIBUS20001_ITEM,
    lt_schedlin_i type standard table of BAPIBUS20001_SCHEDLIN,
    wa_schedlin_i type BAPIBUS20001_SCHEDLIN,
    ITAB_INPUT_FIELDS TYPE TABLE OF bapibus20001_input_fields,
    ls_inputfields TYPE bapibus20001_input_fields,
    WA_PARTNER          TYPE BAPIBUS20001_PARTNER_INS,
    ITAB_RETURN          TYPE STANDARD TABLE OF BAPIRET2,
    WA_OBJECTS_TO_SAVE  LIKE LINE OF ITAB_OBJECTS_TO_SAVE,
               "To store the Objects to be saved.
    WA_CREATED_PROCESS  LIKE LINE OF ITAB_CREATED_PROCESS,
    ITAB_SAVED_OBJECTS   TYPE STANDARD TABLE OF BAPIBUS20001_OBJECT_ID,
    WA_SAVED_OBJECTS    LIKE LINE OF ITAB_SAVED_OBJECTS,
    GC_X type c.
    gc_x = 'x'.
    CALL FUNCTION 'GUID_CREATE'
      IMPORTING
        ev_guid_32 = lv_header_guid.
    CLEAR : WA_HEADER.
    Passing the respective values from the Header table to internal table.
    WA_HEADER-GUID          =  LV_HEADER_GUID.
    WA_HEADER-PROCESS_TYPE  =  'ZTA'.
    APPEND WA_HEADER TO ITAB_HEADER.
    *Appending the values to the ITAB_HEADER.
    ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-REF_KIND = 'A'.
    ls_inputfields-objectname = 'ORDERADM_H'.
    ls_inputfields-logical_key = ' '.
    ls_inputfields-fieldname = 'PROCESS_TYPE'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
    *ls_inputfields-ref_handle = '0000000000'.
    ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-objectname = 'ORDERADM_H'.
      ls_inputfields-fieldname = 'MODE'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
    ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-REF_KIND = 'A'.
    ls_inputfields-objectname = 'ORDERADM_H'.
    ls_inputfields-logical_key = ' '.
    ls_inputfields-fieldname = 'GUID'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
    CHANGES MADE
    ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-REF_KIND = 'A'.
    ls_inputfields-objectname = 'SCHEDLIN'.
    ls_inputfields-logical_key = ' '.
    ls_inputfields-fieldname = 'LOGICAL_KEY'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
      ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-REF_KIND = 'A'.
    ls_inputfields-objectname = 'SCHEDLIN'.
    ls_inputfields-logical_key = ' '.
    ls_inputfields-fieldname = 'MODE'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
      ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-REF_KIND = 'A'.
    ls_inputfields-objectname = 'SCHEDLIN_I'.
    ls_inputfields-logical_key = ' '.
    ls_inputfields-fieldname = 'GUID'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
       ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-REF_KIND = 'A'.
    ls_inputfields-objectname = 'SCHEDLIN_I'.
    ls_inputfields-logical_key = ' '.
    ls_inputfields-fieldname = 'QUANTITY'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
       ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-REF_KIND = 'A'.
    ls_inputfields-objectname = 'SCHEDLIN_I'.
    ls_inputfields-logical_key = ' '.
    ls_inputfields-fieldname = 'MODE'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
    CHANGES MADE
    WA_PARTNER-REF_GUID = LV_HEADER_GUID.
    WA_PARTNER-REF_KIND = 'A'.
    giving the partner function and partner no 000000038 for slod to party
    WA_PARTNER-PARTNER_FCT = '00000038'.
    WA_PARTNER-PARTNER_NO = '10017'.
    APPEND WA_PARTNER TO ITAB_PARTNER.
    *"ADDING VALUES for the product
      wa_product_i-header        = lv_header_guid.
      wa_product_i-handle        = '0000000001'.
      wa_product_i-ordered_prod  = '12000014'.
      wa_product_i-mode          = 'A'.
      APPEND wa_product_i TO lt_product_i.
    *"ADDING VALUES for quantity
      wa_schedlin_i-quantity   = 30.
      wa_schedlin_i-handle = 1.
      APPEND wa_schedlin_i TO lt_schedlin_i.
    ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-REF_KIND = 'A'.
    ls_inputfields-objectname = 'PARTNER'.
    *ls_inputfields-logical_key = ' '.
    ls_inputfields-fieldname = 'REF_GUID'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
    ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-REF_KIND = 'A'.
    ls_inputfields-objectname = 'PARTNER'.
    ls_inputfields-logical_key = ' '.
    ls_inputfields-fieldname = 'PARTNER_FCT'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
    ls_inputfields-ref_guid =  LV_HEADER_GUID.
    ls_inputfields-REF_KIND = 'A'.
    ls_inputfields-objectname = 'PARTNER'.
    ls_inputfields-logical_key = ' '.
    ls_inputfields-fieldname = 'PARTNER_NO'.
    APPEND ls_inputfields TO ITAB_INPUT_FIELDS.
    CALL FUNCTION 'BAPI_BUSPROCESSND_CREATEMULTI'
      TABLES
        HEADER          = ITAB_HEADER
        ITEM            = lt_product_i
        RETURN          = ITAB_RETURN
        PARTNER         = ITAB_PARTNER
        INPUT_FIELDS    = ITAB_INPUT_FIELDS
        CREATED_PROCESS = itab_created_process
        SCHEDULELINE    = lt_schedlin_i.
    READ TABLE ITAB_CREATED_PROCESS INTO WA_CREATED_PROCESS WITH KEY GUID = LV_HEADER_GUID BINARY SEARCH.
    WA_OBJECTS_TO_SAVE-GUID = WA_CREATED_PROCESS-GUID.
    Appending the Guid of the contract to be saved to the internal table
    APPEND WA_OBJECTS_TO_SAVE TO ITAB_OBJECTS_TO_SAVE.
    CALL FUNCTION 'BAPI_BUSPROCESSND_SAVE'
      EXPORTING
        update_task_local = space
        save_frame_log    = GC_X
      TABLES
        objects_to_save   = itab_objects_to_save
        saved_objects     = itab_saved_objects
        return            = itab_return.
    Calling the Standard BAPI to Commit the transcation.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    I have debugged the above code, all the values are passing are passing to the FM "'BAPI_BUSPROCESSND_CREATEMULTI'" and these passed to the CRM_ORDER_MAINTAIN and then to CRM_ORDER_READ which are called inside the "'BAPI_BUSPROCESSND_CREATEMULTI'". Finally the sales order is created but not able to see all the values that i am passing except PROCESS_TYPE.
    Thanks a lot in Advance,
    Lakshman.

  • Create sales order va02--bapi

    i copied the program to create s.order from wiki,
    works fine.
    noew i need to add this
    item-hg_lv_item  = p_uepos.
    itemx-hg_lv_item = 'X'.
    and i get err why??
    pls.

    Hi Stephanie,
      Check this following link for creation of sales order using bapi:
    http://www.sap-img.com/fu036.htm
    Have a look at these links also:
    http://abaplovers.blogspot.com/2008/02/bap-sales-order-create.html
    http://abaplovers.blogspot.com/2008/02/bapi-sales-order-create-code.html
    Hope this helps you.
    Regards,
    Chandra Sekhar

  • HOW TO CONTROL ON CREATION OF SALES ORDER WITH REFERENCE TO EARLIER SO?

    Dear All,
    I want to contol on creation of Sales order with reference to earlier SO?  While creation of sales order our enduser are creating sales order with reference to earlier month SO which I want to restrict. Recently I made changes in sales order like payment terms is grayed, system will atomatically pick pay terms from customer master.Now I am getting correct data also but enduser is using old SO no while creating new SO and old payment data is reflecting in fbl5n.
    I want to restrict enduser while creating new SO with ref. to old SO. Only for returns they should be able to use Billing refrence. Pl. suggest how to control the with reference to ealier SO.
    Nikhil

    Nikhil Deshpande,
          If you dont want allow create a sales order in referent to other one, just delete the copy control between these sales order type, so when the user tries to create a SO in reference to other one a message is displayed that is not possible.
    Thanks,
    Mariano.

  • Creation of Sales Order and Service Contract from Inbound IDOC

    Hi Experts,
    My requirement is to create a Sales Order as well as a Service Contract from one Inbound IDOC. I am getting the Inbound IDOC from a third Party. The message type is ORDERS and Basic Type is ORDERS02. How ever i am using an extension type IDOC which carries all the required data for Sales Order and Service Contract. My requirement is like, to create a Sales Order first.
    I have created a Z FM which is attached to the Process Code and subsequently to the message type. Inside the FM i an calling FM 'IDOC_INPUT_ORDERS' for creation of Sales Order. After that i am changing the IDOC data for the Document Type. I am changing the document type which is responsible for Contract Creation.
    Then I am again calling the FM 'IDOC_INPUT_ORDERS' for creation of Contract with the help of IDOC data. But here the Contract is not getting created. It's getting failed during the Batch input session.
    I need to solve this problem as soon as possible. Please help me. If there are any other options also please share.
    Thanks in Advance.
    Regards,
    Priyabrata

    Actually there is problem with BDCDATA. Inside the FM it's calling transaction with help of BDCDATA. If i am creating a Sales order or contract alone its creating successfully. But when i am trying to create both, it's retuning sy-subrc '1001' after calling the transaction on the second attempt. Is there any problem with BDCDATA like we can't handle with less time gap? Please help and give your inputs.
    Regards,
    Priyabrata

  • Sale Order change BAPI - Storage loc not updated

    Hi Everybody,
    Iam using "BAPI_SALESORDER_CHANGE", to change the sale order items.
    First iam calling above bapi with switch B, for new pricing & then second time for material change.
    When i change any material number, it is getting updated correctly.
    But the storage location, even though iam passing in the bapi it is not updated, & is blank - updation flag is also passed.
    When i execute sale order change again it is updated - ie, for any material change for first bapi call, storage loc is not updated - for 2nd bapi call storage loc is updation - for same input in both the cases.
    Is there any way to update the storage loc is first call of sales order change bapi.
    Below is the parameters iam passing in bapi :
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
        EXPORTING
          SALESDOCUMENT      = LS_SALESDOCUMENT
          ORDER_HEADER_IN    = LT_HEADER_IN
          ORDER_HEADER_INX   = LT_HEADER_X
        TABLES
          RETURN                            = LT_RETURN
          ORDER_ITEM_IN               = LT_ITEMS
          ORDER_ITEM_INX             = LT_ITEM_X
          ORDER_CFGS_REF          = LT_CFGS_REF
          ORDER_CFGS_INST         =  LT_PARTS
          ORDER_CFGS_VALUE     = LT_VALUES
          ORDER_CFGS_BLOB        = LT_CUBLOB
          ORDER_CFGS_VK            = LT_CUVK
          ORDER_CFGS_REFINST   = LT_CUREF
          SCHEDULE_LINES            = LT_SCHEDULE_L
          SCHEDULE_LINESX         = LT_SCHEDULE_X
          ORDER_TEXT                   = LT_TEXT
          CONDITIONS_IN                = LT_CONDITION_L
          CONDITIONS_INX              = LT_CONDITION_X.
    Any help is appreciated.
    Regards,
    Nagarajan.J

    Hi,
    Storage location is updated only when same sale order bapi is called another time with required details.
    rgs,
    Nagarajan J

  • Error while creating Sales Order Through BAPI

    Hi Friends,
      i am creating a RFC where i have to create sales order .
    I am using bapi
    BAPI_SALESORDER_CREATEFROMDAT2
    for same and entering values to it.
    I got the following return messages:
    S V4                   233 SALES_HEADER_IN has been processed successfully
    S V4                   233 SALES_ITEM_IN has been processed successfully
    S V1                   311 BDN Order 3112800903 has been saved
    But when I go to transaction VA03 and enter the number i get the following error:
    SD document 3112800903 is not in the database or has been archived
    Can any one know how to resolve this error.I am also using BAPI_TRANSACTION_COMMIT with wait = 'X'.
    Regards,
    Santosh Alle

    Hi,
    Try to check the return message once.
    SD document 3112800903 is not in the database or has been archived
    You will get this message if the sales document is deleted from the database .The BAPI   'BAPI_SALESORDER_CHANGE'  is used to delete salesorder.Check whether anyone has deleted it
    Also, sometimes it may take few seconds to update the sales order in the database when using BAPI. Check the transaction after some time.
    Regards,
    Lakshman.
    Edited by: Lakshman N on May 14, 2010 7:43 AM

  • Regularly auto creation of sales order

    Hi All,
    Is it possible to define or set auto creation of sales order ? e.g. there 2000 customers that every biweekly Monday will have sales orders created automatically by system, so the user just only see and copy to delivery or A/R invoice. TIA
    Rgd,
    Mark

    This can be performed if you use activity management and set sales quotation as a linked document. use one sales quotation but contains multiples row line of items that have different delivery dates can make it possible, but only as reminder, to create sales order,.although manually, you just use copy to and the add the SO. You could also develop addon to make SBO auto creation of sales order.
    Rgds,

  • Creation of sales order in CRM and replicating it to Multiple ECC system.

    We have a requirement for creation of sales order in CRM and replicating it to Multiple ECC system.
    We have checked the following standard Adapter objects in transaction R3AC1.
    BUS_TRANS_MSG
    The initial flow contexts does not support target site type as R/3(SMOF_ ERPSITE). So we are not able to replicate the sales order from CRM
    to ECC.
        2. SALESDOCUMENT
    Here the initial flow contexts does not support flow from CRM -> R/3 as we don’t see the target site as CRM.
    Please let us know if the standard sap middleware objects don’t support the sales order flow from CRM to multiple ECC or is there any
    other adapter object we need to use for this.

    Hey Vijay Duvvada,
    I hope you are already referred below sap note  and which explains scope & how to do   -
    1084315 - Consulting: Information about the multiple backend scenario
    1763516 - How-to: Basic Setup of MEP
    As explained by Rohit Sharma data should be start flowing to multiple sites.
    please let me know if it does help.
    Regards,
    Arjun

  • Problem in uploading multiple line items while Creating sales order by BAPI

    Hi experts ,  Im able to create sales order  with one item while using this program, but the problem is  when iam having multiple  items or multiple sales order  , iam not able to createthe line items , though its creating  sales order header , Iam copy pasting my code , please add the additional code to my code to take more than 1 line items ,This is urgent requirement . Points will be rewarded for answers , Thanks in advance
    *& Report  Z_SO_CREATE_BAPI
    REPORT  Z_SO_CREATE_BAPI.
    DATA: i_header TYPE bapisdhd1 occurs 0 with header line.
    DATA: i_details TYPE bapisditm OCCURS 0 WITH HEADER LINE.
    DATA: i_partner TYPE bapiparnr OCCURS 0 WITH HEADER LINE.
    DATA: i_return1 TYPE bapiret2 OCCURS 0 WITH HEADER LINE.
    DATA: i_return2 TYPE bapiret2.
    data : ORDER_HEADER_IN like BAPISDHD1.
    data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with HEADER LINE .
    data : ORDER_ITEMS_INX Like BAPISDITMX occurs 0 with HEADER LINE .
    data : RETURN like BAPIRET2 occurs 0 with header line.
    data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
    header line.
    DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
    LiNE.
    data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
    header line.
    data : ORDER_SCHEDULES_INX like BAPISCHDLX occurs 0 with
    header line.
    data : BEGIN OF TAB OCCURS 0,
           SRNO(4),
            DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
            SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
            DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
            DIVISION like ORDER_HEADER_IN-DIVISION,
           REQ_DATE_H(10),
           PURCH_DATE(10),
           PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
           PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
           ITM_NUMBER like BAPISDITM-ITM_NUMBER,
            MATERIAL   LIKE  ORDER_ITEMS_IN-MATERIAL ,
            PLANT LIKE ORDER_ITEMS_IN-PLANT,
           TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
           ITM_NUMBERX like  ORDER_ITEMS_INX-ITM_NUMBER ,
           MATERIALX   LIKE  ORDER_ITEMS_INX-MATERIAL ,
           CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
           PLANTX LIKE ORDER_ITEMS_INX-PLANT,
           TARGET_QTYX LIKE ORDER_ITEMS_INX-TARGET_QTY,
           ITM_NUMBER LIKE ORDER_ITEMS_IN-ITM_NUMBER,
           MATERIAL   LIKE  ORDER_ITEMS_IN-MATERIAL ,
            PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
            PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
          END OF TAB.
    DATA: v_vbeln TYPE bapivbeln-vbeln.
    selection-screen begin of block b1 with frame.
    skip 3.
    parameter:p_infile like rlgrap-filename obligatory.
    skip 3.
    selection-screen end  of block b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
      PERFORM value_help.
    start-of-selection.
    CALL FUNCTION 'WS_UPLOAD'
      EXPORTING
        filename                     = p_infile
       FILETYPE                      = 'DAT'
      HAS_FIELD_SEPARATOR           = 'X'
      HEADER_LENGTH                 = 0
      READ_BY_LINE                  = 'X'
      DAT_MODE                      = ' '
      CODEPAGE                      = ' '
      IGNORE_CERR                   = ABAP_TRUE
      REPLACEMENT                   = '#'
      CHECK_BOM                     = ' '
      VIRUS_SCAN_PROFILE            =
      NO_AUTH_CHECK                 = ' '
    IMPORTING
      FILELENGTH                    =
      HEADER                        =
      tables
        data_tab                      = tab.
    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.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    **Validation for the Create SO screen
    *AT SELECTION-SCREEN ON BLOCK na_create.
    Loop at Tab.
    i_header-doc_type =  TAB-DOC_TYPE .
    i_header-sales_org = TAB-SALES_ORG.
    i_header-distr_chan = TAB-DISTR_CHAN .
    i_header-division = TAB-DIVISION .
    append i_header.
    *endloop.
    i_partner-partn_role = TAB-PARTN_ROLE .
    i_partner-partn_numb =  TAB-PARTN_NUMB.
    APPEND i_partner.
    i_details-material =  TAB-MATERIAL .
    APPEND i_details.
    endloop.
    *Bapi for Creating SO
                   CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
                     EXPORTING
                     SALESDOCUMENTIN               = v_vbeln
                       order_header_in               = i_header
                     ORDER_HEADER_INX              =
                     SENDER                        =
                     BINARY_RELATIONSHIPTYPE       =
                     INT_NUMBER_ASSIGNMENT         =
                     BEHAVE_WHEN_ERROR             =
                     LOGIC_SWITCH                  =
                     TESTRUN                       =
                     CONVERT                       = ' '
                    IMPORTING
                      SALESDOCUMENT                 = v_vbeln
                     tables
                      RETURN                        = i_return1
                      ORDER_ITEMS_IN                = i_details
                      ORDER_ITEMS_INX               = ORDER_ITEMS_INX
                       order_partners                = i_partner .
                     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 v_vbeln IS INITIAL.
    *Bapi Commit Work
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT =
    IMPORTING
    return = i_return2
    ELSE.
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
    IMPORTING
    RETURN =
    ENDIF.
    LOOP AT i_return1 .  "INTO wa_return1.
    WRITE:/ i_return1-message.
    ENDLOOP.
    FORM value_help .
      CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
        EXPORTING
          DEF_FILENAME     = ' '
          DEF_PATH         = ' '
          MASK             = ',.,..'
          MODE             = 'O'
          TITLE            = ' '
        IMPORTING
          FILENAME         = p_infile
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 4
          OTHERS           = 5.
      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.
    txt file data
    order type  salesorg   distch      divison       materialno                  parter role
    TA     PB01     01     00     000000000000000852     WE
    Partner no
    8101000000

    Hi Neerja,
    you can reffer this sample code. It may not be complet soluation for your poblem,
    but you will get some idea.
    *& Report  ZBAPI_SALESORDER_CREATE
    *& Author : Karthik
    REPORT  ZBAPI_SALESORDER_CREATE.
    data : ORDER_HEADER_IN like BAPISDHD1.
    data : ORDER_ITEMS_IN like BAPISDITM occurs 0 with
    header line.
    data : RETURN like BAPIRET2 occurs 0 with header line.
    data : ORDER_PARTNERS like BAPIPARNR occurs 0 with
    header line.
    DATA : ORDER_KEYS LIKE BAPISDKEY OCCURS 0 WITH HEADER
    LINE.
    data : ORDER_SCHEDULES_IN like BAPISCHDL occurs 0 with
    header line.
    data : BEGIN OF TAB OCCURS 0,
            SRNO(4),
            DOC_TYPE like ORDER_HEADER_IN-dOC_TYPE,
            SALES_ORG LIKE ORDER_HEADER_IN-SALES_ORG,
            DISTR_CHAN LIKE ORDER_HEADER_IN-DISTR_CHAN,
            DIVISION like ORDER_HEADER_IN-DIVISION,
           REQ_DATE_H(10),
            PURCH_DATE(10),
            PMNTTRMS LIKE ORDER_HEADER_IN-PMNTTRMS,
            PURCH_NO_C LIKE ORDER_HEADER_IN-PURCH_NO_C,
            ITM_NUMBER like BAPISDITM-ITM_NUMBER,
            CUST_MAT22 LIKE ORDER_ITEMS_IN-CUST_MAT22,
            PLANT LIKE ORDER_ITEMS_IN-PLANT,
            TARGET_QTY LIKE ORDER_ITEMS_IN-TARGET_QTY,
            PARTN_ROLE LIKE ORDER_PARTNERS-PARTN_ROLE,
            PARTN_NUMB LIKE ORDER_PARTNERS-PARTN_NUMB,
          END OF TAB.
    data: itab1 like alsmex_tabline occurs 0 with header
    line.
    DATA: gd_currentrow type i.
    data : PURCHASEORDER like ekko-ebeln.
    Data: tot_rec type i,     "Total Records
         gd_update type i,   "Main Table Increement Counter
         gd_lines type i,    "Success Table increement Counter
         w_textout like t100-text. "VARIABLE TO GET ERRORLOG
    data : begin of it_success occurs 0,
            SALESDOCUMENT LIKE BAPIVBELN-VBELN,  "PROJECT
          end of it_success.
    data : begin of it_error occurs 0,
            srno(4),
            err_msg(73) TYPE c,    "TO RETREIVE ERROR MESSAGES
         end of it_error.
    data : srno(4).
    DATA : SALESDOCUMENT LIKE  BAPIVBELN-VBELN.
    selection-screen begin of block b1 with frame.
    skip 3.
    parameter:p_infile like rlgrap-filename obligatory.
    skip 3.
    selection-screen end  of block b1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_infile.
      PERFORM value_help.
    start-of-selection.
      call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_infile
          i_begin_col             = '1'
          i_begin_row             = '2' "Do not require
    headings
          i_end_col               = '22'
          i_end_row               = '10000'
        TABLES
          intern                  = itab1
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          others                  = 3.
      if sy-subrc <> 0.
        message e010(zz) with text-001. "Problem uploading
    Excel Spreadsheet
      endif.
    *perform open_group.
      sort itab1 by row col.
    Get first row retrieved
      read table itab1 index 1.
    Set first row retrieved to current row
      gd_currentrow = itab1-row.
      loop at itab1.
    Reset values for next row
        if itab1-row ne gd_currentrow.
          append tab .
          clear tab.
          gd_currentrow = itab1-row.
        endif.
        SHIFT ITAB1-VALUE LEFT DELETING LEADING SPACE.
        case itab1-col.
          when '0001'.
            TAB-SRNO = itab1-value.
          when '0002'.
            TAB-DOC_TYPE = itab1-value.
          when '0003'.
            TAB-SALES_ORG = itab1-value.
          when '0004'.
            TAB-DISTR_CHAN = itab1-value.
          when '0005'.
            TAB-DIVISION = itab1-value.
         when '0006'.
           TAB-REQ_DATE_H =  itab1-value.
          when '0006'.
            TAB-PURCH_DATE = itab1-value.
          when '0007'.
            TAB-PMNTTRMS = itab1-value.
          when '0008'.
            TAB-PURCH_NO_C = itab1-value.
            when '0009'.
            TAB-ITM_NUMBER = itab1-value.
           when '0010'.
            TAB-CUST_MAT22 = itab1-value.
          when '0011'.
            TAB-PLANT  = itab1-value.
          when '0012'.
            TAB-TARGET_QTY = itab1-value.
          when '0013'.
            TAB-PARTN_ROLE = itab1-value.
          when '0014'.
            TAB-PARTN_NUMB = itab1-value.
        endcase.
      endloop.
      append tab.
      clear tab.
      sort tab by SRNO.
      LOOP AT TAB.
       concatenate tab-REQ_DATE_H+4(4)
    tab-REQ_DATE_H2(2) tab-REQ_DATE_H0(2) into
    tab-REQ_DATE_H.
        concatenate tab-PURCH_DATE+4(4)
    tab-PURCH_DATE2(2) tab-PURCH_DATE0(2) into
    tab-PURCH_DATE.
        SRNO = TAB-SRNO.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-PARTN_NUMB
          IMPORTING
            OUTPUT = tab-PARTN_NUMB.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT  = tab-CUST_MAT22
          IMPORTING
            OUTPUT = tab-CUST_MAT22.
        IF TAB-SRNO = SRNO.
          ORDER_HEADER_IN-DOC_TYPE = TAB-DOC_TYPE.
          ORDER_HEADER_IN-SALES_ORG = TAB-SALES_ORG.
          ORDER_HEADER_IN-DISTR_CHAN = TAB-DISTR_CHAN.
         ORDER_HEADER_IN-REQ_DATE_H = TAB-REQ_DATE_H.
          ORDER_HEADER_IN-PURCH_DATE = TAB-PURCH_DATE.
          ORDER_HEADER_IN-PMNTTRMS = TAB-PMNTTRMS.
          ORDER_HEADER_IN-PURCH_NO_C = TAB-PURCH_NO_C.
          ORDER_HEADER_IN-DIVISION  = tab-DIVISION.
          ORDER_ITEMS_IN-ITM_NUMBER = tab-ITM_NUMBER.
          ORDER_ITEMS_IN-material = TAB-CUST_MAT22.
          ORDER_ITEMS_IN-PLANT      = TAB-PLANT.
          APPEND ORDER_ITEMS_IN.
          ORDER_PARTNERS-PARTN_ROLE = TAB-PARTN_ROLE.
          ORDER_PARTNERS-PARTN_NUMB = TAB-PARTN_NUMB.
          APPEND ORDER_PARTNERS.
          ORDER_SCHEDULES_IN-ITM_NUMBER = tab-ITM_NUMBER.
          ORDER_SCHEDULES_IN-REQ_QTY = tab-TARGET_QTY.
          append ORDER_SCHEDULES_IN.
        ENDIF.
        AT END OF SRNO.
          CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
            EXPORTING
               SALESDOCUMENTIN               =
                 ORDER_HEADER_IN               = ORDER_HEADER_IN
               ORDER_HEADER_INX              =
               SENDER                        =
               BINARY_RELATIONSHIPTYPE       =
               INT_NUMBER_ASSIGNMENT         =
               BEHAVE_WHEN_ERROR             =
               LOGIC_SWITCH                  =
               TESTRUN                       =
               CONVERT                       = ' '
           IMPORTING
             SALESDOCUMENT                 = SALESDOCUMENT
            TABLES
             RETURN                        = RETURN
                 ORDER_ITEMS_IN                = ORDER_ITEMS_IN
               ORDER_ITEMS_INX               =
                 ORDER_PARTNERS                = ORDER_PARTNERS
                 ORDER_SCHEDULES_IN            = 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                    = ORDER_KEYS
               EXTENSIONIN                   =
               PARTNERADDRESSES              =
          IF SALESDOCUMENT <> SPACE.
            commit work.
            ADD 1 TO gd_update.
            it_success-SALESDOCUMENT = SALESDOCUMENT.
            append it_success.
            CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
            REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
          ELSE.
            loop at return.
              it_error-SRNO = tab-SRNO.
              it_error-err_msg = return-MESSAGE .
              Append it_error.
            ENDLOOP.
            CLEAR :SALESDOCUMENT,ORDER_HEADER_IN.
            REFRESH : RETURN,ORDER_ITEMS_IN,ORDER_PARTNERS.
          ENDIF.
        endat.
      endloop.
      DESCRIBE TABLE it_success LINES gd_lines.
      IF gd_lines GT 0.
        Display result report column headings
        PERFORM display_column_headings.
        Display result report
        PERFORM DISPLAY_SUCESS.
      ENDIF.
    IF SUCESS FAILS Display Error Report
      DESCRIBE TABLE it_error LINES gd_lines.
      IF gd_lines GT 0.
        PERFORM errorheadings.
        PERFORM errorreport.
      ENDIF.
    *&      Form  display_column_headings
          text
    FORM display_column_headings.
      WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
      SKIP.
      WRITE:2 'The following records inserted
    successfully:'(013).
      WRITE:/ sy-uline(15).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
               (10) 'Sales order'(004), sy-vline.
      WRITE:/ sy-uline(15).
    ENDFORM.                    "display_column_headings
    *Subroutine to display SUCESS REPORT
    FORM DISPLAY_SUCESS.
      FORMAT COLOR COL_NORMAL.
      LOOP AT it_success.
        WRITE:/      sy-vline,
            (10)  it_success-SALESDOCUMENT, sy-vline.
        CLEAR it_success.
      ENDLOOP.
      WRITE:/ sy-uline(15).
      REFRESH: it_success.
      FORMAT COLOR COL_BACKGROUND.
    ENDFORM.                               "
    DISPLAY_REPORT
    *&      Form  errorreport
          text
    FORM errorreport.
      LOOP AT it_error.
        WRITE:/      sy-vline,
                (10) it_error-SRNO, sy-vline,
                 (40) it_error-err_msg, sy-vline.
      ENDLOOP.
      WRITE:/ sy-uline(104).
      REFRESH: it_error.
    endform.                    "errorreport
    *&      Form  ERRORHEADINGS
          text
    FORM ERRORHEADINGS.
      SKIP.
      WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
      SKIP.
      WRITE:2 'The following records failed during
    update:'(008).
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
              (10) 'ERROR.'(009), sy-vline.
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_NORMAL.
    ENDFORM.                    "ERRORHEADINGS
    **&      Form  value_help
          text
    -->  p1        text
    <--  p2        text
    FORM value_help .
      CALL FUNCTION 'DSVAS_DOC_WS_FILENAME_GET_50'
        EXPORTING
          DEF_FILENAME     = ' '
          DEF_PATH         = ' '
          MASK             = ',.,..'
          MODE             = 'O'
          TITLE            = ' '
        IMPORTING
          FILENAME         = p_infile
        EXCEPTIONS
          INV_WINSYS       = 1
          NO_BATCH         = 2
          SELECTION_CANCEL = 3
          SELECTION_ERROR  = 4
          OTHERS           = 5.
      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.                    "value_help
    Regards,
    Amit.

  • Need of User-Exit  in the creation of Sales Order(VA01)

    Hi,
    In the creation of Sales Order, I need to Compare the Ordered Quantity and Confirmed Quantity. If the CQ is less than OQ I need to create one more line item with the same material for the rest of the quantity and send the request to Production order for the remaining quantity. For this I am unable to get the exact exit. Please help me in this regard ASAP.
    Thank you.

    the following program are the user exit for billing.
    we often use RV60AFZC and RV60AFZZ.
    RV60AFZA
    RV60AFZB
    RV60AFZC
    RV60AFZD
    RV60AFZZ
    RV60BFZA
    For Sales order
    Pricing, item addtion deletion
    MV45AFZZ
    First, I did not find documentation for the BADI either. But at the first glance the process of implementing it looks quite straightforward. I assume you run R/3 Enterprise (4.7). So, you should implement BADI 'BADI_SD_SALES' - this must be done in transaction SE19. In particular for the purpose of adding some additional items into sales document I would implement method SAVE_DOCUMENT_PREPARE. This method has changing table parameter FXVBAP of type VA_VBAPVB_T - it holds all the sales document items. Just add items of yours to it. Certainly, you have to fill all the appropriate fields carefully.
    Hope this helps somehow.
    In that case you should use USEREXIT_DOCUMENT_SAVE_PREPARE subroutine (form). As far as I remember it has no parameters. To add items to the sales document you should modify internal table XVBAP.
    regards
    vinod

Maybe you are looking for

  • How to open already closed period in MM

    Hello GURU I have heard its porrible to open alrady closed period in MM in MMPI But I would like to know your opinion and how exactyl this can be done?we are in 04 period now and user wnats to open period 01 thanks in advance hana

  • Is it possible for me to delete all my information in my lost ipod touch? It is in IOS 6.

    Is it possible for me to delete all my information in my lost ipod touch? It is in IOS 6.1.1

  • Ipod touch 1st generation won't play on ihome doc

    I have a 1st generation ipod touch, 32GB.  I received an iHome for Christmas last year that states it is compatible with the 1st generation ipod touch however when I put it in the cradle, it connects and disconnects over and over.  I looked and iTune

  • ADF calendar styling

    Hi I am very new to ADF , I was trying to use styling for af:calendar component , but I could not find any sample code on the web , I tried using the instructions in the link but I was not succesfull http://www.art2dec.com/documentation/docs/fmw11g11

  • 3rd Party adapter on different JVM

    Dear Experts, We want to buy a 3rd party adapter for SFTP as that is not supported in standard SAP PI, we are on SAP PI7.0. Can we install the 3rd party adapter on a separate JVM and use it in ID? The adapters we are considering are Advantco & Aedapt