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

Work Area

Former Member
0 Likes
945

Hello..

what is a workarea, how is use in pgm.

9 REPLIES 9
Read only

Former Member
0 Likes
900

hi,

Work area is nothing but an area for an temporary storage of a data. It has the same structure of an internal table or the database table based on the declaration.


*  Work Area
 data : wa_mara like mara.
 

Read only

Former Member
0 Likes
900

Work Area is a structure of a table which holds one record .

eg: data:

wa type sflight.

here wa has the same structure of sflight. It is useful to update the table.

ie,

Modify sflight from wa.

Read only

Former Member
0 Likes
900

Hi,

Work area is like header, it will take single reocrd into it and appends to body of the internal table...

Regards,

kavitha

Read only

Former Member
0 Likes
900

hi,

Follow this link.

https://help.sap.com/saphelp_nw04/helpdata/en/fc/eb36a1358411d1829f0000e829fbfe/frameset.htm

WORK AREAS

Work areas are single rows of data.

It should have the same format as any of the internal tables.

It is used to process the data in an internal table one line at a time.

Internal Tables with Header Line : Here the system automatically creates the work area. The work area has the same data type as internal table. This work area is called the HEADER line. It is here that all the changes or any of the action on the contents of the table are done. As a result of this, records can be directly inserted into the table or accessed from the internal table directly.

Internal Tables without Header Line : Here there is no work area associated with the table. Work area is to be explicitly specified when we need to access such tables. Hence these tables cannot be accessed directly.

You access internal tables line by line. You must use a work area as an interface for transferring data to and from the table.

When you read data from an internal table, the contents of the addressed table line overwrite the contents of the work area.

When you write data to an internal table, you must first enter the data in the work area from which the system can transfer the data to the internal table.

Hope this helps, Do reward.

Edited by: Runal Singh on Apr 24, 2008 5:00 PM

Read only

Former Member
0 Likes
900

Work area can be defined as structure of internal table which consists one record at a time.

There are two types of workareas we have:

1)Implicit workarea:If you specify TABLES statement or in the decleration of internal tables as WITH HEADER LINE..then these statements create implicit workarea.

2)Explicit work area:we have to create explicitly like WA_ITAB.

Reward if useful.

Dara.

Read only

Former Member
0 Likes
900

hi,

Workarea:

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.

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

pls reward if helpful.

Read only

Former Member
0 Likes
900

Hi ,

Work areas are nothing but temporary storages for holding data which holds only one record.

Actully these are used when u have to populate the internal tables with data.

Hopes its useful.

Thanks,

Surya Pydikondala.

Read only

0 Likes
900

hi,

check these links.

details.

Using Header Lines as Work Areas

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:

Operations without header line

Operations with header line

Operations for all Table Types

INSERT <wa> INTO TABLE <itab>.

INSERT TABLE ITAB.

COLLECT <wa> INTO <itab>.

COLLECT <itab>.

READ TABLE <itab> ... INTO <wa>.

READ TABLE <itab> ...

MODIFY TABLE <itab> FROM <wa> ...

MODIFY TABLE <itab> ...

MODIFY <itab> FROM <wa> ...WHERE ...

MODIFY <itab> ... WHERE ...

DELETE TABLE <itab> FROM <wa>.

DELETE TABLE <itab>.

LOOP AT ITAB INTO <wa> ...

LOOP AT ITAB ...

Operations for Index Tables

APPEND <wa> TO <itab>.

APPEND <itab>.

INSERT <wa> INTO <itab> ...

INSERT <itab> ...

MODIFY <itab> FROM <wa> ...

MODIFY <itab> ...

Using the header line as a work area means that you can use shorter statements; however, they are not necessarily easier to understand, since you cannot immediately recognize the origin and target of the assignment. Furthermore, the fact that the table and its header line have the same name can cause confusion in operations with entire internal tables. To avoid confusion, you should use internal tables with differently-named work areas.

Example

The following example shows two programs with the same function. One uses a header line, the other does not.

With header line:

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.

Without header line:

TYPES: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE I,

END OF LINE.

DATA: ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1,

WA LIKE LINE OF ITAB.

DO 4 TIMES.

WA-COL1 = SY-INDEX.

WA-COL2 = SY-INDEX ** 2.

INSERT WA INTO TABLE ITAB.

ENDDO.

WA-COL1 = 2.

READ TABLE ITAB FROM WA INTO WA.

WA-COL2 = 100.

MODIFY TABLE ITAB FROM WA.

WA-COL1 = 4.

DELETE TABLE ITAB FROM WA.

LOOP AT ITAB INTO WA.

WRITE: / WA-COL1, WA-COL2.

ENDLOOP.

The list, in both cases, appears as follows:

1 1

2 100

3 9

The statements in the program that does not use a header line are easier to understand. As a further measure, you could have a further work area just to specify the key of the internal table, but to which no other values from the table are assigned.

regards

vipul

Read only

Former Member
0 Likes
900

Hi,

If the internal table is declared without header area, then to read the record from that internal table , work area will be used.

here the piece of code.

DATA : it_knc1 TYPE STANDARD TABLE OF knc1,

wa_knc1 TYPE st_knc1 . " Work area

LOOP AT it_knc1 INTO wa_knc1 .

WRITE:/ wa_knc1-kunnr,

wa_knc1-bukrs,

wa_knc1-um01s CURRENCY 'INR'.

ENDLOOP.

Regards

Sandeep Reddy