ABAP Dialog Programming : Set Filter data of Table Control


Example ABAP code for Filter data of table control

*---------------------------------------------------------------------*
*      Form  F_filter_data
*---------------------------------------------------------------------*
*  By Oka Wirasatha
*---------------------------------------------------------------------*
form F_FILTER_DATA .
  field-symbols :
    <selected_col> type CXTAB_COLUMN.
  data : LW_COLS like TC_ITEM-COLS.
  data : GT_FIELDCAT type LVC_T_FCAT.
  data LAYO type LVC_S_LAYO.
  data : GT_FILTER_INDEX type LVC_T_FIDX,
         LT_SELCOL type table of LVC_S_COL with header line.
  data : LT_FILT type LVC_T_FILT,
         LW_FILT type LVC_S_FILT,
         LT_LAYOUT type LVC_S_LAYO.

* find out if a column is selected.
  loop at TC_ITEM-COLS assigning <selected_col>.
    if <selected_col>-SELECTED = 'X'.
      LT_SELCOL-FIELDNAME = <selected_col>-SCREEN-NAME+7(10).
      append LT_SELCOL.
    endif.
  endloop.

  call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      I_STRUCTURE_NAME       = 'ZSMM_GRDM'
    changing
      CT_FIELDCAT            = GT_FIELDCAT
    exceptions
      INCONSISTENT_INTERFACE = 1
      PROGRAM_ERROR          = 2
      others                 = 99.

  if SY-SUBRC = 0 and not LT_SELCOL[] is initial.
    call function 'LVC_FILTER'
      exporting
        IT_FIELDCAT      = GT_FIELDCAT
        IT_SELECTED_COLS = LT_SELCOL[]
        IS_LAYOUT        = LT_LAYOUT
      importing
        ET_FILTER_INDEX  = GT_FILTER_INDEX
      tables
        IT_DATA          = T_ITEM "gt_subitems
      changing
        CT_FILTER        = LT_FILT
      exceptions
        others           = 0.
    if SY-SUBRC = 0.
      loop at LT_FILT into LW_FILT.
*     Filter data with dynamic Selected col
        perform F_RANGES_STR
          using LW_FILT-FIELDNAME
                LW_FILT-SIGN
                LW_FILT-OPTION
                LW_FILT-LOW
                LW_FILT-HIGH.
      endloop.
      if SY-SUBRC ne 0.
*        Fill default data to list
      endif.
    endif.
  endif.

endform.                    " F_filter_data

Comments

alpi€R said…
This comment has been removed by the author.

Popular posts from this blog

Step by step Create SAP LIS Report

Step by Step SAP Splitting Document

New GL Manual Update FAGLFLEXA & FAGLFLEXT