04-02-2009 7:33 AM
Hi,
it is my first program in abap, iam getting errors in my program
i take one internal table for vbak (both vbak avbap fields)and another internal table for vbap(only vbap fields)
I want both fields in vbak internal table. How cal i get it.
In this program iam getting runtime error. Pls any one correct this program
tables: vbak,vbap.
types:begin of it_vbak,
vbeln like vbak-vbeln,
audat like vbak-audat,
auart like vbak-auart,
posnr like vbap-posnr,
arktx like vbap-arktx,
end of it_vbak.
types:begin of it_vbap,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
arktx like vbap-arktx,
end of it_vbap.
data:i_vbak type standard table of it_vbak with header line initial size
0,
i_vbap type standard table of it_vbap with header line initial size
0.
select-options: s_audat for vbak-audat.
select vbeln audat auart from vbak into corresponding fields of table
i_vbak where audat in s_audat.
select vbeln posnr arktx from vbap into corresponding fields of table
i_vbap where vbeln = i_vbak-vbeln.
loop at i_vbak.
read table i_vbap with key vbeln = i_vbak-vbeln.
if sy-subrc = 0.
i_vbak-posnr = i_vbap-posnr.
i_vbak-arktx = i_vbap-arktx.
clear i_vbap.
endif.
append i_vbak.
endloop.
loop at i_vbak.
write:/ i_vbak-vbeln,i_vbak-audat,i_vbak-posnr,i_vbak-arktx.
endloop.
04-02-2009 7:42 AM
Hi , make the structure having fields of both VBAP and VBAK.
Types:begin of T_VBAK_VBAP,
vbeln like vbak-vbeln,
audat like vbak-audat,
auart like vbak-auart,
posnr like vbap-posnr,
arktx like vbap-arktx,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
arktx like vbap-arktx,
end of T_VBAK_VBAP.
make a internal table and work area and populate the internal table and use them as per ur requirement.
Amresh
04-02-2009 8:03 AM
What's the error that u r getting.. ur report has a lot of performance issues... the same report can be done in a simple manner.. first do let us know the runtime error which u r getting...then only anyone can help with correct solutions...
04-02-2009 8:03 AM
Hello,
First of all donot use With header line initial size 0 coz header line has become obsolete.
Secondly Write
MODIFY IT_VBAK instead of writing APPEND IT_VBAK
Hope it helps.
04-02-2009 8:16 AM
Hello,
Sorry
In my earlier reply i told to remove the header line.
You need not do that.
Only use modify IT_VBAK instead of Append IT_VBAK and you will get the required result.
Thanks and regards
Richa
04-02-2009 9:07 AM
HI,
Create an internal table with all tghe fields you want from both the table then use inner join on both table and use INTO table <your internal table>.
This will solve your problem.
04-02-2009 12:03 PM
hi sri
i have done some changes in second select statement i think you are not getting the data in second internal table i_vbap. and change Append i_vbak to modify i_vbak. check the below modified code and mark the changes.
tables: vbak,vbap.
types: begin of it_vbak ,
vbeln like vbak-vbeln,
audat like vbak-audat,
auart like vbak-auart,
posnr like vbap-posnr,
arktx like vbap-arktx,
end of it_vbak.
types:begin of it_vbap,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
arktx like vbap-arktx,
end of it_vbap.
data:i_vbak type standard table of it_vbak with header line initial size
0,
i_vbap type standard table of it_vbap with header line initial size
0.
select-options: s_audat for vbak-audat.
select vbeln audat auart from vbak into corresponding fields of table
i_vbak where audat in s_audat.
select vbeln posnr arktx from vbap into corresponding fields of table
i_vbap FOR ALL ENTRIES IN i_vbak where vbeln = i_vbak-vbeln.
loop at i_vbak.
read table i_vbap with key vbeln = i_vbak-vbeln.
if sy-subrc = 0.
i_vbak-posnr = i_vbap-posnr.
i_vbak-arktx = i_vbap-arktx.
clear i_vbap.
endif.
MODIFY i_vbak.
endloop.
loop at i_vbak.
write:/ i_vbak-vbeln,i_vbak-audat,i_vbak-posnr,i_vbak-arktx.
endloop.
04-02-2009 12:19 PM