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: 

SQLScript error triying dynamic schema

naotoxxx
Participant
0 Kudos

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 ???

3 REPLIES 3

UweFetzer_se38
Active Contributor
0 Kudos

I currently don't have a system to test, but I would try the following:

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

0 Kudos

Yes i tried like that but i get this error in this line:

FROM :i_schema."T001K";

DoanManhQuynh
Active Contributor
0 Kudos