Saturday, 2 July 2016

Passing select-options(range of values) and internal table as parameters in Normal Function Module

Steps


To create function module

  • Go to transaction code SE37.

  • Enter the function module name start's with Y or Z<function module name> and click on create button.





  • Enter the function group name.
  • Enter the short description.
  • Click on SAVE button


  • Pop-up will appear. Click on continue.
  • Click on import tab , enter the select-option variable and its type.

To create select-option
  • Go to Transaction code SE11.
  • Enter the Data Type (Structure ) name : RSDSSELOPT




  • Click on Display button.
  • RSDSSELOPT structure matches the structure of Select-options.
  • Copy the structure.

  • Pop-up will appear.
  • Enter the copy structure name and click on continue.





  • Change the Low and high's Data Element.


  • Save -> Check -> Activate.

  • Copy the newly created select-option structure name and go back to Transaction code SE37.
  • Click on Tables Tab and enter the internal table name and it's type.
  • Click on Source code tab.
  • Source code
RANGES R_MATNR FOR MAKT-MATNR.


R_MATNR-SIGN 'I'.
R_MATNR-OPTION 'BT'.
R_MATNR-LOW S_MATNR-LOW.
R_MATNR-HIGH S_MATNR-HIGH.

APPEND R_MATNR .

SELECT FROM MAKT INTO TABLE IT_MAKT WHERE MATNR IN R_MATNR.




  • Save -> Check -> Activate.

Usage of function module

  • Go to transaction code SE38.
  • Enter the program name start's with Y or Z<program name > and click on create button.
  • Enter the Title.
  • Select Attribute Type as Executable Program.
  • Click on save button.


Source code


TABLES MAKT.
DATA IT_MAKT TYPE TABLE OF MAKT.

SELECT-OPTIONS S_MATNR FOR MAKT-MATNR.

call function 'ZPASS_SELECT_INT_TAB'
  exporting
    s_matnr       S_MATNR
  tables
    it_makt       IT_MAKT
          .

IF SY-SUBRC 0.

  LOOP AT IT_MAKT INTO MAKT.

    WRITE / MAKT-MATNR MAKT-SPRAS MAKT-MAKTX.

  ENDLOOP.

ENDIF.


  • Save -> Check ->Activate.
  • Execute.

Input



Output




4 comments:

  1. thank you very much . Great help for beginners.

    ReplyDelete
  2. Thanks for the properly explaining this. Could you also explain is there any alternate solution for this or is this the only solution. Thanks in advance!

    ReplyDelete