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

alv report problem

Former Member
0 Likes
470

I've populated an internal table which is showing values suppose like below.

f1 f2 f3 f4.

1 a b 10

1 a b 20

1 a h 40

2 b c 30

2 b c 40

3 c d 50

3 c d 60

consider:

f1 as matnr-article number

f2 as maktx-article description.

Now for every new matnr (having new maktx) only new matnr and new maktx will be printed, duplicate matnr and maktx won't be displayed. Those fields will display null actually. But corresponding f3 and f4 will be printed as it is.

so values in the next internal table will be like following:

f1 f2 f3 f4.

1 a b 10

N N b 20

N N h 40

2 b c 30

N N c 40

3 c d 50

N N d 60

Consider N as null.

kindly help.

how can i populate such internal table?

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
452

Hai Cinthia,

Try this:

data: lv_f1 type matnr,

lv_f2 type maktx.

sort <internaltable> by f1.

loop at <internaltable>.

clear: lv_f1, lv_f2.

lv_f1 = <internaltable>-f1.

lv_f2 = <internaltable>-f2.

at new f1.

write: lv_f1,

lv_f2.

endat.

write: <internaltable>-f3,

<internaltable>-f4.

endloop.

with regards,

Eswar.

3 REPLIES 3
Read only

Former Member
0 Likes
452

hi,

take two variables, and give first data of itab..

and in loop compare it with new value and if same use modify statement and refresh that two variables with new value..

i think it should work...

Read only

Former Member
0 Likes
452

Hi ,

I can suggest on esimple solution.

you have data in itab.

the declare

data:begin itab_flg occurs 0.

include structure itab.

data:flg(1),

end of itab_flg.

data:v_index like sy-tabix.

data:v_maktx like makt-maktx.

start-of-selection.

sort itab by maktx. "f2

move-corresponding itab to itab_flg.

append itab_flg.

clear itab_flg.

loop at itab_flg.

clear :v_index,v_maktx.

v_index = sy-tabix + 1.

v_maktx = itab_flg-maktx.

read itab_flg index v_index.

if sy-subrc = 0 and v_maktx = itab_flg-maktx .

itab_flg-flg = 'X'.

modify itab_flg index v_index.

clear itab_flg.

endif.

endloop.

loop at itab_flg where flg = 'X'.

itab_flg-maktx = ' '. "Null value.

modify itab_flg.

clear itab_flg.

endloop.

refresh:itab.clear:itab.

Move-corresponding itab_flg to itab.

Append itab.

clear itab.

now in this itab you have the data required for you.

thanks

Sivaparvathi.

Please reward points if helpful.

Read only

Former Member
0 Likes
453

Hai Cinthia,

Try this:

data: lv_f1 type matnr,

lv_f2 type maktx.

sort <internaltable> by f1.

loop at <internaltable>.

clear: lv_f1, lv_f2.

lv_f1 = <internaltable>-f1.

lv_f2 = <internaltable>-f2.

at new f1.

write: lv_f1,

lv_f2.

endat.

write: <internaltable>-f3,

<internaltable>-f4.

endloop.

with regards,

Eswar.