‎2008 Jan 21 8:44 AM
Hi,
I have an internal table itab of fields name1 and land1
itab has 4 records
name1 land1
a 6-a
b 6-b
c 6-cad
d 8-adf
here in itab I don't want the record which is haveing land1 starting other than 6-
my final itab to be
name1 land1
a 6-a
b 6-b
c 6-cad
Edited by: SHIPLA12 1 on Jan 21, 2008 9:44 AM
‎2008 Jan 21 8:47 AM
Hi,
Data : land2 type c.
Loop at itab.
clear: land2.
condense itab-land1.
land2 = itab-land1+0(1).
If land2 NE '6'.
Delete itab.
endif.
Endloop.
‎2008 Jan 21 8:51 AM
Hi,
loop at it_tab where land1 cp '%6-'.
write: name1,
land1.
endloop.
Plzz reward points if it helps.
‎2008 Jan 21 8:51 AM
Hi Shilpa,
Please refer below code:
data : begin of itab occurs 0,
first type c,
second(10),
end of itab.
itab-first = 'a'.
itab-second = '6-a'.
append itab.
clear itab.
itab-first = 'b'.
itab-second = '6-b'.
append itab.
clear itab.
itab-first = 'c'.
itab-second = '6-cad'.
append itab.
clear itab.
itab-first = 'd'.
itab-second = '8-adf'.
append itab.
clear itab.
loop at itab.
if itab-second+0(1) ne '6'.
delete itab.
endif.
endloop.
Piyush
Reward points, if helpfull
‎2008 Jan 21 8:52 AM
Hi Shilpa,
Try this ,
Hi,
Data : land1 type c.
Loop at itab.
clear: land1.
land1 = itab-land+0(1).
If land1 NE '6'.
Delete itab.
endif.
Endloop.
Reward If Useful.
Regards,
Chitra Parameswaran
‎2008 Jan 21 8:52 AM
‎2008 Jan 21 8:56 AM
hi shilpa,
loop at itab where land1 cp '%6-'.
write: name1,'-',land1.
endloop.
‎2008 Jan 21 8:56 AM
hi,
check this program...
DATA:BEGIN OF ITAB OCCURS 0,
NAME1 LIKE KNA1-NAME1,
LAND1 LIKE KNA1-LAND1,
END OF ITAB.
START-OF-SELECTION.
ITAB-NAME1 = 'a'.
ITAB-LAND1 = '6-a'.
APPEND ITAB.
CLEAR ITAB.
ITAB-NAME1 = 'b'.
ITAB-LAND1 = '6-b'.
APPEND ITAB.
CLEAR ITAB.
ITAB-NAME1 = 'c'.
ITAB-LAND1 = '6-cad'.
APPEND ITAB.
CLEAR ITAB.
ITAB-NAME1 = 'a'.
ITAB-LAND1 = '8-adf'.
APPEND ITAB.
CLEAR ITAB.
LOOP AT ITAB.
IF ITAB-LAND1+0(2) EQ '6-'.
WRITE:/ ITAB-NAME1,ITAB-LAND1.
ENDIF.
ENDLOOP.
‎2008 Jan 21 8:58 AM
name1 land1
a 6-a
b 6-b
c 6-cad
d 8-adf
DELETE itab WHERE land1(1) NE '6'.
name1 land1
a 6-a
b 6-b
c 6-cad
‎2008 Jan 21 9:03 AM
when you populate your itab why can't you check if the value to be entered in itab-land1 does have 6 in the first character position or not else you can loop at final itab and then check if any record has land1 starting with 6.
CONSTANTS: gc_6(1) type c VALUE '6'.
LOOP at itab into gwa_itab.
gv_chk = gwa_itab-LAND1+0(1).
IF gv_chk NE gc_6.
DELETE ITAB from gwa_itab..
ENDLOOP....
‎2008 Jan 21 9:12 AM
Hi Shilpa,
I will develop a entire code for ur question.Check it once.I will execute the below code that is executing successfully.plz copy the below code and execute it and ur problem is solved ok..try to debug the code ok..
CODE:
data: begin of itab occurs 0,
name like kna1-name1,
land(20) type c,
end of itab.
data: land1 type c.
start-of-selection.
itab-name = 'a'.
itab-land = '6-a'.
append itab.
itab-name = 'b'.
itab-land = '6-b'.
append itab.
itab-name = 'c'.
itab-land = '6-cad'.
append itab.
itab-name = 'd'.
itab-land = '8-daf'.
append itab.
clear itab.
end-of-selection.
loop at itab.
land1 = itab-land.
land1 = land1+0(1).
if land1 ne '6'.
delete itab index sy-tabix.
endif.
endloop.
loop at itab.
write:/ itab-name, 10 itab-land.
endloop.
Reward points if helpful.
Kiran Kumar.G.A
Have a Nice Day
‎2008 Jan 21 9:13 AM
LOOP at itab into wa_itab.
CHECK wa_itab-land1+0(1) NE '6'.
DELETE wa_itab.
ENDLOOP.
Thanks,
teja.