2010 Nov 17 3:58 PM
DATA A TYPE I VALUE 100.
PERFORM PRINT_DATA.
FORM PRINT_DATA.
DATA A(10) TYPE C 'HELLO'.
WRITE / A. "Wanted to Print 100 (Global)
WRITE / A. "Wanted to Print 'HELLO'(Local)
ENDFORM.
Note : Both the times, the Local Variable 'A' is Printed .
?Is there any way to Differentiate the Local and Global Variables When the Names Are Same.*
*It Might be Possible in Object Oriented But I am Looking for the Same in FORMs.
DATA A TYPE I VALUE 100.
PERFORM PRINT_DATA.
FORM PRINT_DATA.
DATA A(10) TYPE C 'HELLO'.
WRITE / A. "Wanted to Print 100 (Global)
WRITE / A. "Wanted to Print 'HELLO'(Local)
ENDFORM.
Note : Both the times, the Local Variable 'A' is Printed .
?Is there any way to Differentiate the Local and Global Variables When the Names Are Same.*
*It Might be Possible in Object Oriented But I am Looking for the Same in FORMs.
2010 Nov 17 4:13 PM
Local declarations are masking global declarations. Using identical names is extremely bad programming style.
Solution: do not use global variables, and if you must, prefix them with "g_", for example.
Thomas
2010 Nov 17 4:33 PM
Hello Gagan,
You want to print the Global as well as the local values of the variable named "A". Here are a couple of approaches:
1.The 'Subroutines' are part of the modularization techniques. There are certain keywords like "using" & "Changing" so that you can work by passing Values.
2. There is a keyword named "LOCAL". Declare data object with the keyword "LOCAL" and then try the 'write" statement. I suppose this should work for you.
Let me know if any one of the above works or if you need more help.
Best Regards,
Chaitanya
2010 Nov 17 4:48 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |