Skip to Content
0
Feb 20, 2006 at 05:46 AM

problem in deleting additional line items

11 Views

Hello experts,

I am currently modifying a report where in I must delete all P.O's that has one or all of their materials deleted. So when I run my report it only deletes the PO's that have their first line items deleted but it doesnt delete/detect the PO's that have multiple line items/materials in them. For example, my report displays PO number 4550000034 and then I check it in t-code ME23 and it's first material/line is not deleted but additional materials/line items has been deleted(symbolized by a trash can) so it is displayed in my report. What I want to do is to check each and every material in a particular PO and if one of them is deleted I must disregard that certain PO and not include it in my report. the field wherein the deleted indicator is ekpo-loekz/t_ekpo2-loekz. I have pasted below my code. Thanks guys and take care!

LOOP AT it_hdr.

AT NEW refbn.

read table t_ekpo2 with key ebeln = it_hdr-refbn.

if not t_ekpo2-loekz is initial.

delete it_hdr where refbn = t_ekpo2-ebeln.

continue.

endif.

REFRESH: account, history.

CLEAR: account, history.

CALL FUNCTION 'BAPI_PO_GETDETAIL'

EXPORTING

purchaseorder = it_hdr-refbn

account_assignment = 'X'

history = 'X'

TABLES

po_item_account_assignment = account

po_item_history = pohistory

po_item_history_totals = history.

LOOP AT account.

t_account = account.

t_account-ebeln = it_hdr-refbn.

APPEND t_account. CLEAR t_account.

ENDLOOP.

LOOP AT pohistory.

t_pohistory = pohistory.

t_pohistory-ebeln = it_hdr-refbn.

APPEND t_pohistory. CLEAR t_pohistory.

ENDLOOP.

LOOP AT history.

t_history = history.

t_history-ebeln = it_hdr-refbn.

APPEND t_history. CLEAR t_history.

ENDLOOP.

ENDAT.

it_dtl-psphi = it_hdr-psphi.

it_dtl-name1 = it_hdr-name1.

it_dtl-ebeln = it_hdr-refbn.

SELECT SINGLE waers FROM ekko INTO it_dtl-waers

WHERE ebeln = it_hdr-refbn.

APPEND it_dtl. CLEAR it_dtl.

ENDLOOP.