08-30-2016 12:36 PM
Hello SDNers,
Let's consider this scenario.
I have a method fill_table( ) defined as
fill_table
IMPORTING it_integer TYPE int4_table
CHANGING ct_integer TYPE int4_table.
Implementation is:
METHOD fill_table.
ct_integer = VALUE #( BASE ct_integer ( LINES OF it_integer ) ).
APPEND LINES OF it_integer TO ct_integer. " Looks cleaner compared to VALUE??
ENDMETHOD.
Imho, the old APPEND/APPEND LINES OF constructs are cleaner than the VALUE. What are your thoughts?
BR,
Suhas
08-30-2016 1:07 PM
As a standalone statement yes. Why not use INSERT LINES OF. But in the moment you can get rid of an unnecessary helper variable, you use VALUE.
meth( VALUE #( ( LINES OF it_integer ) ) ).
vs.
INSERT LINES OF it_integer INTO TABLE helper.
meth( helper).
And in the moment, you are getting used to it, well ...
08-30-2016 12:39 PM
I agree. New constructor operators add a little complexity, so for simple expressions the old constructs should be preferred.
08-30-2016 1:07 PM
so for simple expressions the old constructs should be preferred.
Absolutely true!
For complex expressions i prefer using the VALUE operator.
08-30-2016 12:53 PM
True.
But just a remark: IMHO you should forget the keyword APPEND, always use INSERT.
Reason: you'll never get Dumps for sorted tables anymore. Example
DATA source TYPE STANDARD TABLE OF i WITH EMPTY KEY.
DATA target TYPE SORTED TABLE OF i WITH UNIQUE KEY table_line.
target = VALUE #( ( 5 ) ( 6 ) ( 7 ) ).
source = VALUE #( ( 3 ) ( 2 ) ( 1 ) ).
INSERT LINES OF source INTO TABLE target.
cl_demo_output=>display( target ).
Try this with APPEND
08-30-2016 1:02 PM
But just a remark: IMHO you should forget the keyword APPEND, always use INSERT.
Reason: you'll never get Dumps for sorted tables anymore.
Thanks for the tip. The code snippet was for demonstration purposes only
I work with SORTED & HASHED tables whenever possible.
08-30-2016 1:06 PM
I know.
It's just because always when I'm seeing APPEND a trigger in my head is pushed and my hair stood on end ...
08-30-2016 1:07 PM
As a standalone statement yes. Why not use INSERT LINES OF. But in the moment you can get rid of an unnecessary helper variable, you use VALUE.
meth( VALUE #( ( LINES OF it_integer ) ) ).
vs.
INSERT LINES OF it_integer INTO TABLE helper.
meth( helper).
And in the moment, you are getting used to it, well ...
08-30-2016 10:19 PM
It does look cleaner and reads like plain English, which is a big plus IMHO.