Skip to Content
author's profile photo Former Member
Former Member

Data selection using select

I am selecting data from COEP(CO Object: Line Items (by Period)) table, which has huge data.

The selection is done using OBJNR field, which is part of secondary index.

...

SELECT

objnr

kstar "Cost Element

rbest "Reference Document Number

....

....

INTO CORRESPONDING FIELDS OF TABLE i_covp

FROM covp

FOR ALL ENTRIES IN i_kstar

WHERE lednr EQ c_ledger

AND objnr IN r_objnr

.....

.....

Now this since r_objnr can be represented by Cost Center/Internal Orders or WBS. This can be very large.

If I try to run the program using this in foreground or background. It dumps, because the select statement is not able to cope up with this range r_objnr....

There are 2 options to solve this problem:

1. Convert r_objnr into an internal table and use "for all entries"

2. There is another option I have seen in one of standard SAP program, where the r_objnr is split into several chunks and select is called repeatedly..

PERFORM prepare_sel TABLES r_objnr

r_sel_objnr

USING l_index

CHANGING l_subrc.

WHILE l_subrc EQ 0.

SELECT

objnr

kstar "Cost Element

rbest "Reference Document Number

....

....

INTO CORRESPONDING FIELDS OF TABLE i_covp PACKAGE SIZE 1000

FROM covp

FOR ALL ENTRIES IN i_kstar

WHERE lednr EQ c_ledger

AND objnr IN r_objnr

.....

.....

ADD 1 TO l_record_counter.

IF sy-batch IS INITIAL AND

sy-binpt IS INITIAL.

PERFORM flash_records_read(sapfgrws)

USING l_record_counter.

ENDIF.

endselect.

ADD 1 TO l_index.

PERFORM prepare_sel TABLES r_objnr

r_sel_objnr

USING l_index

CHANGING l_subrc.

ENDWHILE.

  • Where subroutine prepare_Sel basically picks one record from r_objnr and populates r_sel_objnr.

I wanted to know which of these method is better??

Regards

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2005 at 09:21 AM

    Hi Samir,

    IF I were you, I would have used the second approach, i.e., splitting the data into chunks and executing the selects multipletimes.

    Regards,

    Anand Mandalika.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.