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: 

Performance wise which is the best

Former Member
0 Kudos

Hi all,

Here iam giving you Two programs, which will give the same output. But My question is Performance wise which is the Best program.

Program No: 1.

DATA: WA_SBOOK TYPE SBOOK.

SELECT * FROM SBOOK INTO WA_SBOOK

WHERE

CARRID = 'LH ' AND

CONNID = '0400' AND

FLDATE = '20040424'

ORDER BY PRIMARY KEY.

WRITE: / WA_SBOOK-BOOKID,17 WA_SBOOK-CUSTOMID,

29 WA_SBOOK-CUSTTYPE, 40 WA_SBOOK-SMOKER,

50 WA_SBOOK-LUGGWEIGHT, 65 WA_SBOOK-WUNIT,

75 WA_SBOOK-INVOICE.

ENDSELECT.

-


Program No : 2.

DATA: BEGIN OF A_SBOOK,

BOOKID TYPE SBOOK-BOOKID,

CUSTOMID TYPE SBOOK-CUSTOMID,

CUSTTYPE TYPE SBOOK-CUSTTYPE,

SMOKER TYPE SBOOK-SMOKER,

LUGGWEIGHT TYPE SBOOK-LUGGWEIGHT,

WUNIT TYPE SBOOK-WUNIT,

INVOICE TYPE SBOOK-INVOICE,

END OF A_SBOOK.

DATA: ITAB LIKE STANDARD TABLE OF A_SBOOK.

START-OF-SELECTION.

SELECT BOOKID

CUSTOMID

CUSTTYPE

SMOKER

LUGGWEIGHT

WUNIT

INVOICE

FROM SBOOK

INTO TABLE ITAB

WHERE CARRID = 'LH ' AND

CONNID = '0400' AND

FLDATE = '20040424'.

LOOP AT ITAB INTO A_SBOOK.

WRITE: / A_SBOOK-BOOKID,17 A_SBOOK-CUSTOMID,

29 A_SBOOK-CUSTTYPE, 40 A_SBOOK-SMOKER,

50 A_SBOOK-LUGGWEIGHT, 65 A_SBOOK-WUNIT,

75 A_SBOOK-INVOICE.

ENDLOOP.

Thanks in Advance

Sri..

1 ACCEPTED SOLUTION

Former Member
0 Kudos

<b>Program no 2 is best

In u r Program no 1 you are using select endselect then u r hitting the databasetable SBOOK so many times.

so u r database load will be high

we should reduce this

This can be achived by second program

</b>

5 REPLIES 5

Former Member
0 Kudos

<b>Program no 2 is best

In u r Program no 1 you are using select endselect then u r hitting the databasetable SBOOK so many times.

so u r database load will be high

we should reduce this

This can be achived by second program

</b>

Former Member
0 Kudos

Hi Krishna ,

Program No 2 is better .

I have two reason to support my statement

1. In Program 1 you are selecting all the feilds even though you dont need them , this is not advisable.

2. In program 1 select endselect is used , which shoud be avoided.

Regards

Arun

Former Member
0 Kudos

Program 2 is Best .

Because

Select * == > It select complete fields from table SBOOK , Even if you need 7 Fields for out put .

<i>SELECT BOOKID CUSTOMID CUSTTYPE SMOKER LUGGWEIGHT

WUNIT INVOICE FROM SBOOK</i>

This selects only needed fields from the table .

Former Member
0 Kudos

2nd prog is better than 1.

one already discussed i am saying one thing...

instead of orderby clause in select just take the data in itab and then sort it.

regards

shiba dutta

Former Member
0 Kudos

hi

good

use the tcode SLIN and extended Syntax Check for these two program ,you ll get a good result,bcz some of the messages and syntax you wont find by analysing the code.

Thanks

mrutyun^