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

Rewrite Dump iterator

0 Likes
1,027

hi,

help abap begginer

I found program for my project, except it returns a Dump, (Time-out), the DO iteration never ends, i think i have to add a stop condition but i don't know where exactly and how stop it. plz correct me plz. thanks

l_date = ls_new_p2001-begda - 1.
DO.
LOOP AT lt_persw INTO ls_persw WHERE datum = l_date
                               AND ftkla = 0
                               AND stdaz <> 0.
ENDLOOP.
IF sy-subrc = 0.
SELECT SINGLE * FROM pa2001 INTO pa2001 WHERE pernr = ls_new_p2001-pernr
                                        AND subty = 'CE'
                                        AND begda <= l_date
                                        AND endda >= l_date.
    IF sy-subrc = 0.
     l_date = l_date - 1.
    ELSE.
     EXIT.
    ENDIF.
 ELSE.
   l_date = l_date - 1.
 ENDIF.
ENDDO.


3 REPLIES 3
Read only

matt
Active Contributor
0 Likes
922

READ TABLE ... WHERE

Are you sure?

Read only

matt
Active Contributor
922

For clarity and efficiency use something like this.

l_date = ls_new_p2001-begda - 1.
DO.
  IF entry_exists( l_date ).
    SELECT SINGLE * FROM pa2001 INTO pa2001 WHERE pernr = ls_new_p2001-pernr
                                        AND subty = 'CE'
                                        AND begda <= l_date
                                        AND endda >= l_date.
    IF sy-subrc = 0.
     l_date = l_date - 1.
    ELSE.
     EXIT.
    ENDIF.
 ELSE.
   l_date = l_date - 1.
 ENDIF.
ENDDO.

...
METHOD entry_exists. " Returning parameter r_result type abap_bool
LOOP AT lt_persw INTO ls_persw WHERE datum = l_date AND ftkla = 0 AND stdaz <> 0.
r_result = abap_true. RETURN. ENDLOOP. ENDMETHOD.

But that's not the cause of your error.

There is one place I can see where you'll get an eternal loop. In your LOOP AT - if there are no entries that match from the start date down, then the loop will never end.

Try running it in debug.

Read only

0 Likes
922

matthew.billingham thanks for your answer,