Steps
- Go to Transaction Code SE38.
- Enter the program name start's with Y or Z<program name > and click on Create Button.
Creating custom select-options
- Go to transaction code SE11.
- Click on Data Type radio button.
- Enter the standard SELECT-OPTIONS structure name i.e RSDSELOPT.
- Click on Copy .
- Pop-up will appear.
- Customize select-options name and click on continue.
CLASS C1 DEFINITION.
PUBLIC SECTION.
METHODS : FETCH_DATA IMPORTING IM_MATNR TYPE ZSEL
CHANGING CH_ITAB TYPE MAKT_ITAB,
DISPLAY IMPORTING IM_ITAB TYPE MAKT_ITAB.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS C1 IMPLEMENTATION.
METHOD FETCH_DATA.
SELECT * FROM MAKT INTO TABLE CH_ITAB WHERE MATNR BETWEEN
IM_MATNR-LOW AND IM_MATNR-HIGH.
ENDMETHOD.
METHOD DISPLAY.
DATA : WA_MAKT TYPE MAKT.
LOOP AT IM_ITAB INTO WA_MAKT.
WRITE : / WA_MAKT-MATNR ,WA_MAKT-SPRAS , WA_MAKT-MAKTX.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
TABLES : MAKT.
DATA : OBJ TYPE REF TO C1.
DATA : IT_MAKT TYPE TABLE OF MAKT.
SELECT-OPTIONS : S_MATNR FOR MAKT-MATNR.
START-OF-SELECTION.
CREATE OBJECT OBJ.
CALL METHOD OBJ->FETCH_DATA
EXPORTING
IM_MATNR = S_MATNR
CHANGING
CH_ITAB = IT_MAKT .
CALL METHOD OBJ->DISPLAY
EXPORTING
IM_ITAB = IT_MAKT.
No comments:
Post a Comment