2006 Dec 06 4:58 PM
what is the difference between global variable and local variable?
2006 Dec 06 5:00 PM
Within a program ---
A global variable is available all through the program, every part of the program.
A local variable is availabe with in the subroutine where you have declared the variable.
It basically depends on the scope of the variable.
Regards,
Ravi
Note - Please mark all the helpful answers
2006 Dec 06 8:49 PM
Hi,
Variables are named data objects that you can declare statically using declarative statements, or dynamically while a program is running. They allow you to store changeable data under a particular name within the memory area of a program.
You can declare variables statically using the following statements:
DATA: To declare variables whose lifetime is linked to the context of the declaration
STATICS: To declare variables with static validity in procedures
CLASS-DATA: To declare static variables within classes
PARAMETERS: To declare elementary data objects that are also linked to an input field on a selection screen
SELECT-OPTIONS: To declare an internal table that is also linked to input fields on a selection screen
RANGES: To declare an internal table with the same structure as in SELECT-OPTIONS, but without linking it to a selection screen.
Click the link below to know more about Variables.
http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3034358411d1829f0000e829fbfe/content.htm
Global Variables.
Everything mentioned above remains the same for Global variables, except that they are available across the program. If you refer to Global Objects, then they are available across the applications. Remember If the Local and Global variables have same name then the local variable has the more significance in the block/Program/Subroutine/function module than the global variable.
Regards,
Vara
2006 Dec 06 8:52 PM
Hi
let talk about modulepool.
when youdeclare anything in the top include ,its a global variable and it holds the value until you clear it externally using clear statment.
say if yousing module -
in a particular statment and declaring a variable in side that module then its local to that module,
once you come out of that module it would loose its value automatically.
Hope i am clear
thanks
venki