I think, the code examples spoke for themselves in the previous post, they're thin, readable, and transparent! That's what I want! Today, I'm going to show you another great feature of the 7.4, called Field Symbol inline declaration.
Actually, we need to comply the same rules for Field Symbol inline declarations as in the case of the Data inline declarations.
Using the FIELD-SYMBOL declaration operator, we are able to define a field symbol, that is visible from the FIELD-SYMBOL(<fs>) and valid in the current context (inside a LOOP, method, subroutine, and so on), the list is not complete:
First, let's check a LOOP, for example, we want to improve our code, and use Field Symbols, instead of Work Areas.
It sounds great, we improved the performance, but we still need to define them, before using them. :(
From 7.4 SP02, we can define Field Symbols as embedded into the given context (for example into a LOOP). It means, that our <fs_flight_schedule> field symbol is valid only inside of the LOOP statement.
READ TABLE Statement
If we can perform inline field symbol declaration in case of LOOPs, then of course we can use them in case of READ TABLE statements!
Before 7.4, we need to declare a field symbol separately, before using it.
The code speaks for itself!
Although, it was a short post, but I think it gave another very useful tool to our tool-set. So, from now on we can define any kind of variables and field symbols using inline declarations, that results: thinner, more readable, and transparent code.
In addition to these above, found inline declarations very time-effective, makes my development much-much faster, than before:
- no need to determine the type of your variables (similar effect to C#'s var keyword),
- you need to write fewer lines of code,
- force you to think in smaller units (functions, subroutines, methods, and so on), instead of huge lines of code.
Now, go and try it out! If you don't have any access to any 7.4 based SAP system, then I recommend to watch my colleague's setup guide.
Stay tuned, keep reading! If you want to get notification about the newest posts, follow me or subscribe to our newsletter!
If you liked it, please share it! Thanks!