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

Hi,

Iam not able to create an internal table.

Plz correct 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,

IT_EMP TYPE TABLE OF TY_EMP initial size 0.

*TABLE TYPE:

TYPES:

IT_EMP TYPE TABLE OF TY_EMP OCCURS 0.

FS_EMP-EMPID = 1000.

FS_EMP-ENAME = 'ANIL'.

FS_EMP-SALARY = 10000.

APPEND FS_EMP TO IT_EMP.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

<b>Using write statement </b>

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 initial size 0.

*TABLE TYPE:
*TYPES:IT_EMP TYPE TABLE OF TY_EMP initial size 0.

FS_EMP-EMPID = 1000.
FS_EMP-ENAME = 'ANIL'.
FS_EMP-SALARY = 10000.
APPEND FS_EMP TO IT_EMP.


write 😕 FS_EMP-EMPID,
FS_EMP-ENAME ,
FS_EMP-SALARY .

reward points if it is usefull....

Girish

7 REPLIES 7

Former Member
0 Kudos

Hi,

Dont use occurs statement.

Type table itself creates a table for you.

IT_EMP TYPE TABLE OF TY_EMP.

Reward if useful1

Former Member
0 Kudos

Hi

U can use several ways to declare an internal table:

A)

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.


FS_EMP-EMPID = 1000.
FS_EMP-ENAME = 'ANIL'.
FS_EMP-SALARY = 10000.
APPEND FS_EMP TO IT_EMP.

B)

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.


FS_EMP-EMPID = 1000.
FS_EMP-ENAME = 'ANIL'.
FS_EMP-SALARY = 10000.
APPEND FS_EMP TO IT_EMP.

C)

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 TY_EMP OCCURS 0.


FS_EMP-EMPID = 1000.
FS_EMP-ENAME = 'ANIL'.
FS_EMP-SALARY = 10000.
APPEND FS_EMP TO IT_EMP.

All these kind of declarations create a STANDARD TABLE without header line, so you need to use a workarea to read it:

LOOP AT IT_EMP INTO FS_EMP.

ENDLOOP.

Max

Former Member
0 Kudos

<b>Try now it was working ......</b>

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 initial size 0.

*TABLE TYPE:
TYPES:IT_EMP TYPE TABLE OF TY_EMP initial size 0.

FS_EMP-EMPID = 1000.
FS_EMP-ENAME = 'ANIL'.
FS_EMP-SALARY = 10000.
APPEND FS_EMP TO IT_EMP. 

reward points if it is usefull....

Girish

Former Member
0 Kudos

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 initial size 0.

FS_EMP-EMPID = 1000.
FS_EMP-ENAME = 'ANIL'.
FS_EMP-SALARY = 10000.
APPEND FS_EMP TO IT_EMP. 

0 Kudos

Hi,

I had corrected the program.now it is syntactically correct. Now i want to see the print in the screen when i execute.so what else i have to write

Former Member
0 Kudos

hi,

type table of is similar to occurs keyword. now need to give two.

and initialize values in initialization event.

INITIALIZATION.

FS_EMP-EMPID = 1000.

FS_EMP-ENAME = 'SURESH'.

FS_EMP-SALARY = 10000.

APPEND FS_EMP TO IT_EMP.

if helpful reward some points..

with regards,

Suresh.A

Former Member
0 Kudos

<b>Using write statement </b>

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 initial size 0.

*TABLE TYPE:
*TYPES:IT_EMP TYPE TABLE OF TY_EMP initial size 0.

FS_EMP-EMPID = 1000.
FS_EMP-ENAME = 'ANIL'.
FS_EMP-SALARY = 10000.
APPEND FS_EMP TO IT_EMP.


write 😕 FS_EMP-EMPID,
FS_EMP-ENAME ,
FS_EMP-SALARY .

reward points if it is usefull....

Girish