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

Reading the Data

Former Member
0 Likes
506

Hi every one ,

My Requirement is i have to fetch the data from KONA table.

by comparing the fields VKORG VTWEG SPART with header table .There i have to compare the Agreement type BOART with Ztable , if it is not there it should delete the invoice from header table.

selecting the data from KONA table with SALES AREA and the Reading the Table with KEY KNUMA.

is this the scenario is ok , pls let me know any suggestions on this issue.

Its Urgent.

Regards,

report zcheck.

tables : vbak.

types : begin of t_head,

vbeln type vbeln,

fkart type fkart,

vkorg type vkorg,

vtweg type vtweg,

spart type spart,

knuma type knuma,

end of t_head,

begin of t_kona ,

knuma type knuma,

boart type boart,

vkorg type vkorg,

vtweg type vtweg,

spart type spart,

end of t_kona.

select-options : s_vbeln for vbak-vbeln.

data : i_head type table of t_head,

w_head type t_head,i_kona type table of t_kona ,w_kona type t_kona,

i_inv type table of zsd_com_AG, w_inv type zsd_com_ag.

select vbeln fkart vkorg vtweg spart knuma from vbrk into table i_head

where vbeln in s_vbeln.

select * from zsd_com_ag into table i_inv.

select knuma boart vkorg vtweg spart from kona into table i_kona for all entries in i_head

where vkorg = i_head-vkorg and vtweg = i_head-vtweg and spart = i_head-spart.

if sy-subrc eq 0.

sort i_kona by vkorg.

sort i_inv by boart.

loop at i_head into w_head.

read table i_kona into w_kona with key knuma = w_head-knuma.

if sy-subrc eq 0.

read table i_inv into w_inv with key boart = w_kona-boart binary search.

if sy-subrc ne 0.

delete table i_head from w_head.

endif.

endif.

endloop.

2 REPLIES 2
Read only

Former Member
0 Likes
450

only performance problem,

Regards

Prabhu

Read only

Former Member
0 Likes
450

i modified ur code so that u will not have any performance issue.

report zcheck.

tables : vbak.

types : begin of t_head,

vbeln type vbeln,

fkart type fkart,

vkorg type vkorg,

vtweg type vtweg,

spart type spart,

knuma type knuma,

end of t_head,

begin of t_kona ,

knuma type knuma,

boart type boart,

vkorg type vkorg,

vtweg type vtweg,

spart type spart,

end of t_kona.

select-options : s_vbeln for vbak-vbeln.

data : i_head type table of t_head,

w_head type t_head,i_kona type table of t_kona ,w_kona type t_kona,

i_inv type table of zsd_com_AG, w_inv type zsd_com_ag.

select vbeln fkart vkorg vtweg spart knuma from vbrk into table i_head

where vbeln in s_vbeln.

<b>if i_head[] is not initial.

select knuma boart vkorg vtweg spart from kona into table i_kona for all entries in i_head

where vkorg = i_head-vkorg and vtweg = i_head-vtweg and spart = i_head-spart.

endif.</b>

<b>if i_kona[] is not initial.

select * from zsd_com_ag into table i_inv for all entries in i_kona where boart = i_kona-boart.

endif.</b>

if sy-subrc eq 0.

sort i_kona by knuma.

sort i_inv by boart.

loop at i_head into w_head.

<b>read table i_kona into w_kona with key knuma = w_head-knuma binary search.</b>

if sy-subrc eq 0.

read table i_inv into w_inv with key boart = w_kona-boart binary search.

if sy-subrc ne 0.

delete table i_head from w_head.

endif.

endif.

endloop.