2013 Apr 05 3:37 PM
Hi,
Is there any alternative for this logic below.....
Table1 consist of date field. Date field in a particular record is checked with all other previous record and then some logic is proccessed.
Normal way is this...
Loop at table1.
l_index = sy-tabix.
Loop at table2(copy of table1) untill l_index.
some logic.
Endloop.
Endloop.
Thanks....
2013 Apr 06 7:22 AM
hi Pradosh,
According to me your requirement doesn't require a parallel cursor technique.......the logic you have written is perfect to your requirement.....
thanks and regards,
narayan
2013 Apr 05 3:51 PM
Hi Pradosh,
The above code is a good technique when performance is taken into consideration and u can proceed with it. Called Parallel cursor technique and it is an alternative for Nested Loops.
Could u plz tell if u faced any issue with this one ......
Thanks
Vivek
2013 Apr 06 6:00 AM
2013 Apr 05 4:11 PM
hi,
please find exact code as below
data:lv_index type sy-tabix.
Loop at table1.
Loop at table2(copy of table1) from lv_index.
if table1-field <> table2-field
l_index = sy-tabix.
exit.
endif.
some logic.
Endloop.
Endloop.
2013 Apr 06 6:05 AM
Hi Krishna,
Thanks for u r concern.........Your approach is correct but my scenario is different.
I need to compare the date field of the table2 with all other previous record's date field of table1
and put into another table(result, I need).
I need alternative other than Nested Loop.....
or else I have to implement this itself...
Regards
2013 Apr 06 6:23 AM
2013 Apr 06 7:22 AM
hi Pradosh,
According to me your requirement doesn't require a parallel cursor technique.......the logic you have written is perfect to your requirement.....
thanks and regards,
narayan
2013 Apr 06 9:52 AM
Hi Pradosh,
Suppose TABLE2 is copy of TABLE1 and you have 1 additional field in table2 called ZINDEX of TYPE SY-TABIX.
Also assuming that number of data in both internal tables are same (since table2 is reflecting table1):
DATA: ITAB1 TYPE STANDARD TABLE OF TABLE1,
ITAB2 TYPE STANDARD TABLE OF TABLE2,
WA1 TYPE TABLE1,
WA2 TYPE TABLE1.
DATA: INDEX_COUNT TYPE SY-TABIX.
LOOP AT ITAB1 INTO WA1.
INDEX_COUNT = SY-TABIX.
WA2-ZINDEX = INDEX_COUNT.
MODIFY ITAB2 INDEX INDEX_COUNT FROM WA2 TRANSPORTING ZINDEX.
READ TABLE ITAB2 WITH KEY ZINDEX = INDEX_COUNT
IF SY-SUBRC = 0.
perform logic and changes in itab_2
ENDIF.
ENDLOOP.
*******************************
So when SY-TABIX of ITAB1 is 1, changes are made in ITAB2 at index 1, when SY-TABIX of ITAB2 is 2, logic for ITAB2 is executed at index 2 and so on.. And so logic will be applied on each line of ITAB2 till the current index.
(let me know if i am wrong).
Regards,
Khushboo.
2013 Apr 06 1:41 PM
Thanks for your concern...
You need to understand my requirement....again
Your logic is perfect but it doesn't meet my requirement..
Regards
2013 Apr 06 1:48 PM
hi
Please Check below link and find your solution
http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP+Code+for+Parallel+Cursor+-+Loop+Processing
Thanks & Regards
RKarmakar