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: 

work area

Former Member
0 Kudos

what is work area in a program ? why we define in the program?could u plzz tell me?

6 REPLIES 6

Former Member
0 Kudos

work area(also called header line) means it hold one structure(like one row)

it is very useful in internal tables

while inserting data in to internal table first we put data in to work area after that into internal table

When you create an internal table object you can also declare a header line with the same name. You can use the header line as a work area when you process the internal table. The ABAP statements that you use with internal tables have short forms that you can use if your internal table has a header line. These statements automatically assume the header line as an implicit work area. The following table shows the statements that you must use for internal tables without a header line, and the equivalent statements that you can use for internal tables with a header line:

<b>with header line try this porgram</b>

TYPES: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE I,

END OF LINE.

DATA ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1

WITH HEADER LINE.

DO 4 TIMES.

ITAB-COL1 = SY-INDEX.

ITAB-COL2 = SY-INDEX ** 2.

INSERT TABLE ITAB.

ENDDO.

ITAB-COL1 = 2.

READ TABLE ITAB FROM ITAB.

ITAB-COL2 = 100.

MODIFY TABLE ITAB.

ITAB-COL1 = 4.

DELETE TABLE ITAB.

LOOP AT ITAB.

WRITE: / ITAB-COL1, ITAB-COL2.

ENDLOOP.

reward if it helps u

vijay pawar

Former Member
0 Kudos

Hi,

Work Area is used to hold one record of the internal table/db table at run time.

Work area may be of Internal Table, or database tables or of structure.

We move the single record to work area in the loop and do processing of that record by moving to other internal table or displaying that record.

If we declare TABLES statement and some table that table work area will be created by default, into which you can fetch a single record.

reward if useful

regards

ANJI

Former Member
0 Kudos

Workarea is the memory area on with you perform the required operation related to data. Every Internal table has a header that is work area of the internal table. As soon as you read a row in an internal table the particular record gets filled in the workarea and now you can make modifications to this data, then say update or append the same data to internal table.

if you have defined an internal table with out header line, then you have to separately declare a work area and use as per requirement.

Hope it will help.

Regards,

Vishal

Former Member
0 Kudos

hi Sumit,

WORKAREA is a structure that can hold only one record at a time. It is a collection of fields. We use workarea as we cannot directly read from a table. In order to interact with a table we need workarea. When a Select Statement is executed on a table then the first record is read and put into the header of the table and from there put into the header or the workarea(of the same structure as that of the table)of the internal table and then transferred top the body of the internal table or directly displayed from the workarea.

Each row in a table is a record and each column is a field.

Difference between Work Area and Header Line

While adding or retrieving records to / from internal table we have to keep the record temporarily.

The area where this record is kept is called as work area for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.

Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.


e.g.
data: begin of itab occurs 10,
ab type c,
cd type i,
end of itab. " this table will have the header line.

data: wa_itab like itab. " explicit work area for itab

data: itab1 like itab occurs 10. " table is without header line.

The header line is a field string with the same structure as a row of the body, but it can only hold a single row.

It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table. It is the default work area for the internal table.

Former Member
0 Kudos

hi sumit

WORKAREA is a structure that can hold only one record at a time. It is a collection of fields. We use workarea as we cannot directly read from a table. In order to interact with a table we need workarea. When a Select Statement is executed on a table then the first record is read and put into the header of the table and from there put into the header or the workarea(of the same structure as that of the table)of the internal table and then transferred top the body of the internal table or directly displayed from the workarea.

Each row in a table is a record and each column is a field.

https://www.sdn.sap.com/irj/sdn/profile?userid=3486494

the data in the database cannot ba manipulated directly in some cases so it is first stored into an internal table. now there are thwo kinds of internal table

1) wth header line

2)w/o header line

without header line tables donot have a work area wth them so we need to define a workarea . dat for operation is transfered from internal tab to workarea via loop and then operations are done.

reagrds

navjot

Message was edited by:

navjot sharma

Former Member
0 Kudos

Hi Sumit,

While adding or retrieving records to / from internal table we have to keep the record temporarily.

The area where this record is kept is called as <b>work area</b> for the internal table. The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.

If this is usefull then award points.

Thanks and regards

Vipin Das