Application Development 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: 

BSAD performance issue

S0025444845
Active Participant
0 Kudos

Hi,

I am using the below query to fetch data from bsad.

SELECT bukrs "Company code

kunnr "Customer

augbl "Clearing document

gjahr "Year

belnr "Accounting Document Number

monat " period

vbeln "Billing document no

prctr "Profit center

FROM bsad INTO TABLE git_bsad

FOR ALL ENTRIES IN git_fagl_val

WHERE bukrs EQ git_fagl_val-rbukrs AND

augbl EQ git_fagl_val-docnr.

'But this is too slow and takes more than 2 days to fetch data from basd.

Please suggest.

Regards,

Sudha

9 REPLIES 9

Former Member
0 Kudos

Hi,

most important check every SELECT statement with FOR ALL ENTRIES, check wheather the comparing internal table is empty or not.Because if you put an initial internal table in FOR ALL ENTRIES , it will fetch all data from the data table.

check wheather all the fields in the where condition are in sequence of the source datatable.

Thanks & regards.

Former Member
0 Kudos

Hi,

Create two ranges for bukrs and augbl. Loop at your git_fagl_val and collect datas into your ranges then call select with ranges.


SELECT bukrs "Company code
kunnr "Customer
augbl "Clearing document
gjahr "Year
belnr "Accounting Document Number
monat " period
vbeln "Billing document no
prctr "Profit center
FROM bsad INTO TABLE git_bsad

WHERE bukrs IN r_bukrs AND
             augbl IN r_augbl.

Take care.

Çağatay

0 Kudos

Hi,

I am using the table not initial.

Please tell me there is any possiblity of creating secondary indexes ??

Can you pls expain how the ranges will be better?

Regards,

Sudha

0 Kudos

Hi,

Before using for all entries, you need to check whether itab in filled with values or not?

if not git_bsad [ ] is initial.

SELECT bukrs "Company code

kunnr "Customer

augbl "Clearing document

gjahr "Year

belnr "Accounting Document Number

monat " period

vbeln "Billing document no

prctr "Profit center

FROM bsad INTO TABLE git_bsad

FOR ALL ENTRIES IN git_fagl_val

WHERE bukrs EQ git_fagl_val-rbukrs AND

augbl EQ git_fagl_val-docnr.

Thanks & regards.

0 Kudos

Hi,

I am alreay checking the table is not initial.

My code is:

IF NOT git_fagl_val[] IS INITIAL.

SELECT bukrs "Company code

kunnr "Customer

augbl "Clearing document

gjahr "Year

belnr "Accounting Document Number

monat " period

vbeln "Billing document no

prctr "Profit center

FROM bsad INTO TABLE git_bsad

FOR ALL ENTRIES IN git_fagl_val

WHERE bukrs EQ git_fagl_val-rbukrs AND

augbl EQ git_fagl_val-docnr.

Endif.

Regards,

Sudha

0 Kudos

Hi

You should use the customer code too in order to improve the performance, if you know the clearing document, you can know the customer too

Max

0 Kudos

Hi,

I do not have the customer. I am getting the clearing document from FAGLFLEXA, but I do not have the customer.

below is the code:

SELECT a~docnr "Document Number (Clearing Doc Number)

a~rbukrs "Company Code

a~rtcur "Local Currency

a~racct "G/L account number

a~prctr "Profit Center

a~kokrs "Controlling Area

a~hsl "Amount in local currency

a~poper "Period

a~gjahr "Year

a~budat "Posting date

b~blart "Document Type

INTO TABLE git_fagl

FROM faglflexa AS a INNER JOIN bkpf AS b

ON arbukrs = bbukrs

AND agjahr = bgjahr

AND adocnr = bbelnr

WHERE a~rbukrs = p_cocd

AND a~racct IN s_glac

AND a~gjahr = p_year

AND a~poper = p_prd

AND b~blart IN gr_blart.

IF NOT git_fagl[] IS INITIAL.

*C-- Fetch data from the table BSAD based on the Company Code and doc number

*C-- for from the FAGLL03 transaction

SELECT bukrs "Company code

kunnr "Customer

augbl "Clearing document

gjahr "Year

belnr "Accounting Document Number

monat " period

vbeln "Billing document no

prctr "Profit center

FROM bsad INTO TABLE git_bsad

FOR ALL ENTRIES IN git_fagl_val

WHERE bukrs EQ git_fagl_val-rbukrs AND

augbl EQ git_fagl_val-docnr.

endif.

Regards,

Sudha

0 Kudos

yes

but you can get it:

LOOP AT git_fag.
  SELECT KUNNR UP TO 1 ROWS INTO git_fag-KUNNR
      FROM BSEG
        WHERE BYKRS = git_fag-RBUKRS
             AND BELNR = git_fag-DOCNR
             AND GJAHR = git_fag-GJAHR
             AND KOART = 'D'.
    ENDSELECT.
ENDLOOP.

Max

0 Kudos

Hi Sudha,

When using FOR ALL ENTRIES (FAE), beside checking FAE table not initial, you should try to make it as small as possible.

Here, I see that you just use FAE for 2 fields CCode and Document number, so try this


DATA: lt_temp LIKE git_fagl[].
lt_temp[] = git_fagl[].
SORT lt_temp BY rbukrs docnr.
DELETE ADJACENT DUPLICATES FROM lt_temp COMPARING rbukrs docnr.

And then, use FAE on LT_TEMP instead.

Rgds,