Working with drop down list: -
‘VRM_SET_VALUES’ is the function module which is used to provide the drop down list to the input variable. The input for the above function module is
1.ID (fieldname, for which field we want to provide dropdown),
2.TEXT (Data Internal Table).
Note: - In VRM, we have one type that is VRM_VALUES which contains the above two fields. So we simply declare our internal table by referring VRM_VALUES.
PROGRAM:
*&---------------------------------------------------------------------*
*& Module Pool ZM_DROPDOWN_LIST
*&
*&---------------------------------------------------------------------*
PROGRAM ZM_DROPDOWN_LIST.
TYPE-POOLS VRM.
TABLES T001.
TYPES: BEGIN OF TY_T005T,
LAND1 TYPE T005T-LAND1,
LANDX TYPE T005T-LANDX,
END OF TY_T005T.
DATA: WA_T005T TYPE TY_T005T,
IT_T005T TYPE TABLE OF TY_T005T.
*&---------------------------------------------------------------------*
*& Module STATUS_1000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_1000 OUTPUT.
SET PF-STATUS 'STAT'.
* SET TITLEBAR 'xxx'.
DATA: IT TYPE VRM_VALUES,
WA LIKE LINE OF IT.
SELECT LAND1 LANDX FROM T005T INTO TABLE IT_T005T WHERE SPRAS = SY-LANGU.
LOOP AT IT_T005T INTO WA_T005T.
WA-KEY = WA_T005T-LAND1.
WA-TEXT = WA_T005T-LANDX.
APPEND WA TO IT.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'T001-LAND1'
VALUES = IT.
REFRESH IT.
ENDMODULE. " STATUS_1000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_1000 INPUT.
IF SY-UCOMM = 'BACK'.
LEAVE PROGRAM.
ELSEIF SY-UCOMM = 'INS'.
INSERT T001.
IF SY-SUBRC = 0.
MESSAGE S000(ZMESSAGE1) WITH 'INSERTED SUCCESSFULLY'.
ELSE.
MESSAGE E000(ZMESSAGE1) WITH 'NOT INSERTED'.
ENDIF.
ENDIF.
ENDMODULE. " USER_COMMAND_1000 INPUT
SCREEN 1000:
PROCESS BEFORE OUTPUT.
MODULE STATUS_1000.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_1000.
OUTPUT:
‘VRM_SET_VALUES’ is the function module which is used to provide the drop down list to the input variable. The input for the above function module is
1.ID (fieldname, for which field we want to provide dropdown),
2.TEXT (Data Internal Table).
Note: - In VRM, we have one type that is VRM_VALUES which contains the above two fields. So we simply declare our internal table by referring VRM_VALUES.
PROGRAM:
*&---------------------------------------------------------------------*
*& Module Pool ZM_DROPDOWN_LIST
*&
*&---------------------------------------------------------------------*
PROGRAM ZM_DROPDOWN_LIST.
TYPE-POOLS VRM.
TABLES T001.
TYPES: BEGIN OF TY_T005T,
LAND1 TYPE T005T-LAND1,
LANDX TYPE T005T-LANDX,
END OF TY_T005T.
DATA: WA_T005T TYPE TY_T005T,
IT_T005T TYPE TABLE OF TY_T005T.
*&---------------------------------------------------------------------*
*& Module STATUS_1000 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_1000 OUTPUT.
SET PF-STATUS 'STAT'.
* SET TITLEBAR 'xxx'.
DATA: IT TYPE VRM_VALUES,
WA LIKE LINE OF IT.
SELECT LAND1 LANDX FROM T005T INTO TABLE IT_T005T WHERE SPRAS = SY-LANGU.
LOOP AT IT_T005T INTO WA_T005T.
WA-KEY = WA_T005T-LAND1.
WA-TEXT = WA_T005T-LANDX.
APPEND WA TO IT.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
ID = 'T001-LAND1'
VALUES = IT.
REFRESH IT.
ENDMODULE. " STATUS_1000 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_1000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_1000 INPUT.
IF SY-UCOMM = 'BACK'.
LEAVE PROGRAM.
ELSEIF SY-UCOMM = 'INS'.
INSERT T001.
IF SY-SUBRC = 0.
MESSAGE S000(ZMESSAGE1) WITH 'INSERTED SUCCESSFULLY'.
ELSE.
MESSAGE E000(ZMESSAGE1) WITH 'NOT INSERTED'.
ENDIF.
ENDIF.
ENDMODULE. " USER_COMMAND_1000 INPUT
SCREEN 1000:
PROCESS BEFORE OUTPUT.
MODULE STATUS_1000.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_1000.
OUTPUT: