Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Constructor operator VALUE and its usage.

Former Member
0 Likes
7,192

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

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
3,189

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

2 REPLIES 2
Read only

naimesh_patel
Active Contributor
0 Likes
3,190

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

Read only

0 Likes
3,189

Hello,

           Thanks it works perfectly. I tried the same thing earlier but it did not work!

Thanks,

Tanmoy