Skip to Content

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

XSJS calls

Hello, I have a problem. I have .xsjs and index.html. And I need to get values from .html sample form to .xsjs file.

My function .html file:

function openCreateDialog(){

        

                var oCreateDialog = new sap.ui.commons.Dialog();

                oCreateDialog.setTitle("Sukurti įrašą");

                var oSimpleForm = new sap.ui.layout.form.SimpleForm({

                    maxContainerCols: 2,

                    content:[

                        new sap.ui.core.Title({text:"Duomenys"}),

                        new sap.ui.commons.Label({text:"ID"}),

                        new sap.ui.commons.TextField('id',{value:""}),

                        new sap.ui.commons.Label({text:"Vardas"}),

                        new sap.ui.commons.TextField('name',{value:""}),

                        new sap.ui.commons.Label({text:"Pavardė"}),

                        new sap.ui.commons.TextField('surname',{value:""}),

                        new sap.ui.commons.Label({text:"Telefono numeris"}),

                        new sap.ui.commons.TextField('mobilenumber',{value:""}),

                        new sap.ui.commons.Label({text:"E. paštas"}),

                        new sap.ui.commons.TextField('email',{value:""}),

                        new sap.ui.commons.Label({text:"Galioja nuo"}),

                        new sap.ui.commons.TextField('pdata',{value:""}),

                        new sap.ui.commons.Label({text:"Galioja iki"}),

                        new sap.ui.commons.TextField('enddata',{value:""}),

                        new sap.ui.commons.Label({text:"Kompanija"}),

                        new sap.ui.commons.TextField('company',{value:""}),

                        ]                                                                      

                });

           ///////////////////////////////////////////////////////////////////////

                oCreateDialog.addContent(oSimpleForm);

                oCreateDialog.addButton(

                    new sap.ui.commons.Button({

                        text: "Sukurti",

                        press: function() {

                    

                        var ID = $('#id').val();

                        var NAME = $('#name').val();

                        var SURNAME = $('#surname').val();

                        var MOBILENUMBER = $('#mobilenumber').val();

                        var EMAIL = $('#email').val();

                        var PDATA = $('#pdata').val();

                        var ENDDATA = $('#enddata').val();

                        var COMPANY = $('#company').val();

                      

                           // );

                        }

                    })

                );

and my .xsjs file

$.response.contentType="text/html";                                                                  

var ID = $.request.parameters.get("ID");

var NAME = $.request.parameters.get("NAME");

var SURNAME = $.request.parameters.get("SURNAME");

var MOBILENUMBER = $.request.parameters.get("MOBILENUMBER");

var EMAIL = $.request.parameters.get("EMAIL");

var PDATA = $.request.parameters.get("PDATA");

var ENDDATA = $.request.parameters.get("ENDDATA");

var COMPANY = $.request.parameters.get("COMPANY");

var conn  = $.db.getConnection();

conn.prepareStatement("SET SCHEMA \"NEO_7ZY3SY7D021M1LQP62Y9OLHO6\"").execute();

var query = "INSERT INTO \"p1940820305trial.hanaxs.Programa.Data::LG\" values(?,?,?,?,?,?,?,?,)";

var pstmt = conn.prepareStatement(query);

pstmt.setString(1,ID);

pstmt.setString(2,NAME);

pstmt.setString(3,SURNAME);

pstmt.setString(4,MOBILENUMBER);

pstmt.setString(5,EMAIL);

pstmt.setString(6,PDATA);

pstmt.setString(7,ENDDATA);

pstmt.setString(8,COMPANY);

pstmt.execute();

conn.commit();                                                                                                                                                

pstmt.close();                                                                        

conn.close();                                                               

$.response.setBody(query);

So, how to get values for my sql statement from .html file ?

Former Member
Not what you were looking for? View more on this topic or Ask a question