Skip to Content
author's profile photo Former Member
Former Member

Nested loops....

Hi Gurus,

i need some help with a nested loop and how i can save some performance.

the following coding is in place right now:

DATA: lref_demand TYPE REF TO /mrss/if_sge_single_demand.

DATA: lref_assignment TYPE REF TO /mrss/cl_sge_assignment.

DATA: lt_assignments TYPE TABLE OF /mrss/t_assignment.

DATA: ls_assignments TYPE /MRSS/T_ASSIGNMENT.

DATA: ls_ass2 TYPE /mrss/t_assignment.

DATA: ls_assignment_data_detail TYPE /mrss/t_assignment_wfm_det,

ls_ass_data_detail TYPE /mrss/t_assignment_wfm_det.

lref_demand = ls_demands-object.

lref_assignment = ls_ass2-object.

IF NOT lref_assignment IS INITIAL.

ls_assignments = ls_ass2.

APPEND ls_assignments TO lt_assignments.

ELSE.

  • Get Assignments

CALL METHOD lref_demand->assignments_get

RECEIVING

rt_assignments = lt_assignments.

ENDIF.

sort lt_assignments.

LOOP AT lt_assignments INTO ls_assignments.

lref_assignment = ls_assignments-object.

ls_assignment_data_detail = lref_assignment->data_detail_get( ).

LOOP AT lt_assignments INTO ls_ass2.

lref_assignment = ls_ass2-object.

ls_ass_data_detail = lref_assignment->data_detail_get( ).

  • Compare if overlapped assignment exists

IF ls_assignment_data_detail-beg_tstmp >=

ls_ass_data_detail-beg_tstmp AND

ls_assignment_data_detail-beg_tstmp <=

ls_ass_data_detail-end_tstmp AND

ls_assignment_data_detail-assignment_key <>

ls_ass_data_detail-assignment_key.

  • Call Alert Monitor

CALL METHOD me->alert_update

EXPORTING

lt_ass = ls_assignments

lt_demands = ls_demands

wa_alert = '1'

ls_szena = 'ANV'.

ENDIF.

ENDLOOP. "lt_assignmetns 2

ENDLOOP. " lt_assignments

The performance is very poor due to the nested loops. Anyone have an idea how i can save some performance here?

Thanks alot for you help

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Apr 28, 2008 at 04:43 PM

    If your requirement satifies then replace the second loop by Read Table.

    Regards,

    Amit

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 28, 2008 at 04:50 PM

    to clear up the requirement i will describe it.

    I need to loop over lt_assignments.

    lt_assignments has a field with a object which i need to select the a full set of data which i then need to compare against each other.

    Example:

    lt_assignment has field "object"

    using this code i select the full details

    "lref_assignment = ls_assignments-object.

    ls_assignment_data_detail = lref_assignment->data_detail_get( )."

    Now i need to compare these details which each other to like you can see in the IF clause.

    I hope i could clear up my requirement.

    Edited by: Rene Portz on Apr 28, 2008 6:50 PM

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.