on 07-20-2015 9:11 AM
Hi experts!
we updated our HANA DB from sps 85 to sps 97,unlucky we found all html'text is unreadable code.xsjs file is following:
if ($.request.method === $.net.http.GET) {
var store_id = $.request.parameters.get("store_id");
var result = {};
var sql = "select distinct store_nm from HX_YXT.TB_STORE_INFO where store = ?";
var conn = $.db.getConnection();
var pstmt = conn.prepareStatement(sql);
pstmt.setString(1, store_id);
var rs = pstmt.executeQuery();
var res = {};
if (rs.next()) {
res.store_name = rs.getString(1);
}
rs.close();
pstmt.close();
conn.close();
result = JSON.stringify(res);
$.response.contentType = "application/json; charset=UTF-8";
$.response.setBody(JSON.stringify(result));
}
else {
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
and i did a test using ODATA,it's right and we also get right text by db sql
.i don't konw why.
what can i do?
thank you very much!
What does it look like in the browser when call the xsjs service directly. What data type are your columns? NVARCHAR or VARCHAR? Do you mean to be stringifying the otuput twice?
result = JSON.stringify(res);
$.response.contentType = "application/json; charset=UTF-8";
$.response.setBody(JSON.stringify(result));
What about any of the SAP delivered apps that use XSJS (like SHINE, XSADMIN, or HALM)? Are they are working fine?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your example you are using getString for an NVARCHAR field. That is incorrect. You should be using getNString. Using getString will cause the exact kind of corruption you are seeing because it treats the data as non-Unicode.
returns a string value of the specified column. getNString is used for NCHAR, NVARCHAR,
SHORTTEXT column types.
Returns a string value of the specified column. getString is used for CHAR and VARCHAR column types. ASCII only, not suitable for strings containing Unicode characters.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.