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

Converting FM to Perform

Former Member
0 Likes
2,107

Hello,

i want to convert a Function Module into subroutine.

Can someone give me good tips.

regards

1 ACCEPTED SOLUTION
Read only

andreas_mann3
Active Contributor
0 Likes
1,979

Hi,

you must'nt use form ... tables...

-> only by internal tables with headerline !

-> if it's e.g. a sorted table you can say:

FORM get_info

using it type sorted table

...

regards Andreas

19 REPLIES 19
Read only

Former Member
0 Likes
1,979

You just have to copy paste the code.

For the parameters use :


using " for input parameters
changing " for export parameters
tables " for table

Regards,

Erwan.

Read only

0 Likes
1,979

Erwan,

your tips are very useful,

pls explain one thing , how to declare variables which are under tab 'Tables'.

regards

Read only

0 Likes
1,979

perform form_routine tables itable using p1 p2 p3 changing p4.

*--------------
form form_routine tables  structure t_table
                  using p1 p2 p3
                  changing p4.
....

endform.
Read only

0 Likes
1,979

perform form_routine tables itable using p1 p2 p3 changing p4.

*--------------
form form_routine tables structure t_table
                  using p1 p2 p3
                  changing p4.
....

endform.
Read only

0 Likes
1,979

i think my confusion is still there.

let me explain

say in FM , under tab 'Tables' i have

itab like dbstr.

so when converting this FM to subroutine , i will capture all source code of FM in Form.. Endform.

And i will declare import and export variables globally.

but how to declare these tables?

should i declare them as:

data itab like dbstr occurs 0 with header line.

please clarify .

regard.

Read only

Former Member
0 Likes
1,979

i am little confused.

in a FM we declare tables under 'Tables' tab.

they refer to either a dbtable or structure.

what i want to know that all these new declaration we do in this tab say

manc like str.

is this same as:

data: manc like str occurs 0 with header line.

please if someone can clarify me on this.

regards

Read only

0 Likes
1,979

No,

In fact you use :


perform form_routine tables itable.

....

*--------------------
*   Form_routine
*--------------------
form from_routine tables itab structure t_mara.

...

endform.

Hope it helps,

Erwan.

Read only

Former Member
0 Likes
1,979

Hi,

You can do this by converting the FM's import and export parameters to Changing and using and paste the code of the FM in the body of the subroutine. But can i know why you want to do this??

Cheers,

Sam

Read only

0 Likes
1,979

i want to convert cause some BAPI's of 4.6c don't exist in 4.0B , and i also don't want to create more function group.

regards.

Read only

andreas_mann3
Active Contributor
0 Likes
1,980

Hi,

you must'nt use form ... tables...

-> only by internal tables with headerline !

-> if it's e.g. a sorted table you can say:

FORM get_info

using it type sorted table

...

regards Andreas

Read only

0 Likes
1,979

Andreas can you explain in detail

you must'nt use form ... tables...

-> only by internal tables with headerline !

regards

Read only

0 Likes
1,979

in other words in want to know that when we declare a table in FM under tab 'Tables' is it default internal table with header line or what....?

regards

Read only

0 Likes
1,979

In a FM, you can declare both ( i table with header line or 'table type ..' )

Read only

0 Likes
1,979

Erwan,

in the FM it is declared as

PARAMETER LIKE BAPIPARAM

so when creating subroutine, i should declare it how.

data PARAMETER LIKE BAPIPARAM.

or

data PARAMETER LIKE BAPIPARAM occurs 0.

or

PARAMETER LIKE BAPIPARAM occurs 0 with header line.

pls clarify

regards

Read only

0 Likes
1,979

Hi,

try that:

DATA param TYPE TABLE OF bapiparam.
DATA wa TYPE  bapiparam.
PERFORM form1 USING param wa.

FORM form1 USING par TYPE table wa type bapiparam.

  LOOP AT par INTO wa.

  ENDLOOP.

ENDFORM.

Andreas

Read only

0 Likes
1,979

BAPIPARAM is a structure containning sveral fields ( PARID, PARVA, PARTXT ).

So I suggest you to declare like this :


data : begin of parameter.
include structure bapiparam.
data : end of parameter.

or

data : parameters type bapiparam.

It should work...

Erwan.

Read only

0 Likes
1,979

so Erwan u mean that there is no need to declare them as internal table, is that ok ?

regards

Read only

0 Likes
1,979

YES.

If, in your actual FM/BAPI this is an input parameter, this is just a flat structure.

Not a internal table.

Regards,

Erwan.

Read only

0 Likes
1,979

Hello Erwan,

sorry to say but you were wrong, Andreas is right, i have to declare it as internal table

regards.