Skip to Content
avatar image
Former Member

CREATE VIEW in ABAP (Open SQL or Native SQL)

Hi all you experts!

I want to create a VIEW in ABAP. I have created Table Views using ABAP Dictionary (in transaction SE11), I don't have any problem with them.

But, what I need is to create a dynamic view, I mean, a view that can be created/replaced (or modified) at runtime. Is this possible with SAP Open SQL, I don't think so... that is why I tried to created using native SQL but it is not working.

Here is the code:

  EXEC SQL.
    CREATE VIEW [ZMXRFIV_GLPCA]
      AS SELECT
         T1.GL_SIRID,
         T1.POPER,
         T1.RBUKRS,
         T1.RPRCTR,
         T1.RACCT,
         T1.HSL
      FROM
         GLPCA T1
      INNER JOIN
         SKA1 T2
      ON
         T1.RACCT = T2.SAKNR
      WHERE
        T1.RVERS      =  '000'
        AND T1.RYEAR  =  '2008'
        AND T1.KOKRS  =  'PI01'
        AND T2.KTOPL  =  'PI00'
        AND T2.XBILK  <> 'X'.
  ENDEXEC.

I have tried using quotes (") for the view name, parenthesis and even using only the name but this make no difference.

Do any of you experts have any idea?

PS: After creating the view I need to do a SELECT INTO TABLE to that view and finally delete this view and continue working with the data on the internal table.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    Sep 03, 2008 at 10:25 AM

    What error are you getting? You don't need a full stop at the end of a real SQL statement.

    Why do you need to use a database view? What can you do with it that you can't do using ABAP internal tables?

    Edited by: Christine Evans on Sep 3, 2008 12:27 PM

    Add comment
    10|10000 characters needed characters exceeded