Application Development and Automation 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: 
Read only

Delete Purchase Orders

Former Member
0 Likes
524

Hi Folks,

I want to delete purchase orders from database which is made by past 6 months.

TCODE(ME22n)

Can any one give solution for me.

Thanks in advance.

SubramanyamS

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
484

Hi,

You can delete the PO line items...But I am not sure how you delete the Purchase order itself..

Check this sample of how to delete the line item using the BAPI..

PARAMETERS: p_ebeln LIKE ekko-ebeln OBLIGATORY.

PARAMETERS: p_ebelp LIKE ekpo-ebelp OBLIGATORY.

DATA: t_item LIKE bapimepoitem OCCURS 0 WITH HEADER LINE.

DATA: t_itemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE.

DATA: t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

t_item-po_item = p_ebelp.

t_item-delete_ind = 'X'.

APPEND t_item.

t_itemx-po_item = p_ebelp.

t_itemx-po_itemx = 'X'.

t_itemx-delete_ind = 'X'. "Delivery complete

APPEND t_itemx.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = p_ebeln

TABLES

return = t_return

poitem = t_item

poitemx = t_itemx.

LOOP AT t_return WHERE type = 'A' OR type = 'E'.

EXIT.

ENDLOOP.

IF sy-subrc = 0.

WRITE: / 'FAILED'.

ELSE.

WRITE: / 'SUCCESS'.

COMMIT WORK.

ENDIF.

Thanks,

Naren

3 REPLIES 3
Read only

Former Member
0 Likes
484

Use BDC.

Read only

Former Member
0 Likes
485

Hi,

You can delete the PO line items...But I am not sure how you delete the Purchase order itself..

Check this sample of how to delete the line item using the BAPI..

PARAMETERS: p_ebeln LIKE ekko-ebeln OBLIGATORY.

PARAMETERS: p_ebelp LIKE ekpo-ebelp OBLIGATORY.

DATA: t_item LIKE bapimepoitem OCCURS 0 WITH HEADER LINE.

DATA: t_itemx LIKE bapimepoitemx OCCURS 0 WITH HEADER LINE.

DATA: t_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

t_item-po_item = p_ebelp.

t_item-delete_ind = 'X'.

APPEND t_item.

t_itemx-po_item = p_ebelp.

t_itemx-po_itemx = 'X'.

t_itemx-delete_ind = 'X'. "Delivery complete

APPEND t_itemx.

CALL FUNCTION 'BAPI_PO_CHANGE'

EXPORTING

purchaseorder = p_ebeln

TABLES

return = t_return

poitem = t_item

poitemx = t_itemx.

LOOP AT t_return WHERE type = 'A' OR type = 'E'.

EXIT.

ENDLOOP.

IF sy-subrc = 0.

WRITE: / 'FAILED'.

ELSE.

WRITE: / 'SUCCESS'.

COMMIT WORK.

ENDIF.

Thanks,

Naren

Read only

Former Member
0 Likes
484

Hi Narendra...

Thanks for replay...

But i need to delete not single PO.

I want to delete more no of PO's.

Can you send bdc program for that....

Thanks in Advance.