04-30-2009 10:11 PM
In ECC 6.0, When I do a SLIN on a program it says STOP command is obsolete. I need to fix this issue. What purpose does STOP serve ?
Also, my program's logic is like this..
START-OF-SELECTION.
perform xxx.
If condition 1 is true.
<< do something >>
STOP.
endif.
sss = hhh.
Perform ggg.
END-OF-SELECTION.
What if the original developer had written like this eliminating the STOP ...
If condition is true.
<< do something >>
else
sss = hhh.
Perform ggg.
endif.
Wouldn't have this worked ? why did he use a STOP statement there ? Any tips ?
thks
04-30-2009 10:48 PM
STOP is used to leave current event block and proceed to the next one (here END-OF-SELECTION). Basically it may be used if some critical condition is not fullfilled, then it wouldn't have sense to proceed calculation. It such case you could use STOP to reach END-OF-SELECTION and just display your list or already collected data.
If he eliminates STOP the processing would go further, not branching to next event block.
Some example:
You are processing employees in START-OF-SELECTION and then GET pernr event. The latter just creates a loop on all the employees based on selection createria. When i.e. you meet at least one employee fullfilling some condition you don't want to calculate next employee. Using STOP would make sense here. On the other hand, eliminating STOP would just pick another employee and do a calculation for him/her.
START-OF-SELECTION.
GET pernr. "for each employee
if condition.
STOP. "leave current event block (here GET pernr) and go directly to END-OF-SELECTION, calculation is interrupted then and not proceeded any futher (no other employees are calculated)
endif.
END-OF-SELECTION.
Regards
Marcin
04-30-2009 10:39 PM
You can use EXIT instead of that. Check F1 help.
Basically, STOP is used to come out of the current reporting event.
04-30-2009 10:48 PM
STOP is used to leave current event block and proceed to the next one (here END-OF-SELECTION). Basically it may be used if some critical condition is not fullfilled, then it wouldn't have sense to proceed calculation. It such case you could use STOP to reach END-OF-SELECTION and just display your list or already collected data.
If he eliminates STOP the processing would go further, not branching to next event block.
Some example:
You are processing employees in START-OF-SELECTION and then GET pernr event. The latter just creates a loop on all the employees based on selection createria. When i.e. you meet at least one employee fullfilling some condition you don't want to calculate next employee. Using STOP would make sense here. On the other hand, eliminating STOP would just pick another employee and do a calculation for him/her.
START-OF-SELECTION.
GET pernr. "for each employee
if condition.
STOP. "leave current event block (here GET pernr) and go directly to END-OF-SELECTION, calculation is interrupted then and not proceeded any futher (no other employees are calculated)
endif.
END-OF-SELECTION.
Regards
Marcin
05-01-2009 5:34 PM
Hi Marcin,
From your example I understand clearly the purpose of STOP. Thanks. Now I try to match it up with my code where I dont understand why STOP was used !! In my code I am not using any logical database and logic goes like this.
START-OF-SELECTION.
Perform get_data.
...
...
If cond is true.
Perform CCC.
STOP
endif.
If vcv='x'.
...
endif.
Perform yyyy.
END-OF-SELECTION.
If ccc = 'c'.
...
endif.
The form routines get_data and CCC have some logic that fetches data from custom table into internal tables and if a condition is matched it says "Leave List-processing". Also in form CCC, a report is called using "submit (prog_name) and return ...".
Now my questions are:
1. Why do u think STOP is used there ?
2. Instead if I use EXIT, will it give the same effect as what is happening now ? I dont want the output to be affected.
thks
05-01-2009 12:50 AM
05-01-2009 6:08 PM
STOP statement is obsolete only in context of ABAP OO, so if you are not using OO then you can still continue to use STOP. Beyond that why did the earlier developer use 'STOP' statement instead of 'IF...ELSE...ENDIF' construct, it is clearly a developer perference. In good programming pactice some developers beleive that 'IF.... ELSE... ENDIF' if have too many lines of code makes the code unreadable so instead use a simple IF...ENDIF' construct with 'STOP' for error handling. and then write the compete else part of the code below that. Hope this explains the concern.