‎2007 May 22 7:38 AM
can sombody tell me how to create a function module of our own. where to create it and how to create it.
‎2007 May 22 7:42 AM
hi,
1. go to se37.
2. create an ZFUNCTION_NAME.
3. provide the import and export parameters.
4. save and activate.
5. Fm is ready
Regards
Reshma
‎2007 May 22 7:40 AM
Check the link -
[Removed by the moderator.]
Regards,
Amit
Reward all helpful replies.
‎2007 May 22 7:42 AM
hi,
1. go to se37.
2. create an ZFUNCTION_NAME.
3. provide the import and export parameters.
4. save and activate.
5. Fm is ready
Regards
Reshma
‎2007 May 25 7:48 AM
h reshma can you please help me out with user exit.
i have created a function module exit for the transaction pa40. this exit is performing some change on the Exit for Calculating Salary Percentage from IT0008 . now my question is where vl this fuction module exit be called from.
‎2007 May 25 8:14 AM
Hi,
As u have written the code in FM exit, this FM will trigger whenever u execute ur TCODE : PA40
activate ur include which is within FM.
Revert back if nay issues.
Reward with points if helpful.
Regards,
Naveen
‎2007 May 25 8:43 AM
hi naveen my business scenario is that vn ever i choose the action suspended then if the person is suspend for 0 to 90 days his gross salary should be deducted to 50% else if more then 90 days then his 75 % sal should be deducted.
now using the exit exit_saplpara_002 how can i do the work please help me out with this. please got hrough this exit and tell me what should i write in its include.
waiting for ur reply.
‎2007 May 22 7:49 AM
go to transaction code se37
1st u have to create function group starting with Z
for creating function group
goto>function groups>create group
give package name if it is for ur development then give $tmp
then give any name starting with Z then press F5 or press create then it will ask for function group and short text enter what ever the function group u have created and a short text after that press enter then it wil display an msg as
<b>Function module name is reserved for SAP</b>
then press enter
after that it will directly lead to the function module in which
<b>Import</b>
specify parameter name and in type if it is table then specify LIKE then in associated type enter the table name and field name also as follows
PERNR-PERNR
then at last enter a short text for ur field
same in the case of export parameters also
then in source code define ur code
Rewards if helpfull
Regards
Pavan
‎2007 May 22 8:30 AM
‎2007 May 22 9:27 AM
suppose that i got to generate a function module in which i want to added two number then how to do this. like do i have to write anything in the source code. please reply fast
‎2007 May 22 10:26 AM
Hi madhvi
If the points are helpfull then give points so that it will be boosting to our helpers
and coming to ur code
data: f1 type i,
f2 type i,
tot1 type i,
tot2 type i,
begin of s,
c1 type i value 5,
c2 type i value 6,
c3 type i value 7,
c4 type i value 7,
c5 type i value 8,
c6 type i value 9,
end of s.
do 3 times varying f1 from s-c1 next s-c3
varying f2 from s-c2 next s-c4.
write: / f1, f2.
add: f1 to tot1,
f2 to tot2.
enddo.
write: / '_____________ _____________',
/ tot1,tot2.
ENDFUNCTION.
Rewards if helpfull
Regards
Pavan
‎2007 May 22 11:37 AM
im really sorry.
wat i would like to know is that im passing certain import parameters to fuc module from the main report now in the Func module how to pass these parameters. i hope you got my question
‎2007 May 22 11:41 AM
Declare the parameter same as the type in FM in calling program and pass this to FM. Same for table also.
‎2007 May 22 12:23 PM
Hi madhvi
If u want to declare function module which was already created then u can go through this code this is sample try to understand this is simple coding for u
DATA OBJ TYPE WWWDATATAB.
DATA VERSION TYPE WWWVERSION.
DATA CNDPKEY TYPE CNDP_ASYNC_KEY.
DATA NAMESPACE TYPE CNDP_ASYNC_NAME.
DATA VERSION_TAIL(256) TYPE C.
DATA LIC_NUM(10) TYPE C.
DATA nothing_found TYPE C.
DATA OBJID_DUMMY TYPE W3OBJID.
OBJ-OBJID = OBJID.
OBJ-RELID = 'MI'.
NAMESPACE = CNDP_ASYNC_WEB_NAMESPACE.
CALL FUNCTION 'GET_VERSION_WEB_OBJECT'
EXPORTING
KEY = OBJ
IMPORTING
VERSION = VERSION.
IF VERSION IS INITIAL.
SELECT SINGLE OBJID FROM WWWPARAMS into OBJID_DUMMY
WHERE RELID = obj-RELID
AND OBJID = obj-OBJID.
if sy-subrc ne 0.
nothing_found = 'X'.
endif.
endif.
IF nothing_found IS INITIAL.
CNDPKEY = OBJID.
concatenate '?' 'Version=' Version into VERSION_TAIL. "#EC NOTEXT
CALL FUNCTION 'SLIC_GET_LICENCE_NUMBER'
IMPORTING
LICENSE_NUMBER = LIC_NUM.
* Generate Namespace from werrepository namespace + licence number
concatenate CNDP_ASYNC_WEB_NAMESPACE '/' LIC_NUM into Namespace.
CALL FUNCTION 'DP_GENERATE_ASYNC_URL'
EXPORTING
NAMESPACE = Namespace
KEY = CNDPKEY
TAIL = VERSION_TAIL
IMPORTING
URL = URL
EXCEPTIONS
DP_INVALID_PARAMETERS = 1
DP_ERROR_GENERAL = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
RAISE DP_ERROR_PUBLISH.
ENDIF.
PERFORM REGISTER_DATAREQUEST_HANDLER.
CALL FUNCTION 'DP_PUBLISH_URL'
EXPORTING
NAMESPACE = NAMESPACE
KEY = CNDPKEY
LIFETIME = LIFETIME
CHANGING
URL = URL
EXCEPTIONS
DP_INVALID_PARAMETERS = 1
DP_NO_CACHE = 2
DP_ERROR_GENERAL = 3
DATA_SOURCE_ERROR = 4
DP_SEND_DATA_ERROR = 5
GENERAL_ERROR = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
CASE SY-SUBRC.
WHEN 1. RAISE DP_INVALID_PARAMETERS.
WHEN OTHERS. RAISE DP_ERROR_PUBLISH.
ENDCASE.
ENDIF.
ELSE.
RAISE NO_OBJECT.
ENDIF.
ENDFUNCTION.
or else if u have more doubts then ask ur question clearly plz
Regards
Pavan
‎2007 May 22 7:50 AM
Hi,
1) Go to SE37 transaction.
2) Give the Z*name & Press Create, it will ask for function group
3) To create new function grp In same tran SE37 Goto-> Function groups-> Create Give the fn grp name & use it while creating FM.
4) Activate the FM.
5) You can give Import, Export, Tables etc parameters inside the same.
Thanks
Sandeep
Reward if useful
‎2007 May 22 11:52 AM
Hi,
say you have call to FM
DATA:
lv_guid type crmt_object_guid.
CALL FUNCTION 'CRM_GUID_CREATE'
IMPORTING
ev_guid = lv_guid.
this is called in report program.
in se37 u have to create FM 'CRM_GUID_CREATE'
with exporting parameter lv_guid type crmt_object_guid.
as u say create u get tab exportng u declare lv_guid.
similarly incase if ur program has exporting parameters thn those wud bcome importing for FM.
Reward points if it is useful
‎2007 May 25 7:52 AM
Hi,
Use the following procedure to <b>create a function module</b>
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.
Hope this helps.
Reward if helpful.
Regards,
Sipra