Friday, June 29, 2007

Improved version of Parallel Cursor

Problem with previous Method: The disadvantage of the code in my previous post is that we can not use it when the inner loop key fields are are independent of key fields of outer loop. i.e. The assumption was the inner loop index keeps incrementing as the outer loop index index moves ahead. But this is not the case for 90% of our code. For example let outer loop be VBPA table and inner loop be KNA1 table, in which case, the key field for VBPA will be VBELN, but the key field for KNA1 would be KUNNR. Also reader can note it is not necessary that inner loop index gets incremented for each outer loop parse.

Alternate Method: To overcome this problem, we use a READ statement with binary search before the inner loop starts. This gets the starting index of the inner loop and then rest of the logic remains same.

Reader can witness that this methods is very easy and understandable compared to previous code.


sort: lt_vbpa by vbeln,
kna1 by kunnr.

loop at lt_vbpa into wa_vbpa.
read lt_kna1 into wa_kna1
with key kunnr = wa_vbpa-kunnr
binary search.
if sy-subrc = 0.
v_kna1_index = sy-tabix.
loop at lt_kna1 into wa_kna1 from v_kna1_index.
if wa_kna1-kunnr <> wa_vbpa-kunnr.

****** Your Actual logic within inner loop ******

endloop. "KNA1 Loop
endloop. " VBPA Loop

Labels: , , ,


Anonymous Anonymous said...

Hi this is somewhat of off topic but I was wondering if blogs use WYSIWYG editors or if you have to
manually code with HTML. I'm starting a blog soon but have no coding know-how so I wanted to get guidance from someone with experience. Any help would be greatly appreciated!

Also visit my webpage :: Vimax Extender

May 19, 2013 10:53 PM  

~ * ~

Anonymous Anonymous said...

Hi there, of course this post is genuinely
pleasant and I have learned lot of things from it concerning blogging.

my website - Muscle Factor X REview

May 20, 2013 12:20 PM  

~ * ~

Anonymous Anonymous said...

With havin so much written content do you ever run
into any problems of plagorism or copyright violation?
My site has a lot of unique content I've either created myself or outsourced but it looks like a lot of it is popping it up all over the web without my agreement. Do you know any ways to help stop content from being ripped off? I'd genuinely appreciate it.

Here is my web blog :: Raspberry Ketone Plus Review

May 21, 2013 3:04 AM  

~ * ~

Anonymous Anonymous said...

I was curious if you ever thought of changing the page layout of
your website? Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people could connect
with it better. Youve got an awful lot of text for only
having one or two pictures. Maybe you could space it
out better?

Feel free to surf to my page :: Green coffee diet

May 21, 2013 6:08 AM  

~ * ~

Anonymous Anonymous said...

Do you have a spam issue on this site; I also am a blogger, and I was wanting to know your situation;
we have developed some nice procedures and we are
looking to swap solutions with other folks, be sure to shoot me
an e-mail if interested.

My blog: Stem Cell Wrinkle Cream

May 27, 2013 8:08 AM  

~ * ~

Anonymous Anonymous said...

Keep on working, great job!

My weblog :: Buy Androsolve

May 27, 2013 3:00 PM  

~ * ~

Post a Comment

<< Home