‎2008 Jul 24 4:02 AM
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.
‎2008 Jul 24 4:07 AM
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
‎2008 Jul 24 4:19 AM
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.
‎2008 Jul 24 5:28 AM
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
‎2008 Jul 24 5:31 AM
hi,
Create Another Work Area for the second Internal Table and use it with second Internal table.
Regards
Sumit Agarwal
‎2008 Jul 24 5:33 AM
Hi,
Replace,
*itab1 LIKE itab
itab1 LIKE itab WITH HEADER LINE.Regards
Adil
‎2008 Jul 24 5:38 AM
>
> 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.
‎2008 Jul 24 5:41 AM
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.
‎2008 Jul 24 5:49 AM
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.
‎2008 Jul 24 5:50 AM
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.
‎2008 Jul 24 6:00 AM
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.
‎2008 Jul 24 6:21 AM
Hi Raghu,
Just do this
itab1 like itab. --> itab1 type table of ty,
ur code will run...
reward points if useful.....
regards,
Jay.