9 hours ago
Hi Experts,
I found some codes and wondered which is best?
1. I read before during in earlier ECC to avoid this because of headerline being obsolete in the future.
loop at s_bukrs into data(lwa_bukrs).
append lwa_bukrs-low to gt_bukrs.
endloop.
"Compared to:
gt_bukrs[] = s_bukrs[].2. Similar to above, I still some people use the longer method compare to the shorter below:
loop at <fs_bukrs> assigning <fs_range>
append value#(
sign = <fs_range>-sign
option = <fs_range>-option
low = <fs_range>-low
high = <fs_range>-high
)
to r_bukrs.
endloop.
r_bukrs[] = <fs_bukrs>[].3. Then found this one:
gt_bukrs = VALUE #( FOR lwa_bukrs IN s_bukrs ( lwa_bukrs-low ) ).
"Below is shorter...
gt_bukrs[] = s_bukrs[].In no. 3, why do we still use for if line 5 is shorter?
Appreciate your feedback on these samples.
Thank you.
Geoff
Hi Experts,
I found some codes and wondered which is best?
1. I read before during in earlier ECC to avoid this because of headerline being obsolete in the future.
loop at s_bukrs into data(lwa_bukrs).
append lwa_bukrs-low to gt_bukrs.
endloop.
"Compared to:
gt_bukrs[] = s_bukrs[].2. Similar to above, I still some people use the longer method compare to the shorter below:
loop at <fs_bukrs> assigning <fs_range>
append value#(
sign = <fs_range>-sign
option = <fs_range>-option
low = <fs_range>-low
high = <fs_range>-high
)
to r_bukrs.
endloop.
r_bukrs[] = <fs_bukrs>[].3. Then found this one:
gt_bukrs = VALUE #( FOR lwa_bukrs IN s_bukrs ( lwa_bukrs-low ) ).
"Below is shorter...
gt_bukrs[] = s_bukrs[].In no. 3, why do we still use for if line 5 is shorter?
Appreciate your feedback on these samples.
Thank you.
Geoff
5 hours ago
In number 3 the short and long line are not doing the same thing.
You should also show us the definition of all the ranges and tables. Then we will be able to answer.
4 hours ago
I see it the same way, asuming that the tabels are of type RANGE
the LONG version is only moving the field LOW,
while the short version in 3 is moving all columns.
If you want to move all, then use the short version in 3, as this is the most readable coding then
4 hours ago
In general I will always use the short version as long as it remains readable. Too many nested short notations can sometimes make the code hard to understand.
Performance is usually the same or very similar while readability improves.
35m ago
Tt's personal taste: I use INTO when I want not to modify data, and ASSIGNING when I want... it helps (me) no know if the LOOP will change data or will not with just a glance.
The rest, is everythingn about readability: if you are not comfy with the new syntax, you can try hard to become, or just ignore them. I'm just getting used to most of the new syntax and decided to ignore some of them (like that FOR you've put in the third sample).
About the new options: if the tables are not identical, you can use CORRESPONDING to copy them without FORs.
| User | Count |
|---|---|
| 17 | |
| 9 | |
| 7 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |