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

Using dynamic loops

Former Member
0 Likes
399

Hello,

I am having this loops that i need to do in the same method and my question is

if there is a way to do that in once insted to do that many time for every operation ,i.e. maybe to send the operaion types via daynmic statment...

    LOOP AT lt_operation_list INTO lo_oper.

        IF    lv_operation=>gc_operation_type-update = lo_oper->get_operation_type( )

           OR lv_operation=>gc_operation_type-create = lo_oper->get_operation_type( )

            OR lv_operation=>gc_operation_type-query = lo_oper->get_operation_type( ) .

         

         

        ENDIF.

      ENDLOOP.

    LOOP AT lt_operation_list INTO lo_oper.

        IF    lv_operation=>gc_operation_type-update = lo_oper->get_operation_type( ).

     

         

         

        ENDIF.

      ENDLOOP.

    LOOP AT lt_operation_list INTO lo_oper.

        IF    lv_operation=>gc_operation_type-update = lo_oper->get_operation_type( ) or

    OR lv_operation=>gc_operation_type-create = lo_oper->get_operation_type( ).

     

         

 

        ENDIF.

      ENDLOOP.

Best regards,

Joy

2 REPLIES 2
Read only

Former Member
0 Likes
371

Hi Joy,

Write the code like this

   LOOP AT lt_operation_list INTO lo_oper.

     case lo_oper->get_operation_type( )

        when lv_operation=>gc_operation_type-update

          lv_update = 'TRUE

          write both the function that you want to execute on if update is true or at least one of them is true and set in a variable that one time message has been sent

        when lv_operation=>gc_operation_type-create

'         lv_create  = 'TRUE

             if lv_update eq TRUE

           

write both the function that you want to execute on if create is true or at least one of them is true only if one time message has not been sent

         when  lv''_operation=>gc_operation_type-query

          'lv_query = 'TRUE    

write both the function that you want to execute on if query is true or at least one of them is true only if one time message has not been sent

     endcase.

        if lv_update eq true and lv_create eq true

            write what ever according to your code shown abave in second loop.

        endif

ENDLOOP.

Hope this will help you by this way you can avaoid using loops three times

thanks

Rahul

Read only

0 Likes
371

Hello Rahul,

Thanks for your replay.

Instead of duplicate the code many times I thought to create one method and move

to it the needed parameter in every time (e.g. the name of the operation - sometime one operation like update and sometimes 3 operations ) there is elegant way to do this in ABAP...

Best Regards,    

Joy