如果数据库结果包含超过20万记录,我的xsjs服务将花费更多时间来生成结果

2020-08-19 17:52发布

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


这是我的xsjs,如果我的数据库结果超过20万,则需要3-4分钟,但数据库结果执行时间为88毫秒。 请帮我。 因此,我的ajax调用也不会返回服务响应
 提前致谢


 var connection = $ .hdb.getConnection();
//var businessDate = $ .request.parameters.get(" businessDate");
//var FSDPTables = $。request.parameters.get(" FSDPTables");
//var SourceSystemID = $。request.parameters.get(" SourceSystemID");
//var CountryCode = $。request.parameters.get(" CountryCode");
//var IDSystem = $。request.parameters.get(" IDSystem");
//FSDPTables = decodeURIComponent(FSDPTables);


 if(CountryCode ===" =" KR" && SourceSystemID ===" =" MX2KR")
 {
 IDSystem =" MX2-KR";
 }
 函数格式COBDate(rawDate){
//var str = rawDate;
 //var res = str.substring(0,10);
 var date = new Date(rawDate);
 var day = date.getDate();
 如果(天<10){
 天=" 0" +天;
 }
 var month =(date.getMonth()+ 1);
 如果(月<10){
 month =" 0" + month;
 }
 var COBDate =天+"/" +月+"/" + date.getFullYear();
//var COBDate = date.getFullYear()+"-" +月+"-" +天;
 返回COBDate;
 }


 //businessDate = businessDate.split("/")。reverse()。join("-");
 //businessDate = formatCOBDate_yymmdd(businessDate);
 var businessDate =" 2019-12-31",
 FSDPTables =" sap.fsdm :: ProductClassificationOfFinancialContract",
 SourceSystemID =" MX2",
 CountryCode =" GLOBAL",
 IDSystem =" MX2-XX";


 尝试{
 var resStatus = {};
 resStatus.statusCode = 0;
 resStatus.status = false;
 resStatus.msg ="";
 resStatus.data ="";
 var sqlQuery =" SELECT \" COBDate \"," +
 " \" SourceSystemID \"," +
 " \" CountryCode \"," +
 " \" ErrorCode \"," +
 " \" FSDPTableName \"," +
 " \" SourceKey \"," +
 " \" SouceColumnName \"," +
 " \" FSDPColumnName \"," +
 " \" ErrorMessage \"" +
 " FROM \" :: ErrorRecord ***** \"" +
 "(占位符。\" $$ IP_Date $$ \" =>'" + businessDate +"',"
 +"占位符。\" $$ IP_Tables $$ \" =>'" + FSDPTables +"',"
 +"占位符。\" $$ IP_SourceSystemID $$"" =>'" + SourceSystemID +"',"
 +"占位符。\" $$ IP_CountryCode $$ \" =>'" +国家/地区代码+"',"
 +"占位符。\" $$ IP_IDSystem $$" =>'" + IDSystem +"')";
 var result = connection.executeQuery(sqlQuery);

 如果(结果长度> 0){
 resStatus.statusCode = 1;
 resStatus.msg ="成功检索数据";
 resStatus.status = true;
 对于(结果是我)
 result [i] .COBDate = formatCOBDate(result [i] .COBDate);
 }
 resStatus.data =结果;
 }其他{
 resStatus.data ="找不到数据";
 resStatus.msg ="";
 }


 } catch(err){
 resStatus.statusCode = -2;
 resStatus.status = false;
 resStatus.msg =错误
 }最后{
 如果(连接!==空){
 connection.close();
 }
 }


 $ .response.contentType =" application/json";
 $ .response.setBody(resStatus);
 $ .response.status = $。net.http.OK;
 

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


这是我的xsjs,如果我的数据库结果超过20万,则需要3-4分钟,但数据库结果执行时间为88毫秒。 请帮我。 因此,我的ajax调用也不会返回服务响应
 提前致谢


 var connection = $ .hdb.getConnection();
//var businessDate = $ .request.parameters.get(" businessDate");
//var FSDPTables = $。request.parameters.get(" FSDPTables");
//var SourceSystemID = $。request.parameters.get(" SourceSystemID");
//var CountryCode = $。request.parameters.get(" CountryCode");
//var IDSystem = $。request.parameters.get(" IDSystem");
//FSDPTables = decodeURIComponent(FSDPTables);


 if(CountryCode ===" =" KR" && SourceSystemID ===" =" MX2KR")
 {
 IDSystem =" MX2-KR";
 }
 函数格式COBDate(rawDate){
//var str = rawDate;
 //var res = str.substring(0,10);
 var date = new Date(rawDate);
 var day = date.getDate();
 如果(天<10){
 天=" 0" +天;
 }
 var month =(date.getMonth()+ 1);
 如果(月<10){
 month =" 0" + month;
 }
 var COBDate =天+"/" +月+"/" + date.getFullYear();
//var COBDate = date.getFullYear()+"-" +月+"-" +天;
 返回COBDate;
 }


 //businessDate = businessDate.split("/")。reverse()。join("-");
 //businessDate = formatCOBDate_yymmdd(businessDate);
 var businessDate =" 2019-12-31",
 FSDPTables =" sap.fsdm :: ProductClassificationOfFinancialContract",
 SourceSystemID =" MX2",
 CountryCode =" GLOBAL",
 IDSystem =" MX2-XX";


 尝试{
 var resStatus = {};
 resStatus.statusCode = 0;
 resStatus.status = false;
 resStatus.msg ="";
 resStatus.data ="";
 var sqlQuery =" SELECT \" COBDate \"," +
 " \" SourceSystemID \"," +
 " \" CountryCode \"," +
 " \" ErrorCode \"," +
 " \" FSDPTableName \"," +
 " \" SourceKey \"," +
 " \" SouceColumnName \"," +
 " \" FSDPColumnName \"," +
 " \" ErrorMessage \"" +
 " FROM \" :: ErrorRecord ***** \"" +
 "(占位符。\" $$ IP_Date $$ \" =>'" + businessDate +"',"
 +"占位符。\" $$ IP_Tables $$ \" =>'" + FSDPTables +"',"
 +"占位符。\" $$ IP_SourceSystemID $$"" =>'" + SourceSystemID +"',"
 +"占位符。\" $$ IP_CountryCode $$ \" =>'" +国家/地区代码+"',"
 +"占位符。\" $$ IP_IDSystem $$" =>'" + IDSystem +"')";
 var result = connection.executeQuery(sqlQuery);

 如果(结果长度> 0){
 resStatus.statusCode = 1;
 resStatus.msg ="成功检索数据";
 resStatus.status = true;
 对于(结果是我)
 result [i] .COBDate = formatCOBDate(result [i] .COBDate);
 }
 resStatus.data =结果;
 }其他{
 resStatus.data ="找不到数据";
 resStatus.msg ="";
 }


 } catch(err){
 resStatus.statusCode = -2;
 resStatus.status = false;
 resStatus.msg =错误
 }最后{
 如果(连接!==空){
 connection.close();
 }
 }


 $ .response.contentType =" application/json";
 $ .response.setBody(resStatus);
 $ .response.status = $。net.http.OK;
 
付费偷看设置
发送
1条回答
lukcy2020
1楼-- · 2020-08-19 18:31

如果让HANA DB通过创建进行日期格式化的计算视图来进行日期格式化,则可以提高性能。 然后,在XSJS逻辑中,您只需要从创建的计算视图中进行查询。 这种技术称为代码下推。 我在这里指的是一个使用ABAP作为运行时的博客,但是其原理与XSJS运行时相同。 这是博客: https://blogs.sap .com/2014/02/03/abap-for-hana-code-push-down /

一周热门 更多>