09-29-2015 9:26 AM
Hi
i create a report that i have to select BUDAT MONAT FROM table BKPF with where condition. but run time error occured in this line.i create a view whit 4 required fields but selection from that view raise runtime error also. how i can change my program to fix thise runtime error ?
Regards.
Mahtab
09-29-2015 9:29 AM
Hi,
Can you please paste your select query,
Please check the sequence of the field you have written and match the sequence with VIEW field.
Thanks
Nishant
09-29-2015 9:37 AM
Execute a SQL trace and then analyze the access plan (some full scan table ?) or post more information (the where criteria) to get more help.
Regards,
Raymond
09-29-2015 10:06 AM
Hi
"DATA is an internal table from Bseg with more than 90000 record
LOOP AT DATA INTO WA.
PERFORM GET_PERIOD USING WA-BELNR CHANGING XPERIOD.
FORM GET_PERIOD USING XBELNR CHANGING XPERIOD.
CLEAR XPERIOD.
SELECT single MONAT FROM BKPF INTO XPERIOD WHERE BELNR = XBELNR and gjahr eq xyear.
ENDFORM.
Regards
Mahtab
09-29-2015 10:15 AM
Hi,
Please use the for all entries instead of using the select in loop statement.
Please mention the type of the XPERIOD in changing parameters.
CHANGING XPERIOD
Thanks
Nishant
09-29-2015 10:29 AM
Check declaration of XPERIOD. It should in sync with selection fields for Select Single.
09-29-2015 1:54 PM
So you may be executing 90K full scan of table ?
Are you able to read BKPF information in previous SELECT of data using some JOIN, else can you use some FOR ALL ENTRIES OF or subquery to read BKPF using BUKRS, BELNR and GJAHR in a sorted type table and then update the internal table with some // LOOP or optimized READ TABLE ?
Regards,
Raymond
09-29-2015 10:37 AM
Hi Mahtab,
1. As per the best practice we should not write a Select Statement in a LOOP to improve Performance.
2.As we our aware that BKPF is the Header Table and BSEG is the Item Table for Accounting Documents.
a} Fetch all the BELNR's from BKPF for all entries in the BSEG validating with BELNR,BUKRS,GJAHR.
b) Sort the BKPF with BUKRS BELNR GJAHR.
Now by Looping BSEG values , read the table BKPF and do the validation which you need to process.
Thanks & Regards,
S.Rajendranath
09-29-2015 3:02 PM
Hi Mahtab,
You might have got the solution as I think almost all the above replies are perfect. But if not, i would suggest you an addition field in where clause as BUKRS and instaid of select single try using select up to 1 rows.
Regards -
MT