2014 Jul 11 9:54 AM
Hi,
With all the new additions in ABAP 7.40 language, I can't manage to append a new line with values to an internal table in a single line??
This works:
DATA: lt_users TYPE STANDARD TABLE OF usr03. " User address
DATA(ls_user) = NEW usr03( bname = 'ATURING'
name1 = 'Alan TURING' ).
APPEND ls_user->* TO lt_users[].
But the following does NOT:
DATA: lt_users TYPE STANDARD TABLE OF usr03. " User address
lt_users[ 0 ] = NEW usr03( bname = 'ATURING'
name1 = 'Alan TURING' )->*.
I thought the table expressions could be LHS (Left Hand Side) but what about the case of a new line?
Thanks in advance for correcting me.
Best regards,
Guillaume
2014 Jul 11 10:11 AM
Hello Guillaume,
Finally an ABAP 740 syntax related question
Why do you want to build the table using NEW? The operator VALUE does exactly what you want.
I can't manage to append a new line with values to an internal table in a single line??
DATA: lt_users TYPE STANDARD TABLE OF usr03. " User address
lt_users = VALUE #(
( bname = 'ATURING' name1 = 'Alan TURING') "Line 1
( bname = 'GGARCIA' name1 = 'Guillaume GARCIA') "Line 2
).
BR,
Suhas
2014 Jul 11 10:11 AM
Hello Guillaume,
Finally an ABAP 740 syntax related question
Why do you want to build the table using NEW? The operator VALUE does exactly what you want.
I can't manage to append a new line with values to an internal table in a single line??
DATA: lt_users TYPE STANDARD TABLE OF usr03. " User address
lt_users = VALUE #(
( bname = 'ATURING' name1 = 'Alan TURING') "Line 1
( bname = 'GGARCIA' name1 = 'Guillaume GARCIA') "Line 2
).
BR,
Suhas
2014 Jul 11 10:20 AM
Hi Suhas,
Thanks.
But let's say I am within a loop, the VALUE is going to crush all existing entries in LT_USERS every single time, right?
How would you proceed to append new lines then?.
Thanks in advance.
Best regards,
Guillaume
2014 Jul 11 12:03 PM
Not so difficult VALUE can also be used in operand position and you can use it as follows
DO 2 TIMES.
APPEND VALUE #( bname = |ATURING { sy-index }|
name1 = |Alan TURING { sy-index }|
)
TO lt_users.
ENDDO.
BR,
Suhas
2014 Jul 11 1:30 PM
Nice!
Not accustomed to the expression power yet!
Thanks!
Best regards,
Guillaume
| User | Count |
|---|---|
| 8 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |