<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic f4 help in the GRID on the basis of other field in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976109#M949684</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had an small query regarding F4 help &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have created a class definition &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    METHODS : get_f4 FOR EVENT onf4 OF cl_gui_alv_grid&lt;/P&gt;&lt;P&gt;              IMPORTING e_fieldname&lt;/P&gt;&lt;P&gt;                 e_fieldvalue&lt;/P&gt;&lt;P&gt;                 es_row_no&lt;/P&gt;&lt;P&gt;                 er_event_data&lt;/P&gt;&lt;P&gt;                 et_bad_cells&lt;/P&gt;&lt;P&gt;                 e_display.&lt;/P&gt;&lt;P&gt;in class implementation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; METHOD : get_f4 .&lt;/P&gt;&lt;P&gt;    REFRESH gt_fam.&lt;/P&gt;&lt;P&gt;    DATA:gt_return TYPE TABLE OF ddshretval,&lt;/P&gt;&lt;P&gt;         gs_return LIKE LINE OF gt_return.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    FIELD-SYMBOLS: &amp;lt;itab&amp;gt; TYPE lvc_t_modi.&lt;/P&gt;&lt;P&gt;    DATA: ls_modi TYPE lvc_s_modi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   READ TABLE gt_f4 INTO gs_f4 WITH KEY fieldname = 'CONNID'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    READ TABLE gt_params INTO gs_params INDEX es_row_no-row_id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT prodh FROM t179 INTO TABLE gt_prodh&lt;/P&gt;&lt;P&gt;           WHERE stufe = '4'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    LOOP AT gt_prodh INTO gs_prodh WHERE prodh+4(3) = gs_params-categ.&lt;/P&gt;&lt;P&gt;      gs_fam-fam =  gs_prodh-prodh+7(3) .&lt;/P&gt;&lt;P&gt;      APPEND gs_fam TO gt_fam.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'&lt;/P&gt;&lt;P&gt;      EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      ddic_structure         = 'ZPFT_PARAMS'&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        retfield               = 'FAMILY'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     PVALKEY                = ' '&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;       dynpprog               = sy-cprog&lt;/P&gt;&lt;P&gt;       dynpnr                 = sy-dynnr&lt;/P&gt;&lt;P&gt;       dynprofield            = 'GS_PARAMS-FAMILY'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     STEPL                  = 0&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     WINDOW_TITLE           =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     VALUE                  = ' '&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      value_org              = 'S'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     MULTIPLE_CHOICE        = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     DISPLAY                = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     CALLBACK_PROGRAM       = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     CALLBACK_FORM          = ' '&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      TABLES&lt;/P&gt;&lt;P&gt;        value_tab              = gt_fam&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     FIELD_TAB              =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      return_tab             = gt_return&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     DYNPFLD_MAPPING        =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   EXCEPTIONS&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     PARAMETER_ERROR        = 1&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     NO_VALUES_FOUND        = 2&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     OTHERS                 = 3&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;              .&lt;/P&gt;&lt;P&gt;    IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    ASSIGN er_event_data-&amp;gt;m_data-&amp;gt;* TO &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    READ TABLE gt_return INTO gs_return INDEX 1.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   gs_params-family = gs_return-fieldval.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    IF NOT gs_return IS INITIAL.&lt;/P&gt;&lt;P&gt;      ls_modi-row_id    = gs_return-recordpos.&lt;/P&gt;&lt;P&gt;      ls_modi-fieldname = 'FAMILY'.&lt;/P&gt;&lt;P&gt;      ls_modi-value     = gs_return-fieldval.&lt;/P&gt;&lt;P&gt;      APPEND ls_modi TO &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    er_event_data-&amp;gt;m_event_handled = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDMETHOD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but where as i am getting F4 help, from there i am not capturing the value into the GRID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is urgent .anybody help in technical is appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 19 Jun 2008 13:16:45 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-06-19T13:16:45Z</dc:date>
    <item>
      <title>f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976109#M949684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had an small query regarding F4 help &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have created a class definition &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    METHODS : get_f4 FOR EVENT onf4 OF cl_gui_alv_grid&lt;/P&gt;&lt;P&gt;              IMPORTING e_fieldname&lt;/P&gt;&lt;P&gt;                 e_fieldvalue&lt;/P&gt;&lt;P&gt;                 es_row_no&lt;/P&gt;&lt;P&gt;                 er_event_data&lt;/P&gt;&lt;P&gt;                 et_bad_cells&lt;/P&gt;&lt;P&gt;                 e_display.&lt;/P&gt;&lt;P&gt;in class implementation&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; METHOD : get_f4 .&lt;/P&gt;&lt;P&gt;    REFRESH gt_fam.&lt;/P&gt;&lt;P&gt;    DATA:gt_return TYPE TABLE OF ddshretval,&lt;/P&gt;&lt;P&gt;         gs_return LIKE LINE OF gt_return.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    FIELD-SYMBOLS: &amp;lt;itab&amp;gt; TYPE lvc_t_modi.&lt;/P&gt;&lt;P&gt;    DATA: ls_modi TYPE lvc_s_modi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   READ TABLE gt_f4 INTO gs_f4 WITH KEY fieldname = 'CONNID'.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    READ TABLE gt_params INTO gs_params INDEX es_row_no-row_id.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    SELECT prodh FROM t179 INTO TABLE gt_prodh&lt;/P&gt;&lt;P&gt;           WHERE stufe = '4'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    LOOP AT gt_prodh INTO gs_prodh WHERE prodh+4(3) = gs_params-categ.&lt;/P&gt;&lt;P&gt;      gs_fam-fam =  gs_prodh-prodh+7(3) .&lt;/P&gt;&lt;P&gt;      APPEND gs_fam TO gt_fam.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'&lt;/P&gt;&lt;P&gt;      EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;      ddic_structure         = 'ZPFT_PARAMS'&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;        retfield               = 'FAMILY'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     PVALKEY                = ' '&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;       dynpprog               = sy-cprog&lt;/P&gt;&lt;P&gt;       dynpnr                 = sy-dynnr&lt;/P&gt;&lt;P&gt;       dynprofield            = 'GS_PARAMS-FAMILY'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     STEPL                  = 0&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     WINDOW_TITLE           =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     VALUE                  = ' '&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      value_org              = 'S'&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     MULTIPLE_CHOICE        = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     DISPLAY                = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     CALLBACK_PROGRAM       = ' '&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     CALLBACK_FORM          = ' '&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      TABLES&lt;/P&gt;&lt;P&gt;        value_tab              = gt_fam&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     FIELD_TAB              =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      return_tab             = gt_return&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     DYNPFLD_MAPPING        =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   EXCEPTIONS&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     PARAMETER_ERROR        = 1&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     NO_VALUES_FOUND        = 2&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;     OTHERS                 = 3&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;              .&lt;/P&gt;&lt;P&gt;    IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    ASSIGN er_event_data-&amp;gt;m_data-&amp;gt;* TO &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    READ TABLE gt_return INTO gs_return INDEX 1.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;   gs_params-family = gs_return-fieldval.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;    IF NOT gs_return IS INITIAL.&lt;/P&gt;&lt;P&gt;      ls_modi-row_id    = gs_return-recordpos.&lt;/P&gt;&lt;P&gt;      ls_modi-fieldname = 'FAMILY'.&lt;/P&gt;&lt;P&gt;      ls_modi-value     = gs_return-fieldval.&lt;/P&gt;&lt;P&gt;      APPEND ls_modi TO &amp;lt;itab&amp;gt;.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    er_event_data-&amp;gt;m_event_handled = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  ENDMETHOD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but where as i am getting F4 help, from there i am not capturing the value into the GRID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is urgent .anybody help in technical is appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2008 13:16:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976109#M949684</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-19T13:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976110#M949685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Modify the output internal table of ALV with the data chosen in F4 help and use REFRESH_GRID_DISPLAY to display the new values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Lakshmi.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2008 13:20:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976110#M949685</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-19T13:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976111#M949686</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Varisetty&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a look at sample report &lt;STRONG&gt;BCALV_EDIT_08&lt;/STRONG&gt; which should be quite useful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
program bcalv_edit_08.
*&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;
* Purpose:
* ~~~~~~~~
* This report implements an ALV Grid Control with an application
* specific F4 help. The following aspects are dealth with:
*  o how to replace the standard f4 help
*     NOTE: This example uses a second ALV Grid Control to
*           provide an application specific F4 help.
*           This is probalbly NOT the usual way to
*           provide such a functionality.
*           However, the purpose of this report is not to
*           show you how to implement an F4 help, but to
*           explain how you pass the selected value to ALV,
*           how you take values of other cells into account, etc.
*           For this purpose, it does not matter how the f4 help
*           is actually implemented.
*
*  o how to pass the selected value to the ALV Grid Control
*  o how to build an f4 help, whose value range depend on
*    a value of another cell.
*-----------------------------------------------------------------
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* We use table SBOOK with columns CLASS and SMOKER ready for input.
* The idea of this scenario is that it is only allowed to smoke
* in the first class (value 'F' of field CLASS).
* The application specific f4 help can be called for column CLASS:
* o if the value of column SMOKER in the same row is 'X', only class
*   'F' can be chosen
* o if the value of column SMOKER in the same row is ' ', all
*   classes are allowed ('F','C','Y'). Thus, the f4 help shows all
*   values.
* o if the value of column SMOKER in the same row is not valid
*   (syntactically or semantically), a message is shown and
*   no f4 help pops up.
*-----------------------------------------------------------------
* Essential steps (search for '§')
* ~~~~~~~~~~~~~~~
* Note that this report is rather long because the columns CLASS and
* SMOKER are checked semantically which does not belong to the f4 help
* implementation. Class lcl_application_dc handles semantic checks.
* Local class lcl_application_f4 handles event ONF4 to build up
* the f4 help, to pass the value to the ALV Grid Control and
* to check whether the value of the SMOKER column is valid.
*
* 1. Register event ONF4 at frontend using method
*    register_f4_for_fields. For this purpose, you pass a table
*    with all fields, for which you want to implement your own
*    f4 help.
*   1b. If the value range in your f4 help depends on other
*       values of cells that are input enabled, set the
*       GETBEFORE parameter.
* 2. Implement an event handler method for event ONF4.
* 3. Call your own f4 help. To customize your popup check
*    first if the cell is ready for input (event parameter E_DISPLAY).
* 4. Check whether the value your f4 help depends on is valid.
* 5. If not already caught by your own f4 help, check whether
*    the triggered cell was ready for input by using E_DISPLAY
*    and if not, exit.
* 6. After the user selected a value, pass it to the ALV Grid Control:
*   6a. Define a field symbol of type: LVC_T_MODI and a structure of
*       type LVC_S_MODI to pass the value later on.
*   6b. Dereference attribute M_DATA to your field symbol and add
*       the selected value to the table to which this symbol points to.
* 7. Inform the ALV Grid Control that an own f4 help has been processed
*    to suppress the standard f4 help.
*-----------------------------------------------------------------------
*&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;
...
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Jun 2008 18:39:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976111#M949686</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-06-19T18:39:50Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976112#M949687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;refer to these examples&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BCALV_TEST_GRID_F4_HELP,BCALV_F4,BCALV_GRID_F4_HELP_APPLICATION&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jun 2008 06:32:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976112#M949687</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-20T06:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976113#M949688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for prompt response and right solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But ,I am working on SAP 4.6c version, where i am not able find Standard Report&lt;/P&gt;&lt;P&gt;BCALV_EDIT_08.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please will you let me know in which version it is existing, where as this scenario exactly i need in my issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Madhavi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jun 2008 08:39:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976113#M949688</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-20T08:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976114#M949689</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Varisetty&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The entire report BCALV_EDIT_08 is shown below. I have no doubt that it will work on 4.6c as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
program bcalv_edit_08.
*&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;
* Purpose:
* ~~~~~~~~
* This report implements an ALV Grid Control with an application
* specific F4 help. The following aspects are dealth with:
*  o how to replace the standard f4 help
*     NOTE: This example uses a second ALV Grid Control to
*           provide an application specific F4 help.
*           This is probalbly NOT the usual way to
*           provide such a functionality.
*           However, the purpose of this report is not to
*           show you how to implement an F4 help, but to
*           explain how you pass the selected value to ALV,
*           how you take values of other cells into account, etc.
*           For this purpose, it does not matter how the f4 help
*           is actually implemented.
*
*  o how to pass the selected value to the ALV Grid Control
*  o how to build an f4 help, whose value range depend on
*    a value of another cell.
*-----------------------------------------------------------------
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* We use table SBOOK with columns CLASS and SMOKER ready for input.
* The idea of this scenario is that it is only allowed to smoke
* in the first class (value 'F' of field CLASS).
* The application specific f4 help can be called for column CLASS:
* o if the value of column SMOKER in the same row is 'X', only class
*   'F' can be chosen
* o if the value of column SMOKER in the same row is ' ', all
*   classes are allowed ('F','C','Y'). Thus, the f4 help shows all
*   values.
* o if the value of column SMOKER in the same row is not valid
*   (syntactically or semantically), a message is shown and
*   no f4 help pops up.
*-----------------------------------------------------------------
* Essential steps (search for '§')
* ~~~~~~~~~~~~~~~
* Note that this report is rather long because the columns CLASS and
* SMOKER are checked semantically which does not belong to the f4 help
* implementation. Class lcl_application_dc handles semantic checks.
* Local class lcl_application_f4 handles event ONF4 to build up
* the f4 help, to pass the value to the ALV Grid Control and
* to check whether the value of the SMOKER column is valid.
*
* 1. Register event ONF4 at frontend using method
*    register_f4_for_fields. For this purpose, you pass a table
*    with all fields, for which you want to implement your own
*    f4 help.
*   1b. If the value range in your f4 help depends on other
*       values of cells that are input enabled, set the
*       GETBEFORE parameter.
* 2. Implement an event handler method for event ONF4.
* 3. Call your own f4 help. To customize your popup check
*    first if the cell is ready for input (event parameter E_DISPLAY).
* 4. Check whether the value your f4 help depends on is valid.
* 5. If not already caught by your own f4 help, check whether
*    the triggered cell was ready for input by using E_DISPLAY
*    and if not, exit.
* 6. After the user selected a value, pass it to the ALV Grid Control:
*   6a. Define a field symbol of type: LVC_T_MODI and a structure of
*       type LVC_S_MODI to pass the value later on.
*   6b. Dereference attribute M_DATA to your field symbol and add
*       the selected value to the table to which this symbol points to.
* 7. Inform the ALV Grid Control that an own f4 help has been processed
*    to suppress the standard f4 help.
*-----------------------------------------------------------------------
*&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;

data: ok_code like sy-ucomm,
      save_ok like sy-ucomm,
      g_container type scrfname value 'CC1',
      g_grid  type ref to cl_gui_alv_grid,
      g_custom_container type ref to cl_gui_custom_container,
      gt_fieldcat type lvc_t_fcat,
       g_max type i value 100.

class lcl_application_f4 definition deferred.
class lcl_application_dc definition deferred.


data: g_onf4 type ref to lcl_application_f4,
      g_dc type ref to lcl_application_dc.


data: gt_outtab type table of sbook.

****************************************************************
* LOCAL CLASSES: Definition
****************************************************************
*===============================================================
* class lcl_application_f4: local class to handle own F4.
*
* Definition:
* ~~~~~~~~~~~
class lcl_application_f4 definition.

  public section.
    methods:

             on_f4 for event onf4 of cl_gui_alv_grid
               importing e_fieldname
                         es_row_no
                         er_event_data
                         et_bad_cells
                         e_display.

    methods: reset.
    methods: show_f4.

  private section.
**
* attributes for creating an own F4-Help
* (using a second ALV Grid Control
**
    data: f4_alv type ref to cl_gui_alv_grid,
          f4_cont type ref to cl_gui_custom_container.

    types: begin of f4_itab_type.
    types: value type s_class.
    types: descr(20) type c.
    types: end of f4_itab_type.

    data: f4_itab type table of f4_itab_type.
    data: fieldcatalog type lvc_t_fcat.

**
* attributes to store event parameters
* (after the CALL SCREEN command, the event parameters
* are not accessible)
**
    types: begin of onf4_event_parameters_type.
    types: c_fieldname     type lvc_fname.
    types: cs_row_no       type lvc_s_roid.
    types: cr_event_data   type ref to cl_alv_event_data.
    types: ct_bad_cells    type lvc_t_modi.
    types: c_display       type char01.
    types: end of onf4_event_parameters_type.

    data: f4_params type onf4_event_parameters_type.


**
* Methods to create own F4-Help
* (This is done using a second ALV Grid Control)
**
    methods: init_f4.

    methods: build_fieldcatalog.
    methods: fill_f4_itab importing smoker type c.

    methods: on_double_click for event double_click of cl_gui_alv_grid
                    importing es_row_no.

**
* Methods to check whether the values which the F4-Help needs
* are correct
* (The entries of the F4-Help of field CLASS depend on the value
* of field SMOKER. If field SMOKER of the same row is syntaktically
* or semantically not correct, this has to be handled during ONF4.
**
    methods: smoker_cell_is_bad
                returning value(r_flag) type i.

endclass.                    "lcl_application_f4 DEFINITION
*
* lcl_application_f4 (Definition)
*===============================================================
* class lcl_application_dc: local class to handle event data_changed.
*
* Definition:
* ~~~~~~~~~~~
class lcl_application_dc definition.

  public section.

    methods: handle_data_changed
               for event data_changed of cl_gui_alv_grid
                  importing er_data_changed
                            e_onf4 e_onf4_before e_onf4_after.

  private section.

* This flag is set if any error occured in one of the
* following methods:
    data: error_in_data type c.

    methods:
     perform_semantic_checks
       importing
         pr_data_changed type ref to cl_alv_changed_data_protocol.

    methods: check_smoker
     importing
        ps_good_smoker type lvc_s_modi
        pr_data_changed type ref to cl_alv_changed_data_protocol.

    methods: check_class
     importing
        ps_good_class type lvc_s_modi
        pr_data_changed type ref to cl_alv_changed_data_protocol.

endclass.                    "lcl_application_dc DEFINITION
*
* lcl_application_dc (Definition)
*===============================================================


****************************************************************
* LOCAL CLASSES: Implementation
****************************************************************
*===============================================================
* class lcl_application_f4 (Implementation)
*
class lcl_application_f4 implementation.

*§2. Implement an event handler method for event ONF4.

  method on_f4.

* Save event parameter as global attributes of this class
* (maybe solved differently if you use a function module!)
    f4_params-c_fieldname = e_fieldname.
    f4_params-cs_row_no = es_row_no.
    f4_params-cr_event_data = er_event_data.
    f4_params-ct_bad_cells = et_bad_cells.
    f4_params-c_display = e_display.

*§3. Call your own f4 help. To customize your popup check
*    first if the cell is ready for input (event parameter E_DISPLAY).
* (parameter E_DISPLAY is checked later in method on_double_click)

* (Probably, you would call a function module at this point,
* pass the needed event parameter and call the popup screen
* within that function module. This is not done in this example
* to avoid scattering its code).

    call screen 101 starting at 10 10.

*§7. Inform the ALV Grid Control that an own f4 help has been processed
*    to suppress the standard f4 help.

    er_event_data-&amp;gt;m_event_handled = 'X'.
  endmethod.                                                "on_f4
*---------------------------------------------------------------------
  method show_f4.
    data: ls_outtab type sbook.

* initialize own f4 help if needed
    if f4_cont is initial.
      call method init_f4.
    endif.

*§4. Check whether the value your f4 help depends on is valid.

* The possible values of field CLASS depend on
* the value of field SMOKER of the same row.
* You have to check that this value is valid:
    if smoker_cell_is_bad( ) eq 1.
      leave screen.
    endif.

* determine value of column SMOKER and use appropriate f4 table
    read table gt_outtab into ls_outtab index f4_params-cs_row_no-row_id
.
    call method fill_f4_itab( ls_outtab-smoker ).

* refresh list of values in f4 help and show it
    call method f4_alv-&amp;gt;refresh_table_display.
* CAUTION: Do not use method REFRESH_TABLE_DISPLAY for
* your editable ALV Grid instances while handling events
* DATA_CHANGED or ONf4. You would overwrite intermediate
* values of your output table on frontend.
* 'f4_alv' is a non-editable ALV Grid Control for the
* application specific F4-Help. Therefore, calling
* REFRESH_TABLE_DISPLAY for this instance has no
* negative effect.

    call method cl_gui_cfw=&amp;gt;flush.
  endmethod.                                                "show_f4

*--------------------------------------------------------------------

  method init_f4.
    data: ls_layout type lvc_s_layo.
* build fieldcatalog entries for f4
    call method build_fieldcatalog.

* create controls
    create object f4_cont
              exporting container_name = 'CC_ONF4'.

    create object f4_alv
              exporting i_parent = f4_cont.

* hide toolbar
    ls_layout-no_toolbar = 'X'.

    call method f4_alv-&amp;gt;set_table_for_first_display
      exporting
        is_layout       = ls_layout
      changing
        it_fieldcatalog = fieldcatalog
        it_outtab       = f4_itab.

* register event double click on backend
    set handler me-&amp;gt;on_double_click for f4_alv.

* flush since 'ls_layout' is local!
    call method cl_gui_cfw=&amp;gt;flush.

  endmethod.                                                "init_f4
*-----------------------------------------------------
  method fill_f4_itab.
    data ls_f4_itab type f4_itab_type.

* Delete all entries in f4_itab to determine
* offered values dynamically
    clear f4_itab[].
* create entries depending on SMOKER field
    if smoker is initial.
      ls_f4_itab-value = 'C'.
      ls_f4_itab-descr = text-t03. "Business Class
      append ls_f4_itab to f4_itab.
      ls_f4_itab-value = 'Y'.
      ls_f4_itab-descr = text-t04. "Economie Class
      append ls_f4_itab to f4_itab.
      ls_f4_itab-value = 'F'.
      ls_f4_itab-descr = text-t05. "First Class
      append ls_f4_itab to f4_itab.
    else.
      ls_f4_itab-value = 'F'.
      ls_f4_itab-descr = text-t05. "First Class
      append ls_f4_itab to f4_itab.
    endif.
  endmethod.                    "fill_f4_itab
*----------------------------------------------------
  method build_fieldcatalog.
    data: ls_fcat type lvc_s_fcat.

    clear ls_fcat.
    ls_fcat-fieldname = 'VALUE'.
    ls_fcat-coltext = text-t02.
    ls_fcat-inttype = 'S_CLASS'.
    ls_fcat-outputlen = 5.
    append ls_fcat to fieldcatalog.
    clear ls_fcat.
    ls_fcat-fieldname = 'DESCR'.
    ls_fcat-coltext = text-t01.
    ls_fcat-inttype = 'C'.
    ls_fcat-outputlen = 20.
    append ls_fcat to fieldcatalog.
  endmethod.                    "build_fieldcatalog
*-----------------------------------------------------
  method on_double_click.

*§5. If not already caught by your own f4 help, check whether
*    the triggered cell was ready for input by using E_DISPLAY
*    and if not, exit.
    if f4_params-c_display eq 'X'.
      leave screen.
    endif.

*§6. After the user selected a value, pass it to the ALV Grid Control:

*§  6a. Define a field symbol of type: LVC_T_MODI and a structure of
*       type LVC_S_MODI to pass the value later on.
    field-symbols &amp;lt;itab&amp;gt; type lvc_t_modi.
    data: ls_modi type lvc_s_modi,
          ls_f4_itab type f4_itab_type.

*§  6b. Dereference attribute M_DATA into your field symbol and add
*       the selected value to the table to which this symbol points to.
    assign f4_params-cr_event_data-&amp;gt;m_data-&amp;gt;* to &amp;lt;itab&amp;gt;.
    ls_modi-row_id = f4_params-cs_row_no-row_id.
    ls_modi-fieldname = f4_params-c_fieldname.

    read table f4_itab into ls_f4_itab index es_row_no-row_id.

    ls_modi-value = ls_f4_itab-value.
    append ls_modi to &amp;lt;itab&amp;gt;.

    leave screen.
  endmethod.                    "on_double_click
*-----------------------------------------------------
  method reset.
    field-symbols &amp;lt;itab&amp;gt; type lvc_t_modi.

    assign f4_params-cr_event_data-&amp;gt;m_data-&amp;gt;* to &amp;lt;itab&amp;gt;.
    clear &amp;lt;itab&amp;gt;[].
  endmethod.                    "reset
*-----------------------------------------------------
  method smoker_cell_is_bad.
    data: ls_bad_cell type lvc_s_modi. "#EC NEEDED

    r_flag = 0. "no error initially

* Determine if value of smoker cell of the same
* row has a bad value. If so, a message pops up
* instead of our F4 help.
    read table f4_params-ct_bad_cells into ls_bad_cell
        with key fieldname = 'SMOKER'
                 row_id    = f4_params-cs_row_no-row_id.
    if sy-subrc eq 0.
        r_flag = 1.
        message i000(0k) with text-i01 text-i02.
* NOTE: Although there is a bad value present
*       the ALV Grid Control shows no error protocol.
*       However, the bad value is saved in the
*       protocol and event DATA_CHANGED_FINISHED is
*       not raised.
    endif.

  endmethod.                    "smoker_cell_is_bad
*=====================================================


endclass.                    "lcl_application_f4 IMPLEMENTATION

*
* lcl_application_f4 (Implementation)
*===================================================================

*===============================================================
* class lcl_application_dc (Implementation)
*
class lcl_application_dc implementation.
  method handle_data_changed.
*
    error_in_data = space.

* Distinguish, if DATA_CHANGED was raised because of an
* own F4-help.
* Event DATA_CHANGED provides parameter E_ONF4
* for this purpose.
    if not e_onf4 is initial.
* Add your special handling here if needed.
* Event DATA_CHANGED provides parameters E_ONF4_AFTER
* and E_ONF4_BEFORE to distinguish the context
* additionally.

* In general, semantic checks should be the same no matter if
* they have been entered by hand or using an application
* specific F4 help. So you probably do not need these parameters.
    else.
      call method perform_semantic_checks( er_data_changed ).
    endif.

    if error_in_data = 'X'.
      call method er_data_changed-&amp;gt;display_protocol.
    endif.

  endmethod.                    "handle_data_changed
*------------------------------------
* private methods
*------------------------------------
  method perform_semantic_checks.
*
* In this snenario, only values of cells in columns CLASS or SMOKER
* can be changed. These fields have a value range defined
* in the ABAP dictionary.
* Thus, after ALVs syntaktical check, we only need to
* check if the user tried to enter a smoker seat for
* a class other than 'F' or vice versa.
*
    data: ls_good type lvc_s_modi.

    loop at pr_data_changed-&amp;gt;mt_good_cells into ls_good.
      case ls_good-fieldname.
        when 'SMOKER'.
          call method check_smoker
            exporting
              ps_good_smoker  = ls_good
              pr_data_changed = pr_data_changed.

        when 'CLASS'.
          call method check_class
            exporting
              ps_good_class   = ls_good
              pr_data_changed = pr_data_changed.
      endcase.
    endloop.

  endmethod.                    "perform_semantic_checks
*--------------------------------------
  method check_smoker.
    data: l_smoker type s_smoker,
          l_class  type s_class,
          ls_outtab type sbook,
          ls_good_class type lvc_s_modi. "#EC NEEDED

* first get value of smoker cell:
    call method pr_data_changed-&amp;gt;get_cell_value
      exporting
        i_row_id    = ps_good_smoker-row_id
        i_fieldname = ps_good_smoker-fieldname
      importing
        e_value     = l_smoker.

* If it's a non smoker there is no problem at all
* because every value of CLASS shall be possible then.
    if l_smoker is initial.
      exit.
    endif.

* If not, value of cell CLASS has to be 'F'.
* First check if the value of field CLASS has been
* changed/entered newly, too:
    read table pr_data_changed-&amp;gt;mt_good_cells into ls_good_class
                        with key row_id    = ps_good_smoker-row_id
                                 fieldname = 'CLASS'.
    if sy-subrc eq 0.
* get that new value:
      call method pr_data_changed-&amp;gt;get_cell_value
        exporting
          i_row_id    = ps_good_smoker-row_id
          i_fieldname = 'CLASS'
        importing
          e_value     = l_class.
    else.
* get current value
      read table gt_outtab into ls_outtab index ps_good_smoker-row_id.
      l_class = ls_outtab-class.
    endif.

* Since we have a smoker his class has to be 'F':
    if l_class ne 'F'.
      call method pr_data_changed-&amp;gt;add_protocol_entry
        exporting
          i_msgid     = '0K'
          i_msgno     = '000'
          i_msgty     = 'E'
          i_msgv1     = text-m01           "Klasse
          i_msgv2     = l_class
          i_msgv3     = text-m02           "nicht erlaubt für Raucher
          i_fieldname = ps_good_smoker-fieldname
          i_row_id    = ps_good_smoker-row_id.

      error_in_data = 'X'.
    endif.
  endmethod.                    "check_smoker
*--------------------------------------
  method check_class.
      data: l_smoker type s_smoker,
            l_class  type s_class,
            ls_outtab type sbook,
            ls_good_smoker type lvc_s_modi. "#EC NEEDED

* first get value of class cell:
    call method pr_data_changed-&amp;gt;get_cell_value
      exporting
        i_row_id    = ps_good_class-row_id
        i_fieldname = ps_good_class-fieldname
      importing
        e_value     = l_class.

* If it's CLASS 'F' there is no problem at all
* because every value of SMOKER shall be possible then.
    if l_class eq 'F'.
      exit.
    endif.

* If not, value of cell SMOKER has to be initial.
* First check if the value of field CLASS has been
* changed/entered newly, too:
    read table pr_data_changed-&amp;gt;mt_good_cells into ls_good_smoker
                        with key row_id    = ps_good_class-row_id
                                 fieldname = 'SMOKER'.
    if sy-subrc eq 0.
* get that new value:
      call method pr_data_changed-&amp;gt;get_cell_value
        exporting
          i_row_id    = ps_good_class-row_id
          i_fieldname = 'SMOKER'
        importing
          e_value     = l_smoker.
    else.
* get current value
      read table gt_outtab into ls_outtab index ps_good_class-row_id.
      l_smoker = ls_outtab-smoker.
    endif.

* Since the class is not 'F' it has to be a non smoking person:
    if not l_smoker is initial.
      call method pr_data_changed-&amp;gt;add_protocol_entry
        exporting
          i_msgid     = '0K'
          i_msgno     = '000'
          i_msgty     = 'W'
          i_msgv1     = text-m03         "Als Raucher dürfen Sie Klasse
          i_msgv2     = l_class
          i_msgv3     = text-m04         "nicht buchen
          i_fieldname = ps_good_class-fieldname
          i_row_id    = ps_good_class-row_id.

      error_in_data = 'X'.
    endif.

  endmethod.                    "check_class
*--------------------------------------
endclass.                    "lcl_application_dc IMPLEMENTATION
***********************************************************************

*---------------------------------------------------------------------*
*       MAIN                                                          *
*---------------------------------------------------------------------*
end-of-selection.
  call screen 100.

*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
module pbo output.
  set pf-status 'MAIN100'.
  set titlebar 'MAIN100'.
  if g_custom_container is initial.
    perform create_and_init_alv changing gt_outtab[]
                                         gt_fieldcat.
  endif.

endmodule.                    "pbo OUTPUT
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
module pai input.
  save_ok = ok_code.
  clear ok_code.
  case save_ok.
    when 'EXIT'.
      perform exit_program.
    when 'SWITCH'.
      perform switch_edit_mode.
    when others.
*     do nothing
  endcase.
endmodule.                    "pai INPUT
*---------------------------------------------------------------------*
*       FORM EXIT_PROGRAM                                             *
*---------------------------------------------------------------------*
form exit_program.
  leave program.
endform.                    "exit_program
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BUILD_FIELDCAT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_GT_FIELDCAT  text
*----------------------------------------------------------------------*
form build_fieldcat changing pt_fieldcat type lvc_t_fcat.

  data ls_fcat type lvc_s_fcat.

  call function 'LVC_FIELDCATALOG_MERGE'
    exporting
      i_structure_name = 'SBOOK'
    changing
      ct_fieldcat      = pt_fieldcat.

  loop at pt_fieldcat into ls_fcat.
* Exchange smoker field with invoice field - just to
* make the dependance between SMOKER and CLASS more transparent
* (Smoking is only allowed in the first class).
    if ls_fcat-fieldname eq 'SMOKER'.
      ls_fcat-col_pos = 11.
      ls_fcat-outputlen = 10.
      ls_fcat-edit = 'X'.
* Field 'checktable' is set to avoid shortdumps that are caused
* by inconsistend data in check tables. You may comment this out
* when the test data of the flight model is consistent in your system.
      ls_fcat-checktable = '!'.        "do not check foreign keys

      modify pt_fieldcat from ls_fcat.

    elseif ls_fcat-fieldname eq 'INVOICE'.
      ls_fcat-col_pos = 7.
      modify pt_fieldcat from ls_fcat.

    elseif    ls_fcat-fieldname eq 'CLASS'.

      ls_fcat-edit = 'X'.
      ls_fcat-outputlen = 5.
      ls_fcat-checktable = '!'.        "do not check foreign keys

      modify pt_fieldcat from ls_fcat.
    endif.
  endloop.

endform.                    "build_fieldcat
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  CREATE_AND_INIT_ALV
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_GT_OUTTAB  text
*      &amp;lt;--P_GT_FIELDCAT  text
*      &amp;lt;--P_GS_LAYOUT  text
*----------------------------------------------------------------------*
form create_and_init_alv changing pt_outtab type standard table
                                  pt_fieldcat type lvc_t_fcat.

  data: lt_exclude type ui_functions.

  create object g_custom_container
          exporting container_name = g_container.
  create object g_grid
         exporting i_parent = g_custom_container.

  perform build_fieldcat changing pt_fieldcat.

* Optionally restrict generic functions to 'change only'.
*   (The user shall not be able to add new lines).
  perform exclude_tb_functions changing lt_exclude.

  perform build_data changing pt_outtab.

  call method g_grid-&amp;gt;set_table_for_first_display
    exporting
      it_toolbar_excluding = lt_exclude
    changing
      it_fieldcatalog      = pt_fieldcat
      it_outtab            = pt_outtab[].

* register f4 for field CLASS
  perform register_events.

* Set editable cells to ready for input initially
  call method g_grid-&amp;gt;set_ready_for_input
    exporting
      i_ready_for_input = 1.

endform.                               "CREATE_AND_INIT_ALV

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  EXCLUDE_TB_FUNCTIONS
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_LT_EXCLUDE  text
*----------------------------------------------------------------------*
form exclude_tb_functions changing pt_exclude type ui_functions.
* Only allow to change data not to create new entries (exclude
* generic functions).

  data ls_exclude type ui_func.

  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_copy_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_delete_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_append_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_insert_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_move_row.
  append ls_exclude to pt_exclude.

endform.                               " EXCLUDE_TB_FUNCTIONS
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  build_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
form build_data changing pt_outtab type standard table.
  data: ls_sbook type sbook,
        l_index type i.

  select * from sbook into table gt_outtab up to g_max rows.  "#EC CI_NOWHERE
  if sy-subrc ne 0.
    perform generate_entries changing pt_outtab.
  endif.

  loop at pt_outtab into ls_sbook.
    l_index = sy-tabix.
    clear ls_sbook-class.
* Alternate between smoker and non smoker to make
* it more obvious what this example is about
    l_index = l_index mod 2.
    if l_index eq 1.
      ls_sbook-smoker = 'X'.
    else.
      ls_sbook-smoker = ' '.
    endif.
    modify pt_outtab from ls_sbook.
  endloop.

endform.                               " build_data

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  generate_entries
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_LT_SLFIGHT  text
*----------------------------------------------------------------------*
form generate_entries changing pt_sbook type standard table.
  data: ls_sbook type sbook,
        l_month(2) type c,
        l_day(2) type c,
        l_date(8) type c,
	l_prebookid type i.


  ls_sbook-carrid = 'LH'.
  ls_sbook-connid = '0400'.
  ls_sbook-forcurkey = 'DEM'.
  ls_sbook-loccurkey = 'USD'.
  ls_sbook-custtype = 'B'.

  do 110 times.
    l_prebookid = sy-index.

    ls_sbook-forcuram = sy-index * 10.
    ls_sbook-loccuram = ls_sbook-loccuram * 2.
    ls_sbook-customid = sy-index.
    ls_sbook-counter = 18.
    ls_sbook-agencynum = 11.

    l_month = sy-index / 10 + 1.
    do 2 times.
      l_day = 3 + l_month + sy-index * 2.
      l_date+0(4) = '2000'.
      l_date+4(2) = l_month.
      l_date+6(2) = l_day.
      ls_sbook-fldate = l_date.
      subtract 3 from l_day.
      ls_sbook-order_date+0(6) = l_date+0(6).
      ls_sbook-order_date+6(2) = l_day.
      ls_sbook-bookid = l_prebookid * 2 + sy-index.
      if sy-index eq 1.
        ls_sbook-smoker = 'X'.
      else.
        ls_sbook-smoker = space.
      endif.

      ls_sbook-luggweight = l_prebookid * 10.
      if ls_sbook-luggweight ge 1000.
        ls_sbook-wunit = 'G'.
        ls_sbook-class = 'C'.
      else.
        ls_sbook-wunit = 'KG'.
        ls_sbook-class = 'Y'.
      endif.

      if ls_sbook-bookid &amp;gt; 40 and ls_sbook-wunit eq 'KG'.
        ls_sbook-invoice = 'X'.
      endif.
      if ls_sbook-bookid eq 2.
        ls_sbook-cancelled = 'X'.
        ls_sbook-class = 'F'.
      endif.

      append ls_sbook to pt_sbook.
    enddo.
  enddo.
endform.                               " generate_entries
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  register_events
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
form register_events.
*§1. Register event ONF4 at frontend using method
*    register_f4_for_fields. For this purpose, you pass a table
*    with all fields, for which you want to implement your own
*    f4 help.

* remark: If you want to use an own f4 help for fields where
*         no standard f4 help exists set field F4AVAILABL for
*         this field in the fieldcatalog.
  data: lt_f4 type lvc_t_f4 with header line.

  clear lt_f4.
  lt_f4-fieldname = 'CLASS'.
* If you would like to deregister the field again,
* pass value SPACE with field 'register'.
  lt_f4-register = 'X'.
*§  1b. If the value range in your f4 help depends on other
*       values of cells that are input enabled, set the
*       GETBEFORE parameter.
* The consequence is that the ALV Grid Control raises
* event DATA_CHANGED before the f4 help is called to
* check values that the f4 help depends on.
  lt_f4-getbefore = 'X'.
* The next parameter is used to change values after onf4 has
* been processed. The ALV Grid Control will raise
* event DATA_CHANGED afterwards, if you set it.
  lt_f4-chngeafter = space.
  insert table lt_f4.

  call method g_grid-&amp;gt;register_f4_for_fields
    exporting
      it_f4 = lt_f4[].

* register events for abap objects (backend)
  create object g_onf4.
  set handler g_onf4-&amp;gt;on_f4 for g_grid.

  create object g_dc.
  set handler g_dc-&amp;gt;handle_data_changed for g_grid.

endform.                    " register_events
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  STATUS_0101  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module status_0101 output.
  set pf-status 'POPUP'.
  set titlebar 'POPUP'.
  call method g_onf4-&amp;gt;show_f4.
endmodule.                 " STATUS_0101  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  USER_COMMAND_0101  INPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
module user_command_0101 input.
  perform user_command.
endmodule.                 " USER_COMMAND_0101  INPUT
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  user_command
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
form user_command.

  data: save_ok type sy-ucomm.

  save_ok = ok_code.
  clear ok_code.
  case save_ok.
    when 'CANCEL'.
      call method g_onf4-&amp;gt;reset.
      leave screen.
  endcase.

endform.                    " user_command
*-------------------------------------------------------------------
form switch_edit_mode.

  if g_grid-&amp;gt;is_ready_for_input( ) eq 0.
* set edit enabled cells ready for input
    call method g_grid-&amp;gt;set_ready_for_input
                     exporting i_ready_for_input = 1.

  else.
* lock edit enabled cells against input
    call method g_grid-&amp;gt;set_ready_for_input
                    exporting i_ready_for_input = 0.
  endif.
endform.                               " SWITCH_EDIT_MODE

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jun 2008 08:48:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976114#M949689</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-06-20T08:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976115#M949690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi uwe ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for Report.&lt;/P&gt;&lt;P&gt;That report itself does not exist in the SAP 4.6c version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the report i will work on it .&lt;/P&gt;&lt;P&gt;I will again if i had queries .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Madhavi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Jun 2008 12:02:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976115#M949690</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-20T12:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976116#M949691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;check this.....&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.saptechnical.com/Tutorials/ALV/Edit/F4.htm" target="test_blank"&gt;http://www.saptechnical.com/Tutorials/ALV/Edit/F4.htm&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Jun 2008 09:27:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976116#M949691</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-21T09:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976117#M949692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help in finding the Report in SAP .&lt;/P&gt;&lt;P&gt;The Standard Report i found out in ECC 6 version where it is not existing in SAP 4.6c version.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;when i copied the report from Ecc6 to 4.6 the POPUP window fucntion codes &lt;/P&gt;&lt;P&gt;CANCEL and DOUBLE_CLICK is not working from my end.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it shoing error in Field symbols, which i am not able find the exactly error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will you please help in resolving the issues.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Madhavi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2008 12:29:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976117#M949692</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-23T12:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976118#M949693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Will you help me by sending an small example with this scenario.&lt;/P&gt;&lt;P&gt;some where it is working fine. I am not able find the resolution for it please.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Madhavi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jun 2008 08:08:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976118#M949693</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-06-24T08:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976119#M949694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Madhavi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I copied sample report BCALV_EDIT_08 and made a few changes to show how non-editable columns of the ALV list can be easily changed by the selected (F4-)values in editable columns.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The changes are: Trigger PAI at the end of method ON_F4 by calling cl_gui_cfw=&amp;gt;set_new_ok_code.&lt;/P&gt;&lt;P&gt;In the PAI module routine REFRESH_OUTTAB is called.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you select class = 'C' on the ALV list the method writes 'U' into the non-editable column CUSTTYPE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
PROGRAM zus_sdn_bcalv_edit_08.
*&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;
* Purpose:
* ~~~~~~~~
* This report implements an ALV Grid Control with an application
* specific F4 help. The following aspects are dealth with:
*  o how to replace the standard f4 help
*     NOTE: This example uses a second ALV Grid Control to
*           provide an application specific F4 help.
*           This is probalbly NOT the usual way to
*           provide such a functionality.
*           However, the purpose of this report is not to
*           show you how to implement an F4 help, but to
*           explain how you pass the selected value to ALV,
*           how you take values of other cells into account, etc.
*           For this purpose, it does not matter how the f4 help
*           is actually implemented.
*
*  o how to pass the selected value to the ALV Grid Control
*  o how to build an f4 help, whose value range depend on
*    a value of another cell.
*-----------------------------------------------------------------
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* We use table SBOOK with columns CLASS and SMOKER ready for input.
* The idea of this scenario is that it is only allowed to smoke
* in the first class (value 'F' of field CLASS).
* The application specific f4 help can be called for column CLASS:
* o if the value of column SMOKER in the same row is 'X', only class
*   'F' can be chosen
* o if the value of column SMOKER in the same row is ' ', all
*   classes are allowed ('F','C','Y'). Thus, the f4 help shows all
*   values.
* o if the value of column SMOKER in the same row is not valid
*   (syntactically or semantically), a message is shown and
*   no f4 help pops up.
*-----------------------------------------------------------------
* Essential steps (search for '§')
* ~~~~~~~~~~~~~~~
* Note that this report is rather long because the columns CLASS and
* SMOKER are checked semantically which does not belong to the f4 help
* implementation. Class lcl_application_dc handles semantic checks.
* Local class lcl_application_f4 handles event ONF4 to build up
* the f4 help, to pass the value to the ALV Grid Control and
* to check whether the value of the SMOKER column is valid.
*
* 1. Register event ONF4 at frontend using method
*    register_f4_for_fields. For this purpose, you pass a table
*    with all fields, for which you want to implement your own
*    f4 help.
*   1b. If the value range in your f4 help depends on other
*       values of cells that are input enabled, set the
*       GETBEFORE parameter.
* 2. Implement an event handler method for event ONF4.
* 3. Call your own f4 help. To customize your popup check
*    first if the cell is ready for input (event parameter E_DISPLAY).
* 4. Check whether the value your f4 help depends on is valid.
* 5. If not already caught by your own f4 help, check whether
*    the triggered cell was ready for input by using E_DISPLAY
*    and if not, exit.
* 6. After the user selected a value, pass it to the ALV Grid Control:
*   6a. Define a field symbol of type: LVC_T_MODI and a structure of
*       type LVC_S_MODI to pass the value later on.
*   6b. Dereference attribute M_DATA to your field symbol and add
*       the selected value to the table to which this symbol points to.
* 7. Inform the ALV Grid Control that an own f4 help has been processed
*    to suppress the standard f4 help.
*-----------------------------------------------------------------------
*&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;&amp;amp;

DATA: ok_code LIKE sy-ucomm,
      save_ok LIKE sy-ucomm,
      g_container TYPE scrfname VALUE 'CC1',
      g_grid  TYPE REF TO cl_gui_alv_grid,
      g_custom_container TYPE REF TO cl_gui_custom_container,
      gt_fieldcat TYPE lvc_t_fcat,
       g_max TYPE i VALUE 100.

CLASS lcl_application_f4 DEFINITION DEFERRED.
CLASS lcl_application_dc DEFINITION DEFERRED.


DATA: g_onf4 TYPE REF TO lcl_application_f4,
      g_dc TYPE REF TO lcl_application_dc.


DATA: gt_outtab TYPE TABLE OF sbook.

****************************************************************
* LOCAL CLASSES: Definition
****************************************************************
*===============================================================
* class lcl_application_f4: local class to handle own F4.
*
* Definition:
* ~~~~~~~~~~~
CLASS lcl_application_f4 DEFINITION.

  PUBLIC SECTION.
    METHODS:

             on_f4 FOR EVENT onf4 OF cl_gui_alv_grid
               IMPORTING e_fieldname
                         es_row_no
                         er_event_data
                         et_bad_cells
                         e_display.

    METHODS: reset.
    METHODS: show_f4.

  PRIVATE SECTION.
**
* attributes for creating an own F4-Help
* (using a second ALV Grid Control
**
    DATA: f4_alv TYPE REF TO cl_gui_alv_grid,
          f4_cont TYPE REF TO cl_gui_custom_container.

    TYPES: BEGIN OF f4_itab_type.
    TYPES: value TYPE s_class.
    TYPES: descr(20) TYPE c.
    TYPES: END OF f4_itab_type.

    DATA: f4_itab TYPE TABLE OF f4_itab_type.
    DATA: fieldcatalog TYPE lvc_t_fcat.

**
* attributes to store event parameters
* (after the CALL SCREEN command, the event parameters
* are not accessible)
**
    TYPES: BEGIN OF onf4_event_parameters_type.
    TYPES: c_fieldname     TYPE lvc_fname.
    TYPES: cs_row_no       TYPE lvc_s_roid.
    TYPES: cr_event_data   TYPE REF TO cl_alv_event_data.
    TYPES: ct_bad_cells    TYPE lvc_t_modi.
    TYPES: c_display       TYPE char01.
    TYPES: END OF onf4_event_parameters_type.

    DATA: f4_params TYPE onf4_event_parameters_type.


**
* Methods to create own F4-Help
* (This is done using a second ALV Grid Control)
**
    METHODS: init_f4.

    METHODS: build_fieldcatalog.
    METHODS: fill_f4_itab IMPORTING smoker TYPE c.

    METHODS: on_double_click FOR EVENT double_click OF cl_gui_alv_grid
                    IMPORTING es_row_no.

**
* Methods to check whether the values which the F4-Help needs
* are correct
* (The entries of the F4-Help of field CLASS depend on the value
* of field SMOKER. If field SMOKER of the same row is syntaktically
* or semantically not correct, this has to be handled during ONF4.
**
    METHODS: smoker_cell_is_bad
                RETURNING value(r_flag) TYPE i.

ENDCLASS.                    "lcl_application_f4 DEFINITION
*
* lcl_application_f4 (Definition)
*===============================================================
* class lcl_application_dc: local class to handle event data_changed.
*
* Definition:
* ~~~~~~~~~~~
CLASS lcl_application_dc DEFINITION.

  PUBLIC SECTION.

    METHODS: handle_data_changed
               FOR EVENT data_changed OF cl_gui_alv_grid
                  IMPORTING er_data_changed
                            e_onf4 e_onf4_before e_onf4_after.

  PRIVATE SECTION.

* This flag is set if any error occured in one of the
* following methods:
    DATA: error_in_data TYPE c.

    METHODS:
     perform_semantic_checks
       IMPORTING
         pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.

    METHODS: check_smoker
     IMPORTING
        ps_good_smoker TYPE lvc_s_modi
        pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.

    METHODS: check_class
     IMPORTING
        ps_good_class TYPE lvc_s_modi
        pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.

ENDCLASS.                    "lcl_application_dc DEFINITION
*
* lcl_application_dc (Definition)
*===============================================================


****************************************************************
* LOCAL CLASSES: Implementation
****************************************************************
*===============================================================
* class lcl_application_f4 (Implementation)
*
CLASS lcl_application_f4 IMPLEMENTATION.

*§2. Implement an event handler method for event ONF4.

  METHOD on_f4.

* Save event parameter as global attributes of this class
* (maybe solved differently if you use a function module!)
    f4_params-c_fieldname = e_fieldname.
    f4_params-cs_row_no = es_row_no.
    f4_params-cr_event_data = er_event_data.
    f4_params-ct_bad_cells = et_bad_cells.
    f4_params-c_display = e_display.

*§3. Call your own f4 help. To customize your popup check
*    first if the cell is ready for input (event parameter E_DISPLAY).
* (parameter E_DISPLAY is checked later in method on_double_click)

* (Probably, you would call a function module at this point,
* pass the needed event parameter and call the popup screen
* within that function module. This is not done in this example
* to avoid scattering its code).

    CALL SCREEN 101 STARTING AT 10 10.

*§7. Inform the ALV Grid Control that an own f4 help has been processed
*    to suppress the standard f4 help.

    er_event_data-&amp;gt;m_event_handled = 'X'.

    CALL METHOD cl_gui_cfw=&amp;gt;set_new_ok_code
      EXPORTING
        new_code = 'REFRESH'
*      IMPORTING
*        rc       =
        .

  ENDMETHOD.                                                "on_f4
*---------------------------------------------------------------------
  METHOD show_f4.
    DATA: ls_outtab TYPE sbook.

* initialize own f4 help if needed
    IF f4_cont IS INITIAL.
      CALL METHOD init_f4.
    ENDIF.

*§4. Check whether the value your f4 help depends on is valid.

* The possible values of field CLASS depend on
* the value of field SMOKER of the same row.
* You have to check that this value is valid:
    IF smoker_cell_is_bad( ) EQ 1.
      LEAVE SCREEN.
    ENDIF.

* determine value of column SMOKER and use appropriate f4 table
    READ TABLE gt_outtab INTO ls_outtab INDEX f4_params-cs_row_no-row_id
.
    CALL METHOD fill_f4_itab( ls_outtab-smoker ).

* refresh list of values in f4 help and show it
    CALL METHOD f4_alv-&amp;gt;refresh_table_display.
* CAUTION: Do not use method REFRESH_TABLE_DISPLAY for
* your editable ALV Grid instances while handling events
* DATA_CHANGED or ONf4. You would overwrite intermediate
* values of your output table on frontend.
* 'f4_alv' is a non-editable ALV Grid Control for the
* application specific F4-Help. Therefore, calling
* REFRESH_TABLE_DISPLAY for this instance has no
* negative effect.

    CALL METHOD cl_gui_cfw=&amp;gt;flush.
  ENDMETHOD.                                                "show_f4

*--------------------------------------------------------------------

  METHOD init_f4.
    DATA: ls_layout TYPE lvc_s_layo.
* build fieldcatalog entries for f4
    CALL METHOD build_fieldcatalog.

* create controls
    CREATE OBJECT f4_cont
      EXPORTING
        container_name = 'CC_ONF4'.

    CREATE OBJECT f4_alv
      EXPORTING
        i_parent = f4_cont.

* hide toolbar
    ls_layout-no_toolbar = 'X'.

    CALL METHOD f4_alv-&amp;gt;set_table_for_first_display
      EXPORTING
        is_layout       = ls_layout
      CHANGING
        it_fieldcatalog = fieldcatalog
        it_outtab       = f4_itab.

* register event double click on backend
    SET HANDLER me-&amp;gt;on_double_click FOR f4_alv.

* flush since 'ls_layout' is local!
    CALL METHOD cl_gui_cfw=&amp;gt;flush.

  ENDMETHOD.                                                "init_f4
*-----------------------------------------------------
  METHOD fill_f4_itab.
    DATA ls_f4_itab TYPE f4_itab_type.

* Delete all entries in f4_itab to determine
* offered values dynamically
    CLEAR f4_itab[].
* create entries depending on SMOKER field
    IF smoker IS INITIAL.
      ls_f4_itab-value = 'C'.
      ls_f4_itab-descr = text-t03. "Business Class
      APPEND ls_f4_itab TO f4_itab.
      ls_f4_itab-value = 'Y'.
      ls_f4_itab-descr = text-t04. "Economie Class
      APPEND ls_f4_itab TO f4_itab.
      ls_f4_itab-value = 'F'.
      ls_f4_itab-descr = text-t05. "First Class
      APPEND ls_f4_itab TO f4_itab.
    ELSE.
      ls_f4_itab-value = 'F'.
      ls_f4_itab-descr = text-t05. "First Class
      APPEND ls_f4_itab TO f4_itab.
    ENDIF.
  ENDMETHOD.                    "fill_f4_itab
*----------------------------------------------------
  METHOD build_fieldcatalog.
    DATA: ls_fcat TYPE lvc_s_fcat.

    CLEAR ls_fcat.
    ls_fcat-fieldname = 'VALUE'.
    ls_fcat-coltext = text-t02.
    ls_fcat-inttype = 'S_CLASS'.
    ls_fcat-outputlen = 5.
    APPEND ls_fcat TO fieldcatalog.
    CLEAR ls_fcat.
    ls_fcat-fieldname = 'DESCR'.
    ls_fcat-coltext = text-t01.
    ls_fcat-inttype = 'C'.
    ls_fcat-outputlen = 20.
    APPEND ls_fcat TO fieldcatalog.
  ENDMETHOD.                    "build_fieldcatalog
*-----------------------------------------------------
  METHOD on_double_click.

*§5. If not already caught by your own f4 help, check whether
*    the triggered cell was ready for input by using E_DISPLAY
*    and if not, exit.
    IF f4_params-c_display EQ 'X'.
      LEAVE SCREEN.
    ENDIF.

*§6. After the user selected a value, pass it to the ALV Grid Control:

*§  6a. Define a field symbol of type: LVC_T_MODI and a structure of
*       type LVC_S_MODI to pass the value later on.
    FIELD-SYMBOLS &amp;lt;itab&amp;gt; TYPE lvc_t_modi.
    DATA: ls_modi TYPE lvc_s_modi,
          ls_f4_itab TYPE f4_itab_type.

*§  6b. Dereference attribute M_DATA into your field symbol and add
*       the selected value to the table to which this symbol points to.
    ASSIGN f4_params-cr_event_data-&amp;gt;m_data-&amp;gt;* TO &amp;lt;itab&amp;gt;.
    ls_modi-row_id = f4_params-cs_row_no-row_id.
    ls_modi-fieldname = f4_params-c_fieldname.

    READ TABLE f4_itab INTO ls_f4_itab INDEX es_row_no-row_id.

    ls_modi-value = ls_f4_itab-value.
    APPEND ls_modi TO &amp;lt;itab&amp;gt;.

    LEAVE SCREEN.
  ENDMETHOD.                    "on_double_click
*-----------------------------------------------------
  METHOD reset.
    FIELD-SYMBOLS &amp;lt;itab&amp;gt; TYPE lvc_t_modi.

    ASSIGN f4_params-cr_event_data-&amp;gt;m_data-&amp;gt;* TO &amp;lt;itab&amp;gt;.
    CLEAR &amp;lt;itab&amp;gt;[].
  ENDMETHOD.                    "reset
*-----------------------------------------------------
  METHOD smoker_cell_is_bad.
    DATA: ls_bad_cell TYPE lvc_s_modi.                      "#EC NEEDED

    r_flag = 0. "no error initially

* Determine if value of smoker cell of the same
* row has a bad value. If so, a message pops up
* instead of our F4 help.
    READ TABLE f4_params-ct_bad_cells INTO ls_bad_cell
        WITH KEY fieldname = 'SMOKER'
                 row_id    = f4_params-cs_row_no-row_id.
    IF sy-subrc EQ 0.
      r_flag = 1.
      MESSAGE i000(0k) WITH text-i01 text-i02.
* NOTE: Although there is a bad value present
*       the ALV Grid Control shows no error protocol.
*       However, the bad value is saved in the
*       protocol and event DATA_CHANGED_FINISHED is
*       not raised.
    ENDIF.

  ENDMETHOD.                    "smoker_cell_is_bad
*=====================================================


ENDCLASS.                    "lcl_application_f4 IMPLEMENTATION

*
* lcl_application_f4 (Implementation)
*===================================================================

*===============================================================
* class lcl_application_dc (Implementation)
*
CLASS lcl_application_dc IMPLEMENTATION.
  METHOD handle_data_changed.
*
    error_in_data = space.

* Distinguish, if DATA_CHANGED was raised because of an
* own F4-help.
* Event DATA_CHANGED provides parameter E_ONF4
* for this purpose.
    IF NOT e_onf4 IS INITIAL.
* Add your special handling here if needed.
* Event DATA_CHANGED provides parameters E_ONF4_AFTER
* and E_ONF4_BEFORE to distinguish the context
* additionally.

* In general, semantic checks should be the same no matter if
* they have been entered by hand or using an application
* specific F4 help. So you probably do not need these parameters.
    ELSE.
      CALL METHOD perform_semantic_checks( er_data_changed ).
    ENDIF.

    IF error_in_data = 'X'.
      CALL METHOD er_data_changed-&amp;gt;display_protocol.
    ENDIF.

  ENDMETHOD.                    "handle_data_changed
*------------------------------------
* private methods
*------------------------------------
  METHOD perform_semantic_checks.
*
* In this snenario, only values of cells in columns CLASS or SMOKER
* can be changed. These fields have a value range defined
* in the ABAP dictionary.
* Thus, after ALVs syntaktical check, we only need to
* check if the user tried to enter a smoker seat for
* a class other than 'F' or vice versa.
*
    DATA: ls_good TYPE lvc_s_modi.

    LOOP AT pr_data_changed-&amp;gt;mt_good_cells INTO ls_good.
      CASE ls_good-fieldname.
        WHEN 'SMOKER'.
          CALL METHOD check_smoker
            EXPORTING
              ps_good_smoker  = ls_good
              pr_data_changed = pr_data_changed.

        WHEN 'CLASS'.
          CALL METHOD check_class
            EXPORTING
              ps_good_class   = ls_good
              pr_data_changed = pr_data_changed.
      ENDCASE.
    ENDLOOP.

  ENDMETHOD.                    "perform_semantic_checks
*--------------------------------------
  METHOD check_smoker.
    DATA: l_smoker TYPE s_smoker,
          l_class  TYPE s_class,
          ls_outtab TYPE sbook,
          ls_good_class TYPE lvc_s_modi.                    "#EC NEEDED

* first get value of smoker cell:
    CALL METHOD pr_data_changed-&amp;gt;get_cell_value
      EXPORTING
        i_row_id    = ps_good_smoker-row_id
        i_fieldname = ps_good_smoker-fieldname
      IMPORTING
        e_value     = l_smoker.

* If it's a non smoker there is no problem at all
* because every value of CLASS shall be possible then.
    IF l_smoker IS INITIAL.
      EXIT.
    ENDIF.

* If not, value of cell CLASS has to be 'F'.
* First check if the value of field CLASS has been
* changed/entered newly, too:
    READ TABLE pr_data_changed-&amp;gt;mt_good_cells INTO ls_good_class
                        WITH KEY row_id    = ps_good_smoker-row_id
                                 fieldname = 'CLASS'.
    IF sy-subrc EQ 0.
* get that new value:
      CALL METHOD pr_data_changed-&amp;gt;get_cell_value
        EXPORTING
          i_row_id    = ps_good_smoker-row_id
          i_fieldname = 'CLASS'
        IMPORTING
          e_value     = l_class.
    ELSE.
* get current value
      READ TABLE gt_outtab INTO ls_outtab INDEX ps_good_smoker-row_id.
      l_class = ls_outtab-class.
    ENDIF.

* Since we have a smoker his class has to be 'F':
    IF l_class NE 'F'.
      CALL METHOD pr_data_changed-&amp;gt;add_protocol_entry
        EXPORTING
          i_msgid     = '0K'
          i_msgno     = '000'
          i_msgty     = 'E'
          i_msgv1     = text-m01           "Klasse
          i_msgv2     = l_class
          i_msgv3     = text-m02           "nicht erlaubt für Raucher
          i_fieldname = ps_good_smoker-fieldname
          i_row_id    = ps_good_smoker-row_id.

      error_in_data = 'X'.
    ENDIF.
  ENDMETHOD.                    "check_smoker
*--------------------------------------
  METHOD check_class.
    DATA: l_smoker TYPE s_smoker,
          l_class  TYPE s_class,
          ls_outtab TYPE sbook,
          ls_good_smoker TYPE lvc_s_modi.                   "#EC NEEDED

* first get value of class cell:
    CALL METHOD pr_data_changed-&amp;gt;get_cell_value
      EXPORTING
        i_row_id    = ps_good_class-row_id
        i_fieldname = ps_good_class-fieldname
      IMPORTING
        e_value     = l_class.

* If it's CLASS 'F' there is no problem at all
* because every value of SMOKER shall be possible then.
    IF l_class EQ 'F'.
      EXIT.
    ENDIF.

* If not, value of cell SMOKER has to be initial.
* First check if the value of field CLASS has been
* changed/entered newly, too:
    READ TABLE pr_data_changed-&amp;gt;mt_good_cells INTO ls_good_smoker
                        WITH KEY row_id    = ps_good_class-row_id
                                 fieldname = 'SMOKER'.
    IF sy-subrc EQ 0.
* get that new value:
      CALL METHOD pr_data_changed-&amp;gt;get_cell_value
        EXPORTING
          i_row_id    = ps_good_class-row_id
          i_fieldname = 'SMOKER'
        IMPORTING
          e_value     = l_smoker.
    ELSE.
* get current value
      READ TABLE gt_outtab INTO ls_outtab INDEX ps_good_class-row_id.
      l_smoker = ls_outtab-smoker.
    ENDIF.

* Since the class is not 'F' it has to be a non smoking person:
    IF NOT l_smoker IS INITIAL.
      CALL METHOD pr_data_changed-&amp;gt;add_protocol_entry
        EXPORTING
          i_msgid     = '0K'
          i_msgno     = '000'
          i_msgty     = 'W'
          i_msgv1     = text-m03         "Als Raucher dürfen Sie Klasse
          i_msgv2     = l_class
          i_msgv3     = text-m04         "nicht buchen
          i_fieldname = ps_good_class-fieldname
          i_row_id    = ps_good_class-row_id.

      error_in_data = 'X'.
    ENDIF.

  ENDMETHOD.                    "check_class
*--------------------------------------
ENDCLASS.                    "lcl_application_dc IMPLEMENTATION
***********************************************************************

*---------------------------------------------------------------------*
*       MAIN                                                          *
*---------------------------------------------------------------------*
END-OF-SELECTION.
  CALL SCREEN 100.

*---------------------------------------------------------------------*
*       MODULE PBO OUTPUT                                             *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
  SET PF-STATUS 'MAIN100'.
  SET TITLEBAR 'MAIN100'.
  IF g_custom_container IS INITIAL.
    PERFORM create_and_init_alv CHANGING gt_outtab[]
                                         gt_fieldcat.
  ENDIF.

ENDMODULE.                    "pbo OUTPUT
*---------------------------------------------------------------------*
*       MODULE PAI INPUT                                              *
*---------------------------------------------------------------------*
MODULE pai INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'EXIT'.
      PERFORM exit_program.

    WHEN 'REFRESH'.
      PERFORM refresh_outtab.
    WHEN 'SWITCH'.
      PERFORM switch_edit_mode.
    WHEN OTHERS.
*     do nothing
  ENDCASE.
ENDMODULE.                    "pai INPUT
*---------------------------------------------------------------------*
*       FORM EXIT_PROGRAM                                             *
*---------------------------------------------------------------------*
FORM exit_program.
  LEAVE PROGRAM.
ENDFORM.                    "exit_program
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  BUILD_FIELDCAT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_GT_FIELDCAT  text
*----------------------------------------------------------------------*
FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.

  DATA ls_fcat TYPE lvc_s_fcat.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = 'SBOOK'
    CHANGING
      ct_fieldcat      = pt_fieldcat.

  LOOP AT pt_fieldcat INTO ls_fcat.
* Exchange smoker field with invoice field - just to
* make the dependance between SMOKER and CLASS more transparent
* (Smoking is only allowed in the first class).
    IF ls_fcat-fieldname EQ 'SMOKER'.
      ls_fcat-col_pos = 11.
      ls_fcat-outputlen = 10.
      ls_fcat-edit = 'X'.
* Field 'checktable' is set to avoid shortdumps that are caused
* by inconsistend data in check tables. You may comment this out
* when the test data of the flight model is consistent in your system.
      ls_fcat-checktable = '!'.        "do not check foreign keys

      MODIFY pt_fieldcat FROM ls_fcat.

    ELSEIF ls_fcat-fieldname EQ 'INVOICE'.
      ls_fcat-col_pos = 7.
      MODIFY pt_fieldcat FROM ls_fcat.

    ELSEIF    ls_fcat-fieldname EQ 'CLASS'.

      ls_fcat-edit = 'X'.
      ls_fcat-outputlen = 5.
      ls_fcat-checktable = '!'.        "do not check foreign keys

      MODIFY pt_fieldcat FROM ls_fcat.
    ENDIF.
  ENDLOOP.

ENDFORM.                    "build_fieldcat
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  CREATE_AND_INIT_ALV
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_GT_OUTTAB  text
*      &amp;lt;--P_GT_FIELDCAT  text
*      &amp;lt;--P_GS_LAYOUT  text
*----------------------------------------------------------------------*
FORM create_and_init_alv CHANGING pt_outtab TYPE STANDARD TABLE
                                  pt_fieldcat TYPE lvc_t_fcat.

  DATA: lt_exclude TYPE ui_functions.

  CREATE OBJECT g_custom_container
    EXPORTING
      container_name = g_container.
  CREATE OBJECT g_grid
    EXPORTING
      i_parent = g_custom_container.

  PERFORM build_fieldcat CHANGING pt_fieldcat.

* Optionally restrict generic functions to 'change only'.
*   (The user shall not be able to add new lines).
  PERFORM exclude_tb_functions CHANGING lt_exclude.

  PERFORM build_data CHANGING pt_outtab.

  CALL METHOD g_grid-&amp;gt;set_table_for_first_display
    EXPORTING
      it_toolbar_excluding = lt_exclude
    CHANGING
      it_fieldcatalog      = pt_fieldcat
      it_outtab            = pt_outtab[].

* register f4 for field CLASS
  PERFORM register_events.

* Set editable cells to ready for input initially
  CALL METHOD g_grid-&amp;gt;set_ready_for_input
    EXPORTING
      i_ready_for_input = 1.

ENDFORM.                               "CREATE_AND_INIT_ALV

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  EXCLUDE_TB_FUNCTIONS
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_LT_EXCLUDE  text
*----------------------------------------------------------------------*
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
* Only allow to change data not to create new entries (exclude
* generic functions).

  DATA ls_exclude TYPE ui_func.

  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_copy_row.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_delete_row.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_append_row.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_insert_row.
  APPEND ls_exclude TO pt_exclude.
  ls_exclude = cl_gui_alv_grid=&amp;gt;mc_fc_loc_move_row.
  APPEND ls_exclude TO pt_exclude.

ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  build_data
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM build_data CHANGING pt_outtab TYPE STANDARD TABLE.
  DATA: ls_sbook TYPE sbook,
        l_index TYPE i.

  SELECT * FROM sbook INTO TABLE gt_outtab UP TO g_max ROWS."#EC CI_NOWHERE
  IF sy-subrc NE 0.
    PERFORM generate_entries CHANGING pt_outtab.
  ENDIF.

  LOOP AT pt_outtab INTO ls_sbook.
    l_index = sy-tabix.
    CLEAR ls_sbook-class.
* Alternate between smoker and non smoker to make
* it more obvious what this example is about
    l_index = l_index MOD 2.
    IF l_index EQ 1.
      ls_sbook-smoker = 'X'.
    ELSE.
      ls_sbook-smoker = ' '.
    ENDIF.
    MODIFY pt_outtab FROM ls_sbook.
  ENDLOOP.

ENDFORM.                               " build_data

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  generate_entries
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      &amp;lt;--P_LT_SLFIGHT  text
*----------------------------------------------------------------------*
FORM generate_entries CHANGING pt_sbook TYPE STANDARD TABLE.
  DATA: ls_sbook TYPE sbook,
        l_month(2) TYPE c,
        l_day(2) TYPE c,
        l_date(8) TYPE c,
  l_prebookid TYPE i.


  ls_sbook-carrid = 'LH'.
  ls_sbook-connid = '0400'.
  ls_sbook-forcurkey = 'DEM'.
  ls_sbook-loccurkey = 'USD'.
  ls_sbook-custtype = 'B'.

  DO 110 TIMES.
    l_prebookid = sy-index.

    ls_sbook-forcuram = sy-index * 10.
    ls_sbook-loccuram = ls_sbook-loccuram * 2.
    ls_sbook-customid = sy-index.
    ls_sbook-counter = 18.
    ls_sbook-agencynum = 11.

    l_month = sy-index / 10 + 1.
    DO 2 TIMES.
      l_day = 3 + l_month + sy-index * 2.
      l_date+0(4) = '2000'.
      l_date+4(2) = l_month.
      l_date+6(2) = l_day.
      ls_sbook-fldate = l_date.
      SUBTRACT 3 FROM l_day.
      ls_sbook-order_date+0(6) = l_date+0(6).
      ls_sbook-order_date+6(2) = l_day.
      ls_sbook-bookid = l_prebookid * 2 + sy-index.
      IF sy-index EQ 1.
        ls_sbook-smoker = 'X'.
      ELSE.
        ls_sbook-smoker = space.
      ENDIF.

      ls_sbook-luggweight = l_prebookid * 10.
      IF ls_sbook-luggweight GE 1000.
        ls_sbook-wunit = 'G'.
        ls_sbook-class = 'C'.
      ELSE.
        ls_sbook-wunit = 'KG'.
        ls_sbook-class = 'Y'.
      ENDIF.

      IF ls_sbook-bookid &amp;gt; 40 AND ls_sbook-wunit EQ 'KG'.
        ls_sbook-invoice = 'X'.
      ENDIF.
      IF ls_sbook-bookid EQ 2.
        ls_sbook-cancelled = 'X'.
        ls_sbook-class = 'F'.
      ENDIF.

      APPEND ls_sbook TO pt_sbook.
    ENDDO.
  ENDDO.
ENDFORM.                               " generate_entries
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  register_events
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM register_events.
*§1. Register event ONF4 at frontend using method
*    register_f4_for_fields. For this purpose, you pass a table
*    with all fields, for which you want to implement your own
*    f4 help.

* remark: If you want to use an own f4 help for fields where
*         no standard f4 help exists set field F4AVAILABL for
*         this field in the fieldcatalog.
  DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.

  CLEAR lt_f4.
  lt_f4-fieldname = 'CLASS'.
* If you would like to deregister the field again,
* pass value SPACE with field 'register'.
  lt_f4-register = 'X'.
*§  1b. If the value range in your f4 help depends on other
*       values of cells that are input enabled, set the
*       GETBEFORE parameter.
* The consequence is that the ALV Grid Control raises
* event DATA_CHANGED before the f4 help is called to
* check values that the f4 help depends on.
  lt_f4-getbefore = 'X'.
* The next parameter is used to change values after onf4 has
* been processed. The ALV Grid Control will raise
* event DATA_CHANGED afterwards, if you set it.
  lt_f4-chngeafter = space.
  INSERT table lt_f4.

  CALL METHOD g_grid-&amp;gt;register_f4_for_fields
    EXPORTING
      it_f4 = lt_f4[].

* register events for abap objects (backend)
  CREATE OBJECT g_onf4.
  SET HANDLER g_onf4-&amp;gt;on_f4 FOR g_grid.

  CREATE OBJECT g_dc.
  SET HANDLER g_dc-&amp;gt;handle_data_changed FOR g_grid.

ENDFORM.                    " register_events
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  STATUS_0101  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0101 OUTPUT.
  SET PF-STATUS 'POPUP'.
  SET TITLEBAR 'POPUP'.
  CALL METHOD g_onf4-&amp;gt;show_f4.
ENDMODULE.                 " STATUS_0101  OUTPUT
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  USER_COMMAND_0101  INPUT
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0101 INPUT.
  PERFORM user_command.
ENDMODULE.                 " USER_COMMAND_0101  INPUT
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  user_command
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM user_command.

  DATA: save_ok TYPE sy-ucomm.

  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'CANCEL'.
      CALL METHOD g_onf4-&amp;gt;reset.
      LEAVE SCREEN.
  ENDCASE.

ENDFORM.                    " user_command
*-------------------------------------------------------------------
FORM switch_edit_mode.

  IF g_grid-&amp;gt;is_ready_for_input( ) EQ 0.
* set edit enabled cells ready for input
    CALL METHOD g_grid-&amp;gt;set_ready_for_input
      EXPORTING
        i_ready_for_input = 1.

  ELSE.
* lock edit enabled cells against input
    CALL METHOD g_grid-&amp;gt;set_ready_for_input
      EXPORTING
        i_ready_for_input = 0.
  ENDIF.
ENDFORM.                               " SWITCH_EDIT_MODE

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  REFRESH_OUTTAB
*&amp;amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  --&amp;gt;  p1        text
*  &amp;lt;--  p2        text
*----------------------------------------------------------------------*
FORM refresh_outtab .
* define local data
  DATA: ls_outtab LIKE LINE OF gt_outtab.

" Retrieve selected F4 values from frontend to the ABAP backend
  g_grid-&amp;gt;check_changed_data( ).

" Update non-editable parts of the ALV list by the changed
" values of the editable columns
  LOOP AT gt_outtab INTO ls_outtab WHERE ( class = 'C' ).
    ls_outtab-custtype = 'U'.

    MODIFY gt_outtab FROM ls_outtab INDEX syst-tabix.
  ENDLOOP.

" Refresh list display
  g_grid-&amp;gt;refresh_table_display( ).

ENDFORM.                    " REFRESH_OUTTAB
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Jun 2008 16:04:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976119#M949694</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-06-29T16:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: f4 help in the GRID on the basis of other field</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976120#M949695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;solved myself&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2008 09:19:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/f4-help-in-the-grid-on-the-basis-of-other-field/m-p/3976120#M949695</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-10-30T09:19:23Z</dc:date>
    </item>
  </channel>
</rss>

