2007 Oct 06 5:54 PM
Hi
Please tell me the procedure to create a function module.
Thanks in advance,
Priya
2007 Oct 08 5:08 AM
To create a function module, you first need to create a Function Group which will keep all the function module of same functionality.
To create a Function Group, go to SE80->Click on Workbench-Edit Object->Function Group Tab->Enter Function Group name-> Click Create.
To create a Function Module:
Go to T.Code SE37->Enter the Function name->Enter Function Group name n Short Des.-> Here you need to define Import, Export parameters with the condition. Also you can write your code in source code tab.
check this link
check the FM code. if you don't have this FM code, create it in SE37 and make use of it.
FM MONI_TIME_CONVERT
FUNCTION MONI_TIME_CONVERT.
*"----
""Lokale Schnittstelle:
*" IMPORTING
*" REFERENCE(LD_DURATION) TYPE SY-TABIX
*" EXPORTING
*" REFERENCE(LT_OUTPUT_DURATION) TYPE SWL_PM_CVH-DURATION
*"----
DATA: LD_HOUR(4) TYPE N. "
DATA: LD_MIN(4) TYPE N. "
DATA: LD_SEC(4) TYPE N. "
DATA: LD_VALUE2(2) TYPE N.
DATA: LD_VALUE3(3) TYPE N.
DATA: LD_VALUE4(4) TYPE N.
DATA: SAVE_DURATION LIKE SY-TABIX.
data: ld_minus(1).
SAVE_DURATION = LD_DURATION.
if ld_duration < 0.
save_duration = save_duration * ( -1 ).
ld_minus = true.
endif.
CLEAR LT_OUTPUT_DURATION.
IF SAVE_DURATION NE 0.
LD_HOUR = SAVE_DURATION DIV 3600.
save_duration = save_duration - ld_hour * 3600.
LD_MIN = SAVE_DURATION DIV 60.
save_duration = save_duration - ld_min * 60.
LD_SEC = SAVE_DURATION.
IF LD_HOUR LE 100.
LD_VALUE2 = LD_HOUR.
WRITE LD_VALUE2 TO LT_OUTPUT_DURATION+3(2).
ELSEIF LD_HOUR LE 1000.
LD_VALUE3 = LD_HOUR.
WRITE LD_VALUE3 TO LT_OUTPUT_DURATION+2(3).
ELSE.
LD_VALUE4 = LD_HOUR.
WRITE LD_VALUE4 TO LT_OUTPUT_DURATION(4).
ENDIF.
WRITE ':' TO LT_OUTPUT_DURATION+5.
LD_VALUE2 = LD_MIN.
WRITE LD_VALUE2 TO LT_OUTPUT_DURATION+6(2).
WRITE ':' TO LT_OUTPUT_DURATION+8.
LD_VALUE2 = LD_SEC.
WRITE LD_VALUE2 TO LT_OUTPUT_DURATION+9(2).
LT_OUTPUT_DURATION = LT_OUTPUT_DURATION+1.
if ld_minus = true.
write '-' to lt_output_duration+1(1).
endif.
ELSE.
job running or aborted
ENDIF.
ENDFUNCTION.
Eg:2
Use the following procedure to create a function module
1.From the ABAP/4 Development Workbench screen, press the Function Library button on the Application toolbar.
2.Type the name of your function module in the Function Module field. The name must begin with Y_ or Z_.
3.Press the Create button. The Function Module Create: Administration screen is shown
4.Type the name of a function group in the Function Group field. The function group name must be four characters long and must begin with Y or Z.
5.Type an S in the Application field. This field is used to indicate which function area uses the function module. Our functionality is not used by any functional area, it is simply an example, so any choice will do. (S indicates that the function module contains functionality needed by Basis.)
6.Type a description of the function module in the Short Text field. The contents of this field are seen when displaying a list of function modules.
Press the Save button on the Application toolbar.
7.If the function group does not already exist, a pop-up informs you of that fact and asks you if you want to create it. Press the Yes button to create the function group. The Create Function Group dialog box appears. Type a description in the Short Text field and press the Save button. The Create Object Catalog Entry screen appears. Press the Local Object button. You are returned to the Function Module Change: Administration screen.
8.Press the Source Code button on the Application toolbar. The Function Module Edit screen is displayed.
9.Type the source code for your function module. Do not change the system-generated comment lines under any circumstances! Your function module might fail to operate if you do.
10.Press the Save button on the Application toolbar. The message Program xxxxx saved appears in the status bar at the bottom of the window.
11.Press the Back button on the Application toolbar. You are returned to the Function Library Initial screen.
12.If you want to define import or export parameters, select the Import/Export Parameter Interface radio button. Press the Change pushbutton. You are shown the Import/Export Parameters screen (refer to Figure 19.6). Type the names of your parameters in the first column and enter any other desired characteristics for each parameter. When you are finished, press the Save button and then the Back button.
13.Finally, to activate your function module, press the Activate button on the Application toolbar of the Function Library Initial Screen.
http://www.erpgenie.com/abap/bapi/example.htm
Hope this helps.
Reward if helpful.
2007 Oct 08 7:19 AM
go to se37
Create a Function Group first..
Then create a FM and put the Function Group name in required field..
Give some import parmeters..
write code for import parameters and pass the result to export parameter..
Test it in a report in SE38 ...
u can test in SE37 also but giving input values and u ll get output...
2007 Oct 08 7:34 AM
hi,
to create a function module, you will have to create a function group first as each function module belongs to some function group.
this can be done using se37.
once the FM has been created and activated it can be included in a program.
2007 Oct 08 7:43 AM
Hi
pls follow these links:
http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
http://help.sap.com/saphelp_erp2004/helpdata/en/dc/6b7df143d711d1893e0000e8323c4f/content.htm
Pls reward if useful.
2007 Oct 08 11:07 AM
Hi
To Create Function Module first you need to create Function Group and Activate it.
First go to SE37 then
1. Goto>Function Groups>Create Group.
Here you need to give Group name and Short Text of group.
2. After Creating Function Group again:
Goto>Function Groups>Change Group.
Enter your Function Group name and press enter.
a dialog box will appear where you can see its status is inactive.
So, press Main Program Button and activate your function group.
NOW you Function Group is activated and and you can create Function Module in it.
Now Enter your Function Module Name and press create then
give your Function Group name in respective place and press enter.
Now you can give your Import/Export parameters and and if you want to use TABLES give it in TABLE section only not in Import/Export Parameters.
Then Write Logic in Source Code Tab and Activate it.
Check out the foll.links,
http://help.sap.com/saphelp_nw04/helpdata/en/d1/801ee8454211d189710000e8322d00/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
<b>Reward if usefull</b>