Tip

Improve performance of SELECT

As you all know, it is important to use as many key fields as possible in WHERE clauses of SELECT statements. Sometimes you are not sure about the value of some key fields. They seem to be empty (Initial value) but you are afraid to use this in your ABAP coding.

Using the option GE (greater equal) in your coding can improve your performance considerably without the risk of table lines not being selected.


REPORT ZZBM_SELECT_1 .
TABLES: S001.
CONSTANTS: SSOUR_INI  LIKE S001-SSOUR VALUE   IS INITIAL,
           VRSIO_INI  LIKE S001-VRSIO VALUE   IS INITIAL,
           SPMON_INI  LIKE S001-SPMON VALUE   IS INITIAL,
           SPTAG_INI  LIKE S001-SPTAG VALUE   IS INITIAL,
           SPWOC_INI  LIKE S001-SPWOC VALUE   IS INITIAL,
           SPBUP_INI  LIKE S001-SPBUP VALUE   IS INITIAL.


DATA: TA_S001 TYPE STANDARD TABLE OF S001.
DATA: WA_S001 TYPE S001.

SELECT-OPTIONS:
              SO_SPTAG   FOR S001-SPTAG OBLIGATORY,
              SO_KUNNR   FOR S001-KUNNR OBLIGATORY,
              SO_VKORG   FOR S001-VKORG OBLIGATORY,
              SO_VTWEG   FOR S001-VTWEG OBLIGATORY,
              SO_SPART   FOR S001-SPART OBLIGATORY,
              SO_MATNR   FOR S001-MATNR OBLIGATORY.

START-OF-SELECTION.

SELECT        * FROM  S001
       INTO TABLE TA_S001
       WHERE  SSOUR  GE SSOUR_INI     "Greater Equal initial value
       AND    VRSIO  GE VRSIO_INI     "   idem
       AND    SPMON  GE SPMON_INI     "   idem
     

    Requires Free Membership to View

AND SPTAG IN SO_SPTAG AND SPWOC GE SPWOC_INI " idem AND SPBUP GE SPBUP_INI " idem AND KUNNR IN SO_KUNNR AND VKORG IN SO_VKORG AND VTWEG IN SO_VTWEG AND SPART IN SO_SPART AND MATNR IN SO_MATNR.

This was first published in January 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.