2007 Feb 12 5:37 AM
Hi all,
Performance wise which of the following program is the Best . Why it is Best?
Program No : 1.
DATA: ITAB TYPE STANDARD TABLE OF scarr WITH NON-UNIQUE
DEFAULT KEY INITIAL SIZE 100,
wa_itab TYPE scarr.
WA_ITAB TYPE SCARR.
SELECT * INTO TABLE itab FROM scarr.
LOOP AT itab INTO wa_itab.
WRITE:/ wa_itab-carrid,10 wa_itab-carrname,35 wa_itab-CURRCODE, 45
wa_itab-URL.
ENDLOOP.
-
program No : 2
DATA: BEGIN OF D_SCARR,
CARRID TYPE SCARR-CARRID,
CARRNAME TYPE SCARR-CARRNAME,
CURRCODE TYPE SCARR-CURRCODE,
URL TYPE SCARR-URL,
END OF D_SCARR.
DATA: ITAB LIKE STANDARD TABLE OF D_SCARR.
SELECT CARRID CARRNAME CURRCODE URL
FROM SCARR
INTO TABLE ITAB.
LOOP AT ITAB INTO D_SCARR.
WRITE: D_SCARR-CARRID,10 D_SCARR-CARRNAME, 35 D_SCARR-CURRCODE, 45
D_SCARR-URL.
ENDLOOP.
-
2 ) what is the difference Between these two
wa_itab TYPE scarr. and
WA_ITAB TYPE SCARR.
Thanks in Advance
Sri...
2007 Feb 12 5:51 AM
i think 2nd one is better because instead of using select * always use the fieldnames in select query.
and
wa_itab TYPE scarr. and
WA_ITAB TYPE SCARR.
both are same because abap is not case sensitive.
regards
shiba dutta
i think 2nd one is better because instead of using select * always use the fieldnames in select query.
and
wa_itab TYPE scarr. and
WA_ITAB TYPE SCARR.
both are same because abap is not case sensitive.
regards
shiba dutta
2007 Feb 12 5:39 AM
Hi,
Are you serious about these questions?
I remember someone has answered these questions last week.
Kindly search the SDN for your queries before you post any.
Regards
Subramanian
2007 Feb 12 5:46 AM
Hi Krishna,
2nd is better because in this the internal table has the line type(structure) D_SCARR and fields like of database table SCARR . So loop at internal table instead of database table because internal table has already fetched values from SCARR by select query.
Hope this helps.
Reward if helpful.
Regards,
Sipra
2007 Feb 12 5:51 AM
i think 2nd one is better because instead of using select * always use the fieldnames in select query.
and
wa_itab TYPE scarr. and
WA_ITAB TYPE SCARR.
both are same because abap is not case sensitive.
regards
shiba dutta
2007 Feb 12 5:59 AM
1> the second statement is good, as u have selected only those fields which u need to print and also your internal table also contains the same fields. in the first statement you are selecting all fields wgich are not required in your case and will cause performance issue.
to much improve the second statement. declare the internal table with header line rather than declaring a sepearate work area.
2> the two statements
wa_itab TYPE scarr. and
WA_ITAB TYPE SCARR.
are same as ABAP is not case sensitive
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |