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

Prob in loop statement

Former Member
0 Likes
523

Hi.

When i'm debugging the code it is not coming out of the loop statement.

Can anyone tell me the possible error i made.

Also i'm trying to clear the work area at the start of subroutine but it is not working as seen in debugging mode.

Rgds,

Simran

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
496

Hi.

When i'm debugging the following code it is not coming out of the loop statement.

FORM sub_dowload.

DATA: l_g_lt_dt TYPE dats,

l_g_lt_tm TYPE tims.

l_g_lt_dt = wa_update-last_run_dt.

l_g_lt_tm = wa_update-last_run_tm.

SELECT

prog_name

plant

last_run_dt

last_run_tm

INTO TABLE i_update

FROM z_download

FOR ALL ENTRIES IN i_t001w

WHERE plant EQ i_t001w-werks.

IF NOT i_update[] IS INITIAL.

LOOP AT i_update INTO wa_update.

*if last run date is blank

IF NOT l_g_lt_dt IS INITIAL.

wa_update-last_run_dt = l_g_lt_dt.

ELSE.

wa_update-last_run_dt = g_sysdate - 1.

ENDIF.

*if last run time is blank

IF NOT l_g_lt_tm IS INITIAL.

wa_update-last_run_tm = l_g_lt_tm.

ELSE.

wa_update-last_run_tm = g_systime.

ENDIF.

APPEND wa_update TO i_update.

ENDLOOP.

ENDIF.

ENDFORM. " sub_download

Can anyone tell me the possible error i made.

Also i'm trying to clear the work area at the start of subroutine but it is not working as seen in debugging mode.

Rgds,

Simran

4 REPLIES 4
Read only

Former Member
0 Likes
497

Hi.

When i'm debugging the following code it is not coming out of the loop statement.

FORM sub_dowload.

DATA: l_g_lt_dt TYPE dats,

l_g_lt_tm TYPE tims.

l_g_lt_dt = wa_update-last_run_dt.

l_g_lt_tm = wa_update-last_run_tm.

SELECT

prog_name

plant

last_run_dt

last_run_tm

INTO TABLE i_update

FROM z_download

FOR ALL ENTRIES IN i_t001w

WHERE plant EQ i_t001w-werks.

IF NOT i_update[] IS INITIAL.

LOOP AT i_update INTO wa_update.

*if last run date is blank

IF NOT l_g_lt_dt IS INITIAL.

wa_update-last_run_dt = l_g_lt_dt.

ELSE.

wa_update-last_run_dt = g_sysdate - 1.

ENDIF.

*if last run time is blank

IF NOT l_g_lt_tm IS INITIAL.

wa_update-last_run_tm = l_g_lt_tm.

ELSE.

wa_update-last_run_tm = g_systime.

ENDIF.

APPEND wa_update TO i_update.

ENDLOOP.

ENDIF.

ENDFORM. " sub_download

Can anyone tell me the possible error i made.

Also i'm trying to clear the work area at the start of subroutine but it is not working as seen in debugging mode.

Rgds,

Simran

Read only

0 Likes
496

What you are doing is to append a new row for each row of the table, so the table is continously getting new rows, so apparently it will not come of out the loop.

I guess want to update the row rather than appending a new row.

MODIFY i_update FROM wa_update INDEX SY-INDEX.

OR

MODIFY I_UPDATE FROM WA_UPDATE WHERE XXX = XXXX.

Regards,

Ravi

Note : Please mark all the helpful answers

Read only

0 Likes
496

Hi.

If i want to get records greater than the last run date and last run time,from db table do i need give the range

i.e. GE last_run_dt

and LE sy-datum

or just the GE last_run_dt will retrieve all records uptill sy-datum.

Rgds,

Simran

Read only

0 Likes
496

Anything greater than the LAST_RUN_DT should give you everything till SY_DATUM.

regards,

Ravi

Note : Please close the thread if the issue is resolved.