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 statement reusability

Former Member
0 Likes
1,198

Hi,

I have written a perform statement like this:

PERFORM add_value USING wa_var1

wa_var2.

FORM add_value

data: wa_var3(2) type c.

wa_var3 = wa_var1 + wa_var2.

ENDFORM.

this perform i want to call manny times in a same program with different USING values.

Like:

PERFORM add_value USING wa_var4

wa_var5.

this gives an syntax error .

how to solve this...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,161

1. you havent define the using in your Form.

PEFORM ADD_VALUE using w_var1 w_var2 changing w_var3. " w_var3 holds the output

PEFORM ADD_VALUE using w_var4 w_var5 changing w_var6. " w_var6 holds the output

form add_value USING V1 type any

V2 type any

changing V3 type ANY.

V3 = V1 + V2.

endform.

2. you can try using macros as well.

12 REPLIES 12
Read only

rainer_hbenthal
Active Contributor
0 Likes
1,161

My glass sphere is out for cleaning so i cant figure out what kind of syntax error you're getting. But i guess its because of your weired type setting or var3.

Read only

0 Likes
1,161

Community is not bothered abt your sarcasm

Edited by: mayank verdia on Oct 2, 2009 10:52 AM

Read only

0 Likes
1,161

It is kind of funny though. However basically Rainer is right, and what he's trying to say here is : To help, 'we' need info on the actual problem, without having to guess or (like is done in some of the previous postings) code it ourself and find out.

Read only

0 Likes
1,161

#2

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,161

Hello Mayank,

And do you suggest that the "responsible" community members shoot arrows into the dark.

The question you have asked falls in the "ABAP Basics" category which you can understand by reading the compiler "error" message. Why bother us then?

Good Luck !!

Suhas

Read only

0 Likes
1,161

Kindly dont reply if you find it wrong!! ...

Let moderators reply to me.

Regards,

Mayank

Read only

Former Member
0 Likes
1,161

 FORM add_value USING wa_var1 wa_var2   "Use using parameters in FORM also
 data: wa_var3(2) type c.
  
 wa_var3 = wa_var1 + wa_var2.
 ENDFORM.

Check this sap help it will help you,

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db977635c111d1829f0000e829fbfe/frameset.htm

Edited by: Kartik Tarla on Oct 2, 2009 2:05 PM

Read only

Former Member
0 Likes
1,162

1. you havent define the using in your Form.

PEFORM ADD_VALUE using w_var1 w_var2 changing w_var3. " w_var3 holds the output

PEFORM ADD_VALUE using w_var4 w_var5 changing w_var6. " w_var6 holds the output

form add_value USING V1 type any

V2 type any

changing V3 type ANY.

V3 = V1 + V2.

endform.

2. you can try using macros as well.

Read only

0 Likes
1,161

Hi Soumya,

what you have mentioned seems to be correct.

I too have written like this.

PERFORM add_value USING wa_var1 wa_var2 CHANGING wa_var3.

FORM add_value USING p_wa_var1 p_wa_var2

CHANGING p_wa_var3.

ENDFROM.

My question is if i want to use same routine add_value with different USING like wa_var4 wa_var6 ,

when i call this routine second time in my report than how do i use it.

you are saying like :

FORM add_value USING V1 type any

V2 type any

changing V3 type ANY.

V3 = V1 + V2.

ENDFORM.

will your logic will run for all different variables i use in USING clause when ever i call this routine.

Read only

0 Likes
1,161

yes it will

and by the way.. you can ALSO use macros as:

define add_value.
&3 = &1 + &2.
enddefine.

now call the macro as :

add_value var1 var2 var3. " automatically set var1 to &1 va2 to &2 and var3 to &3. so you get he result in var3
add_value var4 var5 var6. output in var6

there may be lil syntax error, as i am not in front of SAP now.

Read only

0 Likes
1,161

Hi Mayank,

You need to make yourself clear with the theory part of whatever you are going to code, so It would be better if you go through the sap documemtation on subroutines then you would gain much better understanding abt the code that people have suggested above

Read only

Former Member
0 Likes
1,161

Hi,

Your Subroutine should have the correct parameters to match the call



FORM add_value USING wa_var1
                                       wa_var2.

Regards,

Himanshu