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

Build new Method

Former Member
0 Likes
457

HI,

This loop is inside method and i want to separate it and to put it in new method,

What is the best way to that?

Regards


    LOOP AT lt_variant_content INTO line
      LOOP AT line-paramtab INTO line2.
        CASE line2-parname.
          WHEN 'LT_MANAGER_DETAIL'.
            ASSIGN line2-value_ref->* TO <ls_detail>.
          WHEN 'LT_EMP_DETAILS'.
            ASSIGN line2-value_ref->* TO <lt_details>.
          WHEN 'LT_ITEMS'.
            ASSIGN line2-value_ref->* TO <lt_b>. 
        ENDCASE.
      ENDLOOP.

Edited by: ricardo arona on Feb 3, 2009 1:50 PM

Edited by: Matt on Feb 3, 2009 2:50 PM - added tags

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
439

Hi,

You can create another method and call this method from the existing method. The parameters of this method will be the local data of the existing method.

example


class c1 implementation.
method meth1   "implementation.

    call method meth2( ).  " Call the method of the class.

endmethod.

method meth2 " implementation.

Loop ... endloop.

endmethod.

endclass.

regards,

Advait

Edited by: Advait Gode on Feb 3, 2009 3:03 PM

3 REPLIES 3
Read only

Former Member
0 Likes
439

HI,

LOOP AT lt_variant_content INTO line
  PERFROM <Method> table line-paramtab 
ENDLOOP.

FROM <METHOD> TABLES LINE STRUCTURE <struc>.

DATE line2 like line-paramtab. 
LOOP AT line-paramtab INTO line2.
CASE line2-parname.
WHEN 'LT_MANAGER_DETAIL'.
ASSIGN line2-value_ref->* TO <ls_detail>.
WHEN 'LT_EMP_DETAILS'.
ASSIGN line2-value_ref->* TO <lt_details>.
WHEN 'LT_ITEMS'.
ASSIGN line2-value_ref->* TO <lt_b>. 
ENDCASE.

ENDLOOP.

ENDFORM.

Read only

matt
Active Contributor
0 Likes
439

Avinash - he wants a METHOD. Why have you answered with a PERFORM?

Read only

Former Member
0 Likes
440

Hi,

You can create another method and call this method from the existing method. The parameters of this method will be the local data of the existing method.

example


class c1 implementation.
method meth1   "implementation.

    call method meth2( ).  " Call the method of the class.

endmethod.

method meth2 " implementation.

Loop ... endloop.

endmethod.

endclass.

regards,

Advait

Edited by: Advait Gode on Feb 3, 2009 3:03 PM