BIT Monitor: Add custom fields in the selection screen

Attention: The actions on this post are done by changing the SAP standard code. Do it at your own risk.

Usually in BRIM implementations, the users always want to search BITs by custom fields. By standard they can use the top left option “Other Selections”, but is kind annoying to do it every time you want to search a BIT, since the BIT monitor is a key transaction in the CI module.

So, one day I have investigated how can I add custom fields in the selection screen and… I needed to change the standard code. Here is a tutorial about how I did it.

Some of the code can look redundant, but it is important in order to the transaction work properly when you execute, count, go back and forward, or add “Other Selections”


Step 1: Add the table CI_FKKBIXBIT_IT in the data declaration zone

TABLES: CI_FKKBIXBIT_IT


Step 2: Add the desired field/s on selection screen. In this example we are adding the field “yourfield” with the data element “zz_yourfield“. Additionally we are adding the parameter where2, to help us build the where table for those fields.

SELECTION-SCREEN BEGIN OF BLOCK block_misc WITH FRAME TITLE TEXT-004. 
*{   REPLACE
                  billfirs     FOR fkkbix_icbit2_it_all-bill_first.
                  billfirs     FOR fkkbix_icbit2_it_all-bill_first,
                  yourfield    FOR CI_FKKBIXBIT_IT-zz_yourfield.
*}   REPLACE
  PARAMETERS: where  TYPE rsds_where                   NO-DISPLAY,
*{   INSERT
              where2 TYPE rsds_twhere NO-DISPLAY,
*}   INSERT
              ranges TYPE rsds_range NO-DISPLAY, "needed to memorize the freesel screen
              fresel TYPE free_sel_flg AS CHECKBOX   MODIF ID par.


Step 3: Add the logic for the next field/s on the “WHEN ‘FC02′”

    WHEN 'FC02'.
*{   INSERT 
      DATA: S_FIELD_RANGES  TYPE RSDS_RANGE,
            T_FIELD_RANGES  TYPE RSDS_TRANGE,
            S_FRANGE      TYPE RSDS_FRANGE.

      IF where2 IS NOT INITIAL.
        LOOP AT where2[ 1 ]-where_tab INTO DATA(s_where_tab).
          DELETE where-where_tab WHERE line = s_where_tab-line.
        ENDLOOP.
      ENDIF.

      CLEAR: S_FIELD_RANGES, T_FIELD_RANGES, where2, S_FRANGE.

      IF yourfield[] IS NOT INITIAL.
        S_FRANGE-FIELDNAME = 'ZZ_YOURFIELD'.
        S_FRANGE-SELOPT_T[] = pcn[].
        APPEND S_FRANGE TO S_FIELD_RANGES-FRANGE_T.
      ENDIF.

      IF S_FIELD_RANGES IS NOT INITIAL.
        S_FIELD_RANGES-TABLENAME = 'CI_FKKBIXBIT_IT'.
        APPEND S_FIELD_RANGES TO T_FIELD_RANGES.
        CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE'
          EXPORTING
            field_ranges        = T_FIELD_RANGES
          IMPORTING
            WHERE_CLAUSES       = where2.

        IF where2 IS NOT INITIAL.
          IF where-where_tab[] IS NOT INITIAL.
            where2[ 1 ]-where_tab[ 1 ]-line(3) = 'AND'.
          ENDIF.
          LOOP AT where2[ 1 ]-where_tab INTO s_where_tab.
            APPEND s_where_tab TO where-where_tab.
          ENDLOOP.
        ENDIF.
      ENDIF.
*}   INSERT


Step 4: Add the logic for the next fields on the “‘WHEN ‘ONLI’ OR ‘EXEC'”

    WHEN 'ONLI' OR 'EXEC'.
* -------------------------------------------------------------

      " set Parameter
      IF lines( gpart[] ) = 1.
        IF gpart[ 1 ]-sign = 'I' AND gpart[ 1 ]-option = 'EQ' AND gpart[ 1 ]-low IS NOT INITIAL.
          ls_md_ci-gpart = gpart[ 1 ]-low.
          SET PARAMETER ID 'BPA' FIELD ls_md_ci-gpart.
        ENDIF.
      ENDIF.
      IF lines( vkont[] ) = 1.
        IF vkont[ 1 ]-sign = 'I' AND vkont[ 1 ]-option = 'EQ' AND vkont[ 1 ]-low IS NOT INITIAL.
          ls_md_ci-vkont = vkont[ 1 ]-low.
          SET PARAMETER ID 'KTO' FIELD ls_md_ci-vkont.
        ENDIF.
      ENDIF.
*{   INSERT
      IF where2 IS NOT INITIAL.
        LOOP AT where2[ 1 ]-where_tab INTO s_where_tab.
          DELETE where-where_tab WHERE line = s_where_tab-line.
        ENDLOOP.
      ENDIF.


      CLEAR: S_FIELD_RANGES, T_FIELD_RANGES, where2, S_FRANGE.

      IF yourfield[] IS NOT INITIAL.
        S_FRANGE-FIELDNAME = 'ZZ_YOURFIELD'.
        S_FRANGE-SELOPT_T[] = pcn[].
        APPEND S_FRANGE TO S_FIELD_RANGES-FRANGE_T.
      ENDIF.

      IF S_FIELD_RANGES IS NOT INITIAL.
        S_FIELD_RANGES-TABLENAME = 'CI_FKKBIXBIT_IT'.
        APPEND S_FIELD_RANGES TO T_FIELD_RANGES.

        CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE'
          EXPORTING
            field_ranges        = T_FIELD_RANGES
          IMPORTING
            WHERE_CLAUSES       = where2.

        IF where2 IS NOT INITIAL.
          IF where-where_tab[] IS NOT INITIAL.
            where2[ 1 ]-where_tab[ 1 ]-line(3) = 'AND'.
          ENDIF.
          LOOP AT where2[ 1 ]-where_tab INTO s_where_tab.
            APPEND s_where_tab TO where-where_tab.
          ENDLOOP.
        ENDIF.
      ENDIF.
*}   INSERT

Leave a Comment