Quantcast
Channel: SCN : All Content - ABAP Development
Viewing all articles
Browse latest Browse all 8332

Warning 'sales document is not yet complete' with BAPI_SALESORDER_CHANGE after deleting correspnding delivery

$
0
0

Hi,

 

I'm trying to change a sales order (add some positions) after deleting the corresponding delivery to it.

But I get the warning "sales document is not yet complete: Edit Data", because of incomplete dates in schedule lines.

The schedule lines are filled correctly.

 

When I have a Sales Order without corresponding delivery, this Order could be changed successful with BAPI BAPI_SALESORDER_CHANGE.

 

But if there is a Sales Order with corresponding Delivery (where I do delete the delivery first with BAPI BAPI_OUTB_DELIVERY_CHANGE ), than the BAPI for changing the Order gives a warning "sales document is not yet complete: Edit Data".

This is confusing.

 

Is there something I have to consider when changing a sales order after deleting its delivery?

 

Coding:

 

"1. delete delivery to sales order

 

CLEAR ls_header_data.
   CLEAR ls_header_ctrl.
   ls_header_data-deliv_numb = iv_vbeln.
   ls_header_ctrl-deliv_numb = iv_vbeln.
   ls_header_ctrl-dlv_del    = abap_true. "set flag for deletion

* call BAPI to delete delivery
   CALL FUNCTION 'BAPI_OUTB_DELIVERY_CHANGE'
     EXPORTING
       header_data    = ls_header_data
       header_control = ls_header_ctrl
       delivery       = iv_vbeln
     TABLES
       return         = et_msg.

IF ...

COMMIT WORK AND WAIT.

ELSE.

...

ENDIF.


"2. change Sales order (adding new item positions)

"add new/changed data
   LOOP AT IT_NEW_ITEMS ASSIGNING <ls_new_items>.
     CLEAR: ls_order_item_in,
            ls_order_item_inx,
            ls_schedule_line,
            ls_schedule_linex.

     add 10 to lv_posnr.
     ls_order_item_in-itm_number = lv_posnr. "posNr
     ls_order_item_in-material = <ls_new_items>-matnr. "material
     ls_order_item_in-target_qty = <ls_new_items>-menge"quantity
     ls_order_item_in-sales_unit = <ls_new_items>-MEINH. "sales unit
     APPEND ls_order_item_in TO lt_order_item_in.


     "fill order item check table
     ls_order_item_inx-itm_number = lv_posnr.
     ls_order_item_inx-updateflag = 'I'.
     ls_order_item_inx-material   = abap_true.
     ls_order_item_inx-target_qty = abap_true.
     ls_order_item_inx-sales_unit = abap_true.
     APPEND ls_order_item_inx TO lt_order_item_inx.

     "schedule lines
     ls_schedule_line-itm_number   = lv_posnr. "posnr
     ls_schedule_line-sched_line   = '1'.
     ls_schedule_line-req_qty      = ls_order_item_in-target_qty. "quantity
     ls_schedule_line-req_date      = lv_lfdate.               "schedule line date
     APPEND ls_schedule_line TO lt_schedule_line.
     "schedule lines check table
     ls_schedule_linex-itm_number   = lv_posnr. "posnr
     ls_schedule_linex-sched_line   = '1'.
     ls_schedule_linex-req_qty      = abap_true. "quantity
     ls_schedule_linex-req_date      = abap_true.               "schedule line date
     ls_schedule_linex-UPDATEFLAG  = 'I'.
     APPEND ls_schedule_linex TO lt_schedule_linex.
   ENDLOOP.

   "call bapi to add items to sales order
   CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
     EXPORTING
       SALESDOCUMENT    = iv_sales_order
       ORDER_HEADER_INX = ls_order_header_inx
     TABLES
       RETURN           = et_msg
       ORDER_ITEM_IN    = lt_order_item_in
       ORDER_ITEM_INX   = lt_order_item_inx
       SCHEDULE_LINES   = lt_schedule_line
       SCHEDULE_LINESX  = lt_schedule_linex.

IF....

COMMIT WORK AND WAIT.

...

ELSE.

...

ENDIF.
 


Viewing all articles
Browse latest Browse all 8332

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>