Hi Gurus ,
I've a doubt in general SQL select query. I want to know , if suppose I've an internal table - itab . I've fetched G/L Account numbers 1st, based on the input selections . Next , I want to loop on those G/L accounts. However, if the G/L account has multiple line items, then I personally use this select query -- >
loop at itab. select <field> from <table> appending corresponding fields of <itab1> where hkont eq itab-hkont. endloop.
Now, the execution time for this query is longer than expected. The biggest problem here is, i've to sum up the totals as well. So totaling is an added load. I want to reduce the execution time of this. Kindly suggest me some good method in case u have any.
I've pasted the code which I've written , for u ppl to understand--
SELECT DISTINCT HKONT BELNR FROM BSIS INTO CORRESPONDING FIELDS OF TABLE OTAB WHERE HKONT IN S_RACCT * AND PRCTR IN P_PRCTR AND MONAT IN S_POPER AND BUKRS EQ P_BUKRS AND GJAHR EQ P_GJAHR AND PRCTR IN S_PRCTR. ***The code below takes a lot of time to execute.*** LOOP AT OTAB . SELECT DMBTR HKONT FROM BSIS APPENDING CORRESPONDING FIELDS OF TABLE CREDITS WHERE HKONT EQ OTAB-HKONT AND BELNR EQ OTAB-BELNR AND MONAT IN S_POPER AND BUKRS EQ P_BUKRS AND GJAHR EQ P_GJAHR AND PRCTR IN S_PRCTR AND SHKZG EQ 'H'. COLLECT CREDITS. ENDLOOP.