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

How to avoid check inside loop

Former Member
0 Likes
486

Here G_T_VTD1,G_T_VTD are internal tables,

S_TAXNUM is selection option input.

G_RFDYM is a vriable.

S_RFDPRD is selection option input.

G_RFDYM is a variable

S_RFDPRD is selection option input.

<b> LOOP AT G_T_VTD1.

CHECK: S_TAXNUM.

MOVE G_T_VTD1-RFDMY+2(4) TO G_RFDYM(4).

MOVE G_T_VTD1-RFDMY(2) TO G_RFDYM+4(2).

IF S_RFDPRD-LOW <> SPACE.

CHECK: G_RFDYM GE S_RFDPRD-LOW.

ENDIF.

IF S_RFDPRD-HIGH <> SPACE.

CHECK: G_RFDYM LE S_RFDPRD-HIGH.

ENDIF.

CLEAR G_T_VTD.

MOVE-CORRESPONDING G_T_VTD1 TO G_T_VTD.

APPEND G_T_VTD.

ENDLOOP.</b>

Hai All, here how to avoid the check statements inside the loop, tell me logic for that

Thanks,

Sanu

3 REPLIES 3
Read only

Former Member
0 Likes
462

Change your code as below:


IF NOT S_TAXNUM IS INITIAL.
LOOP AT G_T_VTD1.
MOVE G_T_VTD1-RFDMY+2(4) TO G_RFDYM(4).
MOVE G_T_VTD1-RFDMY(2) TO G_RFDYM+4(2).
IF S_RFDPRD-LOW <> SPACE.
CHECK: G_RFDYM GE S_RFDPRD-LOW.
ENDIF.
IF S_RFDPRD-HIGH <> SPACE.
CHECK: G_RFDYM LE S_RFDPRD-HIGH.
ENDIF.
CLEAR G_T_VTD.
MOVE-CORRESPONDING G_T_VTD1 TO G_T_VTD.
APPEND G_T_VTD.
ENDLOOP.
ENDIF.

The other two checks cannot be avoided because they are dependant on the loop values.

Read only

0 Likes
462

IF NOT S_TAXNUM IS INITIAL.

***ur loop.

endif.

amit

Read only

Former Member
0 Likes
462

Hi Sanu,

Use WHERE instead of CHECK.