Report to provide F4 Help for Directory Names (Not File Names)
Requirement:
To display the Directory names of AL11 in Search help for the (Parameter) field on Screen.
Type: Classical Report
Logic:
*&---------------------------------------------------------------------*
*& Report ZAG_TRYTWO_NEW_FM2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zag_trytwo_new_fm2.
*==================
* Data Declarations
*==================
* For Standard Program RSWATCH0 Data
DATA: I_OUTTAB TYPE STANDARD TABLE OF CST_RSWATCH01_ALV,
WA_OUTTAB TYPE CST_RSWATCH01_ALV,
LW_FNAME TYPE CHAR80 VALUE '(RSWATCH0)GT_OUTTAB'.
FIELD-SYMBOLS <LT_OUTTAB> TYPE STANDARD TABLE.
* Structure for Directory Name
TYPES: BEGIN OF T_OUTTAB1,
DIRNAME TYPE SHVALUE_D,
END OF T_OUTTAB1.
* Declaration of variables for FM - F4IF_INT_TABLE_VALUE_REQUEST
DATA: I_OUTTAB1 TYPE STANDARD TABLE OF T_OUTTAB1,
WA_OUTTAB1 TYPE T_OUTTAB1,
I_RETURN LIKE DDSHRETVAL OCCURS 0 WITH HEADER LINE.
* Inputs
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS: P_DIR TYPE CST_RSWATCH01_ALV-DIRNAME LOWER CASE.
SELECTION-SCREEN END OF BLOCK B1.
*======================
* Initialization Event
*======================
INITIALIZATION.
* Fetch Directory Names from RSWATCH0
PERFORM MAIN IN PROGRAM RSWATCH0.
ASSIGN (LW_FNAME) TO <LT_OUTTAB>.
CHECK SY-SUBRC EQ 0.
I_OUTTAB = <LT_OUTTAB>.
* Move the fetched directory names from I_OUTTAB to I_OUTTAB1 which supports Search Help logic
LOOP AT I_OUTTAB INTO WA_OUTTAB.
WA_OUTTAB1-DIRNAME = WA_OUTTAB-DIRNAME.
APPEND WA_OUTTAB1 TO I_OUTTAB1.
CLEAR: WA_OUTTAB1, WA_OUTTAB.
ENDLOOP.
*=============================
* At Selection-screen event
*=============================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_DIR.
CLEAR: I_RETURN.
* Function Module for F4 Help
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'DIRNAME'
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNNR
DYNPROFIELD = 'P_DIR'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = I_OUTTAB1
RETURN_TAB = I_RETURN
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE 'Error' TYPE 'E'.
ENDIF.
To display the Directory names of AL11 in Search help for the (Parameter) field on Screen.
Type: Classical Report
Logic:
- Data declarations
- Selection Screen
- Initialization event:
- Execute the 'MAIN' subroutine in Standard program 'RSWATCH0' to get the directory names
- Move the directory names to an internal table (due to data type mismatch on the fetched data) for Search help
- At Selection Screen Event:
- F4 help has to be provided for the field so we have to use ON VALUE REQUEST FOR the FIELD
- Use Function Module: F4IF_INT_TABLE_VALUE_REQUEST for displaying the search help
- On double clicking the required directory, the same will be displayed in the input field
*&---------------------------------------------------------------------*
*& Report ZAG_TRYTWO_NEW_FM2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zag_trytwo_new_fm2.
*==================
* Data Declarations
*==================
* For Standard Program RSWATCH0 Data
DATA: I_OUTTAB TYPE STANDARD TABLE OF CST_RSWATCH01_ALV,
WA_OUTTAB TYPE CST_RSWATCH01_ALV,
LW_FNAME TYPE CHAR80 VALUE '(RSWATCH0)GT_OUTTAB'.
FIELD-SYMBOLS <LT_OUTTAB> TYPE STANDARD TABLE.
* Structure for Directory Name
TYPES: BEGIN OF T_OUTTAB1,
DIRNAME TYPE SHVALUE_D,
END OF T_OUTTAB1.
* Declaration of variables for FM - F4IF_INT_TABLE_VALUE_REQUEST
DATA: I_OUTTAB1 TYPE STANDARD TABLE OF T_OUTTAB1,
WA_OUTTAB1 TYPE T_OUTTAB1,
I_RETURN LIKE DDSHRETVAL OCCURS 0 WITH HEADER LINE.
* Inputs
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
PARAMETERS: P_DIR TYPE CST_RSWATCH01_ALV-DIRNAME LOWER CASE.
SELECTION-SCREEN END OF BLOCK B1.
*======================
* Initialization Event
*======================
INITIALIZATION.
* Fetch Directory Names from RSWATCH0
PERFORM MAIN IN PROGRAM RSWATCH0.
ASSIGN (LW_FNAME) TO <LT_OUTTAB>.
CHECK SY-SUBRC EQ 0.
I_OUTTAB = <LT_OUTTAB>.
* Move the fetched directory names from I_OUTTAB to I_OUTTAB1 which supports Search Help logic
LOOP AT I_OUTTAB INTO WA_OUTTAB.
WA_OUTTAB1-DIRNAME = WA_OUTTAB-DIRNAME.
APPEND WA_OUTTAB1 TO I_OUTTAB1.
CLEAR: WA_OUTTAB1, WA_OUTTAB.
ENDLOOP.
*=============================
* At Selection-screen event
*=============================
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_DIR.
CLEAR: I_RETURN.
* Function Module for F4 Help
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'DIRNAME'
DYNPPROG = SY-CPROG
DYNPNR = SY-DYNNR
DYNPROFIELD = 'P_DIR'
VALUE_ORG = 'S'
TABLES
VALUE_TAB = I_OUTTAB1
RETURN_TAB = I_RETURN
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE 'Error' TYPE 'E'.
ENDIF.
Comments
Post a Comment