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: 

CURSOR - FETCH Error

Former Member
0 Kudos

Hi All,

I am new to ABAP and I have a situation and don't know why it is erroring out. Could anyone point it out for me.

DATA: BEGIN OF allper,

mbegda TYPE hrp1001-begda,

mendda TYPE hrp1001-endda,

mpos TYPE hrp1001-objid,

morg TYPE hrp1001-sobid,

mper TYPE hrp1001-sobid,

mmgr_id TYPE hrp1008-btrtl,

END OF allper.

DATA: itab_allper1 LIKE TABLE OF allper.

OPEN CURSOR WITH HOLD S_CURSOR FOR

SELECT DISTINCT abegda aendda aobjid asobid bsobid cbtrtl

FROM HRP1001 AS a

LEFT OUTER JOIN HRP1001 AS b ON aobjid = bobjid AND

b~subty = 'A008' AND

b~sclas = 'P'

LEFT OUTER JOIN HRP1008 AS c ON aobjid = cobjid

WHERE a~subty = 'A003' AND

a~sclas = 'O'.

FETCH NEXT CURSOR S_CURSOR

APPENDING CORRESPONDING FIELDS

OF TABLE itab_allper

PACKAGE SIZE 1000.

I get a shohrt dump in the FETCH statment. Looks to me some fields don't match? any clues?

Thx,

Alex.

6 REPLIES 6

Former Member
0 Kudos

What does the short dumpo says.

The table is declared as itab_allper1 but your sentence says

FETCH NEXT CURSOR S_CURSOR

APPENDING CORRESPONDING FIELDS

OF TABLE itab_allper

PACKAGE SIZE 1000.

maybe that's the problem

0 Kudos

Ramiro,

Thank you for looking at this. I do have an internal table as itab_allper as well as itab_allper1 both are of the type allper structure.

Do you think the syntax and the way the variable declarations are correct? I am not sure of those..

Thankx again.

Alex.

0 Kudos

I don't see nothing wrong.

What does the dump says? Can you post it?

What I do find weird is the join on the same table

0 Kudos

Ramiro,

I found the cause for the ABEND because it was not on a development client, after copying to the correct client it does not abend but the cursor fetches only 0's. Is my declaration of structure, table, cursor and FETCH are all correct? Can I Fetch into an internal table?. I am concerned about the declaration part. The SQL is correct and it works right now when I have it with out cursor when I load it in to an internal table. Please let me know my validations are correct?

Thanks,

Alex.

Former Member
0 Kudos

I solved the issue.

0 Kudos

HI Alex,

Can u tel me, how you have solved the issue? Even i facing the same problem...

Thanks

Ram