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

Perform

Former Member
0 Likes
1,145

Hi all,

It is small doubt like in the perform

PERFORM using i_tab1

changing i_tab2. we are giving but in the FORM

FORM USING p_i_tab1

CHANGING p_i_tab2

Why we are passing with the name i_tab1 and i_tab2 and using in the form with different name p_i_tab1 and p_i_tab2 eventhough it will refer to i_tab1 and i_tab2.

We can simply use the same table name or variable name in the form also like i_tab1 and i_tab2 no.What is wrong in that why we should not do like like.What is significance of having different name in the FORM and PERFORM.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,125

Hi Ram,

if u just call :

Perform <formname>. " without using and changing

u can use the same table names itab_1 and itab_2 which are declared globally.

but when u specify using and changing, it is for more clarity of what u r going to do with those tables...

u are passing references to the subroutine..so the parameters: p_itab_1 will be the reference parameter for that...it reflects when u <b>Pass by Value</b>...

even the local variable p_itab1 is change , it doesn't reflects actual itab.

9 REPLIES 9
Read only

Former Member
0 Likes
1,125

Hi

Subroutines are meant for mutiple usage, not for single use

If you are using only once this PERFORM and FORM you can use the same names, nothing will happen but when you wants to use the same FORM..ENDFORM for different PERFORM with different Tables passed then it will not work.

PERFORM using i_tab1

changing i_tab2.

PERFORM using i_tab3

changing i_tab4.

FORM USING p_i_tab1

CHANGING p_i_tab2

.............

ENDFORM.

So now see, for the both Performs we can use the same FORM..ENDFORM...

Reward points if useful

Regards

Anji

..

Read only

Former Member
0 Likes
1,127

Hi Ram,

if u just call :

Perform <formname>. " without using and changing

u can use the same table names itab_1 and itab_2 which are declared globally.

but when u specify using and changing, it is for more clarity of what u r going to do with those tables...

u are passing references to the subroutine..so the parameters: p_itab_1 will be the reference parameter for that...it reflects when u <b>Pass by Value</b>...

even the local variable p_itab1 is change , it doesn't reflects actual itab.

Read only

Former Member
0 Likes
1,125

to distinguish between formal and actual parameters.

regards

padma

Read only

Former Member
0 Likes
1,125

Hi..,

Those are just the naming conventions ... U can use the same names also..

We generally use the naming convention as pr_itab1 for passed by reference and pv_itab1 for Passed by value ..

regards,

sai ramesh

Read only

Former Member
0 Likes
1,125

Hi Shriram,

You can have same names too formal and actual parameters in the routines. There is no wrong in giving same names to formal and actual parameters.

PERFORM using i_tab1

changing i_tab2.

FORM USING i_tab1

CHANGING i_tab2.

Generally whenever you double click on the PERFORM it will implicitly adds P_ to the actual parameters in the FORM formal parameters.

PERFORM using i_tab1

changing i_tab2.

FORM USING p_i_tab1

CHANGING p_i_tab2.

I think this may improve readability to the FORM parameters..

Thanks,

Vinay

Read only

Former Member
0 Likes
1,125

Hi ShriRam,

... USING [VALUE(p1)|p1] ... [VALUE(pn)|pn]

Effect

Defines formal parameters p1,...pn, which are replaced by actual parameters when the subroutine is called.

You can assign a type to the formal parameters p1, ..., pn (see specifying types). You can also specify the method with which they are passed.

Note

Passing methods:

USING ... p ...

The parameters are passed by reference. The field passed can be changed within the subroutine. The changes are kept beyond the subroutine.

USING ... VALUE(p) ...

The VALUE(...) addition passes the parameter by copying the field contents to a corresponding local field. VALUE parameters behave in the same way as local fields.

... CHANGING [VALUE(p1) |(p1)] ... [VALUE(pn) |(pn)]

Effect

The parameters after CHANGING can accept the same specifications as those after USING.

To link the VALUE specification with the change of a parameter value, you can use the addition CHANGING ... . Then, all the formal parameters specified by VALUE(...) are transported back to the actual parameters at the end of the subroutine (i.e. after ENDFORM). If the subroutine is terminated by a dialog message, none of the parameters referenced by CHANGING VALUE ... changes.

Otherwise, the effect of USING and CHANGING is identical.

Read only

Former Member
0 Likes
1,125

Hi,

When using

perform using i_tab1 changing i_tab2.

there is no problem if we are not using the subroutine again .

Like in a program the subroutines are called multiple time and

hence we declare the local variables as formal parameters and pass

the actual parameters (which call the routine) as the actual parameters

vary depending on the call to the routine.

Asha

Read only

Former Member
0 Likes
1,125

Hi Ram,

In perform we pass the refrences.

that we call in Formm ...using......Endform statement

u are passing references to the subroutine. i_tab1 .so the parameters: p_itab_1 will be the reference parameter for that...it reflects when u Pass by Value....

Reward points if helpful.

Regards,

Hemant

Read only

S0025444845
Active Participant
0 Likes
1,125

Hi,

When we call PERFORM using i_tab1

changing i_tab2.

we get

FORM USING p_i_tab1

CHANGING p_i_tab2.

p_i_tab1 is just reference to i_tab1 and

p_i_tab1 is just reference to i_tab2.

We can give the same name like

FORM USING i_tab1

CHANGING i_tab2. still it is same but You have to remember that watever we are using in the form is local to that form only.so just to avoid confusion it is better to use different names it does not make any other difference.

regards,

Sudha

Reward points if useful.