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

syntax for declaring global variable in report

Former Member
0 Likes
3,052

Hello all,

Kindly let me know syntax for declaring global variable in report?

Thnks,

SUnny

9 REPLIES 9
Read only

Former Member
0 Likes
1,633

Hi

data: v_repid type sy-repid,

v_ebeln type ekko-ebeln.

Read only

Former Member
0 Likes
1,633

Hi Sunny

DATA g_matnr type mara-matnr.

Thanks Arjun

Read only

Former Member
0 Likes
1,633

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

Read only

Former Member
0 Likes
1,633

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

Read only

Former Member
1,633

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

Read only

Former Member
0 Likes
1,633

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.

Read only

Former Member
0 Likes
1,633

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...

Read only

Former Member
0 Likes
1,633

DON

Read only

Former Member
1,633

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.