Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to create the funtion module with step by step

Former Member
0 Kudos

friends can u help me regarding how to create the function module very urgent,

regards

bhavani

6 REPLIES 6

former_member386202
Active Contributor
0 Kudos

Hi,

Got SE37 give name -> create. THen give importing n exporting parameters .

Regards,

Prashant

Former Member
0 Kudos

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

Former Member
0 Kudos

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

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>

Former Member
0 Kudos

Goto Se37...

Give the name as you want (with prefix Z)

Click "Create"

It will ask you the function group...to specify...

if you want to create under any existing function group select it....otherwise you can create your own function group...

after that , give your importing and exporting parameters...

importing ===== receiving from program

exporting ===== returning to program

changing ===== receiving / returning

tables ===== to get tables from program

exceptions -===== to raise error message...

methods ===== you can define your own methods..for processing...

save & activate...

Former Member
0 Kudos

Hi,

plz check with this link in detail.

<u>http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm</u>

<a href="http://help.sap.com/saphelp_nw70/helpdata/en/9f/db98ef35c111d1829f0000e829fbfe/content.htm">http://help.sap.com/saphelp_nw70/helpdata/en/9f/db98ef35c111d1829f0000e829fbfe/content.htm</a>

<a href="http://searchsap.techtarget.com/tip/0,289483,sid21_gci949881,00.html">http://searchsap.techtarget.com/tip/0,289483,sid21_gci949881,00.html</a>

Hope u undersatand these links might be helpful to u .

Regards,

sana.

Former Member
0 Kudos

Hi Durga,

Step1.

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 points, if useful.

Thanks,

Nitin.