Skip to content
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

FINAL new ABAP keyword - guidance #285

Open
prokopp80 opened this issue Sep 21, 2022 · 6 comments
Open

FINAL new ABAP keyword - guidance #285

prokopp80 opened this issue Sep 21, 2022 · 6 comments

Comments

@prokopp80
Copy link

Hi colleagues,
recently the new FINAL keyword has been introduced. Do you plan to document a common guidance for it?
In my opinion this was something that I missed in ABAP for long time.

Thank you,
Br. Petr

@ruthiel
Copy link

ruthiel commented Oct 14, 2022

Hello @prokopp80 ,

Can you explain what new keyword FINAL are you referring?

Is it the FINAL for classes and methods? If yes, it exists for a long time yet.

Regards,
Ruthiel

@fabianlupa
Copy link
Contributor

This is referring to the new FINAL keyword for immutable inline declarations. It is available in the BTP Trial with SAP_BASIS 789. The online documentation does not include it yet. Should show up as a third item here: https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abeninline_declarations.htm

image

https://blogs.sap.com/2022/07/04/reverse-loop-finally-possible-with-step-addition-for-abap-internal-tables/comment-page-1/#comment-630060

@jordao76
Copy link
Contributor

Interesting, like const vs let in JavaScript.

I'd say then, that FINAL should be preferred to declare variables that are not reassigned.

@ruthiel
Copy link

ruthiel commented Oct 16, 2022

This is referring to the new FINAL keyword for immutable inline declarations. It is available in the BTP Trial with SAP_BASIS 789. The online documentation does not include it yet. Should show up as a third item here: https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm?file=abeninline_declarations.htm

image

https://blogs.sap.com/2022/07/04/reverse-loop-finally-possible-with-step-addition-for-abap-internal-tables/comment-page-1/#comment-630060

Thank you @fabianlupa for this explanation.
First time hearing about that.

It seems like a constant but inside a specific context.

@nomssi
Copy link

nomssi commented Jan 8, 2023

FINAL in ABAP means the variable value can be changed only at the single write position.
But it can be changed more than once, e.g. in a LOOP.

https://blogs.sap.com/2022/10/25/finally-a-declaration-of-immutable-variables-with-final-in-abap/

The recommendation should probably be: prefer FINAL to DATA whenever possible.

@ConjuringCoffee
Copy link
Contributor

I have closed the pull request I made to fix this issue for now. As Björn explained in his comment, the FINAL keyword has more subtleties to it than I expected and needs a better description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants