How to add column based on existing columns to existing table without header line?

Good day!

I know this is an absolute beginner question, but I ca’t find the right answer. I was playing around with some code and made a new table that has a new column based on two columns from an existing table. Now I want to take this new table and add another column to it based on two of its columns, one of them being a new column.
How do I best do this?
ChatGPT came up with some code but it’s not working yet. So far i have this:

 

SELECT FROM /DMO/flight
fields flight_date,
seats_max,
seats_occupied,
seats_max – seats_occupied as seats_available,
( CAST( seats_occupied as FLTP ) / CAST( seats_max as FLTP ) ) * CAST( 100 as FLTP ) as percentage_occupied

INTO TABLE @DATA(results).

“This is the part I’m stuck at and the part generated by CHATGPT.
LOOP AT results ASSIGNING FIELD-SYMBOL(<line>).
<line>-percentage_available = ( <line>-seats_available / <line>-seats_max ) * 100 .
ENDLOOP.

OUT->WRITE( EXPORTING
data = results
name = ‘My_results’ ).

 

 The problem is that I thought (and ChatGPT too I guess) that <line>-percentage_available would make a new column, but in the error it says that that column is unknown (and so that it should already be existing). Then I also tried something else, i don’t remember what, and the error said you can’t do it with a table without header lines. So do I need to somehow add header lines then? 

 

Thank you so much in advance!

Scroll to Top