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

parallel cursor

Former Member
0 Likes
511

hi experts,

can i use more than one parallel cursor , when i looping thru different internal tables,

i used once it in my current prog as i need multiple Grn no(ekbe-belnr) , with respect to single po(ekpo-ebeln).

but in my current prog. i also need multiple (konv-kposn) vaue with respect to sigle po no,

to display multiple tax calculation!

plz help , i badly needed this answer in no time

3 REPLIES 3
Read only

Former Member
0 Likes
463

hi

You can also open more than one cursor in parallel for a single database table. If a cursor is already open, you cannot reopen it. To close a cursor explicitly, use the following statement:

CLOSE CURSOR <c>.

Aakash Banga

Read only

Former Member
0 Likes
463

Hi,

You can use this..Parallel cursor concept...But make sure you read the internal tables using the index and these tables should be Sorted...Else this will be a performance issues...

Make sure you have the key fields in the read as many as possible

Note that you need to have an exit condition at the end or else it will loop the entire tables(itab2 and itab3)....

Loop at itab1

read table itab2 ito watab2 with key....

if sy-subrc = 0.

loop at itab2 from sy-tabix.

---

---

---

read table itab3 into watab3 with key....

if sy-subrc = 0.

loop at itab 3 from sy-tabix..

-


-


at end of...

exit

endat.

---

endloop

---

---

at end of...

exit

endat.

endloop

endloop.

Regards

Shiva

Read only

Former Member
0 Likes
463

Hi,

Have a look at the code below. The select the entries from KONV based on the requirement. Better not to use the select *, instead select the required fields from the tables.

TABLES : ekko, ekpo, ekbe, konv.

DATA: it_ekpo TYPE TABLE OF ekpo WITH HEADER LINE,

it_ekbe TYPE TABLE OF ekbe WITH HEADER LINE,

it_konv TYPE TABLE OF konv WITH HEADER LINE.

DATA: l_index1 TYPE sytabix,

l_index2 TYPE sytabix.

SELECT-OPTIONS s_ebeln FOR ekko-ebeln.

SELECT-OPTIONS s_knumv FOR konv-knumv.

SELECT * FROM ekpo INTO TABLE it_ekpo WHERE ebeln IN s_ebeln.

IF NOT it_ekpo[] IS INITIAL.

SELECT * FROM ekbe INTO TABLE it_ekbe

FOR ALL ENTRIES IN it_ekpo

WHERE ebeln = it_ekpo-ebeln

AND ebelp = it_ekpo-ebelp.

ENDIF.

SELECT * FROM konv INTO TABLE it_konv

WHERE knumv = s_knumv.

SORT it_ekpo BY ebeln ebelp.

SORT it_ekbe BY ebeln ebelp.

SORT it_konv BY knumv.

LOOP AT it_ekpo.

LOOP AT it_ekbe FROM l_index1.

if ( it_ekbe-ebeln ne it_ekpo-ebeln )

and ( it_ekbe-ebelp ne it_ekpo-ebelp ).

exit.

else.

l_index1 = sy-tabix.

*do the necessary calculations

endif.

LOOP AT it_konv FROM l_index2.

  • write the necessary if condition so that it would exit from the loop

if (.......)

else.

  • fill the required fields and do the necessary calculations

l_index2 = sy-tabix.

ENDLOOP.

ENDLOOP.

ENDLOOP.

The loop of the konv table has to be placed as required based on whether it has to be in the loop of EKBE or out of EKBE.