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

Internal table declaration - work area and body

Former Member
0 Likes
693

Hi all

I have declared my internal table in my program as


data : itab_wa type ZRESULT_LINE,
       itab    type ZRESULT_ROW.

Where ZRESULT_LINE and ZRESULT_ROW are the structure and table types.

Now I want to add


data: TCOLOR TYPE SLIS_T_SPECIALCOL_ALV.

in my internal table declaration. How can I do this. Please remember I need to have work area and body in my internal table as I have used work area and body in my code.

Waiting..............

Message was edited by: Raju Boda

Hi all

I have declared my internal table in my program as


data : itab_wa type ZRESULT_LINE,
       itab    type ZRESULT_ROW.

Where ZRESULT_LINE and ZRESULT_ROW are the structure and table types.

Now I want to add


data: TCOLOR TYPE SLIS_T_SPECIALCOL_ALV.

in my internal table declaration. How can I do this. Please remember I need to have work area and body in my internal table as I have used work area and body in my code.

Waiting..............

Message was edited by: Raju Boda

5 REPLIES 5
Read only

Former Member
0 Likes
643

If the table type is SLIS_T_SPECIALCOL_ALV, then your work area would be SLIS_SPECIALCOL_ALV. So your declaration will be like

DATA : it_color type SLIS_T_SPECIALCOL_ALV,

wa_color type SLIS_SPECIALCOL_ALV.

Also you need to include the following statement in the TOP include of your program:

TYPE-POOLS: SLIS.

hith

Sunil Achyut

Message was edited by: Sunil Achyut

Read only

Former Member
0 Likes
643

HI,

See the Declarion types of workarea and Internal tables

* Table declaration (old method)
DATA: BEGIN OF tab_ekpo OCCURS 0,             "itab with header line
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
 END OF tab_ekpo.

*Table declaration (new method)     "USE THIS WAY!!!
TYPES: BEGIN OF t_ekpo,
  ebeln TYPE ekpo-ebeln,
  ebelp TYPE ekpo-ebelp,
 END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,      "itab
      wa_ekpo TYPE t_ekpo.                    "work area (header line)

* Build internal table and work area from existing internal table
DATA: it_datatab LIKE tab_ekpo OCCURS 0,      "old method
      wa_datatab LIKE LINE OF tab_ekpo.

* Build internal table and work area from existing internal table,
* adding additional fields
TYPES: BEGIN OF t_repdata.
        INCLUDE STRUCTURE tab_ekpo.  "could include EKKO table itself!!
TYPES: bukrs  TYPE ekpo-werks,
       bstyp  TYPE ekpo-bukrs.
TYPES: END OF t_repdata.
DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0,   "itab
      wa_repdata TYPE t_repdata.                 "work area (header line

.

you need to maintain same structure for both workarea as well Internal table

Regards

Sudheer

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
643

You may be able to do somethingn like this.



report  zrich_0003.

Type-pools: slis.

types: begin of ttab.
        include structure ZRESULT_LINE.
types: tcolor type slis_t_specialcol_alv.
types: end of ttab.

data: itab type table of ttab.
data: wa like line of itab.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
643

i think you are using nested table for coloring the cells

use this way..

types: begin of i_struc,

field1 type ....,

field2 type ....,

field3 type ....,

field4 type ....,

TCOLOR TYPE SLIS_T_SPECIALCOL_ALV,

end of i_struc.

data: itab type standard table of i_struc,

line type i_struc,

col_line type slis_specialcol_alv.

now while populating

col_line-fild = ''

..

..

line-tcol = col_line.

append line to itab.

Read only

0 Likes
643

data : tcol type slis_t_specialcol_alv,

scol type slis_specialcol_alv.

scol-filed1 = ''

scol-filed1 = ''

scol-filed1 = ''

append scol to tcol.

move this tcol to your line.

then append this line to your internal table.

all the best