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 confusion!!

Former Member
0 Likes
1,734

Hi Gurus,

I found some helpful articles regarding the parallel cursor and understood the concept as well.But I have some statements and I am confused where to add the parallel cursor method.I am posting the code below....plz check the code and tell me how to and where to include the parallel cursor method i.e. the read statements and loops for better performance.

loop at  e_varianten.

        

        loop at mbew1 where matnr = e_varianten-varnr and  lgort in s_lgort and werks = p_werks.

*          move-corresponding mbew1 to mbew.

***************added 10.09.2015***************************************************         

           move mbew1-matnr to mbew-matnr.

           move mbew1-labst to mbew-labst.

           move mbew1-lgort to mbew-lgort.

           move mbew1-werks to mbew-werks.

           move mbew1-stprs to mbew-stprs.

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

           append mbew.

         endloop.

         read table it_stprs1 into wa_stprs2 with key matnr = e_varianten-satnr.

        

         if sy-subrc = 0.

           loop at it_stprs1 into wa_stprs1 where matnr = e_varianten-satnr.

*            move-corresponding wa_stprs1 to wa_stprs.

******************************Added 10.09.2015****************************************           

            move wa_stprs1-matnr to wa_stprs-matnr.

          move wa_stprs1-stprs to wa_stprs-stprs.

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

             append wa_stprs to it_stprs.

           endloop.

         endif.

         objekt-cuobj = e_varianten-cuobj.

         read table it_ausp1 into wa_ausp2 with key objek = objekt-cuobj.

         if sy-subrc = 0.

           loop at it_ausp1 into wa_ausp1 where objek = objekt-cuobj.

  *           "MOVE-CORRESPONDING wa_ausp1 to wa_ausp.

             move wa_ausp1-objek to wa_ausp-objek.

             move wa_ausp1-atinn to wa_ausp-atinn.

             move wa_ausp1-atwrt to wa_ausp-atwrt.

             move wa_ausp1-atzhl to wa_ausp-atzhl.

             move wa_ausp1 to wa_ausp.

             append wa_ausp to it_ausp.

           endloop.

         endif.

       endloop.

please help me out.

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

former_member188724
Contributor
0 Likes
1,240

Hi Mason,

We use Parallel Cursor when we use multiple Loops.

You Loop at e_varinten and call Loops inside that.

Loop at varienten.

     read table mbew1

with key matnr = e_varianten-varnr.

if sy-subrc is Initial.

..chk for lgort & werks

v_indx = sy-tabix.

Loop at t_mbew1 into wa_mbew1 from v_indx.

if wa_mbew1-matnr ne e_varienten-varnr.

     Exit.

endif.

do your processing and append to tables,modify tables.....

similarly for other Loops.

endloop.

Please try and let me know if you have any issues.

Regards,

KS

3 REPLIES 3
Read only

former_member188724
Contributor
0 Likes
1,241

Hi Mason,

We use Parallel Cursor when we use multiple Loops.

You Loop at e_varinten and call Loops inside that.

Loop at varienten.

     read table mbew1

with key matnr = e_varianten-varnr.

if sy-subrc is Initial.

..chk for lgort & werks

v_indx = sy-tabix.

Loop at t_mbew1 into wa_mbew1 from v_indx.

if wa_mbew1-matnr ne e_varienten-varnr.

     Exit.

endif.

do your processing and append to tables,modify tables.....

similarly for other Loops.

endloop.

Please try and let me know if you have any issues.

Regards,

KS

Read only

Mohamed_Mukhtar
Active Contributor
0 Likes
1,240

Hi Mason,

Please try like below


** First delete records from  internal table mbew1 when lgort's not in S_lgort .

** Delete records from table mbew1 where werks not equal to p_werks,

** Sort MBEW1 by matnr.

**

data : lv_index type sy-tabix.

loop at  e_varianten.    

"" Add read statement here

     Read table mebw1 into wa_mebw1 with key matnr = e_varianten-varnr.

**

*        loop at mbew1 where matnr = e_varianten-varnr and  lgort in s_lgort and werks = p_werks.

if sy-subrc  =  0.

          lv_index = sy-tabix.

         loop at mbew1 from lv_index.

         if wa_mebw1-matnr NE mebwa-matnr.

             EXIT.

         endif.

*          move-corresponding mbew1 to mbew.

***************added 10.09.2015***************************************************        

           move mbew1-matnr to mbew-matnr.

           move mbew1-labst to mbew-labst.

           move mbew1-lgort to mbew-lgort.

           move mbew1-werks to mbew-werks.

           move mbew1-stprs to mbew-stprs.

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

           append mbew.

         endloop.

endif.

         read table it_stprs1 into wa_stprs2 with key matnr = e_varianten-satnr.

      

         if sy-subrc = 0.

            Clear lv_index.

            lv_index = sy-tabix.

*  loop at it_stprs1 into wa_stprs1 where matnr = e_varianten-satnr.

       loop at it_stprs1 into wa_stprs1 from lv_index.

         if wa_stprs2-matnr NE wa_stprs1-matnr.

             EXIT.

         endif.

*            move-corresponding wa_stprs1 to wa_stprs.

******************************Added 10.09.2015****************************************          

            move wa_stprs1-matnr to wa_stprs-matnr.

          move wa_stprs1-stprs to wa_stprs-stprs.

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

             append wa_stprs to it_stprs.

           endloop.

         endif.

         objekt-cuobj = e_varianten-cuobj.

         read table it_ausp1 into wa_ausp2 with key objek = objekt-cuobj.

         if sy-subrc = 0.

            Clear lv_index.

            lv_index = sy-tabix.

*          loop at it_ausp1 into wa_ausp1 where objek = objekt-cuobj.

            loop at it_ausp1 into wa_ausp1 from lv_index.

         if  wa_ausp1-objek NE wa_ausp2-objek.

             EXIT.

         endif

  *           "MOVE-CORRESPONDING wa_ausp1 to wa_ausp.

             move wa_ausp1-objek to wa_ausp-objek.

             move wa_ausp1-atinn to wa_ausp-atinn.

             move wa_ausp1-atwrt to wa_ausp-atwrt.

             move wa_ausp1-atzhl to wa_ausp-atzhl.

             move wa_ausp1 to wa_ausp.

             append wa_ausp to it_ausp.

           endloop.

         endif.

clear : lv_index.

       endloop.

Thanks

-Learner

Read only

shadab_maldar
Active Participant
0 Likes
1,240

Hi Mason,

Here you are having three loops in a loop, So you can apply parallel cursor on all the three loops,

loop at e_varianten.

loop1.

1.Parallel cursor on mbew1 by looping with index and avoiding where condition.

2. IF NOT s_lgort is initial.

    CHECK mbew1-lgort in s_lgort

    ENDIF.

endloop.

IF NOT p_werks is initial.

   CHECK mbew1-werks in p_werks.

ENDIF.

"Parallel Cursor Logic.

Loop2.

endloop.

"Parallel Cursor Logic.

loop3.

endloop.

endloop.