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 not Pulling All Data from Tables

Former Member
0 Likes
4,682

Hello Gurus,

I am having a strange situation. I am pulling data from COEP table and I found out its not pulling all the data (missing thousands).

This is the Select statement I used:

IF i_objnum[] IS NOT INITIAL.

SELECT belnr perio wogbtr objnr kstar gkont matnr

FROM coep INTO TABLE i_inicoep

FOR ALL ENTRIES IN i_objnum

WHERE objnr = i_objnum-objnr AND

lednr = '00' AND

gjahr = p_fyear AND

kokrs = '9999' AND

werks = p_werks AND

perio IN s_perio.

When I used the same criteria and selection to go to check the results in the database (SE11). I was missing thousands of data.

Is there something I'm doing wrong. A good example is from the last debug, i was missing almost 6,000 data.

Thanks.

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
3,031

In for all entries

Duplicate lines are automatically eliminated from the result set.

So try passing all the key fields.

8 REPLIES 8
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
3,032

In for all entries

Duplicate lines are automatically eliminated from the result set.

So try passing all the key fields.

Read only

0 Likes
3,031

Thanks for the prompt reply. I tried that and used all the key fields. It took a while to retrieve the data and it was a lot of data.

Then when i did a loop to to filter the results to take out data not in the i_objnum it takes a long time and eventually time out into a dump saying its reached its 2400s time limit.

Read only

Former Member
0 Likes
3,031

Appears that you are using objnr only to fetch records from database table.

Can you try inner join or view and check .

Hope this helps you.

Read only

Noorie
Active Participant
0 Likes
3,031

Dear Basil,

there might be problem with the structure of ur internal tables.

I faced a problem somewhat like this and found that there is missmatch in the defination of one of the fields of 2 internal tables.

check objnr is same tyee as i_objnum-objnr AND

lednr is of char type (= '00')

gjahr and p_fyear are of same type

kokrs is char '('9999')

werks and p_werks are of same type

perio and s_perio are of same type.

Read only

Former Member
0 Likes
3,031

check the below code

try to fetch all the key field while using for all entries



IF i_objnum[] IS NOT INITIAL.
SELECT KOKRS 
             belnr 
             BUZEI
             perio 
            wogbtr 
             objnr 
              kstar 
             gkont 
              matnr
FROM coep INTO TABLE i_inicoep
FOR ALL ENTRIES IN i_objnum
WHERE perio IN s_perio and
              kokrs = '9999' AND
            lednr = '00' AND
            objnr = i_objnum-objnr AND
           gjahr = p_fyear AND
           werks = p_werks.

Now you will get all the entries from the table

Please let me know if you face any problem still

Regards

Satish Boguda

.

Read only

Former Member
0 Likes
3,031

hi,

try to trigger the primary index of this table by using the key fields in the sequence they are in the table you can pass a constant GE to these key fields whose value is initial for which you dont have any where condition also while using for all enrties try to select all the key fields.

rgds

shivraj

Read only

Former Member
0 Likes
3,031

hi,

On using the FOR ALL ENTRIES must remember on thing that select all the primary fields of that table.

in you condition you are not selcting all the primary fields from the COEP Table , try this..

hope this helps

Regards

Ritesh

Read only

Former Member
0 Likes
3,031

Hi Basil Balogun,

please check with above suggestions and also check with Read statement in the Loop.

It will consume lot of time to read the Internal table with whatever conditions you have specified.

Check the READ statement that you are using in the program.

Make sure that you are sorting the Internal table by key field and using Binary search.

This will fix the issue in many cases.

Ex : 
 
SORT T_PRT BY GUID_PR.
 READ TABLE T_PRT INTO WA_PRT WITH KEY GUID_PR = WA_PR-GUID_PR BINARY SEARCH.

This should help resolve the performance issue.

Regards,

KIttu