Filtering F4 Help Values in Table Control, Based On Other Field Value

原创 2015年11月19日 18:30:17

This BoK provides info on how to create an F4 help by filtering the values based on the value entered in another field (By capturing the values entered in the field without hitting the enter key) in a table control.
 
The regular procedure of fetching theF4 help values does help here But only when <enter> key is pressed after entering the value in the first field. To avoid hitting the <enter> key we need to capture the value entered in the first field dynamically.

Let's consider a scenario where I have two fields in my table control & the F4 help values for the second field depends on the value entered in the first field.

 1. Airline code (SFLIGHT-CARRID)

 2. Flight connection number (SFLIGHT-CONNID)

Let’s select an Airline code

Now the F4 help should be filtered for second field ‘Flight connection number’ based on the ‘Airline code’ selected (without hitting the enter key)

Before selecting the airline code:

 

After filtering,based on the value selected in first field

The procedure toaccomplish the same is detailed below

1.    In the PAI of the table control dynpro, Use the event 'Process onvalue-request'. Under this event use the syntax shown below.

           PROCESS ON VALUE-REQUEST.
                       FIELD <table control field name> MODULE <module name>

           Example:

           PROCESS ON VALUE-REQUEST.
               FIELDwa_add-connid MODULE f4help.

                Where wa_add-connid is my tablecontrol field name.

Note: All thecode shown below is to be written in module ‘f4help’ as mentioned in theprevious step

2.    We need to determine the cursor position to know at which row the F4 help ispressed. To know the row index, use the Function module 'DYNP_GET_STEPL'. ThisFM returns the current line index (Row Index where the F4 help is pressed). Usethe following code in the POV module

       CALL FUNCTION 'DYNP_GET_STEPL'
          IMPORTING
             povstepl =v_index.   (v_index  is a  variable  to hold  the  index  value)

3.    To hold the current screen values i.e. the value entered in the first fieldCARRID, declare an internal table and a work area of type 'dynpread' structure.The ‘stepl’ field of the structure is used to store the row index where the f4help is needed and the field ‘fieldname’ is used to store the field name whosevalues are to be read dynamically.

4.    Pass the current line index to the work area field 'stepl' and the field name bywhich the f4 help needs to be filtered to 'fieldname' to the internal table(Code in f4help module).

    Wa_dynpread-stepl = v_index.

    Wa_dynpread-fieldname = 'WA_ADD-CARRID'.

    Append wa_dynpread TO it_dynpread.

5.    Use FM 'DYNP_VALUES_READ' by passing the report name: 'sy-repid' to dyname ,screen number : 'sy-dynnr' to dynumb and the dynpread internal table to'Tables' to read field contents on screen and transport field to help processor.

       CALL FUNCTION 'DYNP_VALUES_READ'
                  EXPORTING
                     dyname              = sy-repid
                     dynumb              = sy-dynnr
                     translate_to_upper   = 'X'
                 TABLES
                     dynpfields           = 
it_dynpread .

6.    The FM 'DYNP_VALUES_READ' fetches the value entered in the field 'Legreg'.  Select the flight connection number based onthe value in ‘FIELDVALUE’ in IT_DYNPREAD.

 READ TABLE it_dynpread INTO wa_dynpread WITH KEY stepl = v_dynindex.

   IF sy-subrc IS INITIAL.


     SELECTDISTINCT connid FROM sflight 

        INTO TABLE it_connid 

  WHERE carrid = wa_dynpread-fieldvalue

   ENDIF.

7.     Pass the internal table IT_CONNID to theFM 'F4IF_INT_TABLE_VALUE_REQUEST'.

        CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          EXPORTING
             retfield    = 'CONNID'
             dynpprog    = sy-repid
              dynpnr       = sy-dynnr
              dynprofield ='WA_ADD-CONNID'
             value_org   = 'S'
         TABLES
             value_tab   = it_connid.

Now the f4 helpvalues for the field 'connid' will be filtered based on the value entered in'carrid'.

 

 

 

相关文章推荐

F4 help functionality for a dynpro screen field using the PROCESS ON VALUE-REQUEST statement

Pressing the F4 button on a dynpro screen field brings up a list of possible values you can enter in...

Refreshing One Column based on the value of Another Column in ADFdi Table

Refreshing One Column based on the value of Another Column in ADFdi Table  原文地址:RefreshingOne Colum...

【跟着stackoverflow学Pandas】Select rows from a DataFrame based on values in a column -pandas 筛选

Select rows from a DataFrame based on values in a column -pandas 筛选 https://stackoverflow.com/quest...

F4IF_FIELD_VALUE_REQUEST 和 F4IF_INT_TABLE_VALUE_REQUEST的不同

原文地址http://blog.csdn.net/liangziyisheng/article/details/6951941   F4IF_FIELD_VALUE_REQUEST主要功能是将表里...

Take Control Of Web Control ClientID Values in ASP.NET 4

http://www.4guysfromrolla.com/articles/031710-1.aspx Web controls in ASP.NET also have ID value...

Movie recommendation based on collaborative filtering method

Movie recommendation based on collaborative filtering method
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Filtering F4 Help Values in Table Control, Based On Other Field Value
举报原因:
原因补充:

(最多只允许输入30个字)