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

Select statement modification

Former Member
0 Likes
922

HI all,

Because of the below select statement my performance has degraded.

SELECT VBELN FROM LIKP INTO FS_LIKP.

append FS_likP TO T_LIKP.

endselect.

Any suggestions to improve my performance i want to fetch only VBELN records from the table likp.

Regards

VEnk@

8 REPLIES 8
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
886

No where clause ?

Read only

0 Likes
886

Hi all,

I will be bit more clear with my requirement.

Below field1 field2 and field3 are fields of table zfpr_data.

field1 field2 field3

X X Y

Y B Z

A Y A

I have fetched the 3 fields records in an internal table.Now out of three field records X Y Z A B out this any one

can be delivery number, so i need to pick only those out of (X Y Z A B) which is present in LIKP table.

Select query for LIKP

FORM get_likp.

SELECT VBELN FROM LIKP INTO FS_LIKP.

append FS_likP TO T_LIKP.

endselect.

endform.

my select query which i am using to fetch field1,2 and 3 is

SELECT field1 field2 field3 data1

FROM zfpr_data

INTO TABLE t_fpr_data

WHERE ztimestamp

GE w_last_run.

Now i need to fetch only those field records which are present in LIKP.

For this i am looping the records as shown below

loop at t_fpr_data into fs_fpr_data .

READ TABLE t_LIKP into fs_likp WITH KEY

vbeln = fs_fpr_data-field1

BINARY SEARCH.

IF sy-subrc EQ 0.

APPEND fs_fpr_data-tdl_no TO t_vbeln.

CONTINUE.

ENDIF.

Any corrections on this will be welcomed.

Regards

VEnk@

Read only

0 Likes
886

I suggest an option like you can create a range with value X Y Z A B and then use it in select query.

wa-option = 'EQ".

wa-sign = 'I".

loop ait itab into wa1.

wa-low = wa1-field1.

collect wa into ra_del.

wa-low = wa1-field2.

collect wa into ra_del.

wa-low = wa1-field3.

collect wa into ra_del.

endloop.

select * from likp where vbeln in ra_del.

Read only

Former Member
0 Likes
886

se38

CTRL+F8

type Select into, press enter

click 3d option about into table.

read.

Kind regards, Rob Dielemans

Read only

Former Member
0 Likes
886
data: fs_likp type table of vbeln,
         wa_likp type vbeln.

select vbeln from likp into table fs_likp.

loop at fs_likp into wa_likp.
append wa_likp to t_likp.
clear wa_likp.
endloop.

Edited by: Harini Gopinath on Nov 11, 2009 7:35 PM

Edited by: Harini Gopinath on Nov 11, 2009 7:35 PM

Read only

Former Member
0 Likes
886

Hi Venkat,

This will obviously have a performance issue. Because you have not optimized the SELECT query by giving anything in the where clause. In this case the whole databased will be scanned for each & every record.

Please write you complete requirement.

Regards

Abhii....

Read only

former_member191735
Active Contributor
0 Likes
886

> SELECT VBELN FROM LIKP INTO FS_LIKP.

> append FS_likP TO T_LIKP.

> endselect.

> Any suggestions to improve my performance i want to fetch only VBELN records from the table likp.

no wonder why the performance is poor .......

1) There is no where clause - You are selecting all records which means if you have million records in LIKP table, you selecting all of them

2) You are selecting million records then you are appending into table for each record.... this is useless statement.

Define internal table for VBELN and then select VBELN into Table t_likp from likp where vbeln = "your where clause.

If you cannot solve yourself.... try to go to Examples which SAP provided

Go to SE38 - enter into your program - environment (from application menu) - Examples - abap examples- You will see basic select statement there

Read only

Former Member
0 Likes
886

Moderator message - Please re-ask this question stating your requirements at the beginning, not after responders have tried to help you without knowing what you really want - thread locked