Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

codeing help

Former Member
0 Likes
1,200

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

11 REPLIES 11
Read only

Former Member
0 Likes
1,150

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.

Read only

Former Member
0 Likes
1,150

Hi,

loop at it_tab where land1 cp '%6-'.

write: name1,

land1.

endloop.

Plzz reward points if it helps.

Read only

piyush_mathur
Active Participant
0 Likes
1,150

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

Read only

Former Member
0 Likes
1,150

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

Read only

Former Member
0 Likes
1,150

Try this

delete itab where land1+0(2) ne '6-'.

Read only

Former Member
0 Likes
1,150

hi shilpa,

loop at itab where land1 cp '%6-'.

write: name1,'-',land1.

endloop.

Read only

former_member188829
Active Contributor
0 Likes
1,150

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.

Read only

Former Member
0 Likes
1,150

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

Read only

Former Member
0 Likes
1,150

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....

Read only

Former Member
0 Likes
1,150

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

Read only

Former Member
0 Likes
1,150

LOOP at itab into wa_itab.

CHECK wa_itab-land1+0(1) NE '6'.

DELETE wa_itab.

ENDLOOP.

Thanks,

teja.