09-29-2008 1:31 PM
Hello Friends,
I have made an ALV report where I am sorting on the second column which is a field called 'SUPPLIER_ID'.
I am to group the supplier_id, so that only the first row shows the supplier id, and those rows with the same id should not be shown. But am having trouble with this.
check Supplier ID field2 field3
xxxxx xxx xxx
xxx xxx
xxx xxx
xxxxxx xxx xxx.
These are the steps I do in the code.
1. I build the fieldcatalogue
2. then I select the data
3 . set the sort order
DATA: x_sort TYPE slis_sortinfo_alv.
CLEAR x_sort.
x_sort-fieldname = 'SUPPLIER_ID'.
x_sort-tabname = 'GT_OUTTAB'.
x_sort-up = 'X'
x_sort-spos = 2.
APPEND x_sort TO t_sort.
4. Then I call the Reuse function.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = ls_layout
IT_FIELDCAT = t_fieldcat
i_callback_pf_status_set = l_status
i_callback_program = l_repid
it_sort = x_sort
TABLES
T_OUTTAB = gt_outtab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
But all the rows show the supplier ID, what am I doing wrong?
best regards B
Edited by: Baljinder Singh Gosal on Sep 29, 2008 2:36 PM
09-29-2008 1:37 PM
correction in the code..
DATA: x_sort TYPE slis_sortinfo_alv.
CLEAR x_sort.
x_sort-fieldname = 'SUPPLIER_ID'.
x_sort-tabname = 'GT_OUTTAB'.
x_sort-up = 'X'
x_sort-spos = 1. " it should be 1 since this is only field you are
"sorting
APPEND x_sort TO t_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = ls_layout
IT_FIELDCAT = t_fieldcat
i_callback_pf_status_set = l_status
i_callback_program = l_repid
it_sort = t_sort " not x_sort
TABLES
T_OUTTAB = gt_outtab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
09-29-2008 1:37 PM
correction in the code..
DATA: x_sort TYPE slis_sortinfo_alv.
CLEAR x_sort.
x_sort-fieldname = 'SUPPLIER_ID'.
x_sort-tabname = 'GT_OUTTAB'.
x_sort-up = 'X'
x_sort-spos = 1. " it should be 1 since this is only field you are
"sorting
APPEND x_sort TO t_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = ls_layout
IT_FIELDCAT = t_fieldcat
i_callback_pf_status_set = l_status
i_callback_program = l_repid
it_sort = t_sort " not x_sort
TABLES
T_OUTTAB = gt_outtab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
09-29-2008 1:42 PM
I changed it as it, but it still shows all rows... I am using icons and colors in the GT_OUTTAB (deep structure). could this affect the outcome?
09-29-2008 1:51 PM
it is working fine for me, i tried it for Deep structures also. post your code.
09-29-2008 1:56 PM
here is the working example..
REPORT ztest_alv_color.
TYPE-POOLS: slis.
DATA: BEGIN OF it_flight OCCURS 0,
carrid LIKE sflight-carrid,
connid LIKE sflight-connid,
fldate LIKE sflight-fldate,
seatsmax LIKE sflight-seatsmax,
seatsocc LIKE sflight-seatsocc,
price LIKE sflight-price,
currency LIKE sflight-currency,
cellcolors TYPE lvc_t_scol,
END OF it_flight.
DATA: it_sort TYPE slis_t_sortinfo_alv,
wa_sort LIKE LINE OF it_sort.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
layout TYPE slis_layout_alv,
ls_cellcolor TYPE lvc_s_scol .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'IT_FLIGHT'
i_inclname = sy-repid
CHANGING
ct_fieldcat = it_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
SELECT carrid
connid
fldate
seatsmax
seatsocc
price
currency
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE it_flight
UP TO 20 ROWS.
DATA: col TYPE lvc_s_scol,
coltab TYPE lvc_t_scol,
color TYPE lvc_s_colo.
LOOP AT it_flight.
IF it_flight-seatsocc NE it_flight-seatsmax.
IF it_flight-seatsocc GT 300.
ls_cellcolor-fname = 'SEATSOCC' .
ls_cellcolor-color-col = '3' .
ls_cellcolor-color-int = '1' .
APPEND ls_cellcolor TO it_flight-cellcolors .
ELSE.
ls_cellcolor-fname = 'SEATSOCC' .
ls_cellcolor-color-col = '7' .
ls_cellcolor-color-int = '1' .
APPEND ls_cellcolor TO it_flight-cellcolors .
ENDIF.
ENDIF.
MODIFY it_flight.
ENDLOOP.
layout-coltab_fieldname = 'CELLCOLORS'.
wa_sort-fieldname = 'CONNID'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = layout
it_sort = it_sort
it_fieldcat = it_fieldcat
TABLES
t_outtab = it_flight
EXCEPTIONS
program_error = 1.
09-29-2008 2:01 PM
types: begin of gs_outtab.
types:
SUPPLIER TYPE ZSAM_LAC-SUPPLIER,
SUPPLIER_ID TYPE ZSAM_LAC-SUPPLIER_ID,
SPEND TYPE ZSAM_LAC-SPEND,
lights type char1,
color type i,
tabcol type lvc_t_scol,
id type char25,
name type icon-name,
symbol type icon-id,
end of gs_outtab.
data: gt_outtab type standard table of gs_outtab,
wa_outtab type gs_outtab.
data: gr_container type ref to cl_gui_custom_container,
gs_layout type lvc_s_layo,
gt_fieldcat type lvc_t_fcat.
.
.
.
perform display.
.
.
.
form display.
data: ls_layout type slis_layout_alv,
t_fieldcat TYPE slis_t_fieldcat_alv,
x_sort TYPE slis_sortinfo_alv
t_sort TYPE slis_t_sortinfo_alv,
l_status TYPE slis_formname,
l_repid TYPE syrepid.
REFRESH t_sort.
REFRESH t_fieldcat.
g_pf_status = 'SALV_STANDARD'.
l_status = 'SET_PF_STATUS'.
l_repid = sy-repid.
Layout
ls_layout-lights_tabname = '1'.
ls_layout-lights_fieldname = 'LIGHTS'.
ls_layout-coltab_fieldname = 'TABCOL'.
ls_layout-zebra = 'X'.
PERFORM set_fieldcat2 USING:
*pos fieldname ref_field ref_tab len noout text_m text_l txt_s reptxt ddic hotsp icon chckbx edit dosum inttype symbol tech group fieldcat
1 'CHECK' 'XFELD' space space space 'Select' 'Select' 'Sel' 'Select' space space space 'X' 'X' space space space space space t_fieldcat,
2 'SUPPLIER' 'SUPPLIER' 'ZSAM_LAC' space space text-hl5 text-hl5 text-hl5 space space space space space space space space space space space t_fieldcat,
3 'SUPPLIER_ID' 'SUPPLIER_ID' 'ZSAM_LAC' space space text-hl4 text-hl4 text-hl4 space space space space space space space space space space 'A' t_fieldcat,
perform get_data
perform set_icons.
perform set_order USING 'ORKLA_COMP_NAME' 'GT_OUTTAB' 'X' space space t_sort.
CLEAR x_sort.
x_sort-fieldname = 'SUPPLIER_ID'.
x_sort-tabname = 'GT_OUTTAB'.
x_sort-up = 'X'.
x_sort-spos = 1.
APPEND x_sort TO t_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = ls_layout
IT_FIELDCAT = t_fieldcat
IT_EXCEPT_QINFO = gt_exc
i_callback_pf_status_set = l_status
i_callback_program = l_repid
it_sort = t_sort
TABLES
T_OUTTAB = gt_outtab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
endform. " display_fullscreen
09-29-2008 2:38 PM
09-29-2008 2:41 PM
09-29-2008 2:43 PM
If so check this wiki contribution.
https://wiki.sdn.sap.com/wiki/display/Snippets/ABAP-ALVReportGroupFunctionalitywithCheckbox
09-29-2008 2:45 PM
Ahh, so that was the problem, it works when i take away the checkbox... Is it possible to have both? Grouping and checkbox?
09-29-2008 2:52 PM
09-29-2008 1:55 PM
Hi ,
once ur final table has data... then sort it and using control break staments try to populate final table in ur required format and pass it to grid_display.. instead of using sort_info structure..
I think this should help u....
Rgds.,
subash