Problem solve Get help with specific problems with your technologies, process and projects.

Database access alternative

Thanks to Durai Ilango for his tip on using SY-DBCNT to limit database access. This tip presents an alternative technique.

Thanks to Durai Ilango for his tip on using SY-DBCNT to limit database access. An alternative technique is to use...

the UP TO n ROWS feature of the SELECT command.

When you use SY-DBCNT to limit your rows, the database manager does not know that you are doing that and so returns a full 32K block of rows. If you use the UP TO n ROWS feature of SELECT, then that information is passed to the database manager and it will only return the number of rows you requested. You can than avoid APPENDing to your internal table and instead load the table directly.


The original example:

select * from bkpf into corresponding fields of itab
            where bukrs in co_code       "Company code
            and     gjahr in fyear       "fiscal year
            and     blart in doctype     "document type
            and     belnr in docno   .   "test only
  *          AND     cpudt IN pa_cpudt.
      if sy-dbcnt ge 5.
        exit .
      endif.
      append itab.
      clear itab.
    endselect.

and an example using UP TO n ROWS:

select * from bkpf
            up to 4 rows 
            into corresponding fields of table itab
            where bukrs in co_code       "Company code
            and     gjahr in fyear       "fiscal year
            and     blart in doctype     "document type
            and     belnr in docno   .   "test only
  *          AND     cpudt IN pa_cpudt.
   
		
		
This was last published in November 2001

Dig Deeper on SAP ABAP

PRO+

Content

Find more PRO+ content and other member only offers, here.

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.

-ADS BY GOOGLE

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close