‎2011 Mar 14 10:24 AM
Dear all ,
I hav one requirment. Please no needful help.. => How can I not oblige?
i have one internal table
aaa bbb ccc
1 abc 20
1 abc 21
1 abc 23
1 abc 24
1 abc 25
1 abc 26
2 bca 30
2 bca 31
2 bca 32
2 bca 33
3 cab 40
3 cab 41
3 cab 42
3 cab 43
now i have want to count the same lines and have to display in another field in ALV
required output
aaa bbb ccc ddd
1 abc 20 6
1 abc 21
1 abc 23
1 abc 24
1 abc 25
1 abc 26
2 bca 30 4
2 bca 31
2 bca 32
2 bca 33
3 cab 40 4
3 cab 41
3 cab 42
3 cab 43
total 1's are 6
2's are 4
3's are 4.
how to display in ALV?
Moderator Message: Spec-dumping is not allowed. Please put some effort of your own first
Edited by: kishan P on Mar 14, 2011 4:53 PM
‎2011 Mar 14 10:32 AM
Hi there,
You can use the offset concept, so that you can compare the each record from the internal.
With regards,
Aahbha
‎2011 Mar 14 10:34 AM
‎2011 Mar 14 10:37 AM
please have a glane on this webpage.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb341a358411d1829f0000e829fbfe/content.htm
‎2011 Mar 14 10:50 AM
please see i have did like this.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
sort it_ekko by ebeln.
IT_EKKO1[] = IT_EKKO[].
LOOP AT IT_EKKO INTO WA_EKKO.
WA_EKKO2-EBELN = WA_EKKO-EBELN.
WA_EKKO2-cnt1 = WA_EKKO2-cnt1 + 1.
COLLECT WA_EKKO2 INTO IT_EKKO2.
clear wa_ekko2-cnt1.
clear wa_ekko2.
ENDLOOP.
‎2011 Mar 14 10:52 AM
now i have to display the count in it_ekko
loop at it_ekko into wa_ekko where ebeln = wa_ekko2-ebeln.
wa_ekko-cnt = wa_ekko2-cnt1.
modify it_ekko from wa_ekko.
endloop.
i'm not getting the output
‎2011 Mar 14 10:56 AM
Hi,
Sort your internal table by first field.
And then loop itab. Within that loop, use control break statement 'AT END OF' first field. within that AT END..ENDAT. increase the record count. Update your other internal table.
loop at itab into wa.
wa2-fleid1 = wa1-field1.
wa2-fleid2 = wa1-field2.
wa2-fleid3 = wa1-field3.
count = count + 1.
at end of wa-filed1.
wa2-fleid4 = count.
clear count.
endat.
append wa2 to itab2.
endloop.
Thanks,
Naveen Inuganti.
‎2011 Mar 14 10:58 AM
‎2011 Mar 14 11:22 AM
HI,
Use the function module 'REUSE_ALV_GRID_DISPLAY' for ALV grid display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_grid_title = g_c_grid_title
is_layout = g_s_layout
it_fieldcat = g_t_fieldcat
i_save = 'A'
is_variant = g_variant
TABLES
t_outtab = g_t_outtab -
> give your final internal table here
EXCEPTIONS
program_error = 1
OTHERS = 2.
Regards,
Soumya.
‎2011 Mar 14 10:53 AM
Hi Anand,
try to implement below logic...
pass the internla table data into temp internal table.
sort temp internal table by aaa bbb.
clear count.
loop at temp internal table into workarea.
IF sy-tabix EQ 1.
lv_aaa = workarea-aaa.
lv_bbb = workarea-bbb.
ENDIF.
if lv_aaa EQ workarea-aaa and lv_bbb EQ workarea-bbb.
count = count + 1.
else.
update the final table column with the variable COUNT.
clear count.
ENDIF.
claer workarea.
ENDLoop.
‎2011 Mar 14 11:26 AM
Hi
Use the logic below and before calling the function module to display ALV, pass the internal table with all 4 fields.
SORT it_test BY aaa ASCENDING.
LOOP AT it_test INTO wa_test.
lv_index = sy-tabix.
AT NEW aaa.
LOOP AT it_test INTO wa_test_temp WHERE aaa = wa_test-aaa.
lv_count = lv_count + 1.
ENDLOOP.
MOVE lv_count TO wa_test-ddd.
MODIFY it_test FROM wa_test INDEX lv_index TRANSPORTING ddd.
CLEAR lv_count.
ENDAT.
ENDLOOP.