Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Select a column given by parameter via XSDS

Hi,

I'm new to SAP HANA, and know I'm facing this problem:

I've been given an entity declared like this:

Entity translation {

key id: Integer64 not null;

en: String(5000);

fr: String(5000);

de: String(5000);

it: String(5000);

es: String(5000);

zh: String(5000);

ko: String(5000);

ru: String(5000);

jv: String(5000);

ar: String(5000);

pt: String(5000);

ja: String(5000);

};

So you get the id and depending on the language that is been used, you choose one column or other

For example: we are using the language "english" (en). So I've got a global variable: var lang = "en";

Is it possible to perform a select with XSDS like this, so I choose the column i want to display depending on the variable "lang"?

        var XSDS = $.import("sap.hana.xs.libs.dbutils", "xsds");

        var MyEntity = XSDS.$importEntity("package", "model.translation");

       

        // retrieve entity instance

   

        var query = MyEntity.$query().$where(MyEntity.id.$eq(1));

       

        var results = query.$execute();

       

        // process result

        if (results.length > 0){

            $.response.setBody(JSON.stringify(results[0].lang));

        }

Of course this code is wrong, but is just so you canget the idea...

Thank you very much

Tags:
Former Member
replied

Hello Luis,

you can access the property by using the bracket notation in case your property name is stored in a variable.

For your example: results[0][lang]

Best Regards,

Florian

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question