Extending sales order change BAPI and updating custom fields

Hi
i added 3 new fields into VA01/02/03 screen.i added at the header level in the additional data tab B area and appended them in VBAK table.
i want to change these values using sales order change BAPI.i added the fields in the structure VBAKKOZ,VBAKKOZX,BAPE_VBAK,BAPE_VBAKX.
may i know what else i need to do?should i move them anywhere with in the code or does the bapi take those values automatically using EXTENSIONIN structure?
also can some one send me code to actually check if bapi is changing my values?
if poss tell me how should i populate values into BAPI.

After adding field in structures VBAKKOZ,VBAKKOZX,BAPE_VBAK,BAPE_VBAKX, create pair of name-value pair extensiot structure and value.
Fill values as follows :
Data :   ls_parex  TYPE  bapiparex,
            lt_parex  TYPE STANDARD TABLE OF  bapiparex.
ls_parex-structure = 'BAPE_VBAK'.
ls_parex-valuepart1+0(10) = Sales order no
ls_parex-valuepart1+10(XX) = somevalue.  <---- Value for custom field no 1
ls_parex-valuepart1+XX(XX) = somevalue.  <---- Value for custom field no 2
APPEND ls_parex TO lt_parex  .
clear ls_parex.
ls_parex-structure = 'BAPE_VBAKX'.
ls_parex-valuepart1+0(10) = Sales order no
ls_parex-valuepart1+10(1) = 'X'. <--- checkbox mark for custom field no 1
ls_parex-valuepart1+11(1) = 'X'. <--- checkbox mark for custom field no 2
APPEND ls_parex TO lt_parex.
Same pair for VBAKKOZ & VBAKKOZX
Updating custom fields
  CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
      salesdocument    = Sales order number
      order_header_inx = 'U'   <--- U for update
    TABLES
      extensionin      = lt_parex[].
Edited by: nkarwa on Oct 25, 2010 12:39 PM

Similar Messages

  • Sales Order Change BAPI Extension for Customer Fields

    Hello!
    I am working on customer field enhancement for BAPI_salesorder_change. The extensionin parameter has more than 1000 characters (fields in the structure BAPE_VBAP) and hence, the two fields that I added to VBAP (using append structure) are not getting the data.
    I have followed all the steps that was given in the documentation to fill extensionin like adding the fields to VBAPKOZ and BAPE_VBAP. This is the logic I have used to fill EXTENSIONIN:
    BAPE_VBAP-VBELN = P_order.
    BAPE_VBAP-POSNR = i_vbap-posnr.
    BAPE_VBAP-ZZSTART_DT = sy-datum.
    BAPE_VBAP-ZZdnload_DT = sy-datum.
    T_EXTEN-STRUCTURE = 'BAPE_VBAP'.
    *T_EXTEN+30 = BAPE_VBAP.
    T_EXTEN-valuepart1 = bape_vbap.
    T_EXTEN-valuepart2 = bape_vbap+240(240).
    T_EXTEN-valuepart3 = bape_vbap+480(240).
    T_EXTEN-valuepart4 = bape_vbap+720(240).
    APPEND T_EXTEN.
    Clear t_exten.
    BAPE_VBAPX-VBELN = P_order.
    BAPE_VBAPX-POSNR = i_vbap-posnr.
    BAPE_VBAPX-ZZSTART_DTX = 'X'.
    BAPE_VBAPX-ZZdnload_DTX = 'X'.
    T_EXTEN-STRUCTURE = 'BAPE_VBAPX'.
    T_EXTEN-valuepart1 = bape_vbapx.
    APPEND T_EXTEN.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    salesdocument = p_order
    order_header_inx = ORDER_HEADERX
    tables
    return = T_RETURN
    *ORDER_ITEM_IN = T_LINE
    *ORDER_ITEM_INX = T_LINEX
    EXTENSIONIN = T_EXTEN.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    I guess there is 960 character limitation for BAPIPAREX structure but I would like to know if there is a way to work around it.
    Thanks to all for your time.

    Found BAPI myself...... BAPI_SALESORDER_CHANGE

  • Sales order change BAPI not updating items Profit center

    Dear ,
    I am facing the problem in using the BAPI for Item 's profit centre  in blank space.
    I write down the below code <but it's not at all updating the profite centre .
    please ccorrect the code if any required'
    TYPES: BEGIN OF file_data ,
           vbeln TYPE vbap-vbeln, " order numner
           posnr TYPE vbap-posnr, " orderitem
           profit_ctr TYPE vbap-prctr, " [profite centre
          END OF file_data.
    DATA: t_data TYPE STANDARD TABLE OF file_data .
    DATA : wa_data LIKE LINE OF t_data.
    DATA: t_data_item TYPE STANDARD TABLE OF file_data .
    DATA : wa_data_item LIKE LINE OF   t_data_item.
    **DATA: t_data_item TYPE file_data OCCURS 0.
    *DATA: return TYPE STANDARD TABLE OF bapiret2.
    *DATA: wa_return LIKE LINE OF return.
    DATA: wait LIKE bapita-wait VALUE 'X'.
    DATA: s_order_header_in LIKE bapisdh1.
    DATA: s_order_header_inx LIKE bapisdh1x.
    DATA: BEGIN OF i_order_item_in OCCURS 0.
            INCLUDE STRUCTURE bapisditm.
    DATA: END OF i_order_item_in.
    DATA: BEGIN OF i_order_item_inx OCCURS 0.
            INCLUDE STRUCTURE bapisditmx.
    DATA: END OF i_order_item_inx.
    DATA: BEGIN OF it_return OCCURS 0.
            INCLUDE STRUCTURE bapiret2.
    DATA: END OF it_return.
    ***********************selection
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    PARAMETERS : file LIKE rlgrap-filename OBLIGATORY.
    "ctu_mode  TYPE ctu_mode  DEFAULT 'N'.
    SELECTION-SCREEN END OF BLOCK b1.
    *********assign file
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR file.
      CLEAR file.
      CALL FUNCTION 'F4_FILENAME'
        IMPORTING
          file_name = file
        EXCEPTIONS
          OTHERS    = 1.
      DATA:  it_text TYPE truxs_t_text_data .
      CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
        EXPORTING
          i_field_seperator    = 'X'
          i_line_header        = 'X'
          i_tab_raw_data       = it_text
          i_filename           = file
        TABLES
          i_tab_converted_data = t_data[] " Your internal table of structure of Excel sheet
        EXCEPTIONS
          conversion_failed    = 1
          OTHERS               = 2.
      t_data_item[] =  t_data[].
      DELETE ADJACENT DUPLICATES FROM t_data COMPARING vbeln.
    Header update indicator
      s_order_header_inx-updateflag = 'U'.
    Line items
      REFRESH: i_order_item_in, i_order_item_inx.
      LOOP AT t_data INTO wa_data.
        LOOP AT t_data_item INTO wa_data_item WHERE vbeln = wa_data-vbeln. .
          i_order_item_in-itm_number = wa_data_item-posnr.
          i_order_item_in-profit_ctr = wa_data_item-profit_ctr.
          i_order_item_inx-itm_number = wa_data_item-posnr.
          i_order_item_inx-updateflag = 'U'.
          i_order_item_inx-profit_ctr = 'X'.
          APPEND: i_order_item_in, i_order_item_inx.
        ENDLOOP.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = wa_data-vbeln
          IMPORTING
            output = wa_data-vbeln.
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            salesdocument     = wa_data-vbeln
            order_header_in   = s_order_header_in
            order_header_inx  = s_order_header_inx
            behave_when_error = 'P'
          TABLES
            return            = it_return
            order_item_in     = i_order_item_in
            order_item_inx    = i_order_item_inx.

    i already used same But it's not working
    s_order_header_inx-updateflag = 'U'.
    Line items
      REFRESH: i_order_item_in, i_order_item_inx.
      LOOP AT t_data INTO wa_data.
        LOOP AT t_data_item INTO wa_data_item WHERE vbeln = wa_data-vbeln. .
    BAPISDITM
          i_order_item_in-itm_number = wa_data_item-posnr.
          i_order_item_in-profit_ctr = wa_data_item-profit_ctr.
    BAPISDITMX
          i_order_item_inx-itm_number = wa_data_item-posnr.
          i_order_item_inx-updateflag = 'U'.
          i_order_item_inx-profit_ctr = 'X'.
          APPEND: i_order_item_in, i_order_item_inx.
        ENDLOOP.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = wa_data-vbeln
          IMPORTING
            output = wa_data-vbeln.
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            salesdocument     = wa_data-vbeln
            order_header_in   = s_order_header_in
            order_header_inx  = s_order_header_inx
            behave_when_error = 'P'
          TABLES
            return            = it_return
            order_item_in     = i_order_item_in
            order_item_inx    = i_order_item_inx.

  • 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

  • Calling a Sales Order Change BAPI in a Sales Order Exit

    Functional Requirement:
    While creating a Sales Order with Reference to another Sales Order, on saving the new sales order, change something in the referenced sales order.
    I am trying to achieve the same by doing the following:
    In the standard SAP user exit called during saving the new sales order USEREXIT_SAVE_DOCUMENT I am calling the BAPI BAPI_SALESORDER_CHANGE on the referenced Sales Order.
    However the BAPI is unable to change the other sales order giving an error Enter the document number. I am specifying the Document Number while calling the BAPI, so I know that is not the error.
    I just wish to know whether it is technically possible to call a BAPI to update another Sales Order while we are currently saving one Sales Order.

    Hi Girish,
    If it works correctly when run seperately and you are sure the data passed into the BAPI is exactly the same then it may be something like table locks or similar causing your original problems...
    What about packaging up your working Z program into a custom function module and calling that from within USEREXIT_SAVE_DOCUMENT as a seperate task (IN NEW TASK) and building in a slight delay of say 5 seconds at the start of your code?
    I'll be honest, this isn't an ideal solution but might be sufficient to resolve your issues.  I'd be inclined to see if you could just run your Z program as a background process every 5 minutes or so to capture any changes and perform updates but if this is a no no from your functional people I'm not sure what else to suggest sorry.  I've never personally had to update a document from within the save routine of another document so can't give any advice based on my own experiences sorry.
    Gareth.

  • Credit card handling using sales order change BAPI

    Hi all,
      Currently, I am working on creating a custom BAPI for changing the sales order information. I am having a scenario where I need to handle multiple credit cards during the change of the sales order data. For example, if I have created a sales order  with a credit card A and a bill amount of 100. Now, in the change BAPI, I need to handle the situation like I would be getting two credit cards data out of which I need to Bill against credit card A with 200 and credit card B with 300. I need to see the entries in the sales order processing in the following fashion:
    During the creation:
    Credit card type    Credit card number    Maximum amount  Limit To
    AMEX                   A                             100                        Flag checked
    After performing change order:
    Credit card type    Credit card number    Maximum amount  Limit To
    AMEX                   A                             100                       Flag checked
    VISA                    B                              300                       Flag checked
    AMEX                   A                             100                       Flag checked
    Which implies that I am billing 200 against card A and 300 against card B.
    I want to acheive this functionality. Can any one throw some light in order to accomplish my task?
    Thanks in advance,
    From,
    Adithya

    i already used same But it's not working
    s_order_header_inx-updateflag = 'U'.
    Line items
      REFRESH: i_order_item_in, i_order_item_inx.
      LOOP AT t_data INTO wa_data.
        LOOP AT t_data_item INTO wa_data_item WHERE vbeln = wa_data-vbeln. .
    BAPISDITM
          i_order_item_in-itm_number = wa_data_item-posnr.
          i_order_item_in-profit_ctr = wa_data_item-profit_ctr.
    BAPISDITMX
          i_order_item_inx-itm_number = wa_data_item-posnr.
          i_order_item_inx-updateflag = 'U'.
          i_order_item_inx-profit_ctr = 'X'.
          APPEND: i_order_item_in, i_order_item_inx.
        ENDLOOP.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = wa_data-vbeln
          IMPORTING
            output = wa_data-vbeln.
        CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
          EXPORTING
            salesdocument     = wa_data-vbeln
            order_header_in   = s_order_header_in
            order_header_inx  = s_order_header_inx
            behave_when_error = 'P'
          TABLES
            return            = it_return
            order_item_in     = i_order_item_in
            order_item_inx    = i_order_item_inx.

  • Completed sales order changed with the updated ship-to address

    Hi,
    My client did the following test and found that:
    - Change the ship-to address of a customer
    - new sales order of this customer defauted to the update ship-to address (good!)
    - old/completed sales orders of this customer show the new ship-to address (bad!)
    Data used in occurred transactions should not be affected by data maintenances that made after the transactions. So, is the finding a design flaw in OM or there is parameter that can be tuned?
    Thanks in advance for any input!

    Hi,
    Oracle will not store the entire Address in Sales Order tables. It will only store the internal id.
    Now there could be two possible scenarios for which your client tried to chance the ship to address:
    1) There is a correction required in the address(e.g. change in street name). If this is the case then changing the address would be correct approach, and I think all the sales orders(old or new) should reflect correct address.
    2) If there is a relocation, then the correct approach would be to make the current customer site inactive and create a new site for the new address instead of changing the existing site. Changing the address of existing site for such a business scenario may not be a correct approach.
    So based on what was the reason for changing the ship to address, I would say the system is functioning as expected.
    Hope this helps.
    Regards,
    Nitin S. Darji

  • Sale order create BAPI and output types

    Hi Experts,
           In our organization, we are using BAPI BAPI_SALESORDER_CREATEFROMDAT2 to create sales order.
    We are having no problem creating sales orders. But one more functionality they wanted to add.
    We have a screen where user enters all the data and at the same time he selects weather the order should be printed or Faxed or both.
    Please let me know where i can send this information in that BAPI and how.
    I hope ORDER_KEYS is the table to send the data. If that is the case, could you please explain how that works and how that makes entry in NAST table.
    Thanks,
    ABAPer.

    To propose output type automatically, you need to maintain proper output determination for the sales.
    For example, you want to have BA00 output for every order, than you need to maintain the order type for that condition in VV11 transaction. Here you can maintain customer numbers. Now, when you create a Sales order for this customer and saves it, system automatically propose an output.
    So, you need to maintain on output detemination to propose output.
    Regards,
    Naimesh Patel

  • Sales Order Change BAPI - Reason for Rejection

    Hi,
    I want to update reason for rejection field for a particular sales order at item level. When I am executing the BAPI "BAPI_SALESORDER_CHANGE", I am getting the error "Field header_inx-updateflag is not an input field". I did not check this field as I'm not making any change in the header part.
    Please help me in resolving this issue. Let me know if I have to provide any other information.
    regards,
    ravikiran.

    Found BAPI myself...... BAPI_SALESORDER_CHANGE

  • Sales order simulation bapi and material price group???

    Hello every one...
    I am calling BAPI_SALESORDER_SIMULATE to get the pricing simulation of a sales order, My requirement is that I want to enter Material Pricing group (KONDM) so that pricing be simulated according to the material pricing group I enter..... but the simulation bapi does not provide this field,,, I cannot use sales order create from data2 bapi,, as it does not provide condition table as output, which is also my core requirement,,, my question is that is there some bapi/fm where I can provide material pricing group along with other info and retrieve complete simulation of sales order pricing with condition details aswell....
    thanks

    Managed it using abap memory and prepare hearder info user exit routine

  • FM or BAPI to update custom fields in Excise invoice header (J_1IEXCHDR) table

    Dear friends,
    I have created the following custom fields in standard table J_1IEXCHDR (Excise invoice header detail),
    1) ZZKURRF - Exchange rate
    2) ZZWAERK - SD Document Currency
    Is there any BAPI or Function module to update these Custom fields of Excise header table J_1IEXCHDR?
    Have a nice day ....
    Thanks.

    Dear Lakshmipathi,
    Sorry for posting in wrong domain.
    Thanks for your immediate response. I will use the FM J_1I7_USEREXIT_EXCISE_BEF_SAVE for Excise invoices created in future.
    But, I have to update the custom data for existing records in J_1IEXCHDR. For that I need a FM or BAPI.
    Please provide the same.
    Thanks in advance .
    Have a nice day .

  • Sales Orders Change Log question

    Hi All,
    I am currently working on a project that involves querying SAP Database to get custom reports via web browser, I've made a lot of advances and most of the site is ready but I'm missing just one item that I hope you could help me.
    Thing is I am working with the Sales Order change log and the problem comes one a user deletes a row. If I go to the change log inside SAP and see the differences a new record will be shown saying that row X was deleted and
    if I go to the database (ADOC and ADO1 tables) I don't have a way to see wich row was deleted.
    My way of doing this is to check for the number of rows on the current state of the sales order and check the same on the previous instance of the SO and see if a line was deleted. Then I would have to check row by row between instances what rows are there and what row is missing and store that info. I think this kind of approach will definitively kill the server.
    I was wondering if some one can give me a hint about how to approach this problem. Does any body know how SAP works on this area?
    I'm working with SAP2005A and SQL Server 2005 Standard Edition.
    Any help is greatly appreciated.
    Thanks!
    Alejandro.-

    Hola Alejandro,
    Thanks for your answer, as I see it I'm doing exactly what you proposed but the problem comes with the following scenarios:
    a.- If I post a new SO with two lines I will have on the ADO1 table two records with the values 0 and 1 for each line respectively but if I delete the item on LineNum = 1 and then I add a new item, this last item will be also created with LineNum value = 1. This is not a complicated thing to do but the problem comes when the user is used to work with SOs with several items at detail level and is used to add and erase lines once in a while and as I see it it's very difficult for me to track those specific changes. There's also the fact that on the Log table a new instance is created every time the user hits the update button regardless if a modification was actually made or not. I mean I would know that a line was deleted or added but I would have to start comparing each field on each line of a sales order with it's previous instance to check what was actually added/deleted and I'm afraid that this may affect the server performance. I know that SAP does this without affecting to much the system resources and that is what I'm trying to find.
    I forgot the other scenario I was considering he he I will post again as soon as I remember it but I hope I'm explaining this ok (I'm not very good at explaining...) If not let me know and I'll try to explain again.
    I'm also working on trying to get another approach to see what comes up...
    Thanks for checking this thread, your answers are helpful.
    Regards.

  • Updating a child of a BOM material using bapi sales order change

    Hi, Appreciate your thoughts on the following issue..
    We have a batch program which uses a bapi sales order change and updates the plant at the line items of the sales order. when this plant is assigned.. if any of the line item is a BOM item, it explodes and the data from the parent ( like payment terms, fixed val date ) should get copied to the child items same as the parent. This is happening fine if manual mode using va01 and va02 but when plant is updated using bapi the childs are not getting the data from the parent ( which comes through config )...
    Appreciate your inputs and any additional information to be passed to the bapi for the BOM materials to get the same config data as parent to the child when exploded...
    Thanks and will reward helpful answers..

    Hi, Appreciate your thoughts on the following issue..
    We have a batch program which uses a bapi sales order change and updates the plant at the line items of the sales order. when this plant is assigned.. if any of the line item is a BOM item, it explodes and the data from the parent ( like payment terms, fixed val date ) should get copied to the child items same as the parent. This is happening fine if manual mode using va01 and va02 but when plant is updated using bapi the childs are not getting the data from the parent ( which comes through config )...
    Appreciate your inputs and any additional information to be passed to the bapi for the BOM materials to get the same config data as parent to the child when exploded...
    Thanks and will reward helpful answers..

  • Change of open sales order : using BAPI

    Hi
       this  is ravi
                      can any one help me on this  topic
            1)change of open sales order  using BAPI .With appropriate reason( like header level reason)
                       thanks & regards

    hI,
        chk this FM BAPI_SALESORDER_PROXY_UPLOAD how the FM BAPI_SALESORDER_CHANGE was used
    Check this code,
    REPORT Z_SALES_ORDER_CHANGE
    NO STANDARD PAGE HEADING
    LINE-SIZE 132
    LINE-COUNT 65(0)
    MESSAGE-ID ZZ.
    TABLES: VBAP.
    DATA:
    V_FILEIN(90) TYPE C,
    V_RECIN TYPE I,
    V_RECVBAP TYPE I,
    V_RECORDER TYPE I,
    V_VBELN LIKE VBAP-VBELN,
    ORDERHEADERINX LIKE BAPISDH1X.
    DATA: BEGIN OF I_ORDERS OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    BRGEW(18) TYPE C,
    VOLUM(18) TYPE C,
    END OF I_ORDERS.
    DATA: BEGIN OF I_OUTPUT OCCURS 0,
    VBELN LIKE VBAK-VBELN,
    POSNR LIKE VBAP-POSNR,
    GEWEI LIKE VBAP-GEWEI,
    BRGEW LIKE VBAP-BRGEW,
    VOLUM LIKE VBAP-VOLUM,
    CKWGT TYPE C,
    CKVOL TYPE C,
    END OF I_OUTPUT.
    DATA: BEGIN OF ORDERITEMIN OCCURS 0.
    INCLUDE STRUCTURE BAPISDITM.
    DATA: END OF ORDERITEMIN.
    DATA: BEGIN OF ORDERITEMINX OCCURS 0.
    INCLUDE STRUCTURE BAPISDITMX.
    DATA: END OF ORDERITEMINX.
    DATA: BEGIN OF RETURN OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA: END OF RETURN.
    DATA: BEGIN OF BAPIRETURN OCCURS 0.
    INCLUDE STRUCTURE BAPIRET2.
    DATA: END OF BAPIRETURN.
    PARAMETERS:
    P_PATH(45) TYPE C DEFAULT '/usr/users/ftpsapom/' LOWER CASE,
    P_FNAME(32) TYPE C DEFAULT '/sweetjo.txt' LOWER CASE.
    START-OF-SELECTION.
    CONCATENATE PATH AND FILE NAME INTO ONE VARIABLE
    CONCATENATE P_PATH P_FNAME INTO V_FILEIN.
    OPEN DATASET
    IF V_FILEIN IS INITIAL.
    MESSAGE E002 WITH 'FILE' V_FILEIN 'DOES NOT CONTAIN ANY DATA!'.
    ELSE.
    OPEN DATASET V_FILEIN
    FOR INPUT
    IN TEXT MODE.
    IF SY-SUBRC = 0.
    READ DATASET
    DO.
    READ DATASET V_FILEIN INTO I_ORDERS.
    IF SY-SUBRC = 0.
    APPEND I_ORDERS.
    ELSE.
    EXIT.
    ENDIF.
    ENDDO.
    CLOSE DATASET
    CLOSE DATASET V_FILEIN.
    IF SY-SUBRC <> 0.
    MESSAGE E002 WITH 'ERROR - CLOSING' V_FILEIN.
    ENDIF.
    ELSE.
    MESSAGE E002 WITH 'ERROR - COULD NOT OPEN' V_FILEIN.
    ENDIF.
    ENDIF.
    SORT AND REMOVE DUPLICATES FROM I_ORDERS
    SORT I_ORDERS BY VBELN POSNR.
    DELETE ADJACENT DUPLICATES FROM I_ORDERS.
    POPULATE I_OUTPUT
    LOOP AT I_ORDERS.
    SHIFT I_ORDERS-POSNR LEFT DELETING LEADING SPACE.
    CONCATENATE '0' I_ORDERS-POSNR INTO I_ORDERS-POSNR.
    SELECT SINGLE BRGEW VOLUM
    FROM VBAP
    INTO (VBAP-BRGEW, VBAP-VOLUM)
    WHERE VBELN = I_ORDERS-VBELN
    AND POSNR = I_ORDERS-POSNR.
    IF SY-SUBRC = 0.
    IF VBAP-BRGEW = 0.
    I_OUTPUT-CKWGT = 'X'.
    ENDIF.
    IF VBAP-VOLUM = 0.
    I_OUTPUT-CKVOL = 'X'.
    ENDIF.
    I_OUTPUT-VBELN = I_ORDERS-VBELN.
    I_OUTPUT-POSNR = I_ORDERS-POSNR.
    I_OUTPUT-GEWEI = 'ST'.
    I_OUTPUT-BRGEW = I_ORDERS-BRGEW.
    I_OUTPUT-VOLUM = I_ORDERS-VOLUM.
    APPEND I_OUTPUT.
    CLEAR: I_OUTPUT.
    ENDIF.
    V_RECIN = V_RECIN + 1.
    ENDLOOP.
    POPULATE BAPI DATA AND RUN BAPI
    CLEAR: ORDERHEADERINX, ORDERITEMIN, ORDERITEMINX,
    RETURN, BAPIRETURN.
    REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
    ORDERHEADERINX-UPDATEFLAG = 'U'.
    LOOP AT I_OUTPUT WHERE CKWGT = 'X' OR CKVOL = 'X'.
    V_RECVBAP = V_RECVBAP + 1.
    IF I_OUTPUT-VBELN <> V_VBELN AND SY-TABIX <> 1.
    V_RECORDER = V_RECORDER + 1.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    SALESDOCUMENT = V_VBELN
    ORDER_HEADER_INX = ORDERHEADERINX
    TABLES
    RETURN = RETURN
    ORDER_ITEM_IN = ORDERITEMIN
    ORDER_ITEM_INX = ORDERITEMINX.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT = 'X'
    IMPORTING
    RETURN = BAPIRETURN.
    WRITE OUT RETURN
    LOOP AT RETURN.
    WRITE: / RETURN.
    ENDLOOP.
    WRITE: / BAPIRETURN.
    SKIP.
    CLEAR: ORDERITEMIN, ORDERITEMINX,
    RETURN, BAPIRETURN.
    REFRESH: ORDERITEMIN, ORDERITEMINX, RETURN, BAPIRETURN.
    ENDIF.
    ORDERITEMIN-ITM_NUMBER = I_OUTPUT-POSNR.
    ORDERITEMIN-UNTOF_WGHT = I_OUTPUT-GEWEI.
    IF NOT I_OUTPUT-CKWGT IS INITIAL.
    ORDERITEMIN-GROSS_WGHT = I_OUTPUT-BRGEW.
    ORDERITEMINX-GROSS_WGHT = 'X'.
    ENDIF.
    IF NOT I_OUTPUT-CKVOL IS INITIAL.
    ORDERITEMIN-VOLUME = I_OUTPUT-VOLUM.
    ORDERITEMINX-VOLUME = 'X'.
    ENDIF.
    APPEND ORDERITEMIN.
    ORDERITEMINX-ITM_NUMBER = I_OUTPUT-POSNR.
    ORDERITEMINX-UNTOF_WGHT = 'X'.
    ORDERITEMINX-UPDATEFLAG = 'U'.
    APPEND ORDERITEMINX.
    V_VBELN = I_OUTPUT-VBELN.
    ENDLOOP.
    RUN BAPI ON LAST ORDER
    IF NOT ORDERITEMIN IS INITIAL.
    V_RECORDER = V_RECORDER + 1.
    CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
    EXPORTING
    SALESDOCUMENT = V_VBELN
    ORDER_HEADER_INX = ORDERHEADERINX
    TABLES
    RETURN = RETURN
    ORDER_ITEM_IN = ORDERITEMIN
    ORDER_ITEM_INX = ORDERITEMINX.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
    WAIT = 'X'
    IMPORTING
    RETURN = BAPIRETURN.
    WRITE OUT RETURN
    LOOP AT RETURN.
    WRITE: / RETURN.
    ENDLOOP.
    WRITE: / BAPIRETURN.
    SKIP.
    ENDIF.
    WRITE OUT RECORD COUNT FROM FILE
    WRITE: / 'RECORD COUNT FROM FILE ', V_RECIN.
    SKIP.
    WRITE OUT RECORD COUNT FROM FILE
    WRITE: / 'RECORD COUNT OF LINES TO CHANGE ', V_RECVBAP.
    SKIP.
    WRITE OUT RECORD COUNT FROM FILE
    WRITE: / 'RECORD COUNT OF ORDERS TO CHANGE ', V_RECORDER.
    SKIP.
    TOP OF PAGE
    TOP-OF-PAGE.
    WRITE:/1(5) TEXT-H01, 6(8) SY-DATUM MM/DD/YY,
    100(8) TEXT-H02, 126(8) SY-PAGNO.
    WRITE:/1(5) TEXT-H03, 6(8) SY-UZEIT USING EDIT MASK '__:__:__',
    20(77) TEXT-H04,
    100(8) TEXT-H05, 108(25) SY-REPID.
    WRITE:/1(6) TEXT-H06, 8(12) SY-UNAME,
    20(4) TEXT-H07, 25(32) SY-HOST,
    100(13) TEXT-H08, 121(8) SY-SYSID,
    129 '/', 130(3) SY-MANDT.
    ULINE.
    SKIP
    <b>Reward points</b>
    Regards

  • Function module/ Bapi for Sales order change

    Hi Experts,
    I require to have a Bapi/ function module to change a existing sales order to insert value in the field VBAP-SOBKZ.
    Please suggest.
    Thanks,
    Shibaji.

    HI,
    I have identified this Bapi but this Bapi does not contain the relevant field to update. Can you suggest any other Function module/ Bapi to update the field.
    Thanks & Regards,
    Shibaji

Maybe you are looking for

  • IMac slow/freezing when running iTunes

    Hello all, I have an iMac that seems to run flawlessly unless I open iTunes.  It is extremely slow and freezes everything on the computer.  If I close iTunes via the activity monitor, the system snaps right back into action.  I've browsed many soluti

  • System allowing order related Billing for rejected item in sales order

    Hi all, I have created a new reason for rejection: "Billed before Go live" I have then asigned it to sales item 10 in sales order thus rejecting it. I expected that when I do the billing for this sales order, the system will not allow to bill the rej

  • Trade in value of S4

    For unlocked S5

  • Why gnome-ppp establish mobile broadband connection,not networkmanager

    I am using usb radio modem AirPlus MCD-650 on my summer cottage and trying to setup internet. I have both Ununtu and Archlinux partitions, but prefer to use Arch, because my computer is too old for heavy Ubuntu OS. There is no problem to connect to i

  • Looking of tip on nested select statments

    Hi -- I am trying to count the distinct value of field in the table, but when processer get to this line and (b.emplid = z.emplid). It gives me error invalid table name. I used the z as an alias for the selection... would you please tell what I am do