07-02-2012 6:30 PM
Hi All,
I have a requirement in which I need to merge two rows in a particular column in ALV grid display.
Example:- There are two rows in a column one is having no value and the other row is having some value(Quantity).
Can I merge the two rows into a single row?
Thanks in Advance.
07-02-2012 6:43 PM
Hi Nihar,
Check this link. Search the forum. This has been discussed many times.
http://scn.sap.com/thread/1586270
Regards,
Shravan
07-02-2012 6:43 PM
Hi Nihar,
Check this link. Search the forum. This has been discussed many times.
http://scn.sap.com/thread/1586270
Regards,
Shravan
07-02-2012 6:52 PM
Dear Shravan,
This is only applicable if the data in both the rows are same but my requirement is that in one row there is no data while in the second row I have data.So I want to merge these two rows in that particular column into one row having the particular data.
Thanks in Advance
07-02-2012 7:25 PM
Hi Nihar,
Can you give an example in an xls or something similar. The requirement is not clear to me.
Regards,
Shravan
07-02-2012 8:13 PM
Dear Shravan,
Please find below the example
as per the above example I have sorted material number. Now column1 will contain some quantity
so I will pick the first 3 quantities i.e 5,4,3 based on some condition and add it and will show it in column2 and then I will add the quantity 8 and 7 based on another condition and will put it in column3 .
Thanks
07-02-2012 9:02 PM
Hi Nihar,
Make sure your internal table has the data as below and then use the code as you have used for the material.
F1 F2 F3 F4
123 5 12 15
123 4 12 15
123 3 12 15
123 7 12 15
123 8 12 15
data lt_sort TYPE STANDARD TABLE OF slis_sortinfo_alv.
DATA: lwa_sort TYPE slis_sortinfo_alv.
MOVE: 'F3' TO lwa_sort-fieldname,
'X' TO lwa_sort-up.
APPEND lwa_sort TO lt_sort.
MOVE: 'F4' TO lwa_sort-fieldname,
'X' TO lwa_sort-up.
APPEND lwa_sort TO lt_sort.
MOVE: 'F1' TO lwa_sort-fieldname,
'X' TO lwa_sort-up.
APPEND lwa_sort TO lt_sort.
Regards,
Shravan
07-02-2012 9:04 PM
Material no | Column1 | Column2 | Column3 |
---|---|---|---|
123 | 5 | 12 | 15 |
123 | 4 | 12 | 15 |
123 | 3 | 12 | 15 |
123 | 8 | 12 | 15 |
123 | 7 | 12 | 15 |
07-03-2012 6:19 AM
Dear Shravan,
What you have suggested is correct but I am doing the addition AT-END of material 123, so the final value say suppose 12 will come AT-END of material 123 so it is getting populated at the last row so how can I populate the internal table as suggested by you.
07-03-2012 6:28 AM
You can take the starting index of the combination in AT-NEW OF and when the AT-END of is triggered update from that index to the current index.
Say when AT-NEW OF is triggered , the index of table was 3 then and when AT-END OF is triggered the index is 8, then update the table from 3 to 8 with the relevant value.
You should also check out Manu's answer.
Thanks,
Shambu
07-03-2012 8:11 AM
Dear Manu,
Kindly let me know how can I use CL_DD_DOCUMENT to achieve my requirement.
Thanks in Advance.
07-03-2012 2:35 PM
Hi,
Well I still think the easier way is the one suggested by Nihar/Shambu, you just need to update your table correctly so that each cell has the correct value. And then use the ALV sort... (no need to fetch start and end index however, since the material number is known and can be used to update the related rows)
If you want to go with DD_DOCUMENT however, you should first check program DD_ADD_TABLE and particulary table 2.1 (search the code to see how it is built). When I have some more time, I'll try and give you an example with your data...
Cheers,
Manu.
07-03-2012 4:10 PM
If you are providing the sums under AT END, you could simply add a modify statement to update all related column2 & 3:
LOOP AT gt_data ASSIGNING <d>.
AT END OF matnr.
"At this point, you calculate column2 and column3
"...
MODIFY gt_data FROM <d> TRANSPORTING column2 column3
WHERE matnr = <d>-matnr.
ENDAT.
"...
ENDLOOP.
Kr,
Manu.
07-03-2012 4:49 PM
07-03-2012 5:40 PM
Dear Shravan,
Can't we sort column having quantity fields ?
When ever I am going to sort the column having quantity field though sort symbol is coming but the cells having same quantity are not getting merged .
Thanks in Advance
07-03-2012 6:13 PM
Solved myself ...I have converted the quantity filed to character format....now the sort is working properly for quantity field......
Thanks to all for your valuable suggestions....
11-04-2015 7:20 AM