09-15-2008 10:29 AM
Hi,
I am sorting the ALV Display on the basis of Assignment Field. It is getting sorted, but it is displaying the value in all the lines/rows. I want to display it only once(the first row) if the value is same.
Also, the first line of the ALV Output is a checkbox.
At present the check-box is displayed in all the rows.
My requirement is to display the check-box once for every new Assignment. So, if there are 5 rows with the same Assignment Value then only one check-box should appear, either in the first or fifth row.
Your help will be definitely appreciated.
Thanks,
~ Payel
09-15-2008 10:42 AM
09-15-2008 10:48 AM
Populate sort table for Assignment field.
ls_sort-fieldname = 'CARRNAME'.
ls_sort-spos = 1.
ls_sort-up = 'X'.
ls_sort-subtot = 'X'.
append ls_sort to e06_lt_sort.
For details see the std. program BALVST02_GRID
09-15-2008 10:53 AM
There is no Direct solution in this case....
1. Hade one extra field of type lenght 4 chars.
2. populate the ICON value for unselected checkbox.
3. Change the Fieldcatalog for the field which is added in step1.
4. Populate the sort information.
5. Handle the usercommand to check or uncheck based on action.
Check the sample code..
REPORT zalv_total_sub.
TYPE-POOLS: slis.
INCLUDE <icon>.
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,
check(4), "Step1
END OF it_flight.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fcat LIKE LINE OF it_fieldcat,
layout TYPE slis_layout_alv.
DATA: it_sort TYPE slis_t_sortinfo_alv,
wa_sort LIKE LINE OF it_sort.
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
FROM sflight
INTO CORRESPONDING FIELDS OF TABLE it_flight
.
SORT it_flight BY carrid.
"Step 2....
LOOP AT it_flight.
it_flight-check = icon_wd_iframe.
MODIFY it_flight.
ENDLOOP.
wa_fcat-do_sum = 'X'.
MODIFY it_fieldcat FROM wa_fcat TRANSPORTING do_sum
WHERE fieldname = 'SEATSOCC' .
CLEAR wa_fcat.
"Step3...
wa_fcat-hotspot = 'X'.
wa_fcat-icon = 'X'.
wa_fcat-col_pos = 1.
MODIFY it_fieldcat FROM wa_fcat TRANSPORTING col_pos icon hotspot
WHERE fieldname = 'CHECK' .
wa_sort-fieldname = 'CARRID'.
wa_sort-up = 'X'.
wa_sort-subtot = 'X'.
APPEND wa_sort TO it_sort.
" Step 4.
CLEAR wa_sort.
wa_sort-fieldname = 'CHECK'.
wa_sort-up = 'X'.
APPEND wa_sort TO it_sort.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND' "Step5
is_layout = layout
it_fieldcat = it_fieldcat
it_sort = it_sort
TABLES
t_outtab = it_flight
EXCEPTIONS
program_error = 1.
"Step 5 implementation.
FORM user_command USING ucomm TYPE sy-ucomm
selfield TYPE slis_selfield.
CASE ucomm.
WHEN '&IC1'.
CASE selfield-fieldname.
WHEN 'CHECK'.
READ TABLE it_flight INDEX selfield-tabindex.
IF sy-subrc EQ 0.
IF it_flight-check = icon_checkbox.
it_flight-check = icon_wd_iframe.
ELSE.
it_flight-check = icon_checkbox.
ENDIF.
MODIFY it_flight TRANSPORTING check
WHERE carrid = it_flight-carrid.
ENDIF.
ENDCASE.
ENDCASE.
selfield-refresh = 'X'.
ENDFORM. "user_command
Check it and let me know if any issues with the code.
10-13-2009 8:26 AM
Hi,
Are you able to find the solution for this. Please help me if as I have the same requirement
Warm Regards
Hemant
10-13-2009 8:30 AM
Hi,
For Sorting the contents try using,
DATA : IT_SORT TYPE SLIS_T_SORTINFO_ALV ,
WA_SORT TYPE SLIS_SORTINFO_ALV.
END-OF-SELECTION.
PERFORM SORT.
FORM SORT .
WA_SORT-SPOS = 1.
WA_SORT-FIELDNAME = 'MATNR'.
WA_SORT-TABNAME = IT_FINAL.
APPEND WA_SORT TO IT_SORT.
CLEAR WA_SORT.
ENDFORM. " SORT
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = GV_V_REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = 'HEADER'
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE = TEXT-007
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT = IT_FIELD
it_excluding = it_exclude
IT_SPECIAL_GROUPS =
IT_SORT = IT_SORT
Hope it helps,
Regards
Mansi