Thursday, May 7, 2009

best way to code nested loops SAP


REPORT  ZPARALLEL_CURSOR.
TABLES:
  likp,
  lips.

DATA:
      t_likp  
TYPE TABLE OF likp,
      t_lips  
TYPE TABLE OF lips,
      t_lips1 
TYPE SORTED TABLE OF lips
      
WITH NON-UNIQUE KEY vbeln.




DATA:
      w_runtime1 
TYPE I,
      w_runtime2 
TYPE I,
      w_counter 
TYPE I,
      w_index 
LIKE sy-INDEX.

DATA:
      likp_l 
TYPE I,
      lips_l 
TYPE I.

PARAMETERSrows TYPE i OBLIGATORY.

START-
OF-SELECTION.
SELECT *
FROM likp
INTO TABLE t_likp up to rows ROWS.



DESCRIBE TABLE t_likp LINES likp_l.

WRITE:/ 'records in likp: ' .
WRITE likp_l.

SELECT *
INTO TABLE t_lips
FROM lips
  
FOR ALL ENTRIES IN t_likp
  
WHERE vbeln = t_likp-vbeln.


DESCRIBE TABLE t_lips LINES lips_l.


WRITE:/ 'records in lips: ' .
WRITE lips_l.


**********************************************************************
**********************************************************************
**********************************************************************

GET RUN TIME FIELD w_runtime1.

LOOP AT t_likp INTO likp.
  
LOOP AT t_lips INTO lips WHERE vbeln EQ likp-vbeln.

  
ENDLOOP.
ENDLOOP.

GET RUN TIME FIELD w_runtime2.

w_runtime2 = w_runtime2 - w_runtime1.

WRITE:/.
WRITE:/'Time taken on normal where condition:'.
WRITE: w_runtime2.

**********************************************************************
**********************************************************************
**********************************************************************
GET RUN TIME FIELD w_runtime1.
SORT t_likp BY vbeln.
SORT t_lips BY vbeln.

LOOP AT t_likp INTO likp.

  
LOOP AT t_lips INTO lips FROM w_index.
    
IF likp-vbeln NE lips-vbeln.
      w_index = sy-tabix.
      
EXIT.
    
ENDIF.

  
ENDLOOP.
ENDLOOP.


GET RUN TIME FIELD w_runtime2.

w_runtime2 = w_runtime2 - w_runtime1.


WRITE:/.
WRITE:/.
WRITE:/'Time taken with parallel cursor:' , w_runtime2.



**********************************************************************
**********************************************************************
**********************************************************************

GET RUN TIME FIELD w_runtime1.

SORT t_lips BY vbeln.
t_lips1[] = t_lips[].




LOOP AT t_likp INTO likp.
  
LOOP AT t_lips1 INTO lips WHERE vbeln EQ likp-vbeln.
  
ENDLOOP.

ENDLOOP.

GET RUN TIME FIELD w_runtime2.

w_runtime2 = w_runtime2 - w_runtime1.

WRITE:/.
WRITE:/.
WRITE:/'Time taken for a sorted table with where condition:' , w_runtime2.





3 comments:

Rui Dantas said...

Hi,

Nice analysis.

In the second chart, the values are higher than in the table. Which one is correct, the table or the chart?

nafi925 said...

Sry for the late reply thing something wrong with the comment settings.
the table is the correct one i made the graph using the table think some thing wrong with Excel.

Nafran

Anonymous said...

buy pepcid for dogs
[url=http://www.wikio.com/article/buy-pepcid-online-buy-cheap-pepcid-139713077]buy pepcid for dogs[/url]
buy pepcid for dogs
levitra side effects generic levitra levitra male enhancement temporary impotence impotence problem key buy-levitra what is better viagra or levitra
[url=http://levitra.typepad.com/]levitra buy [/url]
buy generic levitra
buy levitra levitra dosage free levitra trial levitra website info levitra generic levitra levitra vs viagra
[url=http://virb.com/yalevi]impotence information [/url]
levitra side effects
z pak for strep throat zithromax z pak buy generic zithromax online discount zithromax zithromax online zithromax pill zithromax pediatric dosing
[url=http://virb.com/bono]buy azithromycin zithromax [/url]
zithromax overnight
buy 40 mg lasix without prescription buy lasix next day where can i buy lasix buy lasix no prescription buy lasix online buy lasix without a prescription buy lasix online overnight shipping
[url=http://www.magentocommerce.com/boards/viewthread/63722/]buy lasix nextday [/url]
buy lasix
-------------------------------------------------------------------
[url=http://fotak.ru/stats.php?r=www.blogger.com]my blog[/url]
blog my

Google