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: 

Smallest / Simplest example of Open Cursor concept - with Code

Former Member
0 Kudos

Team,

Please give Smallest / Simplest example of Open Cursor concept - with ABAP Code.

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Example from help

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3b23358411d1829f0000e829fbfe/content.htm

Regards,

Ravi

Note - Please mark all the helpful answers

2 REPLIES 2

Former Member
0 Kudos

Example from help

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3b23358411d1829f0000e829fbfe/content.htm

Regards,

Ravi

Note - Please mark all the helpful answers

Former Member
0 Kudos

This is an easy example.

REPORT demo_select_cursor_1.

DATA: c1 TYPE cursor,

c2 TYPE cursor.

DATA: wa1 TYPE spfli,

wa2 TYPE spfli.

DATA: flag1(1) TYPE c,

flag2(1) TYPE c.

OPEN CURSOR: c1 FOR SELECT carrid connid

FROM spfli

WHERE carrid = 'LH',

c2 FOR SELECT carrid connid cityfrom cityto

FROM spfli

WHERE carrid = 'AZ'.

DO.

IF flag1 NE 'X'.

FETCH NEXT CURSOR c1 INTO CORRESPONDING FIELDS OF wa1.

IF sy-subrc <> 0.

CLOSE CURSOR c1.

flag1 = 'X'.

ELSE.

WRITE: / wa1-carrid, wa1-connid.

ENDIF.

ENDIF.

IF flag2 NE 'X'.

FETCH NEXT CURSOR c2 INTO CORRESPONDING FIELDS OF wa2.

IF sy-subrc <> 0.

CLOSE CURSOR c2.

flag2 = 'X'.

ELSE.

WRITE: / wa2-carrid, wa2-connid,

wa2-cityfrom, wa2-cityto.

ENDIF.

ENDIF.

IF flag1 = 'X' AND flag2 = 'X'.

EXIT.

ENDIF.

ENDDO.

Reward Points if useful.

Prince