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
756

How to create 2 work areas for one intenal table?

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
732
data: itab type table of string.

data: xtab like line of itab.
data: ytab like line of itab.

Regards,

RIch Heilman

Read only

Former Member
0 Likes
732
data : itab type standard table of mara.

data : wa_itab1 like itab,
          wa_itab2 like itab.
Read only

Former Member
0 Likes
732

how to create a work area.

data : begin of wa,

f1(10),

end of wa.

data : it like table of wa.

creating internal table from standard table.

data : it like table of mara with header line.

creating work area from internal table.

data : wa like it.

Read only

Former Member
0 Likes
732

data : begin of it_mara,

matnr like mara - matnr,

enum like mara - enum,

end of it_mara.

data : wa_mara like it_mara.

in this program since this program is internal tables with headerline.

it_mara is work area

it_mara[] is internal table

one is implicit workarea which is automatically created.

ie : it_mara.

and the other one is wa_mara which we have declared.

So there are two work areas for a single internal table

if u r convinced with this answer reward with points

Read only

Former Member
0 Likes
732

Hi,

data : i_tab type standard table of mseg.

data : wa1 like i_tab,

wa2 like i_tab.

<b>plz reward points if helpful or if it solves ur query.</b>

Thanks

Chinmay

Read only

aris_hidalgo
Contributor
0 Likes
732

Hi Balu,

I have created an example for you which I think will be of help to your question.


REPORT  z_aris_test_11.

TABLES: vbak. "Work area 1

TYPES: BEGIN OF t_vbak,
        vbeln TYPE vbak-vbeln,
        erdat TYPE vbak-erdat,
       END OF t_vbak.

DATA: gt_vbak TYPE STANDARD TABLE OF t_vbak,
      wa_vbak LIKE LINE OF gt_vbak.             "Work area 2

FIELD-SYMBOLS: <fs_vbak> LIKE LINE OF gt_vbak.  "Work area 3

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: r1 RADIOBUTTON GROUP grp1,
            r2 RADIOBUTTON GROUP grp1,
            r3 RADIOBUTTON GROUP grp1.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

*Using Work area 1
  IF r1 = 'X'.
    WRITE: / 'Using work area 1...'.
    SELECT vbeln erdat
    FROM vbak
    INTO (vbak-vbeln, vbak-erdat).
      WRITE: / vbak-vbeln,
               vbak-erdat.
    ENDSELECT.
*Using work area 2
  ELSEIF r2 = 'X'.
    WRITE: / 'Using work area 2...'.
    SELECT vbeln erdat
    FROM vbak
    INTO TABLE gt_vbak.

    LOOP AT gt_vbak INTO wa_vbak.
      WRITE: / wa_vbak-vbeln,
               wa_vbak-erdat.
    ENDLOOP.
    REFRESH gt_vbak.
*Using Work area 3
  ELSEIF r3 = 'X'.
    WRITE: / 'Using work area 3...'.
    SELECT vbeln erdat
    FROM vbak
    INTO TABLE gt_vbak.

    LOOP AT gt_vbak ASSIGNING <fs_vbak>.
      WRITE: / <fs_vbak>-vbeln,
               <fs_vbak>-erdat.
    ENDLOOP.
    REFRESH gt_vbak.
  ENDIF.

As you can see from my example, you can use the table(VBAK) itself as work area, or you can define an explicit work area or even a field-symbol if you prefer.

Hope it helps...

P.S. Please award points if it helps...