‎2007 Apr 30 4:04 PM
Hi Guys,
Any one Please Explain me How to create a Function Module. What are the steps involved What are the T- Codes For that Thanks in advance
Thanks
Kiran.B
‎2007 Apr 30 6:29 PM
You must first create a function group. Go to SE80, choose Function group from drop down list box. Enter the name of your function group, make sure it starts with "Z" or "Y". Hit enter, system will ask you if you want to create it, say yes. Give description, assign package(dev class) Now it is created, you can start creating function modules underneath. right click on the function group node on the tree to the left. Choose create, function module, give name and desription. Click green check. Now you need to put any import parameters, export parameters and the source code of the function module. Save and activate all.
reward helpful answers
Regards,
Venkat
‎2007 Apr 30 4:05 PM
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
se37 is the tcode to work with
‎2007 Apr 30 4:06 PM
goto se37...here u need to create a function group... then u need to create a function module. inside assign import/export parameters. assign tables/exceptions. activate the same. now write ur code within the function module.
check..
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
‎2007 Apr 30 4:06 PM
Hi Kiran,
Look at the below SAP HELP links, These links will show you the way to create a Function Module
http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
Regards
Sudheer
‎2007 Apr 30 4:08 PM
Hi kiran ,
se37 -> create -> fill all the records....
<b>Reward points if Helpfull</b>
Thanks
Chitrakant
‎2007 Apr 30 5:00 PM
Hi,
Refer this link,
http://help.sap.com/saphelp_47x200/helpdata/EN/9f/db988735c111d1829f0000e829fbfe/frameset.htm
Regards
Nilesh
‎2007 Apr 30 5:15 PM
Hi Kiran,
function modules are members of function groups.
In SE80, choose object type function groups, enter name, create.
Then rigth mouse-click on group name in tree, create function.
enter name and interface fields as required.
enter source code as required.
Activate.
Regards,
Clemens
‎2007 Apr 30 5:45 PM
Hi,
T-code for Function Module : SE37
You can only create function modules and function groups using the Function Builder in the ABAP Workbench.
An example to illustrate how a function module is created from the point of view of
ABAP programming:
1. Firstly, we create a new function group DEMO_SPFLI to hold the function module.Then, we can create the new function module.
2. You can specify the types of interface parameters in function modules in the
same way as the parameter interfaces of subroutines. Since function
modules can be used anywhere in the system, their interfaces can only contain
references to data types that are declared systemwide.
The function module READ_SPFLI_INTO_TABLE requires an import parameter
to restrict the selection to a single airline. To specify the type, we can refer to the
key field CARRID of the database SPFLI.
3. To pass data back to the calling program, the function module needs an export
parameter with the type of an internal table. For this, we define a systemwide
table type SPFLI_TAB with the line type SPFLI in the ABAP Dictionary.
4. Our function module needs an exception that it can trigger if there are no entries
in table SPFLI that meet the selection criterion. The exception NOT_FOUND
serves this function.
5. Having defined the parameter interface and exceptions, we can now write the
source code of our function module. To do this, choose Source code in the
Function Builder. This opens the ABAP Editor for the include program
L<fgrp>U<xx>. This is the include that will hold the program code for the function module.
The following program calls the function module READ_SPFLI_INTO_TABLE:
REPORT DEMO_FUNCTION_MODULE.
PARAMETERS CARRIER TYPE S_CARR_ID.
DATA: JTAB TYPE SPFLI_TAB,
WA LIKE LINE OF JTAB.
CALL FUNCTION 'READ_SPFLI_INTO_TABLE'
EXPORTING
ID = CARRIER
IMPORTING
ITAB = JTAB
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
CASE SY-SUBRC.
WHEN 1.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO.
WHEN 2.
MESSAGE E702(AT).
ENDCASE.
LOOP AT JTAB INTO WA.
WRITE: / WA-CARRID, WA-CONNID, WA-CITYFROM, WA-CITYTO.
ENDLOOP.
The actual parameters CARRIER and JTAB have the same data types as their
corresponding interface parameters in the function module. The exception
NOT_FOUND is handled in the program. It displays the same message that the
function module would have displayed had it handled the error.
Regards,
Bhaskar
‎2007 Apr 30 6:29 PM
You must first create a function group. Go to SE80, choose Function group from drop down list box. Enter the name of your function group, make sure it starts with "Z" or "Y". Hit enter, system will ask you if you want to create it, say yes. Give description, assign package(dev class) Now it is created, you can start creating function modules underneath. right click on the function group node on the tree to the left. Choose create, function module, give name and desription. Click green check. Now you need to put any import parameters, export parameters and the source code of the function module. Save and activate all.
reward helpful answers
Regards,
Venkat
‎2007 Apr 30 6:30 PM
Hi
Check the following Methods
Follow the steps.
Step 1.
GO to transaction SE80.In the drop box list select function group enter your Z Function group name.Press enter it will ask for creating the function group.Create your function group.
OR
In SE37 transaction,in the menu bar Goto - > Function Group - > Create Group.Your Function Group will be created.
Step 2.
Go to transaction SE37.Enter your Z Function module name,your recently created function group name and the description.Press Enter.Now your FM is created.
Step 3.
Enter Export,Import parameters.In the source code tab write the code what you want to write.If any exception write in the exception tab.
Method 2)
First u have to create Function Group.
1.se37->Goto->Function Group--->Create.
2.Create FM.
3.maintain import /export parameters and tables , exceptions.
4.based on the ur requirement u have to bulid ur logic in Source Code by using there Import parameters and u can pass the results by using Export or table.
5.u can raise error by using exception.
see simpple FM AC_DOCUMENT_RECORD
Regards
Venkat
‎2007 Jun 08 7:17 AM
hi kiran,
see this might be of some help.
to create function module you have to create a a function group.
and then you create function module.
in function module you have to give IMPORT , EXPORT PARAMETER and EXCEPTION.
and also the SOURCE CODE without which the function module will be sytaxtically correct but you will get processing error.
here is the procedure of creating Function Group and Function Module
FOR Group
goto SE37
move to GOTO and the to function groups and create .
just fill the fields poped up.
FOR Module
now in the se37 screen put the name of the function module you want to create and press create .
there will be a pop asking for function group name now here put you function group name which you have created.
now after pressing save you will have a screen in which you have to enter the import, export,exception and the source code.
in import parameter you can put this(for example)
parameter type associate type
num1 type i
num2 type i
export parameter
parameter type associate type
res type i
exception
parameter type associate type
not a valid entry.
source code
res = num1+num2.
if num1 eq 0
raise not a valid entry.
end if
save activate .
done
note:
alway press enter after putiin the parameter.
anuj
hope this might help you.
Message was edited by:
anuj anuj
‎2007 Jun 08 7:58 AM
hi kiran,
se37 is the transaction code to create function module.
‎2007 Jun 08 7:59 AM
Hi kiran
GO to transaction SE80.In the drop box list select function group enter your Z Function group name.Press enter it will ask for creating the function group.Create your function group.
OR
In SE37 transaction,in the menu bar Goto - > Function Group - > Create Group.Your Function Group will be created.
Step 2.
Go to transaction SE37.Enter your Z Function module name,your recently created function group name and the description.Press Enter.Now your FM is created.
Step 3.
Enter Export,Import parameters.In the source code tab write the code what you want to write.If any exception write in the exception tab.
Method 2)
First u have to create Function Group.
1.se37->Goto->Function Group--->Create.
2.Create FM.
3.maintain import /export parameters and tables , exceptions.
4.based on the ur requirement u have to bulid ur logic in Source Code by using there Import parameters and u can pass the results by using Export or table.
5.u can raise error by using exception.
check these links
http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
http://www.sap-img.com/abap-function.htm
Reward if helpfull answers
Regards
Pavan
‎2007 Jun 25 3:12 PM
hi kiran,
to create a function module first you need to create a function group
step1 : goto t.code se37
step2 :select GOTO (in menu bar) then function group and then create function
group.
step3: now create the function module and when ask for function group give the
name of the func group which you have created .
step4:now give the import and the export parameter and there associated type.
step5 give the source cod eaccording to the reqiurement
step6: save activate and exicute
hope this might help help
anuj