Monday 4 June 2012

Ways to Declare Workarea/Structure in SAP-ABAP

Definition Of Structure or Workarea:


                          Structure/Workarea is a collection of fields which can be of different datatypes. And we can store maximum of one record at a time.


Data Storage in workarea is temporary.


 Few ways of declaring Workarea/Structure are:


*&---------------------------------------------------------------------*
*& Report  ZWA_DECLARATION_TYPES
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ZWA_DECLARATION_TYPES.

*// WORK AREA DECLARATION BY REFERRING STANDARD DATABASE TABLE
DATA: WA_MARA TYPE MARA.

*// DECLARING WORKAREA BY USING INCLUDE STRUCTURE
DATA: BEGIN OF WA_MARA1.
             INCLUDE STRUCTURE MARA.
DATA:  END   OF WA_MARA1.

*// DECLARING WORKAREA BY USING TYPES DECLARATION
TYPES: BEGIN OF TY_MARA,
              MATNR TYPE MARA-MATNR,
              ERSDA TYPE MARA-ERSDA,
              END   OF TY_MARA.

DATA: WA_MARA2 TYPE TY_MARA.


*// WORKAREA DECLARATION BY USING NORMAL METHOD
DATA:  BEGIN OF WA_MARA3,
              MATNR TYPE MARA-MATNR,
              ERSDA TYPE MARA-ERSDA,
              END   OF WA_MARA3.


1 comment:

  1. After you've declared a workarea by using the types declaration how would one loop through this wa if you were checking the value in one of the fields?

    ReplyDelete