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: 

Function Module IMPORT structures not recognized in form subroutines

former_member210148
Participant
0 Kudos

Hello everyone,

Did some searching on SDN and didn't find the answer, so I apologize if this has been covered before.

Just finished my first Function Module. It's a remote-enabled (RFC) function that will be called by XI to do some processing. I have two components declared on the IMPORT tab, which we'll call "A" and "B". Both "A" and "B" are defined with a user type, each of which is a simple structure of 4-5 fields each. My Function Module also has two tables, and these are defined on the TABLES tab.

Here's my problem: When I do a syntax check, I get an error telling me that "A" and "B" are unknown. However, I only get this error where I reference "A" or "B" in the FORM subroutines I have declared at the end of my function.

I have my other data declarations defined globally in the "LZ...TOP" Include for my Function Module, so those don't pose a problem. But these are my Function Module parameters, so I can't go "declare" those as I already have them defined on the appropriate tabs.

Is there a way for me to get around this error and have them recognized globally, or do I have to resort to moving the values to some globally-declared "hold" field? I'm hesitant to have to add them as parameters passed into the FORM routines because I pretty much reference each of the fields within the structures for "A" and "B".

Thanks everyone. Points definitely awarded for helpful answers.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Hi,

You need to do this way....with using and Tables parameters

PERFORM FORMNAME USING PARAMETERS.

FORM FORMNAME USING PARAMETERS.
"here you can access the parameters
"Coding

ENDFORM.

Regards

vijay

8 REPLIES 8

former_member188685
Active Contributor
0 Kudos

Hi,

You need to do this way....with using and Tables parameters

PERFORM FORMNAME USING PARAMETERS.

FORM FORMNAME USING PARAMETERS.
"here you can access the parameters
"Coding

ENDFORM.

Regards

vijay

Former Member
0 Kudos

Dave,

The parameters are visible only in the main program of the function module. So, if the subroutines are directly in the main function, they you should not have a issue. But if you subroutines in an include and you are calling them in the main function, then the paramters are not visible in the subroutines. In that case you will have to hold the values in a globally declared tables.

Or you will have to pass them as parameters to Sub routines as well.

Regards,

Ravi

note : please mark the helpful answers

Message was edited by: Ravikumar Allampallam

0 Kudos

Ravikumar,

That's weird, because my subroutines ARE in the main function. I mean, it's like this:

FUNCTION ABC.

...

perform myform1.

...

perform myform2.

...

...

ENDFUNCTION.

FORM myform1.

...

ENDFORM.

FORM myform2.

...

ENDFORM.

I don't have them in any include. So you're saying I shouldn't be having an issue trying to reference the parameters set up for my Function Module "ABC" in FORM myform1 or FORM myform2?

0 Kudos

Hi Dave,

write the coding as

FUNCTION ABC.

...

perform myform1.

...

perform myform2.

...

...

FORM myform1.

...

ENDFORM.

FORM myform2.

...

ENDFORM.

ENDFUNCTION.

Regards,

GSR.

0 Kudos

Srinivas, I originally tried that, but I get an error on the last FORM statement:

"Incorrect nesting: Before the statement 'FORM', the structure introduced by 'FUNCTION' must be concluded by 'ENDFUNCTION'."

So it wants the ENDFUNCTION placed at the end.

Former Member
0 Kudos

Hi Dave,

U need to pass these IMPORT parameters as actual

parameters and in the FORM subroutines use as

formal parameters.

U cannot use them directly in the FORM subroutines

as the scope of these Parameters are limited for

the FM only.

The FORM subroutines exist independently and cannot

recognize the parameters of the FM.

Regards,

GSR.

0 Kudos

Sorry Dave,

As you have already close ENDFUNCTION, you cannot access them, you will have to declare them globally and use it.

And you cannot write the subroutine before the ENDFUNCTIOn as ABAP does not support nesting of subroutines.

Regards,

Ravi

Message was edited by: Ravikumar Allampallam

former_member210148
Participant
0 Kudos

Okay, I do believe my question's been answered. I've learned a lot. Points awarded for everyone -- thanks guys! I'm about to post one more issue I'm having, so please take a look at my new thread if you can and see if you can assist.

Thanks so much!