Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting Sales Order

Former Member
0 Kudos

Hi All,

My program has three parts;

(1)I generate an SO with reference to another SO using BDC.

(2)Delete the items of the new SO,

(3)Change the SO for new items using BAPI.

My concern is, if there are any errors in changing the items by BAPI,the new SO generated by BDC must be deleted. Is it possible;if yes can anyone suggest me How it can be done!

Thanks

Mahendhar

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Check this sample code for deleting an order..

parameters: P_VBELN LIKE VBAK-VBELN.

DATA: BAPISDH1X LIKE BAPISDH1X.

DATA: T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

BAPISDH1X-UPDATEFLAG = 'D'.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = P_VBELN

order_header_inx = BAPISDH1X

tables

return = t_return

.

COMMIT WORK.

********************************************

check this sample for copying sales order..

parameters: P_VBELN LIKE VBAK-VBELN.

parameters: p_auart like vbak-auart.

DATA: T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

DATA: NEW_VBELN LIKE VBAK-VBELN.

CALL FUNCTION 'BAPI_SALESDOCUMENT_COPY'

EXPORTING

salesdocument = p_vbeln

documenttype = p_auart

IMPORTING

SALESDOCUMENT_EX = NEW_VBELN

TABLES

RETURN = T_RETURN

.

COMMIT WORK.

WRITE: / NEW_VBELN.

Thanks,

Naren

7 REPLIES 7

Former Member
0 Kudos

Hi Mahendhar

In Sales Order Overview Screen: we can find the option for deletion under menupath: Sales Document-> Delete.

Please make sure of the requirement before actually implementing the same. Also, if any post transaction activities.

Kind Regards

Eswar

0 Kudos

Hi Eswar,

Thanks for the reply;but The deletion of sales order should be done in the program itself.Its not like going to the screen and deleting manually.

any further inputs!

mahendhar

0 Kudos

HI Mahendhar

As you are using BDC mechanism, you can record as per the menupath i have given you earlier. To make things simpler for you, here is OK Code for the deleting a sales order from overview screen:<b>LOES</b>

Kind Regards

Eswar

Former Member
0 Kudos

Hi Mahendhar,

I am also working in Sales order creation BDC, could you please send me your code to me.

Thanks a lot.

0 Kudos

Hi kiran,

am using customized include for the bdc which is similar to the zbdcrecxx.

Please let me know if required the algorithm of the program.

Thanks.

Former Member
0 Kudos

Hi,

Check this sample code for deleting an order..

parameters: P_VBELN LIKE VBAK-VBELN.

DATA: BAPISDH1X LIKE BAPISDH1X.

DATA: T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

BAPISDH1X-UPDATEFLAG = 'D'.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = P_VBELN

order_header_inx = BAPISDH1X

tables

return = t_return

.

COMMIT WORK.

********************************************

check this sample for copying sales order..

parameters: P_VBELN LIKE VBAK-VBELN.

parameters: p_auart like vbak-auart.

DATA: T_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

DATA: NEW_VBELN LIKE VBAK-VBELN.

CALL FUNCTION 'BAPI_SALESDOCUMENT_COPY'

EXPORTING

salesdocument = p_vbeln

documenttype = p_auart

IMPORTING

SALESDOCUMENT_EX = NEW_VBELN

TABLES

RETURN = T_RETURN

.

COMMIT WORK.

WRITE: / NEW_VBELN.

Thanks,

Naren

0 Kudos

Thank you very much Naren.