Application Development and Automation 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: 
Read only

"F4" functionality

roberto_falk
Product and Topic Expert
Product and Topic Expert
0 Likes
807

Hello all,

I have the 3 parameters....


PARAMETERS:
p_trfar TYPE t510-trfar,
p_trfgb TYPE t510-trfgb,
p_trfkz TYPE t510-trfkz.

When I press "F4" inside the p_trfkz field, I need to pass the p_trfar and p_trfgb parameters as a filter to the input help screen.

Thanks in advance.

Roberto Falk

1 ACCEPTED SOLUTION
Read only

rodrigo_paisante3
Active Contributor
0 Likes
767

Hi,

You need to use the syntax

AT SELECTION SCREEN ON VALUE_REQUEST FOR p_trfkz.

Regards.

5 REPLIES 5
Read only

Former Member
0 Likes
767

HI,

You need to pass the internal table to the function module F4IF_INT_TABLE_VALUE_REQUEST to get the F4 help, here you need get the data from the tables based on the p_trfar and p_trfgb parameters to that internal table which you are going to pass to that internal table

Regards

Sudheer

Read only

roberto_falk
Product and Topic Expert
Product and Topic Expert
0 Likes
767

Hello Sudheer

In fact, I'm using this FM, and I'm considering this parameters (p_trfar and p_trfgb) in my select before call the FM, but I need to show to the final user that I'm considering this fields as parameters...

There are some screens in the system that when you press F4 in a field, the oder fields are considered and you can change this fields (filters) inside the input help screen.

Thanks the help.

Roberto Falk

Read only

rodrigo_paisante3
Active Contributor
0 Likes
768

Hi,

You need to use the syntax

AT SELECTION SCREEN ON VALUE_REQUEST FOR p_trfkz.

Regards.

Read only

uwe_schieferstein
Active Contributor
0 Likes
767

Hello Roberto

If you look through the flight model sample reports you will find easier solutions than mine. However, the sample report <b>ZUS_SDN_F4IF_INT_TAB_VAL_REQ </b>shows one of the most flexible solution for filling several dependent parameters.

*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_F4IF_INT_TAB_VAL_REQ
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_f4if_int_tab_val_req.

TYPE-POOLS: shlp.


DATA:
  gd_repid     TYPE syrepid,
  gt_knb1      TYPE STANDARD TABLE OF knb1,
*
  gt_values    TYPE STANDARD TABLE OF ddshretval.

PARAMETERS:
  p_bukrs      TYPE bukrs,
  p_kunnr      TYPE kunnr,
  p_pernr      TYPE pernr_d.


INITIALIZATION.
  gd_repid = syst-repid.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_kunnr.
  PERFORM f4_kunnr.


START-OF-SELECTION.



  SELECT * FROM knb1 INTO TABLE gt_knb1 UP TO 100 ROWS.


  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      ddic_structure         = 'KNB1'
      retfield               = 'KUNNR'  " overwritten in callback !!!
*     PVALKEY                = ' '
*     DYNPPROG               = ' '
*     DYNPNR                 = ' '
*     DYNPROFIELD            = ' '
*     STEPL                  = 0
*     WINDOW_TITLE           =
*     VALUE                  = ' '
      value_org              = 'S'  " structure
*     MULTIPLE_CHOICE        = ' '
*     DISPLAY                = ' '
      callback_program       = gd_repid
      callback_form          = 'CALLBACK_F4'
*     MARK_TAB               =
*   IMPORTING
*     USER_RESET             =
    TABLES
      value_tab              = gt_knb1
*     FIELD_TAB              =
      return_tab             = gt_values
*     DYNPFLD_MAPPING        =
    EXCEPTIONS
      parameter_error        = 1
      no_values_found        = 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.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      i_structure_name = 'DDSHRETVAL'
    TABLES
      t_outtab         = gt_values
    EXCEPTIONS
      program_error    = 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.



END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Form  CALLBACK_F4
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM callback_f4
            TABLES record_tab STRUCTURE seahlpres
            CHANGING shlp TYPE shlp_descr
                     callcontrol LIKE ddshf4ctrl.
* define local data
  DATA:
    ls_intf     LIKE LINE OF shlp-interface,
    ls_prop     LIKE LINE OF shlp-fieldprop.



  " Hide unwanted fields
  CLEAR: ls_prop-shlpselpos,
         ls_prop-shlplispos.
  MODIFY shlp-fieldprop FROM ls_prop
    TRANSPORTING shlpselpos shlplispos
  WHERE ( fieldname NE 'BUKRS'  AND
          fieldname NE 'KUNNR'  AND
          fieldname NE 'PERNR' ).


  " Overwrite selectable fields on search help
  REFRESH: shlp-interface.
  ls_intf-shlpfield = 'BUKRS'.
  ls_intf-valfield  = 'X'.
  APPEND ls_intf TO shlp-interface.
  ls_intf-shlpfield = 'KUNNR'.
  APPEND ls_intf TO shlp-interface.


ENDFORM.                    " CALLBACK_F4




*&---------------------------------------------------------------------*
*&      Form  F4_KUNNR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f4_kunnr .
* define local data
  DATA:
    ls_shlp    TYPE shlp_descr.

  DATA:
    ls_value    LIKE LINE OF gt_values,
    ls_intf     LIKE LINE OF ls_shlp-interface,
    ls_prop     LIKE LINE OF ls_shlp-fieldprop.

  DATA:
    lt_dynpflds   TYPE STANDARD TABLE OF dynpread,
    ls_dynpfld    TYPE dynpread.


  CALL FUNCTION 'F4IF_GET_SHLP_DESCR'
    EXPORTING
      shlpname       = 'DEBIP'  " customer by personnel number
*       SHLPTYPE       = 'SH'
    IMPORTING
      shlp           = ls_shlp.

  " Hide unwanted fields
  CLEAR: ls_prop-shlpselpos,
         ls_prop-shlplispos.
  MODIFY ls_shlp-fieldprop FROM ls_prop
    TRANSPORTING shlpselpos shlplispos
  WHERE ( fieldname NE 'BUKRS'  AND
          fieldname NE 'KUNNR'  AND
          fieldname NE 'PERNR' ).


  " Overwrite selectable fields on search help
  REFRESH: ls_shlp-interface.
  CLEAR: ls_intf.
  ls_intf-shlpfield = 'BUKRS'.
  ls_intf-valfield  = 'X'.
  APPEND ls_intf TO ls_shlp-interface.
  CLEAR: ls_intf.
  ls_intf-shlpfield = 'KUNNR'.
  ls_intf-valfield  = 'X'.
  APPEND ls_intf TO ls_shlp-interface.
  CLEAR: ls_intf.
  ls_intf-shlpfield = 'PERNR'.
  ls_intf-valfield  = 'X'.
  APPEND ls_intf TO ls_shlp-interface.

  REFRESH: gt_values.
  CALL FUNCTION 'F4IF_START_VALUE_REQUEST'
    EXPORTING
      shlp                = ls_shlp
*     DISPONLY            = ' '
*     MAXRECORDS          = 500
*     MULTISEL            = ' '
*     CUCOL               = SY-CUCOL
*     CUROW               = SY-CUROW
*   IMPORTING
*     RC                  =
    TABLES
      return_values       = gt_values.

  CHECK ( gt_values IS NOT INITIAL ).
  REFRESH: lt_dynpflds.
  LOOP AT gt_values INTO ls_value.
    CONCATENATE 'P_' ls_value-fieldname INTO ls_dynpfld-fieldname.
    ls_dynpfld-fieldvalue = ls_value-fieldval.

    APPEND ls_dynpfld TO lt_dynpflds.
  ENDLOOP.

  CALL FUNCTION 'DYNP_VALUES_UPDATE'
    EXPORTING
      dyname = gd_repid
      dynumb = '1000'
  TABLES
    dynpfields                 = lt_dynpflds
  EXCEPTIONS
*     INVALID_ABAPWORKAREA       = 1
*     INVALID_DYNPROFIELD        = 2
*     INVALID_DYNPRONAME         = 3
*     INVALID_DYNPRONUMMER       = 4
*     INVALID_REQUEST            = 5
*     NO_FIELDDESCRIPTION        = 6
*     UNDEFIND_ERROR             = 7
    OTHERS                     = 8.
  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.                                                    " F4_KUNNR

Regards

Uwe

Read only

uwe_schieferstein
Active Contributor
0 Likes
767

Hello Roberto

Forget to show how to restrict the displayed values on the search help. Here comes the coding...


*&---------------------------------------------------------------------*
*& Report  ZUS_SDN_F4IF_INT_TAB_VAL_REQ
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zus_sdn_f4if_int_tab_val_req.

TYPE-POOLS: shlp.


DATA:
  gd_repid     TYPE syrepid,
  gt_knb1      TYPE STANDARD TABLE OF knb1,
*
  gt_values    TYPE STANDARD TABLE OF ddshretval.

PARAMETERS:
  p_bukrs      TYPE bukrs,
  p_kunnr      TYPE kunnr,
  p_pernr      TYPE pernr_d.


INITIALIZATION.
  gd_repid = syst-repid.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_kunnr.
  PERFORM f4_kunnr.


START-OF-SELECTION.



  SELECT * FROM knb1 INTO TABLE gt_knb1 UP TO 100 ROWS.


  CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
      ddic_structure         = 'KNB1'
      retfield               = 'KUNNR'  " overwritten in callback !!!
*     PVALKEY                = ' '
*     DYNPPROG               = ' '
*     DYNPNR                 = ' '
*     DYNPROFIELD            = ' '
*     STEPL                  = 0
*     WINDOW_TITLE           =
*     VALUE                  = ' '
      value_org              = 'S'  " structure
*     MULTIPLE_CHOICE        = ' '
*     DISPLAY                = ' '
      callback_program       = gd_repid
      callback_form          = 'CALLBACK_F4'
*     MARK_TAB               =
*   IMPORTING
*     USER_RESET             =
    TABLES
      value_tab              = gt_knb1
*     FIELD_TAB              =
      return_tab             = gt_values
*     DYNPFLD_MAPPING        =
    EXCEPTIONS
      parameter_error        = 1
      no_values_found        = 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.


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
      i_structure_name = 'DDSHRETVAL'
    TABLES
      t_outtab         = gt_values
    EXCEPTIONS
      program_error    = 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.



END-OF-SELECTION.
*&---------------------------------------------------------------------*
*&      Form  CALLBACK_F4
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM callback_f4
            TABLES record_tab STRUCTURE seahlpres
            CHANGING shlp TYPE shlp_descr
                     callcontrol LIKE ddshf4ctrl.
* define local data
  DATA:
    ls_intf     LIKE LINE OF shlp-interface,
    ls_prop     LIKE LINE OF shlp-fieldprop.



  " Hide unwanted fields
  CLEAR: ls_prop-shlpselpos,
         ls_prop-shlplispos.
  MODIFY shlp-fieldprop FROM ls_prop
    TRANSPORTING shlpselpos shlplispos
  WHERE ( fieldname NE 'BUKRS'  AND
          fieldname NE 'KUNNR'  AND
          fieldname NE 'PERNR' ).


  " Overwrite selectable fields on search help
  REFRESH: shlp-interface.
  ls_intf-shlpfield = 'BUKRS'.
  ls_intf-valfield  = 'X'.
  APPEND ls_intf TO shlp-interface.
  ls_intf-shlpfield = 'KUNNR'.
  APPEND ls_intf TO shlp-interface.


ENDFORM.                    " CALLBACK_F4




*&---------------------------------------------------------------------*
*&      Form  F4_KUNNR
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f4_kunnr .
* define local data
  DATA:
    ls_shlp    TYPE shlp_descr.

  DATA:
    ls_value    LIKE LINE OF gt_values,
    ls_intf     LIKE LINE OF ls_shlp-interface,
    ls_prop     LIKE LINE OF ls_shlp-fieldprop,
    ls_selopt   LIKE LINE OF ls_shlp-selopt.

  DATA:
    lt_dynpflds   TYPE STANDARD TABLE OF dynpread,
    ls_dynpfld    TYPE dynpread.


  CALL FUNCTION 'F4IF_GET_SHLP_DESCR'
    EXPORTING
      shlpname       = 'DEBIP'  " customer by personnel number
*       SHLPTYPE       = 'SH'
    IMPORTING
      shlp           = ls_shlp.


  CLEAR: ls_dynpfld.
  ls_dynpfld-fieldname = 'P_BUKRS'.
  APPEND ls_dynpfld TO lt_dynpflds.

  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname                         = gd_repid
      dynumb                         = '1000'
*     TRANSLATE_TO_UPPER             = ' '
*     REQUEST                        = ' '
*     PERFORM_CONVERSION_EXITS       = ' '
*     PERFORM_INPUT_CONVERSION       = ' '
*     DETERMINE_LOOP_INDEX           = ' '
    TABLES
      dynpfields                     = lt_dynpflds
    EXCEPTIONS
*     INVALID_ABAPWORKAREA           = 1
*     INVALID_DYNPROFIELD            = 2
*     INVALID_DYNPRONAME             = 3
*     INVALID_DYNPRONUMMER           = 4
*     INVALID_REQUEST                = 5
*     NO_FIELDDESCRIPTION            = 6
*     INVALID_PARAMETER              = 7
*     UNDEFIND_ERROR                 = 8
*     DOUBLE_CONVERSION              = 9
*     STEPL_NOT_FOUND                = 10
      OTHERS                         = 11.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.


  READ TABLE lt_dynpflds INTO ls_dynpfld
       WITH KEY fieldname = 'P_BUKRS'.
  IF ( syst-subrc = 0 ).
    ls_selopt-shlpfield = 'BUKRS'.
    ls_selopt-sign      = 'I'.
    ls_selopt-option    = 'EQ'.
    ls_selopt-low       = ls_dynpfld-fieldvalue.

    APPEND ls_selopt TO ls_shlp-selopt.  " restrict for company code
  ENDIF.

  " Hide unwanted fields
  CLEAR: ls_prop-shlpselpos,
         ls_prop-shlplispos.
  MODIFY ls_shlp-fieldprop FROM ls_prop
    TRANSPORTING shlpselpos shlplispos
  WHERE ( fieldname NE 'BUKRS'  AND
          fieldname NE 'KUNNR'  AND
          fieldname NE 'PERNR' ).


  " Overwrite selectable fields on search help
  REFRESH: ls_shlp-interface.
  CLEAR: ls_intf.
  ls_intf-shlpfield = 'BUKRS'.
  ls_intf-valfield  = 'X'.
  APPEND ls_intf TO ls_shlp-interface.
  CLEAR: ls_intf.
  ls_intf-shlpfield = 'KUNNR'.
  ls_intf-valfield  = 'X'.
  APPEND ls_intf TO ls_shlp-interface.
  CLEAR: ls_intf.
  ls_intf-shlpfield = 'PERNR'.
  ls_intf-valfield  = 'X'.
  APPEND ls_intf TO ls_shlp-interface.

  REFRESH: gt_values.
  CALL FUNCTION 'F4IF_START_VALUE_REQUEST'
    EXPORTING
      shlp                = ls_shlp
*     DISPONLY            = ' '
*     MAXRECORDS          = 500
*     MULTISEL            = ' '
*     CUCOL               = SY-CUCOL
*     CUROW               = SY-CUROW
*   IMPORTING
*     RC                  =
    TABLES
      return_values       = gt_values.

  CHECK ( gt_values IS NOT INITIAL ).
  REFRESH: lt_dynpflds.
  LOOP AT gt_values INTO ls_value.
    CONCATENATE 'P_' ls_value-fieldname INTO ls_dynpfld-fieldname.
    ls_dynpfld-fieldvalue = ls_value-fieldval.

    APPEND ls_dynpfld TO lt_dynpflds.
  ENDLOOP.

  CALL FUNCTION 'DYNP_VALUES_UPDATE'
    EXPORTING
      dyname = gd_repid
      dynumb = '1000'
  TABLES
    dynpfields                 = lt_dynpflds
  EXCEPTIONS
*     INVALID_ABAPWORKAREA       = 1
*     INVALID_DYNPROFIELD        = 2
*     INVALID_DYNPRONAME         = 3
*     INVALID_DYNPRONUMMER       = 4
*     INVALID_REQUEST            = 5
*     NO_FIELDDESCRIPTION        = 6
*     UNDEFIND_ERROR             = 7
    OTHERS                     = 8.
  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.                                                    " F4_KUNNR

Regards

Uwe