Application Development and Automation 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: 
Read only

Can't we use forms in a function module?

Former Member
0 Likes
2,090

Hi,

I have a extractor based on a function module. In the function module i need a set of lines to be called lot many times.

So , i tried using form and kept the code that needs to be called frequently in it.

The problem is FM is not allowing to keep the form inside the function (showing error).

Is there any other way to call a particular code in the FunctionModule repeatedly?

Can any one help me ASAP?

Thanks.

6 REPLIES 6
Read only

Former Member
0 Likes
1,388

Hi,

Yes, you can do this.

Either move the FROM to after the ENDFUNCTION.

or

Move the FORM to an include of the function group, this will be available to all function modules in the group.

Regards,

Nick

Read only

abdulazeez12
Active Contributor
0 Likes
1,388

Hi Prasad-

You can put PERFORM statements inside FUNCTIOn-ENDFUNCTION, whereas all FORMS need to be put only afetr ENDFUNCTION.

You can also put FORMs inside an Include Program of the respective Function Group.

Go to SE80 and look for the include programs. In one of those programs, u can put ur FORMS..

Hope this is clear to u..

Reward if useful

Cheeers

Shakir

Read only

vinod_vemuru2
Active Contributor
0 Likes
1,388

Hi,

When ever u create a FM it will ask for function group and when u create function group it will create following includes by default.

1. LFunction group nameTOP - Similar to TOP include where we will do our data declarations.

2. LFunction group nameU01 - All function module source codes will present here.

3.LFunction group nameUXX - Will contain includes equal to number of function module(i.e one include for each FM)

U create one more include LFunction group nameF01.

WRITE ur PERFORM formname. In ur function module source code.

Just double click on form name. It will ask for creation and display one pop up asking for where to place. Select newly created include LFunction group nameF01. So ur perform will be in FM source code and FORM will be in this include.

Dont forgot to activate this include before u use it.

Hope this solves ur problem.

Thanks,

Vinod.

Read only

Former Member
0 Likes
1,388

Hi every one,

Thanks for your replies.

I have created 2 includes , one for all declarations and the other include for the form which contains the code.

I have included them in the my actual program.

And in the actual program, i have a select statement on the internal table delared in the first include and i am looping into that table and assigning values to the fields and calling the form.

Now i am getting error like " the statement is not accessible" starting from the select stmt.

Can i know what is wrong in the code?

Thanks.

Read only

Former Member
0 Likes
1,388

hi,

Your FM always belongs to a function group...... so if u want to create forms then u write the perform stmt and double click on it.

and create it in a new include......which will be in same FG.....

Read only

Former Member
0 Likes
1,388

hi,

Your FM always belongs to a function group...... so if u want to create forms then u write the perform stmt and double click on it.

and create it in a new include......which will be in same FG.....