2014 Mar 14 5:14 AM
Hi all,
i have to fetch some fields values from bseg table, firstly i have selected some fields from bkpf table then after i passed belnr in bseg table along with other fields, but while fetching data from bseg table, it is giving "maximum run time exceeds" and not fetching any data during debugging too.
Here is my code, please tell me what to do next
SELECT XBLNR
BLDAT
WAERS
CPUDT
MONAT
BLART
BELNR
BUKRS
GJAHR
FROM BKPF
INTO TABLE IT_BKPF
WHERE BELNR IN P_BELNR
AND BLDAT IN P_BLDAT.
SELECT MENGE
MEINS
HKONT
WRBTR
MWSKZ
BUPLA
BELNR
VALUT
ZFBDT
ZUONR
BSCHL
AUFNR
SGTXT
BUKRS
GJAHR
FROM BSEG INTO TABLE IT_BSEG
FOR ALL ENTRIES IN IT_BKPF
WHERE BELNR = IT_BKPF-BELNR
AND BUKRS = IT_BKPF-BUKRS
AND GJAHR = IT_BKPF-GJAHR
AND HKONT EQ '12345'
OR HKONT EQ '54321' .
2014 Mar 14 5:28 AM
Hi Swetha,
Firstly check with your database tables whether you have data for your search criteria by passing the same values in the execution of BKPF and BSEG Tables.
If you have records , put a condition after BFKP select statement as If IT_BKPF[] is not initial.
then pass the values of Bkpf as input to Bseg and fetch them too...
If your select condition having many number of records , then it takes too much time to process and it will return "maximum run time exceeds" at a certain point of time.
Thanks.
2014 Mar 14 5:34 AM
U can use BSIS,BSAS for GL account Based Retrieval..
Regards,
Siva
2014 Mar 14 5:57 AM
Hi ,
It is because there may be large set of records being fetched from bseg table and bkpf table.
Try running your report in background or refine your your selection a little.
2014 Mar 14 5:59 AM
Hi Shweta ,
while fetching data from bseg table, it is giving "maximum run time exceeds" and not fetching any data .
So Only 2 Condition for this problem.
1. Firstly you make indexer for BSEG table.
for these fields
BELNR,BUKRS,GJAHR
and also add in your select query fields.
2. And Make sure That data you try to fetch from BSEG with reference BKPF table
that is available on both table.
Please Tell Which Problem You Facing now.
Thanks
2014 Mar 14 6:02 AM
Hi,
Maximum run time error on select statement occurs for the following reasons.
1. When the DDIC table has a large amount of data.
2. When the key fields of the DDIC table are not properly considered in the WHERE clause of the SELECT statement.
3. When the FOR ALL ENTRIES table is empty ( in your case IT_BKPF ). That's the reason it is a must to check wehether the itab is INITIAL or not before using it in FOR ALL ENTRIES clause.
Check if your scenario has any of the the above mentioned situations.
2014 Mar 14 6:14 AM
Hi,
The SQL statement is problematic. It is asking the system to run a full scan of BSEG and return all records whose hkont is '54321'.
Please add parentheses like the code below.
SELECT *
FROM BSEG INTO TABLE IT_BSEG
FOR ALL ENTRIES IN IT_BKPF
WHERE BELNR = IT_BKPF-BELNR
AND BUKRS = IT_BKPF-BUKRS
AND GJAHR = IT_BKPF-GJAHR
AND ( HKONT EQ '12345' OR HKONT EQ '54321' ).
2014 Mar 14 6:25 AM
Hi Shweta,
Note 25528 - Parameter rdisp/max_wprun_time Check this note
the rule of thumb that we use at in our project is any job that runs longer than 10 min has to run in the background, or else if everyone does that it will fill up the DIA processes and then no one can logon or work until they free up or system restart.http://scn.sap.com/thread/278023
2014 Mar 14 6:28 AM
Hi shweta,
when you are using for all entries, you first check the header level data is there or not.
you should not check the header data it fetch the total item level data. then it takes too much time to process and it will return "maximum run time exceeds" .
before writing the for all entries you check that internal table having data or not
regards,
lakshman.
2014 Mar 15 9:01 AM
Try this code
DATA:IT_BSEG1 TYPE STANDARD TABLE OF (IT_BSEG TYPE)
eg:SELECT XBLNR
BLDAT
WAERS
CPUDT
MONAT
BLART
BELNR
BUKRS
GJAHR
FROM BKPF
INTO TABLE IT_BKPF
WHERE BELNR IN P_BELNR
AND BLDAT IN P_BLDAT.
IF IT_BKPF[] IS NOT INITIAL.
SELECT MENGE
MEINS
HKONT
WRBTR
MWSKZ
BUPLA
BELNR
VALUT
ZFBDT
ZUONR
BSCHL
AUFNR
SGTXT
BUKRS
GJAHR
FROM BSEG INTO TABLE IT_BSEG1
FOR ALL ENTRIES IN IT_BKPF
WHERE BELNR = IT_BKPF-BELNR
AND BUKRS = IT_BKPF-BUKRS
AND GJAHR = IT_BKPF-GJAHR
AND HKONT EQ '12345'
OR HKONT EQ '54321' .
APPEND LINES OF IT_BSEG1 TO IT_BSEG.
REFRESH IT_BSEG1.
CLEAR IT_BSEG1.
ENDIF.
This query will increase the performance of the report,it wannot go for dump.
2014 Mar 20 9:28 AM
Hi, Shweta ,
You can use the Range of Belnr in stead of the For all entries and try.
SELECT XBLNR
BLDAT
WAERS
CPUDT
MONAT
BLART
BELNR
BUKRS
GJAHR
FROM BKPF
INTO TABLE IT_BKPF
WHERE BELNR IN P_BELNR
AND BLDAT IN P_BLDAT.
data: r_belnr type range of bkpf-BELNR .
data: wa_bkpf like line of it_bkpf .
loop at it_bkpf into wa_bkpf .
r_belnr-sign = 'I' .
r_belnr-option = 'EQ'.
r_belnr-low = wa_bkpf-belnr .
append r_belnr .
endloop .
SELECT MENGE
MEINS
HKONT
WRBTR
MWSKZ
BUPLA
BELNR
VALUT
ZFBDT
ZUONR
BSCHL
AUFNR
SGTXT
BUKRS
GJAHR
FROM BSEG INTO TABLE IT_BSEG
WHERE
belnr IN r_belnr
BELNR = IT_BKPF-BELNR
AND BUKRS = IT_BKPF-BUKRS
AND GJAHR = IT_BKPF-GJAHR
AND HKONT EQ '12345'
OR HKONT EQ '54321' .
Regards,
Joyjit
2014 Mar 16 6:47 AM
Hello Shweta,
My question is why don't you try with INNER JOINS, as INNER JOINS has always the better performance than FOR ALL ENTRIES.
You won't get the runtime error if you use INNER JOINS.
Refer to the below links which explains why INNER JOINS is better than For all entries.
Inner Joins vs For All Entries - performance query | SCN
ABAP Performance tips - Contributor Corner - SCN Wiki
Regards,
TP
2014 Mar 16 1:01 PM
My question is why don't you try with INNER JOINS, as INNER JOINS has always the better performance than FOR ALL ENTRIES.
How would you use join on BSEG? What was your rationale behind posting this incorrect info (using JOINs on BSEG)?
- Suhas
2014 Mar 16 1:21 PM
Hello Suhas,
Yes you are right, we can't use for all entries with BSEG.
Sorry I didn't analyse it before posting.
Please remove the comments from the discussion.
Regards,
Thanga
2014 Mar 16 1:49 PM
Hi Shweta,
Reading data from BSEG Table is always time consuming sometimes also resulting in the dump that you got. Solution for this would be to optimize the select statment by better data fetching techniques like Open Cursor method or reading less number of records at a time.
Regards
2014 Mar 20 9:34 AM
2014 Mar 20 10:29 AM
First of all check if table IT_BKPF is not initial if not initial then only write second query.
Avoid using OR condition where .
Instead filter those records from your internal table this will improve performance
hope it helps/
Thanks
Rahul