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

Problem with the syntax

Former Member
0 Likes
1,434

Hi,

I am writing the below piece of code and it was throwing syntax error that 'actual parameters and formal parameters are not equal'.

its really irritating, can any one solve this.

data: var1 type i value 5,
      var2 type i value 10.

perform form1 
              using var1:
                     '1',
                     '2',
                     '3',
              changing var2.
              
*&---------------------------------------------------------------------*
*&      Form  FORM1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_VAR1  text
*      -->P_0019   text
*----------------------------------------------------------------------*
form FORM1  
            using    p_var1
                     p_no
            changing p_var2.
            

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,399

Hi jaya,

You can use the perform statement as you want but you can not use changing becuase you are passing the value 1,2 nad 3 directly to p_no and these values wiil be woked as constant for p_no (you can check this also in debugging) that is why you can not use statement changing.

2 Program is giving the syntax error beacuse after colon you are passing the value 1,2 and 3 and these values are passed to variable p_no , when you declare new actual parameter 'var2', perform stetement still consider that this is the value which need to pass to the vaiable p_no and does not accept it as a actual parameter.

3 if you will use like this then it can accept var2 as a actual parameter and will not give any error.

perform form1

using var1

var2:

'1',

'2',

'3'.

write: 'test'.

&----


*& Form FORM1

&----


  • text

----


  • -->P_VAR1 text

  • -->P_0019 text

----


form FORM1

using p_var1

p_no

p_var2.

endform.

in the above code both the actual and formal parameters are same (3), so whenever you want to pass the value directly to any variable of subroutine then keep it at the end of perform statement.

Hope this will clear to you, if not then plz let me know.

12 REPLIES 12
Read only

Former Member
0 Likes
1,399

Dont understand what you are trying to do. Are 1, 2 and 3 different values of var1?

Read only

0 Likes
1,399

yes one by one those should be passed.

If i dont have changing then it will work, but if i have changing then its not.


perform form1
              using var1:
                     '1',
                     '2',
                     '3'.
*              changing var2.

*&---------------------------------------------------------------------*
*&      Form  FORM1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_VAR1  text
*      -->P_0019   text
*----------------------------------------------------------------------*
form FORM1
            using    p_var1
                     p_no.
*            changing p_var2.



endform.                    " FORM1

Read only

0 Likes
1,399

But why are you trying to pass 3 values for one variable?

Read only

0 Likes
1,399

Declare more 2 variable for value 2 and 3.

Read only

0 Likes
1,399

do 3 times.

        • ur code for setting the var1 value here***

perform form1

using var1

changing var2.

enddo.

Read only

0 Likes
1,399

I am still working on that why it was not working? is there any restriction that we should not use changing?

Read only

0 Likes
1,399

Hi Jaya sri, Check your modified program. It works. I have just added some logic inside subroutine.

REPORT ztest_notepad.

DATA: var1 TYPE i VALUE 5,
      var2 TYPE i VALUE 10.

PERFORM form1 USING var1
                     '1'
                     '2'
                     '3'
           CHANGING var2.
WRITE var2.
*&---------------------------------------------------------------------*
*&      Form  FORM1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_VAR1      text
*      -->p_value_1   text
*      -->p_value_2   text
*      -->p_value_3   text
*      <--P_VAR2      text
*----------------------------------------------------------------------*
FORM form1  USING    p_var1
                     p_value_1
                     p_value_2
                     p_value_3
            CHANGING p_var2.
  p_var2 = p_var2 + p_var1 + p_value_1 + p_value_2 + p_value_3.

ENDFORM.                                                    " FORM1
I hope that it solves your problem. Thanks Venkat.O

Read only

0 Likes
1,399

HI VENKAT,

Thanks for your code, but what you wrote is general approach. I dont want to mention those number of formal parameters. Did you check my previous code, in the similar way it should work even if i use CHANGING parameter.

Thanks

Jaya

Read only

0 Likes
1,399

Try this way,

REPORT ztest_notepad.
DATA: var1 TYPE i VALUE 5,
      var2 TYPE i VALUE 10.
PERFORM: form1 USING: var1 '1' CHANGING var2,
         form1 USING: var1 '2' CHANGING var2,
         form1 USING: var1 '3' CHANGING var2.
FORM form1  USING    p_var1
                     p_no
            CHANGING p_var2.
  p_var2 = p_var2 + p_var1.
ENDFORM.  

venkat.O

Read only

Former Member
0 Likes
1,399

Hi,

Your Syntax is wrong.

Step 1 Write

Perform get_details using var1 var2

changing var3 var4.

Step 2 Double Click on the above line in editor, Body of the Perform will be automatically created in Program.

FORM test USING p1 TYPE string

p2 TYPE string

CHANGING value(p3) TYPE string

value(p4) TYPE string.

...

ENDFORM

Plz look in following link.

thanks and Regards,

ShreeMohan

Edited by: ShreeMohan Pugalia on Jul 16, 2009 11:05 PM

Read only

Former Member
0 Likes
1,400

Hi jaya,

You can use the perform statement as you want but you can not use changing becuase you are passing the value 1,2 nad 3 directly to p_no and these values wiil be woked as constant for p_no (you can check this also in debugging) that is why you can not use statement changing.

2 Program is giving the syntax error beacuse after colon you are passing the value 1,2 and 3 and these values are passed to variable p_no , when you declare new actual parameter 'var2', perform stetement still consider that this is the value which need to pass to the vaiable p_no and does not accept it as a actual parameter.

3 if you will use like this then it can accept var2 as a actual parameter and will not give any error.

perform form1

using var1

var2:

'1',

'2',

'3'.

write: 'test'.

&----


*& Form FORM1

&----


  • text

----


  • -->P_VAR1 text

  • -->P_0019 text

----


form FORM1

using p_var1

p_no

p_var2.

endform.

in the above code both the actual and formal parameters are same (3), so whenever you want to pass the value directly to any variable of subroutine then keep it at the end of perform statement.

Hope this will clear to you, if not then plz let me know.

Read only

Former Member
0 Likes
1,399

Hi,

You have wrongly used Chain Operator i.e. ':'

In your Code you have used after variable Var1.

perform form1

using var1: <------- Your Chain Operator.

'1',

'2',

'3'.

Instead it should be place after Word PERFORM.

Actual Postion Of Chain Operator.

l

l

v

PERFORM : form1 USING: var1 '1' CHANGING var2,

form1 USING: var1 '2' CHANGING var2,

form1 USING: var1 '3' CHANGING var2.

I Hope This help you.

Thanks and Regards,

Shreemohan