‎2015 May 14 2:57 PM
Hi,
I have used the constructor operator VALUE in the following way:
The above screen-shot works perfect!
Now I noticed that we can't define the table type as generic and must be defined as one with a KEY for the syntax to work.
Why can't we also use a work area instead of internal table based on a line type after VALUE keyword to work in ABAP? It seems that is not supported! Does anyone know how this works or is it me who is making any sort of mistakes?
Many Thanks,
Tanmoy
‎2015 May 14 3:48 PM
As of ABAP 740, the table without the key specification is obsolete. See the last lines:
Starting with release 7.40 you declare your standard tables either with a good key or an empty key but never with the chancy default key!
Since VALUE operator is also introduced in ABAP 740, it uses stricter check and doesn't allow with a table which doesn't have key specification.
Now for the VALUE operator for the Structure, which you referred as WA, it also works as
http://help.sap.com/abapdocu_740/en/abenvalue_constructor_params_struc.htm
From ABAP Help:
TYPES: BEGIN OF t_struct,
col1 TYPE i,
col2 TYPE t_col2,
END OF t_struct.
DATA: struct TYPE t_struct,
col2 TYPE t_col2.
struct = VALUE t_struct( col1 = 1
col2-col1 = 1
col2-col2 = 2 ).
Find more example of VALUE operator usage at ABAP 740 – VALUE Operator to create ITAB entries | ABAP Help Blog
Regards,
Naimesh Patel
‎2015 May 14 3:48 PM
As of ABAP 740, the table without the key specification is obsolete. See the last lines:
Starting with release 7.40 you declare your standard tables either with a good key or an empty key but never with the chancy default key!
Since VALUE operator is also introduced in ABAP 740, it uses stricter check and doesn't allow with a table which doesn't have key specification.
Now for the VALUE operator for the Structure, which you referred as WA, it also works as
http://help.sap.com/abapdocu_740/en/abenvalue_constructor_params_struc.htm
From ABAP Help:
TYPES: BEGIN OF t_struct,
col1 TYPE i,
col2 TYPE t_col2,
END OF t_struct.
DATA: struct TYPE t_struct,
col2 TYPE t_col2.
struct = VALUE t_struct( col1 = 1
col2-col1 = 1
col2-col2 = 2 ).
Find more example of VALUE operator usage at ABAP 740 – VALUE Operator to create ITAB entries | ABAP Help Blog
Regards,
Naimesh Patel
‎2015 May 14 5:44 PM
Hello,
Thanks it works perfectly. I tried the same thing earlier but it did not work!
Thanks,
Tanmoy