2008 Jul 28 6:33 AM
Hi Friends,
I have declared an internal table with fields for e.g. A , B , C , D.
This does not have any records as of now.
I have to fetch data from a DATABASE TABLE with fields A , B , X , Y , Z having records .
I only need records for fields A B fron DB table.Can any one pls tell how can I do that with performance issues in mind as lots of records are there.
I had written a query where:
SELECT A B from dbtab
into CORRESPONDING FIELDS of table it_table.
It_table i had defined with only two fields A B.
Is this correct?
Please tell wats the way to do it as I am new to ABAP.
THANKS in ADVANCE..
2008 Jul 28 6:38 AM
your code seems perfect no problem in it ..
TABLES : SFLIGHT.
DATA : STRUCT LIKE SFLIGHT,
BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE STRUCT.
SELECT * FROM SFLIGHT WHERE CARRID = SFLIGHT-CARRID.
"and connid = sflight-connid.
MOVE-CORRESPONDING SFLIGHT TO ITAB.
APPEND ITAB.
ENDSELECT.
2008 Jul 28 6:38 AM
hi,
When you have created Internal table with only two fields Dont use Corresponding Field Of Addition.
It is not good for performance reasons.
You ca use.
Select A B
from <table>
into table <i_tab>.
Regards
Sumit Agarwal
2008 Jul 28 6:38 AM
your code seems perfect no problem in it ..
TABLES : SFLIGHT.
DATA : STRUCT LIKE SFLIGHT,
BEGIN OF ITAB OCCURS 0.
INCLUDE STRUCTURE STRUCT.
SELECT * FROM SFLIGHT WHERE CARRID = SFLIGHT-CARRID.
"and connid = sflight-connid.
MOVE-CORRESPONDING SFLIGHT TO ITAB.
APPEND ITAB.
ENDSELECT.
2008 Jul 28 6:42 AM
Hi,
As you said You have Declare the internal table with Fields A and B.
So here No need of Corresponding fields of table
Statement.Because it decrease the performance.
You can write-
SELECT A B from dbtab
into table it_table.
Hope you got it.
Regards,
Sujit
2008 Jul 28 6:45 AM
Hii!
Do like this.
As per your query, declare a field string
DATA:
BEGIN OF fs_tab,
a TYPE dbtab1-a,
b TYPE dbtab1-b,
c TYPE dbtab2-c,
d TYPE dbtab2-d,
END OF fs_tab.
DATA:
it_tab LIKE
TABLE OF
fs_tab.
START-OF-SELECTION.
SELECT A
B
FROM dbtab1
INTO CORRESPONDING FIELDS OF TABLE it_tab.
Regards
Abhijeet
2008 Jul 28 6:49 AM
Hi
1. if the internal table "it_table" contains only 2 components A & B so you can use the following SQL.
SELECT A B from dbtab into table it_table.
2. If the internal table "it_table" contains components A, B, C & D so you can use the following SQL.
SELECT A B from dbtab into CORRESPONDING FIELDS of table it_table.
Hope it helps.
Murthy
2008 Jul 28 6:51 AM
Switch BI,
you wrote:
I have declared an internal table with fields for e.g. A , B , C , D.
than you wrote:
It_table i had defined with only two fields A B.as far as you query looks good there is no problem.but you may just modified like this:
SELECT A B from dbtab
into table it_table.
i hope you decleare your it_table like this:
data:begin of occurs 0,
a like ..,
b like...,
end of it_table.
as far as your internal table field declearation are same sequence as same with select query you need not to write into corresponding field because it cause performance issure.
hope this would cleare to you.
Amit.
2008 Jul 28 6:52 AM
Hi.....
What mentioned in all above answers is very helpful for ur requirement...
and...
Here some Steps to increase the performence of your programs...
>Use Select Single when only one row is expected
>Use Select Where rather than Selectu2026Check
>Use Select with aggregate functions (SUM, MAX, MINu2026)
>Use a View instead of nested Selects
>Use Select column specific instead of select * for few fields
>Use Selectu2026Into Table rather than Select...Move Corru2026Apend
>Use Join extension with Select if possible
>Use special operators (CO, CA, CS) rather than code your own
>Use Delete Adjacent Duplicates rather than manual processing
>Specify key fields for Readu2026Binary Search
>Use Loop At Where rather than Loop Atu2026Check
>Copy Internal Tables with TAB_DEST() = TAB_SRC()
>Specify the sort key as restrictively as possible
>Use Append To, Insert Into, Collect Into rather than Move
>Compare tables with If Tab1() = Tab2()u2026
>Use Delete ITAB Whereu2026 instead of Loop At ITAB Whereu2026Delete..
>Use Case statements instead of If-constructions
>Use Call Functions wisely, Performs use less memory
>Use While instead of Do Exit
>Use Type I for Indices
>Keep Occurs clause realistic or use 0
>Use COMMIT WORK as appropriate to free the Data Base and preserve work
>
>Avoid:
>Using Shift inside a While-loop
>Leaving unneeded declarations in your program
>Using Move-corresponding for just a few fields
>Excessive nested includes within function calls
>Using DB field names if the value will be changed
>Using Occurs clause if only the header is needed
Thanks,
Naveen.I
2008 Jul 28 7:00 AM
hi.
from performance point of view you do not need to use into corresponding fields of.This is because your internal table only has two fields .
So you can directly use select a b from table... into table.....
thats it...