Skip to Content
0
Former Member
Jan 18, 2008 at 05:26 AM

Delete data from internal table?

18 Views

Hi,

I have an internal table T as following:

-


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.

  • REFRESH t3.*

LOOP AT t WHERE xblnr EQ space. "change from belnr to xblnr by LI_Y 2008/01/16

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.

-


The outcome like this:

KUNNR XBLNR

11111 SPACE

11111 A1B2C3

11111 DEF34

22222 SPACE

22222 0980

33333 98987

33333 78648

44444 9804

My problem is that

*The first KUNNR (11111) which has space value was deleted,

But the second KUNNR (22222) which has space value can not be deleted.*

My Question

Is there any problem in my refresh t3?

How to correc the coding inorder to deleted all the recording of KUNNR which XBLNR has space value there????

Please help?

Thank you!!