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

Writing data from an Internal Table declared indirectly

Former Member
0 Likes
1,092

Hi All!

I'm a new ABAP learner. First of all this forums seems to be a very valuable resource for starters like me. I have a small rather silly problem. I want to write data from an internal table which is declared indirectly in the following manner:

TYPES : BEGIN OF TEMP,

A TYPE I,

B TYPE I,

END OF TEMP.

DATA : TEMP1 TYPE TEMP. " using a structure obj as HL

DATA : ITAB TYPE TEMP1 OCCURS 3.

DO 3 TIMES.

TEMP1-A = SY-INDEX.

TEMP1-B = SY-INDEX * 10.

APPEND TEMP1 TO ITAB.

ENDDO.

From here I want to write the values from ITAB.

can someone help me with this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,056

Hi

LOOP AT ITAB INTO TEMP1.

WRITE: / TEMP1-A,

TEMP1-B.

ENDLOOP.

Max

10 REPLIES 10
Read only

Manohar2u
Active Contributor
0 Likes
1,056

Welcome srikanth.

TYPES : BEGIN OF TEMP,

A TYPE I,

B TYPE I,

END OF TEMP.

DATA : TEMP1 TYPE TEMP. " using a structure obj as HL

DATA : ITAB TYPE TEMP1 OCCURS 3.

DO 3 TIMES.

TEMP1-A = SY-INDEX.

TEMP1-B = SY-INDEX * 10.

APPEND TEMP1 TO ITAB.

ENDDO.

After append you can write itab in this way.

<b>loop at itab.

write itab-a, itab-b.

endloop.</b>

Regds

Manohar

Message was edited by: Manohar Reddy

Read only

Former Member
0 Likes
1,056

Well thanks for the quick reply Manohar!

Unfortunately this did'nt work as I have tried before. The reason is the internal table ITAB does not have a direct header line so it cannot have attributes A and B so we can't use ITAB-A and ITAB-B here.

Read only

0 Likes
1,056

This works good for me.



types : begin of temp,
a type i,
b type i,
end of temp.

data : temp1 type temp. " using a structure obj as HL
<b>data : itab type temp occurs 3.</b>

do 3 times.
  temp1-a = sy-index.
  temp1-b = sy-index * 10.
  append temp1 to itab.
enddo.


<b>loop at itab into temp1.
  write:/ temp1-a, temp1-b.
endloop.</b>


Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,056

Thanks once again Rich!

Regards,

Sri.

Read only

0 Likes
1,056

Please mark <b>ANY</b> helpful answers here.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,056

Thanks Rich

Max

Read only

Former Member
0 Likes
1,057

Hi

LOOP AT ITAB INTO TEMP1.

WRITE: / TEMP1-A,

TEMP1-B.

ENDLOOP.

Max

Read only

0 Likes
1,056

Thanks Max and Rich!

Looks like u have given me the right solution. I will try this.

Thanks once aagain.

Regards,

Sri.

Read only

0 Likes
1,056

Please make sure that you award helpful answers and mark your post as solved when solved completely. Thanks.

Regards,

Rich Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,056
Loop at itab into temp1.
write:/ temp1-a, temp1-b.
endloop.

Regards,

Rich Heilman