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: 

Manipulate Data in SQL Statement

Former Member
0 Kudos

Hello there!

I want to manipulate Data in a SQL Statement. For instance:

SELECT
   name
   age
FROM pers INTO CORROSPONDING FIELDS OF it_ppl WHERE company = '01'.

The outcome would be something like


Hans   25
Sam    23
Marie  28
Julia  23

So what if I want to add an column behind the selected data, where the data output should not be variable from the database but a konstant, fix value?

I tried it like that:

SELECT
   name
   age
   'Fix value' AS value
FROM pers INTO CORROSPONDING FIELDS OF it_ppl WHERE company = '01'.

Outcome should be like

Hans   25  Fix value
Sam    23  Fix value
Marie  28  Fix value
Julia  23  Fix value

The big question is: a) Is this possible with Open SQL and if so b) how?!

Thanks in advance,

kind regards,

Christof!

2 REPLIES 2

kesavadas_thekkillath
Active Contributor
0 Kudos

Its possible through Native SQL. I have done some small modification to the standard SAP help program . Please check it.


types: BEGIN OF ty,
        connid   TYPE spfli-connid,
        cityfrom TYPE spfli-cityfrom,
        cityto   TYPE spfli-cityto,
        text type char03,  "<---
      END OF ty.

DATA c1 TYPE spfli-carrid VALUE 'LH'.

data:it type table of ty,wa type ty.

EXEC SQL PERFORMING loop_output.
  SELECT connid, cityfrom, cityto, 'abc' as text  "<---
  INTO   :wa
  FROM   spfli
  WHERE  carrid = :c1
ENDEXEC.

break-point. "Check the values in IT here

FORM loop_output.
  append wa to it. "<---
ENDFORM.

matt
Active Contributor
0 Kudos

Have you tried it? That would seem to me to be most pragmatic way of finding out.