Skip to Content

Sales Order Condition Data delete not happening..

Hi Gurus,

I'm trying to change the Sales Order by deleting any (possible) condition from header or from item level.

can you share any sample working code for the sales order condition data( of Line item) delete operation?

Or please check out my code below which is not giving any error and is not deleting the condition data as well.

Kindly correct me if I am guin wrong somewhere.

REPORT ZCOND NO STANDARD PAGE HEADING.

*** For BAPI_SALESORDER_CHANGE
DATA:
slogics TYPE bapisdls,
uheader TYPE bapisdh1,
uheaderx TYPE bapisdh1x,
x_items TYPE TABLE OF bapisditm WITH HEADER LINE,
x_itemsx TYPE TABLE OF bapisditmx WITH HEADER LINE,
x_prtns TYPE TABLE OF bapiparnr WITH HEADER LINE,
x_prtnsch TYPE TABLE OF bapiparnrc WITH HEADER LINE,
x_schds TYPE TABLE OF bapischdl WITH HEADER LINE,
x_schdsx TYPE TABLE OF bapischdlx WITH HEADER LINE,
x_cndts TYPE TABLE OF bapicond WITH HEADER LINE,
x_cndtsx TYPE TABLE OF bapicondx WITH HEADER LINE,
x_text TYPE TABLE OF bapisdtext WITH HEADER LINE.

DATA xreturn TYPE TABLE OF bapiret2 WITH HEADER LINE.

DATA message TYPE string.

*** Main program ***
START-OF-SELECTION.

* Header
CLEAR uheader.
uheader-sales_org = '2300'.
uheader-distr_chan = '01'.
uheader-division = '00'. uheader-currency = 'AED'.

CLEAR uheaderx.
uheaderx-updateflag = 'U'.
uheaderx-collect_no = 'X'. uheaderx-currency = 'X'.

x_items-ITM_NUMBER = '000010'.
x_items-MATERIAL = '17LMLE0008'.
* x_items-PLANT = '000010'.
* x_items-000010'.
APPEND x_items.

x_itemsX-ITM_NUMBER = '000010'.
x_itemsX-MATERIAL = 'X'.
* x_itemsX-PLANT = '000010'.
* x_items-000010'.
APPEND x_itemsX.


* Conditions
CLEAR x_cndts.
x_cndts-itm_number = '000010'.
x_cndts-cond_st_no = '050'.
x_cndts-cond_count = '01'.
x_cndts-cond_type = 'K004'.
x_cndts-CURRENCY = 'AED'.
APPEND x_cndts.

CLEAR x_cndtsx.
x_cndtsx-itm_number = '000010'.
x_cndtsx-cond_st_no = '050'.
x_cndtsx-cond_count = '01'.
x_cndtsx-cond_type = 'K004'.
x_cndtsx-CURRENCY = 'X'.
x_cndtsx-updateflag = 'D'. " <- delete key
APPEND x_cndtsx.

REFRESH xreturn.

slogics-COND_HANDL = 'X'.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
logic_switch = slogics
salesdocument = '0008736500'
order_header_in = uheader
order_header_inx = uheaderx
TABLES
return = xreturn
order_item_in = x_items
order_item_inx = x_itemsx
partnerchanges = x_prtnsch
schedule_lines = x_schds
schedule_linesx = x_schdsx
conditions_in = x_cndts
conditions_inx = x_cndtsx
order_text = x_text.



LOOP AT xreturn WHERE ( type = 'E' ) OR ( type = 'A' ).
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
LOOP AT xreturn.
WRITE: / xreturn-id, xreturn-type, xreturn-number, xreturn-message.
ENDLOOP.
MESSAGE 'Failed!' TYPE 'S' DISPLAY LIKE 'E'.
RETURN.
ENDLOOP.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
* EXPORTING
* wait = 'X'.
MESSAGE 'Successfully!' TYPE 'S'.

Also I have checked out the OSS note:593246 but no success.

Note: If I don't pass logic switch.. I get sy-subrc = 0.(but it doesn't delete) and When I pass Logic Switch then I get error as follows:

Thanks,

-PavanG

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Dec 08, 2015 at 10:16 AM

    Is it possible to delete the condition online in the screen ? It could be that it is just not allowed to delete these conditions ? Did you try it ?

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 08, 2015 at 02:15 PM

    Hi,

    Please try adding the below too:

    logic_switch-cond_handl = 'X'.

    Also try with FM SD_SALESDOCUMENT_CHANGE

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.