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: 

Tables

Former Member
0 Kudos
86

Hi

what does the tables statement do?.

8 REPLIES 8

Former Member
0 Kudos
50

TABLES

Syntax

TABLES table_wa.

Effect

This statement is not allowed in classes and declares a data object table_wa as a table work area whose data type is adopted from the identically named structured data type table_wa from the ABAP Dictionary. table_wa must be defined as a flat structure in the ABAP Dictionary. You can specify database tables or Views for table_wa.

Work table areas declared with TABLES are interface work areas and should only be declared in the global declaration section of a program for the following purpose:

The statement TABLES is required for exchanging data between screen fields that were defined in a program screen when transferring from the ABAP Dictionary and the ABAP program. For the screen event PBO, the content of the table work area is transferred to identically named screen fields; for PAI, the system adopts the data from identically named screen fields.

In executable programs, flat table work areas can be used for adopting data that were provided for the event GET table_wa from a linked logical database. TABLES is synonymous with the statement NODES for this purpose.

Notes

Work table areas declared with TABLES behave like the data declared with the addition COMMON PART, meaning the data are used by the programs of a program group.

Table work areas declared with TABLES can be declared in subroutines and function modules. However, this is not recommended. A table work area declared in a procedure is not local but belongs to the context of a framework program. The table work area can be viewed starting from the declaration in the framework program and lives as long as the framework program. In contrast to normal program-global data, the content of the table work areas declared in subroutines and function modules is stored temporarily when these subroutines and function modules are called. Value assignments that were made during runtime of the procedure are preserved until the procedure is completed. When exiting the procedure, the table work areas are filled with the contents that they contained when the procedure was called. Table work areas declared in procedures behave like global data to which the statement LOCAL is applied in the procedure.

Former Member
0 Kudos
50

if u use select * statement then u required tables statement

Madhavi

Former Member
0 Kudos
50

TABLES

This statement is not allowed in classes and declares a data object table_wa as a table work area whose data type is adopted from the identically named structured data type table_wa from the ABAP Dictionary. table_wa must be defined as a flat structure in the ABAP Dictionary. You can specify database tables or Views for table_wa.

Work table areas declared with TABLES are interface work areas and should only be declared in the global declaration section of a program for the following purpose:

The statement TABLES is required for exchanging data between screen fields that were defined in a program screen when transferring from the ABAP Dictionary and the ABAP program. For the screen event PBO, the content of the table work area is transferred to identically named screen fields; for PAI, the system adopts the data from identically named screen fields.

In executable programs, flat table work areas can be used for adopting data that were provided for the event GET table_wa from a linked logical database. TABLES is synonymous with the statement NODES for this purpose.

Work table areas declared with TABLES behave like the data declared with the addition COMMON PART, meaning the data are used by the programs of a program group.

Table work areas declared with TABLES can be declared in subroutines and function modules. However, this is not recommended. A table work area declared in a procedure is not local but belongs to the context of a framework program. The table work area can be viewed starting from the declaration in the framework program and lives as long as the framework program. In contrast to normal program-global data, the content of the table work areas declared in subroutines and function modules is stored temporarily when these subroutines and function modules are called. Value assignments that were made during runtime of the procedure are preserved until the procedure is completed. When exiting the procedure, the table work areas are filled with the contents that they contained when the procedure was called. Table work areas declared in procedures behave like global data to which the statement LOCAL is applied in the procedure.

The form TABLES * is obsolete.

Reward if usefull

Former Member
0 Kudos
50

Hi,

The TABLES statement actually creates a default workarea. If the workarea is not refered or if the into clause is not used in the select statement then it uses this default workarea.

Former Member
0 Kudos
50

Hi Rajyalaxmi,

TABLES Statement

TABLES requests < / options > ;

The TABLES statement requests one-way to n-way frequency and crosstabulation tables and statistics for those tables.

If you omit the TABLES statement, PROC FREQ generates one-way frequency tables for all data set variables that are not listed in the other statements. The following argument is required in the TABLES statement.

requests

specifies the frequency and crosstabulation tables to produce. A request is composed of one variable name or several variable names separated by asterisks. To request a one-way frequency table, use a single variable. To request a two-way crosstabulation table, use an asterisk between two variables. To request a multiway table (an n-way table, where n>2), separate the desired variables with asterisks. The unique values of these variables form the rows, columns, and strata of the table.

For two-way to multiway tables, the values of the last variable form the crosstabulation table columns, while the values of the next-to-last variable form the rows. Each level (or combination of levels) of the other variables forms one stratum. PROC FREQ produces a separate crosstabulation table for each stratum. For example, a specification of ABC*D in a TABLES statement produces k tables, where k is the number of different combinations of values for A and B. Each table lists the values for C down the side and the values for D across the top.

You can use multiple TABLES statements in the PROC FREQ step. PROC FREQ builds all the table requests in one pass of the data, so that there is essentially no loss of efficiency. You can also specify any number of table requests in a single TABLES statement. To specify multiple table requests quickly, use a grouping syntax by placing parentheses around several variables and joining other variables or variable combinations. For example, the following statements illustrate grouping syntax.

Reward if helpful.

Thankyou,

Regards.

UdayS
Participant
0 Kudos
50

Hi,

In simple if you want to use any table in your program then you have to declare that table in your program with TABLES statement as below

TABLES mara.

And this is going to create an implicit work area (internal table) of that table with the same name. If you want you can use it as a internal table not necessary to declare one more internal table or workarea but we will create one more for readability.

Former Member
0 Kudos
50

Hi,

The tablses statement declares a work area of that table.

Tables:

sflight.

equals

data: wa_sflight type sflight.

Regards,

Renjith Michael.

Former Member
0 Kudos
50

Hi,

TABLES statement creates a work area in the Program.

For eg.

TABLES mara.

creates a structure(or work area) MARA of type MARA.

  • The structure can be used as any other work area of type MARA.

  • The advantage of using this statement is while writing a Select statement the into work area need not be explicitly mentioned if the structure has been defined using TABLES Statement.