Skip to Content
0
Jun 20, 2019 at 05:21 PM

SQLScript error triying dynamic schema

94 Views

Hello! i'm triying to make a query from a different schema from default like this:

My class

definition of the method:  
methods BUSCA_BUKRS
    importing
      VALUE(I_FILTRO) type string " MANDT = '110' and BWKEY = '1000'
      VALUE(I_SCHEMA) type string "SLT_S4R
    exporting
      VALUE(O_BUKRS) type ZCL_TT_BUKRS .

implementation:
method BUSCA_BUKRS BY DATABASE PROCEDURE
                        FOR HDB
                        LANGUAGE SQLSCRIPT
                        OPTIONS READ-ONLY.
*     SQL script
      it_data = SELECT T001K.MANDT, T001K.BUKRS, T001K.BWKEY
                FROM "i_schema"."T001K";
      it_query = SELECT * FROM
                  :it_data AS A;
      O_BUKRS = APPLY_FILTER(:it_query, :I_FILTRO);
  endmethod.

as you can see i'm using i_schema to assing my schema but i get thie error:

So i can't activate my class, i tried to activate obligatory this and run my program but i get a dump

And if i try to write my query like this it works (hard code)

      it_data = SELECT T001K.MANDT, T001K.BUKRS, T001K.BWKEY
                FROM "SLT_S4R"."T001K";

if i debbug in my scenario where i'm facing the error: i_schema = SLT_S4R so it's the same but i don't know why i'm getting an error :c . I am specifying the schema be cause those tables are not in the default schema that's why and i noticed this when i transported to QAS the schema there it's like SLT_S4Q. Any idea or different way to do this ???

Attachments

error.png (11.7 kB)
dump.png (3.1 kB)