Thursday 8 December 2011

Help Value Request (F4)

This sample program demonstrate how to create "Help Value Request". It will appear when user pressing F4 (help) on an input field to request list of available value.

To do this we are using function module F4IF_INT_TABLE_VALUE_REQUEST. It provide help value request with following feature:
1. single / multiple choice.
2. update screen without PBO, so it can be used to update more than one field on one request.

Here is the code:


REPORT ZAALGAL0003 .

TABLES: usr02.

parameters: p_bname LIKE usr02-bname,
p_class LIKE usr02-class.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_bname.
PERFORM f_valuerequest_vbeln.
*&---------------------------------------------------------------------*
*& Form f_valuerequest_vbeln
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_valuerequest_vbeln.

DATA: BEGIN OF t_data OCCURS 1,
data(20),
END OF t_data.

DATA: lwa_dfies TYPE dfies.

data h_field_wa LIKe dfies.
data h_field_tab like dfies occurs 0 with header line.
data h_dselc like dselc occurs 0 with header line.

SELECT * FROM usr02.
t_data = usr02-bname. APPEND t_data.
t_data = usr02-class. APPEND t_data.
ENDSELECT.

PERFORM f_fieldinfo_get USING 'USR02'
'BNAME'
CHANGING h_field_wa.
APPEND h_field_wa TO h_field_tab.
PERFORM f_fieldinfo_get USING 'USR02'
'CLASS'
CHANGING h_field_wa.
APPEND h_field_wa TO h_field_tab.

h_dselc-fldname = 'BNAME'.
h_dselc-dyfldname = 'P_BNAME'.
APPEND h_dselc.
h_dselc-fldname = 'CLASS'.
h_dselc-dyfldname = 'P_CLASS'.
APPEND h_dselc.

DATA: ld_repid LIKE sy-repid.
ld_repid = sy-repid.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'P_BNAME'
dynpprog = ld_repid
dynpnr = '1000'
dynprofield = 'P_BNAME'
* multiple_choice = ''
* value_org = 'S'
TABLES
value_tab = t_data
field_tab = h_field_tab
* return_tab = return_tab
DYNPFLD_MAPPING = h_dselc
EXCEPTIONS
OTHERS = 0.

ENDFORM. " f_valuerequest_vbeln
*&---------------------------------------------------------------------*
*& Form f_fieldinfo_get
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0079 text
* -->P_0080 text
* <--P_H_FIELD_WA text
*----------------------------------------------------------------------*
FORM f_fieldinfo_get USING fu_tabname
fu_fieldname
CHANGING fwa_field_tab.


CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
TABNAME = fu_tabname
FIELDNAME = fu_fieldname
LFIELDNAME = fu_fieldname
IMPORTING
DFIES_WA = fwa_field_tab
EXCEPTIONS
NOT_FOUND = 1
INTERNAL_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


ENDFORM. " f_fieldinfo_get

No comments:

Post a Comment