Skip to Content
0
Former Member
Apr 07, 2011 at 03:03 PM

How to do dynamic filtering on a parameter?

438 Views

Hi all,

I am trying to do a dynamic filtering with the matchcode of two parameters.

My program will be used to do the correspondence between two types of account.

For example:

If the first parameter is "BA000000" the second matchcode will only allow to choose between account who are like "BP000000"

I've done this but the filtering is not dynamic:

DATA: TAB_SKA1 TYPE TABLE OF SKA1,
      WA_SKA1  LIKE SKA1,
      TAB_TEMP TYPE TABLE OF SKA1.

SELECTION-SCREEN BEGIN OF BLOCK S_VARIABLE WITH FRAME TITLE TEXT-000.
PARAMETERS:
           P_MAGNI  LIKE SKA1-BILKT OBLIGATORY,
           P_CORRES LIKE SKA1-BILKT OBLIGATORY.
SELECTION-SCREEN END OF BLOCK S_VARIABLE.

*Extracting Magnitude account
  SELECT * FROM SKA1 INTO TABLE TAB_SKA1
    WHERE KTOPL = 'PCBP'
    AND KTOKS <> 'SG' AND KTOKS <> 'CG' AND KTOKS <> 'TI' AND KTOKS <> 'BQ'
    ORDER BY SAKNR.

*Matchcode for P_MAGNI
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MAGNI.
  IF P_CORRES IS INITIAL.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        DDIC_STRUCTURE = 'SKA1'
        RETFIELD       = 'SAKNR'
        DYNPPROG       = SY-REPID
        DYNPNR         = SY-DYNNR
        DYNPROFIELD    = 'P_MAGNI'
        STEPL          = 0
        WINDOW_TITLE   = 'Comptes Magnitude'
        VALUE_ORG      = 'S'
      TABLES
        VALUE_TAB      = TAB_SKA1.
  ELSEIF P_CORRES+0(2) EQ 'BA'.
    LOOP AT TAB_SKA1 INTO WA_SKA1.
      IF WA_SKA1-SAKNR+0(2) EQ 'BP'.
        APPEND WA_SKA1 TO TAB_TEMP.
      ENDIF.
    ENDLOOP.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        DDIC_STRUCTURE = 'SKA1'
        RETFIELD       = 'SAKNR'
        DYNPPROG       = SY-REPID
        DYNPNR         = SY-DYNNR
        DYNPROFIELD    = 'P_MAGNI'
        STEPL          = 0
        WINDOW_TITLE   = 'Comptes Magnitude'
        VALUE_ORG      = 'S'
      TABLES
        VALUE_TAB      = TAB_TEMP.
    CLEAR TAB_TEMP.
  ELSEIF P_CORRES+0(2) EQ 'BP'.
    LOOP AT TAB_SKA1 INTO WA_SKA1.
      IF WA_SKA1-SAKNR+0(2) EQ 'BA'.
        APPEND WA_SKA1 TO TAB_TEMP.
      ENDIF.
    ENDLOOP.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        DDIC_STRUCTURE = 'SKA1'
        RETFIELD       = 'SAKNR'
        DYNPPROG       = SY-REPID
        DYNPNR         = SY-DYNNR
        DYNPROFIELD    = 'P_MAGNI'
        STEPL          = 0
        WINDOW_TITLE   = 'Comptes Magnitude'
        VALUE_ORG      = 'S'
      TABLES
        VALUE_TAB      = TAB_TEMP.
    CLEAR TAB_TEMP.
  ENDIF.

*Matchcode for P_CORRES
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_CORRES.
  IF P_MAGNI IS INITIAL.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        DDIC_STRUCTURE = 'SKA1'
        RETFIELD       = 'SAKNR'
        DYNPPROG       = SY-REPID
        DYNPNR         = SY-DYNNR
        DYNPROFIELD    = 'P_CORRES'
        STEPL          = 0
        WINDOW_TITLE   = 'Comptes Magnitude'
        VALUE_ORG      = 'S'
      TABLES
        VALUE_TAB      = TAB_SKA1.
  ELSEIF P_MAGNI+0(2) EQ 'BA'.
    LOOP AT TAB_SKA1 INTO WA_SKA1.
      IF WA_SKA1-SAKNR+0(2) EQ 'BP'.
        APPEND WA_SKA1 TO TAB_TEMP.
      ENDIF.
    ENDLOOP.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        DDIC_STRUCTURE = 'SKA1'
        RETFIELD       = 'SAKNR'
        DYNPPROG       = SY-REPID
        DYNPNR         = SY-DYNNR
        DYNPROFIELD    = 'P_CORRES'
        STEPL          = 0
        WINDOW_TITLE   = 'Comptes Magnitude'
        VALUE_ORG      = 'S'
      TABLES
        VALUE_TAB      = TAB_TEMP.
    CLEAR TAB_TEMP.
  ELSEIF P_MAGNI+0(2) EQ 'BP'.
    LOOP AT TAB_SKA1 INTO WA_SKA1.
      IF WA_SKA1-SAKNR+0(2) EQ 'BP'.
        APPEND WA_SKA1 TO TAB_TEMP.
      ENDIF.
    ENDLOOP.
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
      EXPORTING
        DDIC_STRUCTURE = 'SKA1'
        RETFIELD       = 'SAKNR'
        DYNPPROG       = SY-REPID
        DYNPNR         = SY-DYNNR
        DYNPROFIELD    = 'P_CORRES'
        STEPL          = 0
        WINDOW_TITLE   = 'Comptes Magnitude'
        VALUE_ORG      = 'S'
      TABLES
        VALUE_TAB      = TAB_TEMP.
    CLEAR TAB_TEMP.
  ENDIF.

Do you know how to do a dynamic filtering?

Thank you.