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

difference between

Former Member
0 Likes
844

what is the difference between Work Area, Header , Table and body .

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
814

Hi Buddy,

Internal table must be having body. it can have header but it is not necessary.

u can assign a table without header line.

work area is nothing but temp storage area .

If table is assigned as with header line.then there is no need to take any wok area.table header is worked as work area.otherwise work area is necessary is deal with internal table.

Example:

<u>table without header</u>

types : begin of t_struct,

matnr type matnr,

end of t_struct.

data : i_tab type standrad table of t_struct..

data : w_area type t_struct..

loop at i_tab into w_area.

write:/ w_area-matnr.

endloop.

<u>If table is assign as with header line.</u>

types : begin of t_struct,

matnr type matnr,

end of t_struct.

data : i_tab type standrad table of t_struct with header line.

loop at i_tab.

write:/ i_tab-matnr.

endloop.

Rewards points if helpful.

Regards,

Hemant

6 REPLIES 6
Read only

Former Member
0 Likes
814

Hi,

Work area -> An explicit structure to hold the value of the row of the internal table ..Generally the work area are used for internal tables created without header line.

Ex..

DATA: ITAB LIKE TABLE OF MARA.

DATA: WA LIKE MARA.

READ TABLE ITAB INTO WA INDEX 1.

2) Header line -> An implicit structure that holds the value of the row of the internal table..Generally the header line are used for internal tables created with header line...

Ex..

DATA: ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.

READ TABLE ITAB INDEX 1.

But for with header line internal table you can still use an explicit work area..

3) Body -> it is the entire contents of the internal table..

Thanks,

Naren

Read only

Former Member
0 Likes
814

hi,

work area is similar to header.It consists of only one record n the body consists of no: of records.

begin of itab means the header gets created n itab[] means the body gets created.

table consists of records..In the select statement when we give

select * from zstd into table itab. means the values will be going directly into the table. n it table is not mentioned then it goes into the field string first n the intop the body.

if usefull reward with points.

with regards,

madhuri.

Read only

Former Member
0 Likes
814

<b>Body</b> hold the rows of the internal table.all rows within it have the same structure.The term <b>'Internal ta</b>ble' itself usually refers to the body of the internal table.

<b>Work area</b> or header is a field string with the same structure as a row of the body,but can hold only a single row.It is a buffer used to hold each record before it is added to internal table.

ex:

Data: begin of it_tab occurs 3,

field1(1),

field2(2),

end of it_tab.

<b>Occurs </b>: creates the body of the internal table.without occurs you have only a field string.

<b>Begin of or With header</b> line creates a work area(header).

if statisfied, reward points

Read only

Former Member
0 Likes
814

I explain with an example.

Header

data: itab type mara occurs 0 with header line.

Now here a header line is created with same name itab (as the table name )which can hold at a time one record.

next u fill itab table .

loop at itab. endloop.

"this statement will move one record at a time from itab table into itab(header line). so u can access an field of that record using itab-feildname

Work area

here u explicitly define a structure same as itab as shown below.

data: itab type mara occurs 0 .

data wa_itab type mara.

Now here a WA is created with name wa_itab (as the table name )which can hold at a time one record.

next u fill itab table .

loop at itab <b>INTO WA_ITAB</b>.endloop.

"this statement will move one record at a time from itab table into WA_itab. so u can access an field of that record using WA_itab-feildname

Message was edited by:

sushilnath shukla

Read only

Yogitha
Product and Topic Expert
Product and Topic Expert
0 Likes
814

<b>Internal Table:</b>

An internal table is a data object, in which you can keep several identically

structured data records at runtime (table variable). The number of data records is

restricted only by the capacity of specific system installations.

Example:

DATA itab1 TYPE TABLE OF scarr

<b>Work Area:</b>

For single record processing of an internal table, you usually need a work area for

which the structure variable has to be defined with the same type as the line type of the internal table.

<b>Header:</b>

The WITH HEADER LINE addition in the definition of the internal table gives you

the option of creating a table with header line. When this is done a work area (header line) that suits the table is created automatically so that the additional definition of the same is not necessary. This also simplifies the syntax of the table commands, as the system always refers to the automatically generated work area, which therefore no longer has to be specified explicitly.

DATA itab1 TYPE TABLE OF scarr WITH HEADER LINE.

DATA itab2 LIKE itab1.

itab1 = itab2 . Only operations with header lines

<b>Body</b> is the contents of the internal table

You can address the body of the table with itab[].

itab1[] = itab2[] . Operations with table bodies

Read only

Former Member
0 Likes
815

Hi Buddy,

Internal table must be having body. it can have header but it is not necessary.

u can assign a table without header line.

work area is nothing but temp storage area .

If table is assigned as with header line.then there is no need to take any wok area.table header is worked as work area.otherwise work area is necessary is deal with internal table.

Example:

<u>table without header</u>

types : begin of t_struct,

matnr type matnr,

end of t_struct.

data : i_tab type standrad table of t_struct..

data : w_area type t_struct..

loop at i_tab into w_area.

write:/ w_area-matnr.

endloop.

<u>If table is assign as with header line.</u>

types : begin of t_struct,

matnr type matnr,

end of t_struct.

data : i_tab type standrad table of t_struct with header line.

loop at i_tab.

write:/ i_tab-matnr.

endloop.

Rewards points if helpful.

Regards,

Hemant