‎2008 Jan 18 5:26 AM
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!!
‎2008 Jan 18 5:28 AM
hi.,
use delete t3 where XBLNR = Space.
Reward points if useful
Chandra
‎2008 Jan 18 5:28 AM
hi.,
use delete t3 where XBLNR = Space.
Reward points if useful
Chandra
‎2008 Jan 18 6:11 AM
Hi,
Where should I put the
delete t3 where XBLNR = Space.
in my coding?
Thank you!
studyabap
‎2008 Jan 18 5:29 AM
Hi,
Use this statement.
delete itab where xblnr is initial.
regards,
Santosh Thorat
‎2008 Jan 18 5:33 AM
Hi Study
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 by XBLNR.
read table t where xblnr is initial.
if sy-subrc eq 0.
delete t where kunnr = t-kunnr.
endif.
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.
‎2008 Jan 18 5:56 AM
HI Jackandjay,
I write the coding as you advice like:
-
END-OF-SELECTION.
SORT t BY xblnr.
READ TABLE t with key xblnr = space.
IF sy-subrc EQ 0.
DELETE t WHERE kunnr = t-kunnr.
ENDIF.
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 result was not change. That means:
kunnr xblnr
11111 space
11111 aaaaaaaaa
22222 bbbbbbbbb
22222 space
33333 ccccccccc
*The records for 111111 has been deleted, but the records for 22222 can not been deleted.
If I select 11111 or 22222 seperatly to execute It works, but when I select 11111 TO 33333, It was not work.
how can I correct it.
Please help, thank you
‎2008 Jan 18 6:00 AM
But as per your question , you need to delete all KUNNR which have atleast one space in XBLNR.. so the code works accordingly...
How to differentiate not to delete 2222 with space? and delete 11111 with space?
‎2008 Jan 18 6:08 AM
Hi,
Yes, I need to delete all KUNNR which have at least one space in XBLNR.
But the outcome is that The 11111 which have at least one space in XBLNR was deleted from t and was shown in alv. While 22222 which supposed to be deleted either (because it has at least one space in XBLNR) was still shown in alv.
How can I correct it?
Thankyou.
studyabap.
‎2008 Jan 18 6:17 AM
Hi try this .....
END-OF-SELECTION.
SORT t BY xblnr.
loop at t where xblnr = space.
DELETE t WHERE kunnr = t-kunnr.
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.
award points if helpful...
‎2008 Jan 18 7:35 AM
Hi,
I tried that , but the outcome did not change.
When I the Kunnr which is supposed to be seleted into t3 could not be selected.
Is there any other methods??
Thank you in advance.
studyabc
‎2008 Jan 18 5:33 AM
Hi,
Use the following statement.
Delete itab where XBLNR eq 'SPACE'.
Should work.
Regards,
Lalit
‎2008 Jan 18 5:44 AM
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
‎2008 Jan 18 7:42 AM
YOU CAN MAKE USE OF THIS STATEMENT
delete t3 where XBLNR = Space.
‎2008 Jan 18 7:48 AM
Hi,
Thank you for your advice.
How can i write the coding?
Please guid!!
thank you
‎2008 Jan 18 7:54 AM
Hi,
You can use the below code :
delete itab where field = space.
Thanks,
Sri.