Skip to Content
0
Former Member
Jan 18, 2008 at 12:29 AM

Delete data from internal table?

29 Views

Hi,

I have a problem in deleting data from internal table.

When xblnr = space, all the belnr data belong to the same kunnr should be deleted from internal t.

My problem is that the belnr data still remain in the inter table T when xblnr = space.

Could you please correct my coding? Thank you.

-


DATA: BEGIN OF t OCCURS 0,

bukrs LIKE knb1-bukrs,

zuonr LIKE bsid-zuonr, "sort key "CR01

belnr LIKE bsid-belnr,

kunnr LIKE kna1-kunnr,

bldat LIKE bsid-bldat,

budat LIKE bsid-budat,

netdt LIKE bsega-netdt,

waers LIKE bsid-waers,

wrbtr LIKE bsid-wrbtr,

shkzg LIKE bsid-shkzg,

xblnr LIKE bsid-xblnr, "WD041005a

sgtxt LIKE bsid-sgtxt,

dmbtr LIKE bsid-dmbtr,

END OF t.

DATA : t1 LIKE STANDARD TABLE OF t WITH HEADER LINE.

DATA : BEGIN OF t3 OCCURS 0,

kunnr TYPE kna1-kunnr,

END OF t3.

...........................................

End-of-selection.

Sort t.

LOOP AT t WHERE xblnr EQ space. "

t3-kunnr = t-kunnr.

APPEND t3.

ENDLOOP.

SORT t3.

DELETE ADJACENT DUPLICATES FROM t3.

LOOP AT t.

READ TABLE t3 WITH KEY kunnr = t-kunnr BINARY SEARCH.

IF sy-subrc EQ 0.

MOVE-CORRESPONDING t TO t1.

APPEND t1.

DELETE T.

ENDIF.

ENDLOOP.