Wednesday, September 16, 2009

when and where we can use parallel cursor


Loop AT i_primary into wa_primary.
Loop AT i_secondary into wa_secondary from lv_index.
If ( wa_primary-field1 NE wa_secondary-field1 ) or
( wa_primary-field2 NE wa_secondary-field2 ).
Lv_index = sy-tabix.
Endif.
“ your code comes here “
Endloop.
Endloop.
To use this following should be true
1)      Both tables should be sorted with the same key ( in the above case field1 and field2 )
2)      The mapping between primary to secondary tables should be
a.       one to many ( for one record in primary there are multiple records in secondary )
b.      one to one (for one record in primary there is only one in secondary )
Please note that other than the above 2 other 2 scenarios (many to many & many to one) will not work with the above logic and make sure you don’t use in such case.
3)      The secondary table should not contain a record which does not map to the primary table ( this will not happen if the secondary is fetched using for all entries from primary )
4)      Please make sure you do not delete any record from primary before using the logic which will make the point 3 false  
5)      If you were to use a 'AND' in where statement of the inner loop you should use or in the inner loop if condition in the above logic. 
 

No comments:

Google