Hide Last 5 Columns and Display First 5 Columns

How to I hide last 5 columns and display first 5 columns or vice versa?

*&---------------------------------------------------------------------*
*& Report Z03_HIDE
*&---------------------------------------------------------------------*
REPORT z03_hide.
TABLES: mara,makt.
DATA: BEGIN OF itab OCCURS 0,
        matnr LIKE mara-matnr,
        maktx LIKE makt-maktx,
      END OF itab.
TYPE-POOLS:slis.
DATA: t_fcat TYPE slis_t_fieldcat_alv,
      t_eve TYPE slis_t_event.
SELECTION-SCREEN: BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
  PARAMETERS: chk1 AS CHECKBOX,
  chk2 AS CHECKBOX.
SELECTION-SCREEN: END OF BLOCK blk1.
*INITIALIZATION.
   
START-OF-SELECTION.
  PERFORM cre_fcat USING t_fcat.
  PERFORM cer_eve.
  PERFORM fetch_data.
  PERFORM dis_data.
*&---------------------------------------------------------------------*
*& Form cre_fcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_FCAT text
*----------------------------------------------------------------------*
FORM cre_fcat USING p_fcat TYPE slis_t_fieldcat_alv.
  DATA: wa_fcat TYPE slis_fieldcat_alv.
  wa_fcat-tabname = 'ITAB'.
  wa_fcat-fieldname = 'MATNR'.
  wa_fcat-seltext_l = 'Material Numebr'.
  wa_fcat-outputlen = '30'.
  IF chk1 = 'X'.
  wa_fcat-no_out = 'X'.
  ENDIF.
  APPEND wa_fcat TO p_fcat.
  CLEAR wa_fcat.
  wa_fcat-tabname = 'ITAB'.
  wa_fcat-fieldname = 'MAKTX'.
  wa_fcat-seltext_l = 'Material Description'.
  wa_fcat-outputlen = '40'.
  IF chk2 = 'X'.
  wa_fcat-no_out = 'X'.
  ENDIF.
  APPEND wa_fcat TO p_fcat.
  CLEAR wa_fcat.
ENDFORM. " cre_fcat
*&---------------------------------------------------------------------*
*& Form cer_eve
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM cer_eve .
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
  EXPORTING
  i_list_type = 0
  IMPORTING
  et_events = t_eve
  * EXCEPTIONS
  * LIST_TYPE_WRONG = 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. " cer_eve
*&---------------------------------------------------------------------*
*& Form fetch_data
*&---------------------------------------------------------------------*
* text

*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM fetch_data .
SELECT mara~matnr makt~maktx INTO CORRESPONDING FIELDS OF TABLE itab FROM mara INNER JOIN makt
ON mara~matnr = makt~matnr WHERE mara~matnr LIKE '1%'.
ENDFORM. " fetch_data
*&---------------------------------------------------------------------*
*& Form dis_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM dis_data .
 CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
  i_callback_program = 'Z03_HIDE'
  it_fieldcat = t_fcat
  it_events = t_eve
  TABLES
  t_outtab = itab.
ENDFORM. " dis_data

Related:

ABAP Books List
ABAP/4 Certification, Programming, Smartforms, Sapscripts and Object Oriented Programming Books

Smart Forms
SAP Smartforms

ABAP Menu:
ABAP Example Hints and Tips

Return to Index:-
SAP ABAP/4 Programming, Basis Administration, Configuration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.  The site www.gotothings.com is in no way affiliated with SAP AG.
Any unauthorised copying or mirroring is prohibited.