Tuesday, May 1, 2012

How to create a functional module

A function module can only be created within a function group.
To create a function group click goto-function groups- create function group.
give a name for the function group then give a short text.

click Goto -main prog.
It will have 2 include prog.
1-maintop
1-mainuxx
in the first prog u can define variables and other things which u can use in the any of the function modules which come under that.
in the second one all the function module which falls under it will appear.

Go to SE37.
give a functional module name with z  and press f5 or press create.
In Import tab type parameter name type data element name in associated type and if you want to give it a default value. u can give it now in the default value column and u press enter, the short text will get filled automatically.


In export tab give a it table name. For that create a table type in se11.
Creating in se11.
click on table type. give a name with z  and press f5 or press create.
in short text  give a short description. In line type give the table name, u want it to take the structure of .
and press activate and save.

now go to se37 screen and give the table type in the function module creation screen and press enter.

go to exceptions. Give the possible exceptions that the system will throw out.
now goto source code and do a  select command. write a sy-subrc in that in the else command give RAISE and the name of the exception.

In Attributes, u can select either normal function module or remote enabled module(RFC).
If it is RFC then it can be accessed by softwares other than SAP. It is mainly helpful for BAPI.
If it is rfc the all the field in the function module should be passed only by value.
That means in Import , export and other tabs u should put tick on pass by value field.
If it is not rfc it is not nessary to pass by value.
Now save and activate.




No comments:

Post a Comment