Problem in sales order change via BAPI

We are in AFS system and we try to reduce a quantity in sales order via BAPI.
We recive back an error 8w 280. We are not able to find wich is and where is a problem.
Does anyone have experince on that problem/error message
Thanks in advance
Andrea

Hi Andrea,
Since BAPI invloves more programming stuff, I adivce you to post this thread in the ABAP forums also.
Regards,
Senthilkumar SD

Similar Messages

  • Unloading Points (KUWEV-ABLAD) on Sales Order Header via BAPI

    Hello all, first day posting on this forum, but I thought I'd answer a question before posting my own.
    We've built a nice .net based solution to entering sales orders into SAP using BAPI's, however I cannot find where we can set the Unloading Point ( field KUWEV-ABLAD) at the header level for a sales order. We're using BAPI_SALESORDER_CREATEFROMDAT2 to create the sales order, and that works fine, but there's nothing in ORDERHEADERIN to set this field.
    I found a field in ORDERPARTNERS, called Unload_Pt , which relates to an ABLAD field, but passing the value to this parameter doesn't seem to work, which makes me think that it's a different unlaoding point.
    Can anyone help me here? Does the parameter not exist? Do I have to extend the BAPI (something I've never done before) or is there a simple method of updating the field directly somehow?
    Any help would be appreciated,
    Thanks
    Matthew

    I've found the answer to this problem, in case anyone comes across this forum when searching in the future.
    the answer WAS to use the UNLOAD_PT field, but (and this should have been obvious) you have to add a line for the Ship-to-Party in the ORDERPARTNER structure, this has the function parameter "WE" (you'll have a line for sold-to "AG" already)
    you can then enter the text of the correct unloading point into the UNLOAD_PT field
    hope this helps
    Matthew

  • Sales order change through bapi

    iam uploading va02 changes through bapi..but its not changing the sales order
    details in bapi_change function module item number its taking as zero. plz can any one
    say where iam going wrong.this is my code
    *______BAPI STRUCTURES
    data : bapi_header type BAPISDH1 occurs 0 with header line,
           bapi_item type BAPISDITM occurs 0 with header line,
           bapi_header_x like BAPISDH1X occurs 0 with header line,
           bapi_item_x type BAPISDITMX occurs 0 with header line,
         it_return type BAPIRET2 occurs 0 with header line.
    data: v_vbeln like BAPIVBELN-VBELN,
          v_bstkd like bapisdh1-purch_no_c,
          v_zterm like bapisdh1-pmnttrms,
          v_inco1 like bapisdh1-incoterms1,
          v_inco2 like bapisdh1-incoterms2,
          v_arktx like  bapisditm-short_text,
          v_koe1n like  bapisditm-currency.
    *_____ Internal to hold the records in the text file
    DATA : BEGIN OF it_header OCCURS 100,
      VBELN(10) ,
      BSTKD(35) ,
      ZTERM(4) ,
      INCO1(3) ,
      INCO2(28) ,
      POSNR(6) ,
      matnr(18) ,
      ARKTX(40) ,
    END OF it_header.
    *_____ Internal table to hold excel file data
    DATA : it_intern TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
    SELECTION-SCREEN BEGIN OF BLOCK scr1 WITH FRAME TITLE text-111.
    PARAMETER : p_file TYPE rlgrap-filename OBLIGATORY .
    *paRAMETERS : p_header TYPE i DEFAULT 0.
    parameters :  p_begcol TYPE i DEFAULT 1 NO-DISPLAY,
                 p_begrow TYPE i DEFAULT 1 NO-DISPLAY,
                 p_endcol TYPE i DEFAULT 100 NO-DISPLAY,
                 p_endrow TYPE i DEFAULT 32000 NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK scr1.
    ___________START-OF-SELECTION________________
    START-OF-SELECTION.
    PERFORM convert_xls_itab. "to convert excel data into internal table
    ___________END-OF-SELECTION________________
    END-OF-SELECTION.
    *&      Form  convert_xls_itab
          text
    -->  p1        text
    <--  p2        text
    FORM convert_xls_itab .
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
       filename    = p_file
          i_begin_col = p_begcol
          i_begin_row = p_begrow
          i_end_col   = p_endcol
          i_end_row   = p_endrow
        TABLES
          intern      = it_intern.
    EXCEPTIONS
      INCONSISTENT_PARAMETERS       = 1
      UPLOAD_OLE                    = 2
      OTHERS                        = 3
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    PERFORM move_data. " to move the data into an internal table
    ENDFORM.                    " convert_xls_itab
    ___________END-OF-SELECTION________________
    END-OF-SELECTION.
    PERFORM upload_so.   "to upload salesorder changes
    *&      Form  upload_so
          text
    -->  p1        text
    <--  p2        text
    *&      Form  move_data
          text
    -->  p1        text
    <--  p2        text
    FORM move_data .
      DATA : lv_index TYPE i.
      FIELD-SYMBOLS <fs>.
      SORT it_intern BY row col.  "Sorting Internal Table
      CLEAR it_intern.
      LOOP AT it_intern.
        MOVE it_intern-col TO lv_index.
        ASSIGN COMPONENT lv_index OF STRUCTURE it_header TO <fs>. " assigning each record to internal table row
        MOVE it_intern-value TO <fs>.
        AT END OF row.
          APPEND it_header.
          CLEAR it_header.
        ENDAT.
      ENDLOOP.
    ENDFORM.                    " MOVE_DATA
                       " move_data
    *&      Form  upload_so
          text
    -->  p1        text
    <--  p2        text
    FORM upload_so .
    LOOP AT it_header.
    Header
       v_vbeln            = it_header-VBELN.
       bapi_header-purch_no_c  = it_header-BSTKD.
       bapi_header-pmnttrms    = it_header-ZTERM.
       bapi_header-incoterms1  = it_header-INCO1.
       bapi_header-incoterms2  = it_header-INCO2.
    APPEND BAPI_header.
        bapi_header_x-updateflag = 'U'.
       bapi_header_x-purch_no_c  = 'X'.
       bapi_header_x-pmnttrms    = 'X'.
       bapi_header_x-incoterms1  = 'X'.
       bapi_header_x-incoterms2  = 'X'.
    APPEND BAPI_header_x.
    item
       REFRESH BAPI_item.
        bapi_item-ITM_NUMBER = it_header-POSNR.
        bapi_item-material =  it_header-matnr.
        bapi_item-short_text = it_header-arktx.
       bapi_item-currency   = it_item-koein.
        APPEND BAPI_item.
    bapi_item_x-updateflag = 'U'.
        bapi_item_x-ITM_NUMBER = it_header-POSNR.
        bapi_item_x-MATERIAL = 'X'.
        bapi_item_x-short_text = 'X'.
       bapi_item_x-currency   = 'X'.
        APPEND  bapi_item_x.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            INPUT         = V_VBELN
         IMPORTING
           OUTPUT        = V_VBELN.
    BAPI to change sales order
                       CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
                         EXPORTING
                           SALESDOCUMENT               = v_vbeln
                        ORDER_HEADER_IN             = bapi_header
                           ORDER_HEADER_INX            = bapi_header_x
                         SIMULATION                  =
                         BEHAVE_WHEN_ERROR           = ' '
                         INT_NUMBER_ASSIGNMENT       = ' '
                         LOGIC_SWITCH                =
                         NO_STATUS_BUF_INIT          = ' '
                         TABLES
                           RETURN                      = it_return
                        ORDER_ITEM_IN               = bapi_item
                        ORDER_ITEM_INX              = bapi_item_x
                         PARTNERS                    =
                         PARTNERCHANGES              =
                         PARTNERADDRESSES            =
                         ORDER_CFGS_REF              =
                         ORDER_CFGS_INST             =
                         ORDER_CFGS_PART_OF          =
                         ORDER_CFGS_VALUE            =
                         ORDER_CFGS_BLOB             =
                         ORDER_CFGS_VK               =
                         ORDER_CFGS_REFINST          =
                         SCHEDULE_LINES              =
                         SCHEDULE_LINESX             =
                         ORDER_TEXT                  =
                         ORDER_KEYS                  =
                         CONDITIONS_IN               =
                         CONDITIONS_INX              =
                         EXTENSIONIN                 =
    COMMIT WORK.
    ENDLOOP.
      IF IT_return-type = 'E'.
          WRITE: / 'Error :', IT_return-message, / 'for VBELN:',it_HEADER-VBELN.
        ELSEIF IT_return-type = 'S'.
          WRITE: / 'Successfully CHANGED', it_HEADER-VBELN.
        ENDIF.
    ENDFORM.                    " upload_so
    thanks

    hi
    You can use ORDER_ITEMS_IN. For further details use the documentation of the function module.This must help you in your requirement.
    regards
    Aakash Banga

  • Sales Order changes via change history (transaction logs)

    Hi guys,
    If I happen to change delivery date to a new date, as we see from the change history of the previous commit dates, I wish I could see the various date
    changes from any table?
    I did tried VBEP, CDHDR, CDPOS & program RVSCD100. But it says “No records found”, when I did change the dates in my SO (item level).
    What is the table VBUK & VBUP for?  I cannot retrieve from them too.
    I just want to know if there is a way I could retireve the changes via the change history field in SO.
    Rgds,
    Ann

    Hello Ann,
    In the VBUK table and give the delivery doc number, The various status indicators for the table will be there by which you can get the delivery status.
    Goods movement status could be got from VBUP table.
    Overall delivery status of an item could be got from this table
    The status for sales order are stored in VBUK header level status and VBUP for item level. U can check if the statuses are not C than the sales order is open. There are different status available in VBUK/P tables like delivery status/goods movement status/invoice status etc
    <b>**reward if this helps**</b>
    Regards
    AK

  • Problem in Sales order create using BAPI with reference to quotation

    Hi,
    I am creating a sales order from Quotation using BAPI /AFS/BAPI_SALESORD_CREATEFDATA.
    The Sale order is getting created and the document flow is updated. When i check the status of quotation it is "OPEN".
    Ideally when a sale order is created in VA01 with reference to a quotation and if all items are added in the order from quotation, then the status of the quotation must be "Complete".
    When i use the BAPI, the status of the quotation is sill "Open". Has anyone faced this issue?
    Even if anyone has faced this issue with BAPI_SALESORDER_CREATEFROMDAT2, please let me know...
    Regards

    Hi RV,
    I am using BAPI  to create order reference to contracts. I am facing same issue. Its not updating document flow (vbfa-plmin field). After creating orders I am forcing to update plmin field in vbfa. This worked fine. But now status in reference document not updating properly. I saw your thread. It looks like similar issue. I saw your comments "Customization was not maintained properly for the Order types ". Please can you explain little bit more about your solution. It will helps us lot.
    Thanks,
    srini

  • Sales order copy via BAPI

    Hi developers,
                 does anybody know if there is a bapi to copy a sales order starting from a different order?
    What I'd like to do is calling a bapi with the document number of the sales order I have to copy as input and obtain a new one identical to the first.
    Is this possible?
    Thanx to all of you and have a nice day.

    Please check in to BAPI_SALESDOCUMENT_COPY.
    Regards,
    Rich HEilman

  • Problem in sales order change - output types

    hi,
    my output types is not displaying after i saved my output type
    i assigned the Output message and saved it thru
    Menu path : Extras->Output->header->Edit     
    when i viewed my thru Initial Screen from Menu Select : Sales Document->Issue output to...
    my output types is not proposing .
    Ganesh

    check out the outtype determination in
    SPRO->SALES & DISTRIBUTION->BASIC FUNCTION->OUTPUT CONTROL->OUTPUT DETERMINATION.
    PLEASE REWARD IF USEFUL.

  • BAPI - Problem in Sales order creation

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

    what messages u are gettting in RETURN ? Please check the RETURN tables data.
    [code]CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
    EXPORTING
    sales_header_in = header
    sales_header_inx = headerx
    IMPORTING
    salesdocument_ex = v_vbeln
    TABLES
    return = return
    sales_items_in = item
    sales_items_inx = itemx
    sales_schedules_in = lt_schedules_in
    sales_schedules_inx = lt_schedules_inx
    sales_partners = partner.
    Regards
    Prabhu

  • Reena Prabhakar - Sales order creation Using BAPI

    Hi Reena,
    This is Dinesh,i also face problem in Sales order creation using BAPI if you can send me the code it would be great help to me.
    Regards,
    Dinesh

    Anyhow, here is the code that I am using currently which works perfectly well. Not sure if it will be of any help to you, since the values to the BAPI come from the Webdynpro application. I have values stored in my "Test data directory" which I use for testing from the backend.
    FUNCTION ztest.
    Call the BAPI to create Sales Order
      CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
        EXPORTING
          order_header_in     = l_order_header
        IMPORTING
          salesdocument       = l_salesdocument
        TABLES
          return              = it_return
          order_items_in      = it_order_items
          order_partners      = it_order_partners
          order_schedules_in  = it_order_schdl
          order_conditions_in = it_order_conditions
          order_text          = it_order_text.
      READ TABLE it_return WITH KEY type = 'E'.
      IF sy-subrc = 0.
    *-- error occured
        CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
      ELSE.
    *-- no error
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
      ENDIF.
    ENDFUNCTION.

  • 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.

  • 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

  • Change only material qunatity in sales order by using BAPI

    Hi All,
    How to change only the material quantity in existing sales order by using BAPI.
    Please help me in this regards.
    Regards
    Deekshitha.

    Hi
    See the sample code and do accordingly
    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.
    Reward points if useful
    Regards
    Anji

  • 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..

  • 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

  • Sales order change log problem

    in sales order changes are visible in change log but if I want to enter the reason for those changes how to do it?

    Hi,
    If I understand you requirement right then you want to customize your system in that way,
    For e.g If you are changing the payment term in order then there is some place where you mention why you are changing the payment term in order.
    I dont think in change log you will get this facility but I can suggest you another way
    Maintain the Text id at header and tell every user that whenever they change something in order then they have to mention the reson in Text (Header).
    Anyways as per the change log id, senior manager will ask them directly.
    So everybody take it seriouly and enter the reason for every change.
    Hope this helps,
    Regards,
    MT

Maybe you are looking for

  • Selecting Simulator playback for output via DV camera

    Hi, I'm trying to use a different window for viewing my DVD project in Simulator. I cannot seem to access "Digital Cinema Desktop Preview" which is specified in the manual. It says "The two choices are Simulator Window, which is the default setting,

  • OTL - data for Dummy Element Context wrong entry in HXC_TIME_ATTRIBUTES

    Hi, I have create a Choice_List in the timecard using one of the seeded Custom view objects. In the LDT file, I specified QUALIFIER_ATTRIBUTE26 = 'Dummy Element Context'. It's showing up correctly, but when I save the created timecard, the value is b

  • Replace 2 Nodes in Cluster

    Have a 2 node SQL Cluster & looking for best way to replace these with two new servers. I was thinking of removing 1 SQL node and then remove node from windows failover cluster mmc. Then unplug crossover cable and plug into new server and make new se

  • Creating Callouts

    We are migrating few reports from MS excel to Bi publisher. And we need to create callouts on the chart. Is there any option in BIP to create Callouts? Please share with me if any workaround for this..

  • How do I download internet explorer to my mac

    How do I download internet explorer to my mac pro?