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: 

Internal Table.

Former Member
0 Kudos
149

Hi,

I want to create an Internal table.

But iam programming error that IT_EMP is not defined. plz correct it.

TYPES:

BEGIN OF TY_EMP,

EMPID(4) TYPE N,

ENAME(20) TYPE C,

SALARY TYPE I,

END OF TY_EMP.

DATA:

FS_EMP TYPE TY_EMP.

IT_EMP TYPE TABLE OF TY_EMP OCCURS 0.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
115

please see this internal table decalration types

* 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)

reward points if it is usefull...

Girish

11 REPLIES 11

Former Member
0 Kudos
115

please try now ...

TYPES:
BEGIN OF TY_EMP,
EMPID(4) TYPE N,
ENAME(20) TYPE C,
SALARY TYPE I,
END OF TY_EMP.

DATA:FS_EMP TYPE TY_EMP,
IT_EMP TYPE TABLE OF TY_EMP . 

reward points if it is usefull.....

Girish

0 Kudos
115

Hi

If i write occurs 0 means it creats an internal table with psace 8 k.b. So what is the wrong there.

Thanks.

gopi_narendra
Active Contributor
0 Kudos
115

TYPES: BEGIN OF TY_EMP,
         EMPID(4) TYPE N,
         ENAME(20) TYPE C,
         SALARY TYPE I,
       END OF TY_EMP.
DATA: FS_EMP TYPE TY_EMP,
      IT_EMP TYPE STANDARD TABLE OF TY_EMP INITIAL SIZE 0. " SEE HERE

OR SEE THIS

TYPES:BEGIN OF ty_emp,
empid(4) TYPE n,
ename(20) TYPE c,
salary TYPE i,
END OF ty_emp.

DATA:fs_emp TYPE ty_emp.
DATA :it_emp TYPE TABLE OF ty_emp.

Regards

Gopi

Former Member
0 Kudos
115

Hi,

you have put 'dot' on the end of line that FS_EMP TYPE TY_EMP. please put 'comma' on the end of the line.

correct syntax is,

DATA:

FS_EMP TYPE TY_EMP,

IT_EMP TYPE TABLE OF TY_EMP OCCURS 0.

If it helps you please reward me....

Regards,

Suresh kumar. V

0 Kudos
115

hI,

I had corrected.

still it is giving the error.

*LINE TYPE:

TYPES:

BEGIN OF TY_EMP,

EMPID(4) TYPE N,

ENAME(20) TYPE C,

SALARY TYPE I,

END OF TY_EMP.

DATA:

FS_EMP TYPE TY_EMP,

IT_EMP TYPE TABLE OF TY_EMP OCCURS 0.

Occurs is not defined. this is the error.

0 Kudos
115

take out occurs 0 and follow the code in my above post

Regards

Gopi

0 Kudos
115

Hi,

Change this

IT_EMP TYPE TABLE OF TY_EMP OCCURS 0.

to

IT_EMP TYPE TABLE OF TY_EMP.

Regards,

Atish

Former Member
0 Kudos
115

TYPES: BEGIN OF TY_EMP,
                   EMPID(4) TYPE N,
                   ENAME(20) TYPE C,
                   SALARY TYPE I,
              END OF TY_EMP.

DATA: IT_EMP TYPE TABLE OF TY_EMP .

Hope this answers your curiosity,

Award points if useful else getbk,

Aleem.

Former Member
0 Kudos
116

please see this internal table decalration types

* 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)

reward points if it is usefull...

Girish

Former Member
0 Kudos
115

TYPES:BEGIN OF TY_EMP,

EMPID(4) TYPE N,

ENAME(20) TYPE C,

SALARY TYPE I,

END OF TY_EMP.

DATA : WA_ITAB TYPE TABLE OF TY_EMP.

YOU CAN WRITE LIKE THIS , IT WILL CREAT BOTH WORK AREA AND INTERNAL TABLE BODY WITH THE SAME NAME

REWARD IF USEFUL

REGARDS

NAREHS

Former Member
0 Kudos
115

so based on the last message i gave about the internal table declarations your query is

TYPES:
BEGIN OF TY_EMP,
EMPID(4) TYPE N,
ENAME(20) TYPE C,
SALARY TYPE I,
END OF TY_EMP.

DATA:
FS_EMP TYPE TY_EMP,
IT_EMP TYPE STANDARD TABLE OF TY_EMP INITIAL SIZE 0.

reward points if it is usefull ....

Girish