Hi,
I have an internal table T as following:

DATA: BEGIN OF t OCCURS 0,
bukrs LIKE knb1bukrs,
zuonr LIKE bsidzuonr, "sort key "CR01
belnr LIKE bsidbelnr,
kunnr LIKE kna1kunnr,
bldat LIKE bsidbldat,
budat LIKE bsidbudat,
netdt LIKE bseganetdt,
waers LIKE bsidwaers,
wrbtr LIKE bsidwrbtr,
shkzg LIKE bsidshkzg,
xblnr LIKE bsidxblnr, "WD041005a
sgtxt LIKE bsidsgtxt,
dmbtr LIKE bsiddmbtr,
END OF t.
DATA : t1 LIKE STANDARD TABLE OF t WITH HEADER LINE.
DATA : BEGIN OF t3 OCCURS 0,
kunnr TYPE kna1kunnr,
END OF t3.
...................
Endofselection.
SORT t.
REFRESH t3.*
LOOP AT t WHERE xblnr EQ space. "change from belnr to xblnr by LI_Y 2008/01/16
t3kunnr = tkunnr.
APPEND t3.
ENDLOOP.
SORT t3.
DELETE ADJACENT DUPLICATES FROM t3.
LOOP AT t.
READ TABLE t3 WITH KEY kunnr = tkunnr BINARY SEARCH.
IF sysubrc EQ 0.
MOVECORRESPONDING 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!!
hi studyabap,
after reading your code i can understand ur problem.The first problem i.e., is there any problem in refresh t3. yes problem is there better you can use the below statement.
delete t3 where XBLNR = Space
and i think now it will work.and automatically your other problems also solved if u use this statement.
kindly reward me if it's ok
Hi Study
DATA: BEGIN OF t OCCURS 0,
bukrs LIKE knb1bukrs,
zuonr LIKE bsidzuonr, "sort key "CR01
belnr LIKE bsidbelnr,
kunnr LIKE kna1kunnr,
bldat LIKE bsidbldat,
budat LIKE bsidbudat,
netdt LIKE bseganetdt,
waers LIKE bsidwaers,
wrbtr LIKE bsidwrbtr,
shkzg LIKE bsidshkzg,
xblnr LIKE bsidxblnr, "WD041005a
sgtxt LIKE bsidsgtxt,
dmbtr LIKE bsiddmbtr,
END OF t.
DATA : t1 LIKE STANDARD TABLE OF t WITH HEADER LINE.
DATA : BEGIN OF t3 OCCURS 0,
kunnr TYPE kna1kunnr,
END OF t3.
...........................................
Endofselection.
Sort t by XBLNR.
read table t where xblnr is initial.
if sysubrc eq 0.
delete t where kunnr = tkunnr.
endif.
SORT t3.
DELETE ADJACENT DUPLICATES FROM t3.
LOOP AT t.
READ TABLE t3 WITH KEY kunnr = tkunnr BINARY SEARCH.
IF sysubrc EQ 0.
MOVECORRESPONDING t TO t1.
APPEND t1.
DELETE T.
ENDIF.
ENDLOOP.
Add a comment