Application Development 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: 

Global variable declaration

Former Member
0 Kudos

Hi all,

can u please tel me hoe to declare the variable globally in abap report so that i can use it in any of my include program in that report.

thanx....

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Make all Data Declarartions in TOP include.

like


REPORT  ZSDR_INV_INR.

include ZSDR_Di_TOP.
include ZSDR_DI_FORM.

START-OF-SELECTION.

PERFORM get_sales_data.
perform get_delivery_data.
perform process_data.
perform refresh_tables.
perform get_sales_data_ZIO2.
perform get_delivery_data_ZIO2.
perform process_data_ZIO2.
*Perform Filter_Fieldcat.
perform display_report_DI.

Here make all ur data declarartions in ZSDR_Di_TOP .

THEN U CAN USE ALL VARIABLES GLOBALLY.

10 REPLIES 10

Former Member
0 Kudos

Hi

Make declaration of the variable in TOP include , and it can be used across the entire report pgm in any include & FG too

0 Kudos

>

> Hi

>

> Make declaration of the variable in TOP include , and it can be used across the entire report pgm in any include & FG too

i didnt get TOP include what does it means ??

thanx...

0 Kudos

Top include is a normal Include program in a report program

For example-

REPORT z_mbbel_consign_pdf .

*Top declaration

INCLUDE z_mbbel_consign_top.

*Include for subroutines

INCLUDE z_mbbel_consign_f01.

i have declared wf_flag under include-INCLUDE z_mbbel_consign_top, then variable WF_FLAG can be accessed in INCLUDE z_mbbel_consign_f01 too

0 Kudos

Its the SAP practice to SAPERATE out all the global declarations in a INCLUDE program, so that we get better clarity and understanding of the program.

You can open any Function group of your choice and check in the TOP Include program of it.

Example:

Goto SE80->

choose 'Function Group' in the list ->

Type function group name as 'SLVC_FULLSCREEN' (This the function group name of 'Reuse_alv_grid_display' FM'). - >

Check the main program of it.

As a very first statement, it will have an include ' INCLUDE LSLVC_FULLSCREENTOP."

Open it and see, it will contain only the declaration part for that Func group.

regards,

Padma

Former Member
0 Kudos

Make all Data Declarartions in TOP include.

like


REPORT  ZSDR_INV_INR.

include ZSDR_Di_TOP.
include ZSDR_DI_FORM.

START-OF-SELECTION.

PERFORM get_sales_data.
perform get_delivery_data.
perform process_data.
perform refresh_tables.
perform get_sales_data_ZIO2.
perform get_delivery_data_ZIO2.
perform process_data_ZIO2.
*Perform Filter_Fieldcat.
perform display_report_DI.

Here make all ur data declarartions in ZSDR_Di_TOP .

THEN U CAN USE ALL VARIABLES GLOBALLY.

0 Kudos

>

> Make all Data Declarartions in TOP include.

>

> like

>


> REPORT  ZSDR_INV_INR.
> 
> include ZSDR_Di_TOP.
> include ZSDR_DI_FORM.
> 
> START-OF-SELECTION.
> 
> PERFORM get_sales_data.
> perform get_delivery_data.
> perform process_data.
> perform refresh_tables.
> perform get_sales_data_ZIO2.
> perform get_delivery_data_ZIO2.
> perform process_data_ZIO2.
> *Perform Filter_Fieldcat.
> perform display_report_DI.
> 

>

> Here make all ur data declarartions in ZSDR_Di_TOP .

>

> THEN U CAN USE ALL VARIABLES GLOBALLY.

and if i also have some standard includes with them, but im not making any changes to them

like.

std incl

std incl

Z incl

std incl

Z incl

like this .

still will it be work in this condition??

thanx..

0 Kudos

TRY TO FIND OUT TOP INCLUDE IN STADARD AND MAKE CHANGES IN THAT.

OR ELSE DEFINE UR ZTOP INCLUDE BEFORE ALL INCLUDES.

0 Kudos

It will sure work given that its the first include in the program lines.

Regards

Karthik D

0 Kudos

>

> TRY TO FIND OUT TOP INCLUDE IN STADARD AND MAKE CHANGES IN THAT.

>

> OR ELSE DEFINE UR ZTOP INCLUDE BEFORE ALL INCLUDES.

i have made the changes as u said but it gives error that

"the variable has already been declared"

and i haven declare it anywhere else.

thanx...

0 Kudos

Hi,

This error is typical while using includes. Just activate and on error dialog give Activate Anyway...And then check it again...

Regards,

Karthik D