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

Question about check

Former Member
0 Likes
665

hi,

Why exit and check can only used in loop , why cannot it be used in if ... else statement ?

this warning message was reported by extended check.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
647

Hi,

If. endif.

is a conditional statement.

The conditional statement is not a loop statement.

if you use the same in conditional if the check is not satisfied with the condition.the it will go directly to the end of the program.

that is the reason why we not use the same in between if and endif

Regards,

madan

5 REPLIES 5
Read only

Former Member
0 Likes
648

Hi,

If. endif.

is a conditional statement.

The conditional statement is not a loop statement.

if you use the same in conditional if the check is not satisfied with the condition.the it will go directly to the end of the program.

that is the reason why we not use the same in between if and endif

Regards,

madan

Read only

0 Likes
647

hi,

if lv_tmp is initial.

return.

endif.

There will be 3 lines,

but

check lv_tmp is not initial.

need only one line.

Why not use it?

Best regards,

Read only

0 Likes
647

Hi Blake Le,

RETURN

This statement immediately ends the current processing block. It can appear in any area of a processing block and ends this block regardless of which statement block or control structure the statement is in.

After leaving the processing block, the runtime environment, except for the reporting event blockSTART-OF-SELECTION, follows the schema in Leave processing blocks.

After you end the reporting event block START-OF-SELECTIONwith RETURN, the runtime environment does not trigger any further reporting events, rather, it calls the list processor directly to display the basic list.

CHECK

If the statement CHECK is executed outside a loop and log_exp is incorrect, the statement terminates the current process block.

The behavior of the runtime environment after exiting the processing block is described under Exiting Processing Blocks.

SAP recommends to use this procedure with the statement CHECK only inside loops

Hope this helps...

Best regards,

raam

Read only

0 Likes
647

hi, raam,

Thanks , this solve my problem.

Best regards,

Read only

Former Member
0 Likes
647

Hi,

Blake,

if....else is a condotional statement that iterates only once. There is no chance of iterating more than once.

The main intention behind using EXIT and CHECK is to come out of a situation which is not satisfies a certain condition at some point of time during iteration. This iteration is not possible in IF condition. because it executes only once.It contains ELSE condition.It specifies what to do IF condition fails.

This is the main reason behind SAP suggestion

CHECK is used in loops.

If useful, reward points.

Thank u

Prasad G.V.K