Application Development 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: 

vbak and vbap fields in one internal table

Former Member
0 Kudos

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.

7 REPLIES 7

Former Member
0 Kudos

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

former_member305388
Active Contributor
0 Kudos

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...

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

umashankar_sahu
Active Participant
0 Kudos

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.

0 Kudos

Hi umashankar,

i got the output . Thanks umashankar