Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

problem in report

hi all,

i made a report and when i m executing it then its wondering in infinite loop. while i m looking in debugger then itab contains only one value and its wondering within select and endselect.

can anyone plz help me?

this is the code.

SELECT VKBUR KUNNR FROM VBAK INTO CORRESPONDING FIELDS OF TABLE ITAB

WHERE KUNNR IN KUNNR

AND VKBUR IN VKBUR.

IF SY-SUBRC <> 0.

MESSAGE 'DATA NOT FOUND.' TYPE 'I'.

ENDIF.

SORT ITAB BY KUNNR.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING KUNNR.

LOOP AT ITAB.

SELECT BEZEI FROM TVKBT INTO ITAB-BEZEI WHERE VKBUR = ITAB-VKBUR.

MODIFY ITAB . "INDEX SY-TABIX TRANSPORTING BEZEI.

ENDSELECT.

SELECT NAME1 FROM KNA1 INTO ITAB-NAME1 WHERE KUNNR = ITAB-KUNNR.

MODIFY ITAB. " INDEX SY-TABIX TRANSPORTING NAME1.

ENDSELECT.

SELECT CASSD AUFSD LIFSD FAKSD INTO (ITAB-CASSD , ITAB-AUFSD , ITAB-LIFSD , ITAB-FAKSD) FROM KNA1

WHERE KUNNR = ITAB-KUNNR.

IF SY-SUBRC = 0 AND ITAB-CASSD = '' AND ITAB-AUFSD = '' AND ITAB-LIFSD = '' AND ITAB-FAKSD = '' .

SELECT CASSD AUFSD LIFSD FAKSD INTO (ITAB-CASSD , ITAB-AUFSD , ITAB-LIFSD , ITAB-FAKSD) FROM KNVV

WHERE KUNNR = ITAB-KUNNR.

IF SY-SUBRC = 0 AND ITAB-CASSD = '' AND ITAB-AUFSD = '' AND ITAB-LIFSD = '' AND ITAB-FAKSD = '' .

DELETE ITAB.

ELSE.

ITAB-SEL = ITAB-CASSD.

APPEND ITAB .

ENDIF.

ENDSELECT.

ELSE.

ITAB-ALL = ITAB-CASSD.

MODIFY ITAB INDEX SY-TABIX TRANSPORTING ALL.

ENDIF.

IF ITAB-AUFSD NE ''.

SELECT VTEXT FROM TVAST INTO ITAB-VTEXT WHERE AUFSP = ITAB-AUFSD

AND SPRAS = 'EN'.

MODIFY ITAB INDEX SY-TABIX TRANSPORTING VTEXT.

ENDSELECT.

ENDIF.

IF ITAB-LIFSD NE ''.

SELECT VTEXT FROM TVLST INTO ITAB-VTEXT WHERE LIFSP = ITAB-LIFSD

AND SPRAS = 'EN'.

MODIFY ITAB INDEX SY-TABIX TRANSPORTING VTEXT.

ENDSELECT.

ENDIF.

IF ITAB-FAKSD NE ''.

SELECT VTEXT FROM TVFST INTO ITAB-VTEXT WHERE FAKSP = ITAB-FAKSD

AND SPRAS = 'EN'.

MODIFY ITAB INDEX SY-TABIX TRANSPORTING VTEXT.

ENDSELECT.

ENDIF.

IF ITAB-ALL NE ''.

ITAB-VTEXT = 'ALL SALES AREAS'.

MODIFY ITAB INDEX SY-TABIX TRANSPORTING VTEXT.

ENDIF.

IF ITAB-SEL NE ''.

ITAB-VTEXT = 'SELECTED SALES AREAS'.

MODIFY ITAB INDEX SY-TABIX TRANSPORTING VTEXT.

ENDIF.

ENDSELECT.

CLEAR ITAB.

ENDLOOP.

and its performance is also very slow and taking too much time.

regards saurabh.

Tags:
Former Member
replied

Hi

If you want to improve the performance of you report first

SELECT VKBUR KUNNR FROM VBAK INTO CORRESPONDING FIELDS OF TABLE ITAB
WHERE KUNNR IN KUNNR
AND VKBUR IN VKBUR.
IF SY-SUBRC 0.
MESSAGE 'DATA NOT FOUND.' TYPE 'I'.
ENDIF.
SORT ITAB BY KUNNR.
DELETE ADJACENT DUPLICATES FROM ITAB COMPARING KUNNR.
LOOP AT ITAB.
SELECT BEZEI FROM TVKBT INTO ITAB-BEZEI WHERE VKBUR = ITAB-VKBUR.
MODIFY ITAB . 
ENDSELECT. " Remove this SELECT..... ENDSELECT

and

I hope you have not declared the internal tables with exact fields that you want that's why your report is taking more time , so declare the internal table types only with the fields that you want to read the data from the database tables

Regards

Pavan

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question