‎2008 Mar 14 8:35 AM
Hello all,
Kindly let me know syntax for declaring global variable in report?
Thnks,
SUnny
‎2008 Mar 14 8:36 AM
‎2008 Mar 14 8:38 AM
‎2008 Mar 14 8:39 AM
Hi Sunny,
A global variable can be declared as follows :
DATA:g_var1 TYPE c,
g_var2 TYPE n. etc..
Regards,
Esha Raj
Edited by: Esha Raj on Mar 14, 2008 9:39 AM
‎2008 Mar 14 8:41 AM
Hi
global variable declaration:
syntax:
data:<var1> type/like <predefined variable>
data:num type i.
data: okcode_100 like sy-ucomm,
okcode_200 like sy-ucomm,
v_kna1 like kna1-kunnr,
v_dynnr like sy-dynnr.
like in this way we declare the global variables
‎2008 Mar 14 8:47 AM
Any variable with in the main prgram is global
Eg data : G_v. in the main program
in case of function modules the global variables are those specified in the top include.
to go to gbobal varibles in a function module use menu path goto->global data
reward if useful
‎2008 Mar 14 8:50 AM
Hi,
declaring global variable in a report:
syntax:
data : var type dataelementname. or
data : var like tabname-fieldname.
DATA : V_var1 type vbak-vbeln,
v_var2 like mara-matnr.
regards,
vineela.
‎2008 Mar 14 8:58 AM
hi sunny,
u can declare global variable on top most area of report...
preferably before defining SELECTION-SCREEN...
----
Data Begin with g_
----
DATA : g_var1 TYPE c.
reward points if useful...
‎2008 Mar 14 9:04 AM
‎2008 Mar 14 9:04 AM
Hi Sunny,
All data declaration in the main program is global.
Only if you do some data declaration withtin the subroutines then the scope of the variable is limited to that FORM ....ENDFORM.
As you read in the above reply for a global variable in FM you need to declare in the top include.
This means that you want this variable to be made available to all the Function Modules in that Function Group.
If you want to make the variabe be available only within that FM then do the declaration in the source code itself.
hope this explaination helps,
Taher.