Application Development 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: 

Append Table Line to Deep Structure Using Table Expression

chaosodio
Explorer

HI,
i´m just a little confused. I want to append a table_line to deep structure by using table expression, but the syntax check didn´t know the ITAB (field"..." unknown...."

Append value #( wa ) to itab_a[ col_a = 'xyz' ]-itab_b.

Could anyone explain me my fault?

Thanks a lot 🙂

11 REPLIES 11

chaosodio
Explorer
0 Kudos
TYPES:
 BEGIN OF ty_alv_data,
 kunnr TYPE kunnr,
 name1 TYPE name1,
 ort01 TYPE ort01,
 land1 TYPE land1,
 t_color TYPE lvc_t_scol,
 END OF ty_alv_data.
TYPES: tt_alv_data TYPE STANDARD TABLE OF ty_alv_data
 WITH DEFAULT KEY.
DATA(itab_alv) = VALUE tt_alv_data( ( 
kunnr = '123' 
name1 = 'ABCD'  
ort01 = 'LV' 
land1 = 'NV'  
t_color = VALUE #( ( fname = 'KUNNR' 
color-col = col_negative
color-int = 0
color-inv = 0 )


 ( fname = 'ORT01'
 color-col = col_total
 color-int = 1
 color-inv = 1 ) ) )

 ( kunnr = '456' name1 = 'XYZ'
 ort01 = 'LA' land1 = 'CA' ) ).

* ### EDIT ###
DATA(wa_col) = VALUE lvc_s_scol( fname = 'KUNNR'
 color-col = col_negative
 color-int = 0
 color-inv = 0 ).


APPEND VALUE #( wa_col ) TO itab_alv[ 2 ]-t_color.
*FAIL "ITAB_ALV[" is not a field name.


APPEND wa_col TO itab_alv[ 2 ]-t_color.
* "ITAB_ALV[" is not a field name.

chaosodio
Explorer
0 Kudos

Each append throws the msg ""ITAB_ALV[" is not a field name."

Maybe the append-statement cannot process the table expression?

Sure, i can use assign fieldsymbol etc. but i wanna try it to build it with "new logic".

Sandra_Rossi
Active Contributor
0 Kudos

As SAP says (right of SUBMIT form): "You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details."

Sandra_Rossi
Active Contributor
0 Kudos

As SAP says (right of SUBMIT form): "You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details."

In your case, being the OP, you should edit your question, or add a comment below the question.

Sandra_Rossi
Active Contributor

For APPEND ... TO itab, SAP doesn't say that itab can be a functional operand position, so you have to indicate an internal table, not an expression.

EDIT: I was wrong about the two next points, cf solution by Quynh Doan Manh

  • As you want to update an internal table, you cannot use a constructor expression either.
  • So, no other solution than first assigning itab_a[ col_a = 'xyz' ]-itab_b to a field symbol, then append to that field symbol".

0 Kudos

Asking for more information does not harms others, but helps for finding the right solution.

Arthur Fuscella Silva Of course. I was just quoting SCN "before anwering":

matt
Active Contributor
0 Kudos

You should use INSERT INTO TABLE, not APPEND.

DoanManhQuynh
Active Contributor

Maybe you can switch the table to the left side like below:

itab_alv[ 2 ]-t_color = VALUE #( BASE itab_alv[ 2 ]-t_color ( wa_col ) ).

P/S: I looked at your code again and found out that you define wa_col as a table no a work area. you should change it cause it confused. incase its a table, you can try:

itab_alv[ 2 ]-t_color = CORRESPONDING #( BASE ( itab_alv[ 2 ]-t_color ) wa_col ).

0 Kudos

Thanks, the fail ist gone 😄
I will try the first method. I forgot this alternative.

arthursilva
Active Participant

Hello Eric,

Instead of using APPEND, why don't you try to assign the value directly

itab_alv[ 2 ]-t_color = VALUE lvc_t_scol( ( wa_col ) ) .

Reward points if it's helpful.

KR,
Arthur Silva