-
Notifications
You must be signed in to change notification settings - Fork 449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Returning a value #290
Comments
Where did you this form of My gut feeling is someone defined a macro with the same name as ~Suhas |
Hi I am just back from vacation and will check tomorrow |
The ABAP release is 751. I checked the TRMAC and there is no entry for 'RETURN'. |
You also cannot redefine keywords using macros (I assume this also applies to TRMAC)
7.51 was released 6 years ago. |
Ohh sorry, I had no idea how to look it up and must have been looking at the wrong value. My coworker just told me that it is 7.58 |
Ah now it makes sense, then we externals got another sneak peek with this styleguide repo ;) (S/4 2022 was just released with 7.57 and the BTP ABAP Environment is on the equivalent 7.89.) |
Let's wait till that ABAP version is available to the external world, then recommend it as the default variant. |
As 7.58 is already officially supported, can this be added as recommended variant? |
This is interesting, and appears to work on A4H 2022 / 7.58 Now a question is whether this is a recommended approach? But it does read nicely, and eliminates the need for naming the result variable anywhere other than the declaration. I like this simplification. I mean it would be awkward if we compacted the result assignment into a METHOD calculate_stuff.
IF someattribute < 0.
RETURN -1.
ENDIF.
...
result = a + b.
ENDMETHOD. So for consistency I'd rather use RETURN throughout: METHOD calculate_stuff.
IF someattribute < 0.
RETURN -1.
ENDIF.
...
RETURN a + b.
ENDMETHOD. |
In the guideline, as well as all trainings, it is said that one should name the return value result and then assign the return parameter in the code.
In other languages the form
return Value;
is used. This works also in Abap ( at least in the newest version ), I find it much easier to read. Why is it not mentioned? Also in the Language Help it is not mentioned. Is it a bug, is the feature coming soon?The text was updated successfully, but these errors were encountered: