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

Check statement

Former Member
0 Likes
2,059

Hi

Please let me know if I am using CHECK statement within a loop instead of IF,ELSE; will it affect the performance of the program.

Ideally, which is better way to code with check or if.

Regards

Amit.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,543

hi

u can check examples in the SAP system. that is probably the best way to have the comparison test for performance. for that u plz go to se11. in that

<b>ENVIROMNMENT->EXAMPLES->PERFORMANCE EXAMPLES</b>

regards

ravish

<b>plz dont forget to reward points if helpful</b>

9 REPLIES 9
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,543

Hi,

CHECK statement will have better effect.

Since when you use IF ENDIF, ENDLOOP statement has to be executed

where as CHECK if fails comes back to first statement in the loop for the next loop pass.

<b>But the differnece is only very less since these days most of the application servers are good in performance and CHECK and IF both will be processed in the application servers Work process there is not much difference but if you ask in minute levels CHECK Is better.

But careful to use it as it skips all the code below that statement.</b>

Regards,

Sesh

Read only

Former Member
0 Likes
1,543

Hi amit,

If there is only one IF statement , then you can use CHECK statement instead of IF

if you have to IF ..ELSEIF ..ENDIF, then there is no other way you have to use If instead of CHECK

performance wise both are sam i guess

Read only

Former Member
0 Likes
1,543

Hi Amit,

Yes CHECK gives u more performance that in using IF...ENDIF.

Ideally you should be using more of CHECK than IF...ENDIF. but circumstances can impact your usage.

Kiran

Read only

Former Member
Read only

Former Member
0 Likes
1,544

hi

u can check examples in the SAP system. that is probably the best way to have the comparison test for performance. for that u plz go to se11. in that

<b>ENVIROMNMENT->EXAMPLES->PERFORMANCE EXAMPLES</b>

regards

ravish

<b>plz dont forget to reward points if helpful</b>

Read only

Former Member
0 Likes
1,543

Hi...

Performance should be about the same...

You can try your code out from SE30 ABAP Runtime Analysis... choose the 'Tips & Tricks' button... enter your code and execute it...

Dave...

Message was edited by:

Dave Taranovich

Read only

alejandro_bindi
Active Contributor
0 Likes
1,543

Performance wise it may be better...helping make programs maintenable it's not. When for example, inside a loop there's a lot of code, I think IF...ELSE is better for that reason. Using IF helps to understand logic easily, specially for people new to ABAP.

My two cents.

Read only

Former Member
0 Likes
1,543

HI

Check statement would be performane oriented.

If you use the CHECK <expr> statement within an event block but not within a loop, and the condition <expr> is not fulfilled, the system exits the processing block immediately.

<expr> can be any logical expression or the name of a selection table. If you specify a selection table and the contents of the corresponding table work are do not fulfill the condition in the selection table, it is the same as a false logical expression.

If the CHECK statement occurs in a loop using DO, WHILE, or LOOP, it is the loop that terminates, not the processing block.

Within a GET event block, this means the next GET event at the same hierarchical level. When it leaves the event block, the logical database reads the next line of the current node, or the next-highest node if it has already reached the end of the hierarchy level. Nodes that are lower down in the hierarchical structure of the logical database are not processed.

Inside GET events, you can use an extra variant of the CHECK statement:

CHECK SELECT-OPTIONS.

This statement checks the contents of the table work area of the current node against all selection tables linked to that node.

Note that CHECK statements for checking database contents in GET events are only processed after the data has been read from the logical database. For performance reasons, you should therefore avoid using checks of this kind. Instead, try to check before the data is read, for example, by using dynamic selections.

Read only

Former Member
0 Likes
1,543

Thanks for your useful responses.