Application Development and Automation 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: 
Read only

Can we use a FM inside do loop after FETCH NEXT CURSOR statement?

Former Member
0 Likes
476

Hello Gurus,

Can we use a FM inside do loop after FETCH NEXT CURSOR statement?....is it gives any short dumps?

i have code like this:

OPEN CURSOR WITH HOLD db_cursor FOR

SELECT * FROM -


DO.

FETCH NEXT CURSOR db_cursor

INTO CORRESPONDING FIELDS OF TABLE ABC

PACKAGE SIZE package_size.

IF sy-subrc NE 0.

CLOSE CURSOR db_cursor.

EXIT.

ENDIF.

LOOP AT ABC INTO XYZ.

MOVE-CORRESPONDING XYZ TO SRT.

IF 123 = 234.

-


ELSE.

CALL FUNCTION 'G_PERIOD_GET'

EXPORTING

company = company_code

date = date

variant = fiscal_variant

IMPORTING

period = period

year = year.

ENDIF.

is anything wrong in this code plz suggest...

from the above code iam getting an runtime error : The current ABAP program "SAP-----" had to be terminated because it has

come across a statement that unfortunately cannot be executed. Unable to perform database selection fully.

Appriciate for useful answers...

Thanks,

Sree.

Hello Gurus,

Can we use a FM inside do loop after FETCH NEXT CURSOR statement?....is it gives any short dumps?

i have code like this:

OPEN CURSOR WITH HOLD db_cursor FOR

SELECT * FROM -


DO.

FETCH NEXT CURSOR db_cursor

INTO CORRESPONDING FIELDS OF TABLE ABC

PACKAGE SIZE package_size.

IF sy-subrc NE 0.

CLOSE CURSOR db_cursor.

EXIT.

ENDIF.

LOOP AT ABC INTO XYZ.

MOVE-CORRESPONDING XYZ TO SRT.

IF 123 = 234.

-


ELSE.

CALL FUNCTION 'G_PERIOD_GET'

EXPORTING

company = company_code

date = date

variant = fiscal_variant

IMPORTING

period = period

year = year.

ENDIF.

is anything wrong in this code plz suggest...

from the above code iam getting an runtime error : The current ABAP program "SAP-----" had to be terminated because it has

come across a statement that unfortunately cannot be executed. Unable to perform database selection fully.

Appriciate for useful answers...

Thanks,

Sree.

1 REPLY 1
Read only

Former Member
0 Likes
388

hi check this example....to under stand....

DATA: BEGIN OF count_line,

carrid TYPE spfli-carrid,

count TYPE i,

END OF count_line,

spfli_tab TYPE TABLE OF spfli.

DATA: dbcur1 TYPE cursor,

dbcur2 TYPE cursor.

OPEN CURSOR dbcur1 FOR

SELECT carrid count(*) AS count

FROM spfli

GROUP BY carrid

ORDER BY carrid.

OPEN CURSOR dbcur2 FOR

SELECT *

FROM spfli

ORDER BY carrid.

DO.

FETCH NEXT CURSOR dbcur1 INTO count_line.

IF sy-subrc <> 0.

EXIT.

ENDIF.

FETCH NEXT CURSOR dbcur2

INTO TABLE spfli_tab PACKAGE SIZE count_line-count.

ENDDO.

CLOSE CURSOR: dbcur1,

dbcur2.

regards,

venkat.