BAPI_SALESORDER_CHANGE [delete line item and update ]

LOOP AT itab_ch .
  *IF itab_ch-itm_number = selpos1 AND  delflag = 'X'.*
*     Delete Line items
    s_order_header_inx-updateflag = 'U'.
    i_order_item_in-itm_number = itab_ch-itm_number.
   schedule_lines-itm_number = itab_ch-itm_number.
    schedule_lines-sched_line = zsd_tab_z-etenr.
    schedule_lines-req_qty = itab_ch-target_qty.
    i_order_item_inx-updateflag = 'D'.
    i_order_item_inx-itm_number = itab_ch-itm_number.
  schedule_linesX-itm_number = itab_ch-itm_number.
  schedule_linesx-sched_line = zsd_tab_z-etenr.
  schedule_linesx-req_qty = 'X'.
  APPEND schedule_lines.
  APPEND schedule_linesx.
    APPEND: i_order_item_in, i_order_item_inx.
ELSE.
    if itab_ch-item_categ = 'ZFRS'.
s_order_header_inx-updateflag = 'U'.
    i_order_item_in-itm_number = itab_ch-itm_number.
    i_order_item_in-target_qty =  itab_ch-target_qty.
schedule_lines-itm_number = itab_ch-itm_number.
schedule_lines-sched_line = zsd_tab_z-etenr.
    schedule_lines-req_qty = itab_ch-target_qty.
    i_order_item_inx-updateflag = 'U'.
    i_order_item_inx-itm_number = itab_ch-itm_number.
     i_order_item_inx-target_qty =  itab_ch-target_qty.
schedule_linesX-itm_number = itab_ch-itm_number.
schedule_linesx-sched_line = zsd_tab_z-etenr.
  schedule_linesx-req_qty = 'X'.
  APPEND schedule_lines.
  APPEND schedule_linesx.
    APPEND: i_order_item_in, i_order_item_inx.
    ENDIF.
    ENDIF.
      ENDLOOP.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
  EXPORTING
    salesdocument     = vbap-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
   schedule_lines     = schedule_lines
   schedule_linesx    = schedule_linesx.
here line item is delete perfect but when i use  updateflag = 'U'  for other line itme then
quantity is not modify
Code Formatted by: Alvaro Tejada Galindo on Dec 26, 2008 10:26 AM

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.
  DATA: BEGIN OF i_sched OCCURS 10.
  INCLUDE STRUCTURE bapischdl.
  DATA: END OF i_sched.
  DATA: BEGIN OF i_schedx OCCURS 10.
  INCLUDE STRUCTURE bapischdlx.
  DATA: END OF i_schedx.
LOOP AT itab_ch .
s_order_header_inx-updateflag = 'U'.
IF itab_ch-itm_number = selpos1 AND  delflag = 'X'.
Delete Line items
    i_order_item_in-itm_number = itab_ch-itm_number.
    i_order_item_in-TARGET_QTY = itab_ch-target_qty.
    i_order_item_inx-updateflag = 'D'.
    i_order_item_inx-itm_number = itab_ch-itm_number.
    i_order_item_inx-TARGET_QTY  = 'X'.
    APPEND: i_order_item_in, i_order_item_inx.
  Fill schedule line flags
  i_sched-itm_number = itab_ch-itm_number.
  i_sched-sched_line = '0001'.
  APPEND i_sched.
  i_schedx-itm_number  = itab_ch-itm_number.
  i_schedx-sched_line  = '0001'.
  i_schedx-updateflag  = 'D'.
  APPEND i_schedx.
ELSE.
*****UPDATE TIEM.
  if itab_ch-item_categ = 'ZFRS' .
  Fill schedule lines
  i_sched-itm_number = itab_ch-itm_number.
  i_sched-sched_line = '0001'.
  i_sched-req_qty    = itemdiv.
  APPEND i_sched.
  Fill schedule line flags
  i_schedx-itm_number  = itab_ch-itm_number.
  i_schedx-sched_line  = '0001'.
  i_schedx-updateflag  = 'U'.
  i_schedx-req_qty     = 'X'.
  APPEND i_schedx.
ENDIF.
ENDIF.
ENDLOOP.
IF errorflag IS INITIAL.
CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
  EXPORTING
    salesdocument     = vbap-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
   schedule_lines     = i_sched
   schedule_linesx    = i_schedx.
  ENDIF.
  LOOP AT it_return.
READ TABLE it_return WITH KEY NUMBER = '233'.
      IF sy-subrc = 0.
     CONCATENATE it_return-message  INTO zmsg.
      MESSAGE i000(38) WITH it_return-message .
      EXIT.
       ENDIF.
ENDLOOP.

Similar Messages

  • How to Reject Quotation line item and update New line item

    Hi all,
    I have a doubt in Quotation Rejection,Here it goes....
    For VC implementation,We are Creating a quotation with Dummy Material,and after Creating Material Masters we have to update the Newly created material back in Quotation for same quotation number and after this the dummy material i.e the previous line item should be rejected with reason as a duplicate(reason code 23)..
    So Pls help me in Rejecting the line item of quotation.how this is done.
    Reply soon.
    Thanks in Advance,
    Balaji Meda

    Hi,
    The requirement is also to Update the Quotation with the newly created material.
    So we need a Bapi or a function module which does 2 things:
    1. Reject the previous Line item with a reason code.
    2. Update the Quoation with the new material and insert a a new line item.
    Thanks,
    Balaji.

  • Reconfigure sales BOM deletes line item and creates new line item

    We are having issue with Sales BOM. Once sales BOM is reconfigure, line item is automatically deleted and creates new line item. These changes are not captured by reporting tool. Is it standard SAP behavior? if its not standard behavior, how to fix this issue?

    Hi,
    If i am not wrong, i assume you are using site instead of plant.   If it is plant , then "yes", we can have a order with same material being line item 10 and 20 with different plants.  Reg delivery, if the plants are configured to a same shipping point then you will have one delievery.  if the plants are configured for a different shipping point , then delivery will be split up.
    Reward if it helps,
    Thanks & regards,
    CLN

  • Due to deleted Sales order line items and Archived Sales order is still showing as Incomplete in BW as Open Order reports because of Incorrect SAP R/3 Rejection Status("A") in VBUP table.

    In a archived saler Order user had deleted Line Item and completed overall sales order. Now this sales order is archived, but it is stll appearing in BW report as open order because of deleted item  with rejection Status is maintained as “A” (Not yet Processed).
    We want to change this status from "A" (Not yet Processed) to "C" as completed.
    I have tried to reload Archive data but due to some limitation I was not able to do it. Also I feel this will like this s not the proper way to do it.
    Could you please help me to correct way to do it???
    Thanks in advance....

    Hi Vaibhav,
    If you can get the list of Sales orders which has deleted line items and force completion status. You can manage them in BI via lookup  or navigation attribute.
    Just my views I am sharing .
    Thanks,
    KDJ

  • Error while editing PO - deleting service line item and creating material line item.

    In SAP SRM Extended classic scenario, PO is in 'ordered' status and contains a service line item. While editing this PO, I delete the service line item and create a new material line item. This gives me the following error.
    Back end error: Enter G/L account
    Back end error: LIne item still contains faulty items.
    This happens only with service- material comibination and no other combination(material-service, service-service, material-material).
    I need to know the reason for this issue and how it can be solved?

    PO Values (Inc Tax):
    Item 1: INR 228 L
    Item 2: INR 27.83 L   (Payment also done in 2008)
    GR for Item 1: INR 207.46 L
    Remaining Comm = INR 21.01 L
    Item 1 having 73 sub line items.... fo some of the sub-line items GR for some qty already done in last fiscals.
    User changing for remaining qty.
    Budget Report values:
    Previous Years:  Budget, Actual & Assigned = 304.85 L
                                Available = 0      (Carry Forward done for Budget & Commitments)
    2011:                   Budget = 75.15 L
                                Actual = 53.86 L
                                Comm = 21.01 L   (Same as Remaining Commitment)
                                Avai = 0.28 L
    Hope this will help.

  • SAPF150D-Dunning Notice Print - With Update of Line Items and Master Record

    When I am running this program SAPF150D(Dunning Notice Print - With Update of Line Items and Master Records) with a variant containing run date, runc id, update mode, pimmed & pcount; the job is failing to execute. It is giving message like,
    "The field symbol is no longer assigned because there was an attempt makde previously in a Unicode program to set the field symbol using ASSIGN with offset and/or length specification. Here, the memory addressed by the offset/length specification was not within the allowed area."
    "GETWA_NOT_ASSIGNED_RANGE" "SAPF150D" or "F150DFS0" "SORTFELDER_ERMITTELN"

    Hi,
    Search for routine FORM SORTFELDER_ERMITTELN
    in SAPF150D.
    Put a breakpoint in statement
    ASSIGN (T047F-FELDN) TO <H1>.
    in above routine and debug to the point where error is occuring.
    Most likely there is a mismatch in the length assigned to some field FELDN in table T047F.
    In that case, simply change the T047F-LENGT field accordingly in change mode.
    Cheers,
    Vikram
    Edited by: Vikram Jalali on May 27, 2008 5:56 PM

  • Not able to delete line items using BAPI_OUTB_DELIVERY_CHANGE

    Hi,
        Not able to delete line items of a delivery using BAPI 'BAPI_OUTB_DELIVERY_CHANGE', with thte below code and even return parameter has zero messages.
    I have even checked existing below posting.
    https://www.sdn.sap.com/irj/scn/logon?redirect=http%3a%2f%2fforums.sdn.sap.com%2fthread.jspa%3fthreadid%3d782509
    Below is the code that i am using.........
    *wa1-deliv_numb = wa_lips-vbeln.
    wa1-deliv_item = wa_lips-posnr.
    APPEND wa1 to item_data.
    wa-deliv_numb = vbeln_so .
    wa-deliv_item = l_item.
    wa-del_item = 'X'.
    APPEND wa TO item_control.
    w_header_data-deliv_numb = vbeln_so .
    w_header_control-deliv_numb = vbeln_so .
    w_delivery = vbeln_so .
    *w_header_control-dlv_del = 'X'. "Delete whole Delivery
    CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
      EXPORTING
        header_data    = w_header_data
        header_control = w_header_control
        delivery       = w_delivery
      TABLES
       item_data      = item_data
        item_control   = item_control
        return         = return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait = 'X'.
    I have even  tried uncommenting item_data parameter but not able to delete line item.....i am able to delete whole delivery but not line items .........can any one of u help me in resolving this issiue plz ???
    Regards,
    M, Manohar

    Kindly use WS_DELIVERY_UPDATE to delete the items
    Sample code:
    L_VBKOK-VBELN_VL = vbeln_so.
    clear l_vbpok.
             refresh l_vbpok.
             l_vbpok-vbeln_vl = vbeln_so
             l_vbpok-posnr_vl = wa_deliv_item.
             l_vbpok-lips_del = c_x.
             append l_vbpok.
             set update task local.
             call function 'WS_DELIVERY_UPDATE'
               exporting
                 vbkok_wa = l_vbkok
                 commit   = ' '
                 delivery = lv_delivery
               tables
                 vbpok_tab = l_vbpok
               exceptions
                 others   = 0.
             commit work and wait.

  • Deleted line  item not display in Print preview

    Dear All ,
                                    Pl guide that when i delete the line item from a P.O then this deleted item is not visible in Print Preview .pl help what are the exact setting due to which i can know why this del item is not coming in Print Preview.
    Rgds ,
    Rajeev
    Edited by: sap11 on Feb 11, 2009 10:37 AM

    HI,
    Using the standard programm and print form the system works as follows:
    When you will create a new Purchase order with two line item. System
    will create new message record with  Change message flag (NAST-AENDE) as
    space and processing status (NAST-VSTAT) as  0 "not processed".
    After this if you will output the message using ME9F then system will
    update the message processing status NAST-VSTAT as 1 "Successfully
    processed".
    When you will delete line item 10, at that time system will create
    one more message record with indicator Change message flag
    (NAST-AENDE = X ) and processing status 0 "not processed".
    Now system contains two message records in table NAST, one for which
    processing has been done and one change message record for which
    processing has not been done.
    If you will run ME9F with processing status 0 then this means you
    wants to output the change message record means you wants to inform
    your vendor that item 10 has been deleted. That's why system show
    line item 10 but you can notice in print preview, system mentions that
    item 10 has been cancelled.
    If you will run the message with processing status as 1 then this is
    not change message output means system will show you latest print
    of purchasing document and thus will not show line item 10.
    Please take the print out of both message record and you can see the
    difference.
    I hope this information helps!
    Best Regards,
    Arminda Jack

  • 2LIS_11_VAITM - Deleted Line Items

    I am having an issue with sales order line items that have been deleted.
    I load my data using 2LIS_11_VAITM into a DSO EDW Layer. I then pass this up to another DSO layer. I noticed that users were deleting line items from Orders and this was causing me an issue in my data. To remove the problem I have linked ROCANCEL to 0RECORDMODE in the Technical rule up to my EDW layer and now in my EDW layer the line item goes completely when it is deleted out of the ERP system ad the deletion is passed into BW.
    I got the idea for this from here Deleted line item appears in BI report
    My problem lies in the layer above where I am still left with a line in the DSO relating to the deleted line. But the KF are zero. Is there anyway to also get this line to be deleted out as per my EDW layer?
    Thanks,
    Joel

    Hi Joel,
    What is not completely clear to me is what happens in the first DSO. Are the deleted records removed from the active table or are the key figures set to 0?
    Furthermore, what is update rule for key figures: overwrite or addition (in the transformation to both DSOs)?
    The record mode is indeed the crucial factor. It must become clear which one is delivered by the DataSource: 'R' for a reversed record or a 'D' for an entire deletion? And what is the record mode in the update to second DSO?
    Best regards,
    Sander

  • Deleting Line item

    Hi ,
    How do i delete line items of a sales order using bapi or by any other means..Please help.
    Thanx and regards,
    Sres

    Hi ,
    use BAPI_SALESORDER_CHANGE
    and pass this information.
    To delete specific order lines enter the foll fields...
    SALESDOCUMENT = Your Sales Doc
    ORDER_ITEM_IN-ITM_NUMBER = Your Sales Order Item
    ORDER_ITEM_INX-ITM_NUMBER = Your Sales Order Item
    ORDER_ITEM_INX-UPDATEFLAG = 'D'
    Deleting deliveries and sales orders using BAPI
    Cheers
    VJ

  • 2LIS_02_ITM deleted line items are not reflected in BW

    Hi,
    Our current Data flow 2LIS_02_ITM-->DSO-->CUBE.
    I am analyzing a Invoice, When it is created 01.04.2014 it has got 10 Line Items and all the data is load to BW,Invoice with 10 Line items.
    In ECC I can now see the same Invoice only got 5 line items and from change log I can see 5 line items are deleted on 15.04.2014.These changes are not reflected in BW.In BW invoice data still shows 10 line items.
    If I perform setup table job and ECC RSA3 for that invoice I am getting only 5.
    I believe it’s something to do with 0RECORDMODE,Can you please let me know how to fix this in BW.
    Thanks

    Yes this is a known behavior in case of deltas.
    For Deleted line items Rocancel field will have an entry with R.
    To handle this you need to map ROCANCEL field in Technical group of transformation (Between Datasource to DSO) with 0Recordmode.
    Once you will do that then after activating the data in DSO it will nullify the records and deleted order or item will not appear.
    Regards,
    AL

  • How to release Stock blocked against deleted line items from  Sales order.

    We have Scenario as follows.
    Sales order made for  items available in stock.  Deleted few lineitems from sales order balance items delivered and invoiced. Sales cycle is complete in all sense.
    What we have noticed is when we are creating new sales order / Delivery for deleted items from above Sales order it shows deleted quantity is blocked against old sales order. These line items are no longer
    available in old sales order since it is deleted also it is not appearing in open sales order report (VA05).
    Overall stock available is same as quantity mentioned in deleted line item.
    In MD04 - Sales requirenment transaction it shows sales order / line item against which it is blocked.
                    i.e deleted line item.
    How to release these stock and make available for sales. Any standard process available ? or any other solutions
    Thanks & Regards,

    I got a solution for my question from other forum. for info
    Go to SE38 and enter program SDRQCR21 then execute...
    Enter line item which is blocked for sales order in MD04 and enter plant then check Data
    transfer box and uncheck other boxes... It will pop up information and click yes...
    You will get one report and Stock inconsistency will go off and then check it in MD04....
    regards

  • Not to be able to delete line items from sales orders

    I have to do something so as not to be able to delete the line items from a sales order if I have already received a down payment for this sales order

    Dear Stilianos
    Assign Reason for Rejection for that line item and create a new line item in the same sale order.
    Incidentally, why do you want to delete the line item ??
    thanks
    G. Lakshmipathi

  • Deleting line items in sales order.

    Hi All,
    I got as issue while creating the order.
    issue:
    I try creatin an order by deleting some of the line items and the customer got the credit check. when i tried chek in the debug mode the deleted line items are not reflecting in the internal table.
    Is there any user exit availble thru which i can delete the line items from internal table on the basis of UPDKZ ffield?.
    Regards,
    Neslin.
    Edited by: neslin on Jan 16, 2008 8:21 AM

    Hi,
    This is the standard SAP behaviour.
    ...Seems development inside a relevant include is the only fix to achieve this.
    Regards,
    Anubhav

  • Deleted line item in Purchase Order?

    Dear forumers,
    I need to display data for PO history from the SAP MM module, but I will also need to exclude deleted line item.
    Is it right to check for this deleted line item condition in the EKPO-LOEKZ field? But, what do the values ' ' and 'L' mean here?
    Please help. Thanks!

    L - Deleted..
    space - Not Deleted..
    Thanks
    Amol Lohade

Maybe you are looking for

  • Text encoding with non english characters

    I'm trying to publish a site in Swedish, a language with 3 extra characters (Ö, Ä, Å). When I try to publish the site I keep getting a 404 error from my ftp server. I have check the site folder contents with webmeastro and it says that the characters

  • Loading date

    hey all is it  possible to enter in SAP a fixed day of the week when material should be loaded for a specified destination. For example all orders for Japan should be loaded on a Tuesday. Would it be possible to enter this information in SAP to take

  • Can you change still clip duration default setting?

    I create wedding videos, and at the end of my movie I add about 100 still clips as edited highlights. In older versions of imovie you were able to alter the length of still clips created in the preferences to whatever time you wanted. In this newer (

  • To "control/select" a group of emails and delete takes forever

    when using 'select/control' to group a number of emails for deletion it takes forever to select (7-8 seconds) and to delete takes just as much time. It makes cleaning up email data very troublesome. I have to go to my provider, Windstream, and delete

  • ALV Tree, Expanded node do not show data in certain column

    Hi all, I need your help regard to below problem. I have an ALV grid in which one of the columns has F4 (search help). If search help is called by pressing a F4 button a dialog box will be shown with ALV tree on it. The ALV Tree has 2 columns which a