Friday 1 July 2016

Simple example ( Division operation ) for creating Normal function module and usage

Steps:

  • 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 attribute tab and select Normal Function Module.
  • Enter the import parameters.
  • Enter the export parameters.
  • Click on exception tab and enter the exceptions.
  • Click on source code tab.

Source code


IF  NUM1 IS INITIAL AND NUM2 IS INITIAL.
   RAISE INITIAL_VALUE.

ELSEIF NUM2 IS INITIAL.

   RAISE DIVIDE_BY_ZERO.

 ELSE.

   RES NUM1 / NUM2.
ENDIF.



  • Save -> Check -> Activate.

Usage of function module



Steps

  • 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.




  • Enter the source code ,

To call function module

  • Click on Pattern .

  • Pop-up will appear.
  • Source code look like this,
  • Pass program's import and export parameters
  • Note : Enable import / export / exceptions using "CTRL +  >".
  • Handle output as well as exceptions.
  • Save -> Check -> Activate.
  • Execute (F8).

Input-1

  • Without input value's.

Output

  • Execute

Input-2

  • Enter N1  value and do not enter the value N2.
  • Execute.

Input-3

  • Enter N1 and N2 values.
  • Execute.

                                           more information..................



No comments:

Post a Comment