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

How to READ internal table without LOOP.

Former Member
0 Likes
6,135

experts,

i have a populated internal table with say 4 fields .

without using a loop operation can i get field4 values into an another internal table.

thanks in advance.

Edited by: Julius Bussche on Dec 6, 2008 10:52 AM

13 REPLIES 13
Read only

Former Member
0 Likes
2,772

Hi,

I think you can do it by using Read statement

Read only

Former Member
0 Likes
2,772

This message was moderated.

Read only

Former Member
0 Likes
2,772

THID IS WITH TWO FIELDS IT ALSO WORKS FOR 4FIELDS

TYPES: BEGIN OF TT ,

F1 TYPE CHAR1,

F2 TYPE CHAR1,

END OF TT.

DATA: IT TYPE STANDARD TABLE OF TT,

WA TYPE TT,

IT2 TYPE STANDARD TABLE OF TT,

WA2 TYPE TT.

WA-F1 = 'K'.

WA-F2 = 'I'.

APPEND WA TO IT.

WA-F1 = 'R'.

WA-F2 = 'A'.

APPEND WA TO IT.

WA-F1 = 'N'.

WA-F2 = 'P'.

APPEND WA TO IT.

IT2 = IT.

LOOP AT IT2 INTO WA2 .

WRITE:/ WA2-F1 ,

WA2-F2.

ENDLOOP.

Regards,

Kiran Posanapalli.

Read only

Former Member
0 Likes
2,772

Hi,

Use READ table statement with the specified index.

you will be able to see the record you want.

Thanks

Rajesh kumar

Read only

0 Likes
2,772

experts,

i need all the values at a single stretch nor with any indexing or with key specifications

Read only

0 Likes
2,772

Hi

No! U can't do it, u need LOOP or READ TABLE statament in order to read all records and then move the value of the field to the target table:

LOOP AT ITAB.
   MOVE ITAB-FIELD4 TO ITAB2-FIELD4.
   APPEND ITAB2.
ENDLOOP.

or

DO.
  READ TABLE ITAB INDEX SY-INDEX.
  IF SY-SUBRC <> 0. EXIT. ENDIF.
   MOVE ITAB-FIELD4 TO ITAB2-FIELD4.
   APPEND ITAB2.
ENDDO.

Max

Read only

Former Member
0 Likes
2,772

Hi,

You can just use DESCRIBE statement for gettin number of rows in your internal table.
Then use DO statement for that number of times and move corresponding fields to other internal table.

Thanks

Nitesh

Read only

Former Member
0 Likes
2,772

Hi,

See this code snippet..

DATA n TYPE i.
DESCRIBE TABLE itab1 LINES n.
DO n TIMES.
MOVE-CORRESPONDING itab1 TO itab2.
ENDDO.

Thanks

Read only

Former Member
0 Likes
2,772

hi ,

use MOVE ITAB2 TO ITAB2..

Read only

Former Member
0 Likes
2,772

Hi,

2 ways you can transfer your data from 1 internal table(ITAB1) to other (ITAB2):

1. MOVE ITAB1 TO ITAB2.

2. ITAB2 = ITAB1.

Regards,

Suruchi.

Read only

Former Member
0 Likes
2,772

what do u want exactly?

something like this?

itab2 = itab1

if yes check the statement in ur program it works

Edited by: amit kumar on Dec 6, 2008 4:24 PM

Edited by: amit kumar on Dec 6, 2008 4:25 PM

Read only

0 Likes
2,772

hi amit should be as follows :

itab2[] = itab1-fiel4 ,without looping itab1 or any loop operation as do..enddo etc is it possible with field symbols, ie can we avoid a loop operation to do this.

Edited by: rae z on Dec 6, 2008 12:12 PM

Read only

0 Likes
2,772

Hi

No! U can't do it.