11-22-2019 5:30 PM
Hi,
I'm trying to learn the new 7.4 ABAP syntax for Value and adding new records into an internal table. I have code like:
BEGIN OF ty_data,
fld1 TYPE CHAR10,
fld2 TYPE i,
fld3 TYPE i,
END OF ty_data.
data: it_data type standard table of ty_data.
do 10 times.
it_data = value #( base it_Data ( fld1 = 'ITERATION'
fld2 = sy-index
fdl3 = 1 ) ).
enddo.
This works. But when I do this in a method and parameterize the internal table as a changing parameter, I get: No component exists with the name "(". "(". error.
methods example
changing
!C_DATA type ty_data.
methods example
c_data = value ty_data( base it_Data ( fld1 = 'ITERATION'
fld2 = sy-index
fdl3 = 1 ) ).
What am I doing wrong?
11-22-2019 6:49 PM
It's because you declared your parameter as type TY_DATA which is a structure instead of a table type...
11-22-2019 5:54 PM
@Dae Jin Swope I noticed one thing, there is spell mistake in last line it should be fld3 = 1, as in your declaration it is fld3. Also I tried with below similar code and it doesn't give any syntax, you can try like below.
CLASS lcl_local DEFINITION.
PUBLIC SECTION.
TYPES:ty_t009 TYPE TABLE OF t009.
METHODS example
CHANGING
c_data TYPE ty_t009.
ENDCLASS.
CLASS lcl_local IMPLEMENTATION.
METHOD example.
c_data = VALUE #( BASE c_data ( mandt = '100'
periv = 'Z9' ) ).
ENDMETHOD.
ENDCLASS.
11-22-2019 6:18 PM
Hi Thanga,
Thanks for the quick feedback. Yes, you're right. Those are typos when writing up the sample code. I can try to fix it if I can edit my original post. Using your example, can you try this:
CLASS lcl_local DEFINITION.
PUBLIC SECTION.
METHODS example
CHANGING
c_data TYPE t009.
ENDCLASS.
CLASS lcl_local IMPLEMENTATION.
METHOD example.
c_data = VALUE #( BASE c_data ( mandt = '100'
periv = 'Z9' ) ).
ENDMETHOD.
ENDCLASS.<br>
11-22-2019 6:49 PM
It's because you declared your parameter as type TY_DATA which is a structure instead of a table type...
11-22-2019 7:03 PM