04-10-2006 5:12 AM
Hi all,
I have developed a report using ALV in that report my main issue is that when the user press a button on the daplay output a set of fields should be hided can any one suggest the coding.
rgards
paul
04-10-2006 5:16 AM
HI Paul,
just change the fieldcatalogue i.e
remove some fields from it on the button press event and call the FM again using that fieldcat...
regards
satesh
04-10-2006 5:16 AM
HI Paul,
just change the fieldcatalogue i.e
remove some fields from it on the button press event and call the FM again using that fieldcat...
regards
satesh
04-10-2006 5:36 AM
Hi Paul,
Three steps are needed in this case.
1) Clear the internal table for the field catalog
2) Append new values in the field catalog
3) Call the method SET_TABLE_FOR_FIRST_DISPLAY for displaying the changed contents.
Code:
-
Suppose the function code for the button is CLICK.In PAI of the screen, code in the following manner.
when 'CLICK'.
clear field_catalog[].
data ls_fcat type lvc_s_fcat .
ls_fcat-fieldname = 'CARRID' .
ls_fcat-inttype = 'C' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Carrier ID' .
ls_fcat-web_field = 'carrid_handle'.
ls_fcat-edit = 'X'.
*ls_fcat-emphasize = 'C310'. "needed for column coloring
append ls_fcat to field_catalog .
clear ls_fcat .
ls_fcat-fieldname = 'FLDATE' .
ls_fcat-ref_table = 'SFLIGHT' .
ls_fcat-ref_table = 'FLDATE' .
ls_fcat-outputlen = '20' .
ls_fcat-coltext = 'Flight Date' .
ls_fcat-web_field = 'fldate_handle'.
append ls_fcat to field_catalog .
CALL METHOD GO_GRID->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
it_outtab = itab[]
IT_FIELDCATALOG = field_catalog.
04-10-2006 5:47 AM
Paul,
Where is the button, in the program's PF-STATUS in the toolbar of the Grid.
Change the field catalog that you using by setting NO_OUT for the fields that you don't want to display. Once this is done call the SET_TABLE_FOR_FIRST_DISPLAY and it should reflect the new field catalog.
Regards,
Ravi
Note : please mark the helpful answers
04-10-2006 6:34 AM
Hi,
Check this code...
this will work for you...
REPORT ZTEST_ALV.
type-pools:slis.
DATA: GT_SFLIGHT TYPE TABLE OF SFLIGHT.
DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
FIELDCAT type SLIS_FIELDCAT_ALV.
data: l_layout type SLIS_LAYOUT_ALV.
SELECT * FROM SFLIGHT INTO TABLE GT_SFLIGHT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = sy-repid
I_STRUCTURE_NAME = 'SFLIGHT'
I_INCLNAME = sy-repid
CHANGING
CT_FIELDCAT = gt_fieldcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
perform alv_display.
*&--------------------------------------------------------------------*
*& Form status
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
form status USING P_EXTAB TYPE SLIS_T_EXTAB .
set pf-status 'AAA' excluding p_extab.
endform. "status
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->P_UCOMM text
* -->P_SELFIELD text
*---------------------------------------------------------------------*
FORM USER_COMMAND USING P_UCOMM LIKE SY-UCOMM
P_SELFIELD TYPE SLIS_SELFIELD.
case p_ucomm.
when <b>'TEST'.</b> "Button okcode
fieldcat-no_out = 'X'.
modify gt_fieldcat from fieldcat
transporting no_out where fieldname = 'PRICE'.
<b>p_selfield-exit = 'X'.</b>
perform alv_display.
endcase.
ENDFORM. "USER_COMMAND
*&---------------------------------------------------------------------*
*& Form alv_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
IS_LAYOUT = l_layout
I_CALLBACK_PROGRAM = sy-repid
I_STRUCTURE_NAME = 'SFLIGHT'
I_CALLBACK_PF_STATUS_SET = 'STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = GT_FIELDCAT[]
TABLES
T_OUTTAB = GT_SFLIGHT.
ENDFORM. " alv_display
Regards
vijay