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

Re : Internal table

Former Member
0 Likes
962

Hi all,

I have one doubt in internal table.

My code as follows ;

types : begin of ty,

vbeln type vbak-vbeln,

ernam type vbak-ernam,

netwr type vbak-netwr,

end of ty.

data : itab type table of ty,

wa type ty

itab1 like itab.

select vbeln ernam netwr from vbak into table itab up to 10 rows.

loop at itab into wa.

write : wa-vbeln,wa-ernam,wa-netwr.

endloop.

move itab to itab1.

loop at itab1.

write 😕 itab1-vbeln,itab1-ernam,itab1-netwr.

endloop.

when I check the above .The error message will show itab1 has no header-line and therefore no vbeln.

My question is, How can I get data from Itab1.

thanks in advance,

raghul.

11 REPLIES 11
Read only

peter_ruiz2
Active Contributor
0 Likes
937

hi,

you need to create a work area for your internal table.


types : begin of ty,
vbeln type vbak-vbeln,
ernam type vbak-ernam,
netwr type vbak-netwr,
end of ty.

data : itab type table of ty,
wa type ty
itab1 like itab,
wa1 type ty.

select vbeln ernam netwr from vbak into table itab up to 10 rows.

loop at itab into wa.
write : wa-vbeln,wa-ernam,wa-netwr.
endloop.

move itab to itab1.

*loop at itab1.
loop at itab1 into wa1.

*write :/ itab1-vbeln,itab1-ernam,itab1-netwr.
write:/ wa1-vbeln, wa1-ernam, wa1-netwr.

endloop.

regards,

Peter

Read only

Former Member
0 Likes
937

Hi,

see below coding..

types : begin of ty,

vbeln type vbak-vbeln,

ernam type vbak-ernam,

netwr type vbak-netwr,

end of ty.

data : itab type table of ty.

data : itab1 like itab with header line,

wa type ty.

select vbeln ernam netwr from vbak into table itab up to 10 rows.

loop at itab into wa.

move wa-vbeln to itab1-vbeln.

move wa-ernam to itab1-ernam.

move wa-netwr to itab1-netwr.

append itab1.

write : wa-vbeln,wa-ernam,wa-netwr.

endloop.

skip 2.

loop at itab1.

write 😕 itab1-vbeln,itab1-ernam,itab1-netwr.

endloop.

Read only

Former Member
0 Likes
937

Hi Ragul,

You need to deaclare another Work Area(WA1),

TYPES : BEGIN OF ty,

vbeln TYPE vbak-vbeln,

ernam TYPE vbak-ernam,

netwr TYPE vbak-netwr,

END OF ty.

DATA : itab TYPE TABLE OF ty.

DATA : wa TYPE ty.

DATA : itab1 LIKE itab.

DATA : wa1 TYPE ty.

SELECT vbeln ernam netwr FROM vbak INTO TABLE itab UP TO 10 ROWS.

LOOP AT itab INTO wa.

WRITE : wa-vbeln,wa-ernam,wa-netwr.

ENDLOOP.

MOVE itab TO itab1.

LOOP AT itab1 INTO wa1.

WRITE 😕 wa-vbeln,wa-ernam,wa-netwr.

ENDLOOP.

Regards

Hema

Read only

Former Member
0 Likes
937

hi,

Create Another Work Area for the second Internal Table and use it with second Internal table.

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
937

Hi,

Replace,

*itab1 LIKE itab 
  itab1 LIKE itab WITH HEADER LINE.

Regards

Adil

Read only

Former Member
0 Likes
937

>

> Hi all,

>

> I have one doubt in internal table.

>

> My code as follows ;

>

> types : begin of ty,

> vbeln type vbak-vbeln,

> ernam type vbak-ernam,

> netwr type vbak-netwr,

> end of ty.

>

> data : itab type table of ty,

> wa type ty

> itab1 like itab.

>

> select vbeln ernam netwr from vbak into table itab up to 10 rows.

>

> loop at itab into wa.

> write : wa-vbeln,wa-ernam,wa-netwr.

> endloop.

>

> move itab to itab1.

>

> loop at itab1.

>

> write :/ itab1-vbeln,itab1-ernam,itab1-netwr.

>

> endloop.

>

> when I check the above .The error message will show itab1 has no header-line and therefore no vbeln.

>

> My question is, How can I get data from Itab1.

>

> thanks in advance,

>

> raghul.

u r getting the error because u have not defined any header line or explicit work area.

for example there are 2 ways doing it

data: itab1 type standard table of ty with header line.

or

data: itab1 type standard table of ty,

wa1 like line of itab1.

and while looping

loop at itab1 into wa1.

so u r code should be modified as

types : begin of ty,

vbeln type vbak-vbeln,

ernam type vbak-ernam,

netwr type vbak-netwr,

end of ty.

data : itab type table of ty,

wa type ty

itab1 like itab,

wa1 like line of itab1.

select vbeln ernam netwr from vbak into table itab up to 10 rows.

loop at itab into wa.

write : wa-vbeln,wa-ernam,wa-netwr.

endloop.

move itab to itab1.

loop at itab1 into wa1.

write 😕 wa1-vbeln,wa1-ernam,wa1-netwr.

endloop.

Read only

Former Member
0 Likes
937

Hi Raghul,

you can do ur task in following way...

types : begin of ty,

vbeln type vbak-vbeln,

ernam type vbak-ernam,

netwr type vbak-netwr,

end of ty.

data : itab type table of ty with header line,"(include with header line)

wa type ty,

itab1 like itab.

select vbeln ernam netwr from vbak into table itab up to 10 rows.

loop at itab into wa.

write : wa-vbeln,wa-ernam,wa-netwr.

endloop.

move itab to itab1.

loop at itab1.

write 😕 itab1-vbeln,itab1-ernam,itab1-netwr.

endloop.

i hope this will work ...

Thanks & regards

Ashu Singh.

Read only

Former Member
0 Likes
937

Try this.....

TYPES : BEGIN OF TY,
VBELN TYPE VBAK-VBELN,
ERNAM TYPE VBAK-ERNAM,
NETWR TYPE VBAK-NETWR,
END OF TY.

DATA : ITAB TYPE TABLE OF TY,
WA TYPE TY,
ITAB1 TYPE STANDARD TABLE OF TY.

SELECT VBELN ERNAM NETWR FROM VBAK INTO TABLE ITAB UP TO 10 ROWS.

LOOP AT ITAB INTO WA.
WRITE : / WA-VBELN,WA-ERNAM,WA-NETWR.
ENDLOOP.

MOVE ITAB TO ITAB1.

LOOP AT ITAB1 INTO WA.
WRITE :/ WA-VBELN,WA-ERNAM,WA-NETWR.

ENDLOOP.

Read only

Former Member
0 Likes
937

types : begin of ty,

vbeln type vbak-vbeln,

ernam type vbak-ernam,

netwr type vbak-netwr,

end of ty.

data : itab type table of ty,

wa TYPE ty,

itab1 like itab.

select vbeln ernam netwr from vbak into table itab up to 10 rows.

loop at itab into wa.

write 😕 wa-vbeln,wa-ernam,wa-netwr.

endloop.

move itab to itab1.

skip 5.

loop at itab1 into wa.

*write 😕 itab1-vbeln,itab1-ernam,itab1-netwr.

write 😕 wa-vbeln,wa-ernam,wa-netwr.

endloop.

Read only

Former Member
0 Likes
937

Hi,

For itab there is no header line and u have created header line explicitly..

if u want u r code to be executed then create the header line for itab1 with the same name as,

data:

itab1 like standard table of itab with header line.

writew like this..

regards

Sunil KUmar Mutyala.

Read only

Former Member
0 Likes
937

Hi Raghu,

Just do this

itab1 like itab. --> itab1 type table of ty,

ur code will run...

reward points if useful.....

regards,

Jay.