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

Efficiency problem

Former Member
0 Likes
440

I need to make the best efficient selection, i have to catch the data in 2 tables, the registers have to be in the first table, but not in the second, can i make a join?,

example:

select * from ekpo where LOEKZ <> 'X'.

select single * from lips where VGBEL = ekpo-vbeln.

if sy-subrc <> 0.

append gt_result.

endif.

endselect.

Thanks in advance,

regards

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
407

Maybe you can do a subquery in an fetch. VBELN does not exist in EKPO in my system. Even with this there will be some issues, you are not selecting from EKPO with a valid key. It will do an entire table scan.



select ebeln into table gt_result
           from ekpo as e
                 where loekz = space
                    and not exists ( Select * from lips
                                        <b>where vgbel = e~ebeln</b> ).


Regards,

Rich Heilman

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
408

Maybe you can do a subquery in an fetch. VBELN does not exist in EKPO in my system. Even with this there will be some issues, you are not selecting from EKPO with a valid key. It will do an entire table scan.



select ebeln into table gt_result
           from ekpo as e
                 where loekz = space
                    and not exists ( Select * from lips
                                        <b>where vgbel = e~ebeln</b> ).


Regards,

Rich Heilman

Read only

naimesh_patel
Active Contributor
0 Likes
407

hello,

First go to EKKO.. use any index based on the Date. and then go to EKPO to search for the LOEKZ = 'X' for the PO number.

Regards,

Naimesh

Read only

christian_wohlfahrt
Active Contributor
0 Likes
407

Hi Carl!

Of course you should make your EKPO select more efficient (have a look into SE11 - Indizes), but for LIPS is an easy way possible:

  SELECT * INTO TABLE gt_result
          FROM ekpo AS e
         WHERE ebeln IN s_ebeln
          AND  loekz EQ space
          AND NOT EXISTS ( SELECT * FROM lips
                                WHERE vgbel = e~ebeln ).

LIPS has an index on VGBEL, so this should be fine. Maybe you make a range for ebeln, than you can start several jobs in parallel... or re-use already select lists.

Regards,

Christian