Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

F4 Help in ALV Grid (using CL_GUI_ALV_GRID)

Former Member
0 Kudos

Hi Friends,

I have created a report which has a ALV Grid control. In the output one of the column X (from Z table) is editable and should have F4 help. Data element of X column has a searchhelp attached with. While creating Fieldcatlog set the ref_field & ref_table columns.

When I press F4 button column X on grid, I'm able to get Popup and able to select value among the list. But the value whatever selected should be moved (in DATA_CHANGED event) to the internal table which is base for report output. But for the same if I remove F4 then the value is being moved to internal table.

Why system is behaving like this for F4 fields? How to move value selected in F4 field to internal table? If anyone knows answer, please reply..

Regards

Jaker.

4 REPLIES 4

former_member156446
Active Contributor
0 Kudos

in the search help for that field IMP(importing) checkbox need to be checked.. SE11> Search help name..

Former Member
0 Kudos

Hi,

Develop a method in your class as follows.

CLASS CL_PRICE_DATA DEFINITION.
PUBLIC SECTION.
ON_F4
FOR EVENT ONF4 OF CL_GUI_ALV_GRID
IMPORTING ES_ROW_NO E_FIELDNAME ER_EVENT_DATA.

CLASS CL_PRICE_DATA IMPLEMENTATION.

    *
          o F4 for Reason Code

METHOD ON_F4.

FIELD-SYMBOLS: <FT_MODI> TYPE LVC_T_MODI .
REFRESH :GT_FIELD_TAB,GT_VALUE_TAB,GT_RETURN.
IF E_FIELDNAME = 'CTMBRCHGREASCD'.

LOOP AT VALUES_TAB INTO VALUE_TAB.
MOVE VALUE_TAB-CTMBRCHGREASCD TO GS_VALUE_TAB-STRING .
APPEND GS_VALUE_TAB TO GT_VALUE_TAB.
CLEAR : GS_VALUE_TAB.
MOVE VALUE_TAB-CTMBRCHGRSNDSC TO GS_VALUE_TAB-STRING .
APPEND GS_VALUE_TAB TO GT_VALUE_TAB.
CLEAR :GS_VALUE_TAB.
ENDLOOP.

GS_FIELD_TAB-FIELDNAME = 'CTMBRCHGREASCD' .
GS_FIELD_TAB-TABNAME = '/CPC/TCTMBRCHG'.
APPEND GS_FIELD_TAB TO GT_FIELD_TAB.
clear GS_FIELD_TAB.

GS_FIELD_TAB-FIELDNAME = 'CTMBRCHGRSNDSC' .
GS_FIELD_TAB-TABNAME = '/CPC/TCTMBRCHG'.
APPEND GS_FIELD_TAB TO GT_FIELD_TAB.
clear GS_FIELD_TAB.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'CTMBRCHGREASCD'
VALUE_ORG = 'C'
TABLES
VALUE_TAB = GT_VALUE_TAB
FIELD_TAB = GT_FIELD_TAB
RETURN_TAB = GT_RETURN.
ASSIGN ER_EVENT_DATA->M_DATA->* TO <FT_MODI>.

GWA_MODI-ROW_ID = ES_ROW_NO-ROW_ID.

LOOP AT GT_RETURN INTO GWA_LS_RETURN .
GWA_MODI-FIELDNAME = GWA_LS_RETURN-FIELDNAME.
GWA_MODI-VALUE = GWA_LS_RETURN-FIELDVAL.
INSERT GWA_MODI INTO TABLE <FT_MODI>.
READ TABLE VALUES_TAB INTO VALUE_TAB WITH KEY CTMBRCHGREASCD =
GWA_LS_RETURN-FIELDVAL.
GWA_MODI-FIELDNAME = 'CTMBRCHGRSNDSC'.
GWA_MODI-VALUE = VALUE_TAB-CTMBRCHGRSNDSC.
INSERT GWA_MODI INTO TABLE <FT_MODI>.
ENDLOOP.

ER_EVENT_DATA->M_EVENT_HANDLED = 'TRUE'.
ELSEIF E_FIELDNAME = 'CONTMBRSTATCODE'.
loop at gt_member_status into gs_member_status.
MOVE gs_member_status-status TO GS_VALUE_TAB-STRING .
APPEND GS_VALUE_TAB TO GT_VALUE_TAB.
CLEAR : GS_VALUE_TAB.

    * MOVE gs_member_status-description TO GS_VALUE_TAB-STRING .
    * APPEND GS_VALUE_TAB TO GT_VALUE_TAB.
    * CLEAR :GS_VALUE_TAB.

endloop.

GS_FIELD_TAB-FIELDNAME = 'CONTMBRSTATCODE' .
GS_FIELD_TAB-TABNAME = '/CPC/TCTMBRHST'.
GS_FIELD_TAB-reptext = 'Member Status'.
APPEND GS_FIELD_TAB TO GT_FIELD_TAB.
clear GS_FIELD_TAB .

    * GS_FIELD_TAB-FIELDNAME = 'CTSTATSHRTDESC' .
    * GS_FIELD_TAB-TABNAME = '/CPC/TCONSTAT'.
    * APPEND GS_FIELD_TAB TO GT_FIELD_TAB.


    * GS_FIELD_TAB-FIELDNAME = 'CTMBRCHGRSNDSC' .
    * GS_FIELD_TAB-TABNAME = '/CPC/TCTMBRCHG'.
    * APPEND GS_FIELD_TAB TO GT_FIELD_TAB.


CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'CONTMBRSTATCODE'
VALUE_ORG = 'C'
TABLES
VALUE_TAB = GT_VALUE_TAB
FIELD_TAB = GT_FIELD_TAB
RETURN_TAB = GT_RETURN.
ASSIGN ER_EVENT_DATA->M_DATA->* TO <FT_MODI>.

GWA_MODI-ROW_ID = ES_ROW_NO-ROW_ID.

LOOP AT GT_RETURN INTO GWA_LS_RETURN .
GWA_MODI-FIELDNAME = GWA_LS_RETURN-FIELDNAME.
GWA_MODI-VALUE = GWA_LS_RETURN-FIELDVAL.
INSERT GWA_MODI INTO TABLE <FT_MODI>.

    * READ TABLE VALUES_TAB INTO VALUE_TAB WITH KEY CTMBRCHGREASCD =
    * GWA_LS_RETURN-FIELDVAL.
    * GWA_MODI-FIELDNAME = 'CTMBRCHGRSNDSC'.
    * GWA_MODI-VALUE = VALUE_TAB-CTMBRCHGRSNDSC.
    * INSERT GWA_MODI INTO TABLE <FT_MODI>.

ENDLOOP.
ER_EVENT_DATA->M_EVENT_HANDLED = 'TRUE'.
ELSEIF E_FIELDNAME = 'SH_CUST_NMBR'.
LOOP AT GT_SHARED_CUSTOMER INTO GS_SHARED_CUSTOMER.

SELECT SINGLE CUST_NAME FROM /CPC/TCUSTOMER INTO
GS_SHARED_CUSTOMER-CUST_NAME
WHERE CUST_NMBR = GS_SHARED_CUSTOMER-SH_CUST_NMBR.
MOVE GS_SHARED_CUSTOMER-SH_CUST_NMBR TO GS_VALUE_TAB-STRING .
APPEND GS_VALUE_TAB TO GT_VALUE_TAB.
CLEAR : GS_VALUE_TAB.
MOVE GS_SHARED_CUSTOMER-CUST_NAME TO GS_VALUE_TAB-STRING .
APPEND GS_VALUE_TAB TO GT_VALUE_TAB.
CLEAR : GS_VALUE_TAB.
ENDLOOP.

GS_FIELD_TAB-FIELDNAME = 'SH_CUST_NMBR' .
GS_FIELD_TAB-TABNAME = '/CPC/TGRPSHRHLD'.
APPEND GS_FIELD_TAB TO GT_FIELD_TAB.
clear GS_FIELD_TAB.

GS_FIELD_TAB-FIELDNAME = 'CUST_NAME' .
GS_FIELD_TAB-TABNAME = '/CPC/TCUSTOMER'.
APPEND GS_FIELD_TAB TO GT_FIELD_TAB.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'SH_CUST_NMBR'
VALUE_ORG = 'C'
TABLES
VALUE_TAB = GT_VALUE_TAB
FIELD_TAB = GT_FIELD_TAB
RETURN_TAB = GT_RETURN.
ASSIGN ER_EVENT_DATA->M_DATA->* TO <FT_MODI>.

GWA_MODI-ROW_ID = ES_ROW_NO-ROW_ID.

LOOP AT GT_RETURN INTO GWA_LS_RETURN .
GWA_MODI-FIELDNAME = GWA_LS_RETURN-FIELDNAME.
GWA_MODI-VALUE = GWA_LS_RETURN-FIELDVAL.
INSERT GWA_MODI INTO TABLE <FT_MODI>.
ENDLOOP.
ER_EVENT_DATA->M_EVENT_HANDLED = 'TRUE'.
ENDIF.
ENDMETHOD.

This will trigger when do a F4 on the field .

Apart from this in the fieldcatalog for that field assign 'X' for the field F4AVAILABL and also set handler eventobj->on_f4 for grid .

Thanks

Vikranth

Former Member
0 Kudos

Hi,

chk this BCALV_TEST_GRID_F4_HELP

Thanks

Vikranth