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: 

Regarding report

Former Member
0 Kudos

hi experts,

i have made a report using 4 tables.there is no syntatic error.but when i try to execute it..it gives a short dump after 5-10 min displaying msg that execution time exceeds..m sending you the code.please check all the select queries that i hav used..n give me the related solution..

REPORT ZFI_R_VENDOR .

TABLES:BSEG,LFA1,BKPF,VBRK.

DATA: BEGIN OF ITAB OCCURS 0,

BUKRS LIKE BSEG-BUKRS,

BELNR LIKE BKPF-BELNR,

DOC LIKE BSEG-BELNR,

LIFNR LIKE BSEG-LIFNR,

BUDAT LIKE BKPF-BUDAT,

VBELN LIKE VBRK-VBELN,

ORT01 LIKE LFA1-ORT01,

PSTLZ LIKE LFA1-PSTLZ,

STRAS LIKE LFA1-STRAS,

NAME1 LIKE LFA1-NAME1,

KOART LIKE BSEG-KOART,

SHKZG LIKE BSEG-SHKZG,

DMBTR LIKE BSEG-DMBTR,

DEBIT LIKE BSEG-DMBTR,

CREDIT LIKE BSEG-DMBTR,

AMOUNT LIKE BSEG-DMBTR,

END OF ITAB.

DATA PTAB LIKE ITAB OCCURS 0 WITH HEADER LINE.

DATA:WBUDAT LIKE BKPF-BUDAT,

WABUKRS LIKE BKPF-BUKRS,

WVBELN LIKE VBRK-VBELN,

WBUKRS LIKE VBRK-BUKRS.

DATA:WCREDIT LIKE BSEG-DMBTR VALUE '0',

WDEBIT LIKE BSEG-DMBTR VALUE '0'.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETER CMP_CD LIKE VBRK-BUKRS.

SELECT-OPTIONS:VENDOR FOR LFA1-LIFNR,

P_DATE FOR BKPF-BUDAT.

SELECTION-SCREEN END OF BLOCK B1.

SELECT BUDAT BUKRS FROM BKPF INTO (WBUDAT, WABUKRS) WHERE BUDAT IN P_DATE.

SELECT BUKRS VBELN FROM VBRK INTO (WBUKRS, WVBELN) WHERE BUKRS = CMP_CD.

SELECT BUKRS BELNR LIFNR KOART SHKZG DMBTR FROM BSEG INTO (ITAB-BUKRS, ITAB-DOC, ITAB-LIFNR, ITAB-KOART, ITAB-SHKZG, ITAB-DMBTR)

WHERE BUKRS = WABUKRS

AND BUKRS = WBUKRS

AND LIFNR IN VENDOR

AND KOART = 'K'.

APPEND ITAB.

ENDSELECT.

ENDSELECT.

ENDSELECT.

LOOP AT ITAB.

SELECT SINGLE NAME1 ORT01 PSTLZ STRAS FROM LFA1 INTO (ITAB-NAME1,ITAB-ORT01,ITAB-PSTLZ,ITAB-STRAS) WHERE LIFNR = ITAB-LIFNR.

MODIFY ITAB.

ENDLOOP.

LOOP AT ITAB.

SELECT SINGLE VBELN FROM VBRK INTO ITAB-VBELN WHERE BUKRS = ITAB-BUKRS.

MODIFY ITAB.

ENDLOOP.

*

SORT ITAB BY LIFNR.

LOOP AT ITAB.

IF ITAB-SHKZG = 'H'.

WCREDIT = WCREDIT + ITAB-DMBTR.

ELSEIF ITAB-SHKZG = 'S'.

WDEBIT = WDEBIT + ITAB-DMBTR.

ENDIF.

ITAB-CREDIT = WCREDIT.

ITAB-DEBIT = WDEBIT.

ITAB-AMOUNT = ITAB-CREDIT - ITAB-DEBIT.

MOVE-CORRESPONDING ITAB TO PTAB.

AT END OF LIFNR.

APPEND PTAB.

CLEAR: WCREDIT,WDEBIT.

ENDAT.

ENDLOOP.

LOOP AT PTAB.

WRITE:/ PTAB-BELNR,PTAB-BUDAT,PTAB-CREDIT,PTAB-DEBIT,PTAB-AMOUNT.

regards,

raman.

2 REPLIES 2

former_member378318
Contributor
0 Kudos

Run the report in background to get around the timout issue.

Also it is very inefficient to use nested SELECT ENDSELECT statements. Replace all SELECT ENDSELECT statements with SELECT INTO TABLE and then process the internal tables.

This should give you something to go on.

Former Member
0 Kudos

hi prakash.......

the error may be due to the infinite loops that may be running.

some suggestions:

instead of using nested select statements, use inner joins.

try avoiding select queries inside the loop. instead go for the syntax:

'select * from <table> for all enteries.......'.

--regards

alex b justin