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

internal table

Former Member
0 Likes
533

hi guyz , i have an internal table with values such as

1234 X 0000

1234 Q 1234

3456 X 0000

now i have to manipulate onli the entry which got Q for 1234 and 3456 should still remain in the internal table.

wot i mean is if i have 2 entries with same number and with X and Q i dont wanna use X nomore all i need is Q one.

plz advise

thanks

6 REPLIES 6
Read only

Former Member
0 Likes
501

you can maintain you're z table in sm30 if you have set up the maintenance generator in se11 for you're table

kind regards

arthur de smidt

Read only

prasanth_kasturi
Active Contributor
0 Likes
501

hi,

Use On Change Of statement

data : begin of itab occurs 0,

f1 type i,

f2 ,

end of itab.

data var .

itab-f1 = 1234.

itab-f2 = 'Q'.

append itab.

itab-f1 = 1234.

itab-f2 = 'X'.

append itab.

itab-f1 = 3456.

itab-f2 = 'Q'.

append itab.

sort itab by f1.

loop at itab.

on change of itab-f1.

var = itab-f2.

else.

itab-f2 = var.

modify itab TRANSPORTING f2 where f1 = itab-f1.

endon.

endloop.

loop at itab.

write :/ itab-f1,

itab-f2.

endloop.

regards

prasanth

Edited by: Prasanth Kasturi on Aug 6, 2008 10:06 AM

Read only

Former Member
0 Likes
501

hi look at this..

data:begin of itab occurs 0,

f1 type i,

f2 type c,

f3 type i,

end of itab .

itab-f1 = 1234.

itab-f2 = 'X'.

itab-f3 = 0000.

append itab .

itab-f1 = 1234.

itab-f2 = 'Q'.

itab-f3 = 1234.

append itab .

itab-f1 = 3456.

itab-f2 = 'X'.

itab-f3 = 1234.

append itab .

loop at itab where f1 = 1234 and f2 = 'Q'.

write:/ itab-f1,itab-f2,itab-f3.

endloop.

Read only

Former Member
0 Likes
501

hi,

you can solve it by these ways:

loop at itab.

if itab-field2 = 'Q'.

write down your manipulation here.

endif.

endloop.

or

loop at itab where field2 = 'Q'.

write down your manipulation here.

endloop.

Read only

Former Member
0 Likes
501

Hi,

Try this.

Let the fields be f1, f2, f3.

Clear: temp.

Itab1[] = itab2[]

Sort itab1 by f1 f2 ascending.

Sort itab1 by f1 f2 ascending.

Loop at itab1 into wa1.

If wa1-f2 eq u2018Xu2019.

Read table itab2 into wa2 with key f1 = wa1-f1

F2 = u2018Qu2019.

If sy-subrc eq 0.

Append wa2 to itab3.

Delete itab1 from wa2.

Endif.

Else.

Append wa1 to itab3.

Endif.

Endloop.

Then use the internal table itab3 as per your requirement.

Sharin.

Read only

Former Member
0 Likes
501

Hi

Try this logic...itz workin...

DATA:BEGIN OF itab OCCURS 0,

f1 TYPE i,

f2 TYPE c,

f3 TYPE i,

END OF itab .

data : itab3 like itab occurs 0 with header line.

data : itab2 like itab occurs 0 with header line.

itab-f1 = 1234.

itab-f2 = 'X'.

itab-f3 = 0000.

APPEND itab .

itab-f1 = 1234.

itab-f2 = 'Q'.

itab-f3 = 1234.

APPEND itab .

itab-f1 = 3456.

itab-f2 = 'X'.

itab-f3 = 1234.

APPEND itab .

Sort itab by f1 f2 ascending.

itab2[] = itab[].

delete adjacent duplicates from itab2 comparing f1.

Loop at itab.

at new f1.

loop at itab2 where f1 = itab-f1.

if itab2-f2 eq 'Q'.

move itab2 to itab3.

else.

move itab2 to itab3.

Endif.

append itab3.

Endloop.

endat.

Regards

Mamtha