Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Hide a set of fields when I press a button on the ALV grid display

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

4 REPLIES 4

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

former_member188685
Active Contributor
0 Kudos

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