on 03-22-2019 6:24 AM
Hi Experts,
We are working on Cloud SDK Filter. But, its not working. As per below blog, its in roadmap and when we can expend working version in SDK package.
Regards,
Dileep
Hello Dileep,
could you explain a bit what you are trying and what is not working?
Are you maybe looking for a way to pass filters from the query to the OData VDM? Then this release blog may be relevant to you: https://blogs.sap.com/2019/02/28/sap-s4hana-cloud-sdk-version-2.12.0-is-available/ (Section Further Improvements).
Best regards,
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Henning,
OData VDM query filter is working for single CDS service.But, I am trying a scenario to retrieve data from two separate services and merging it based on primary key.
Finally I am getting the list of merged data.After that is it possible to use ODATA VDM query filter?
I am adding my cds and merged code
my-service.cds
using CUSTOM_CDS from '../srv/external/csn/CUSTOM_CDS.json';
service ProfitCtrSegment {
@cds.persistence.skip
entity profitctrRes as Projection on CUSTOM_CDS.CUSTOMType {
key CompanyCode,
PRCTR,
GLAccount,
Customer,
AccountingDocument,
AccountingDocumentItem,
FiscalYear,
ProfitCntr,
SEGMENT,
AccountingDocumentType,
FiscalYearPeriod,
NetDueDate,
NetDueArrearsDays,
AmountInTransactionCurrency,
CompanyCodeCurrency,
CustomerName,
KeyDate,
ClearingStatus
};
}
Business logic
@Query(serviceName = "ProfitCtrSegment", entity = "profitctrRes")
public QueryResponse readProfitCtr_segment(QueryRequest req) throws Exception{
List<CUSTOM> results = new ArrayList<>();
String profitCenter = "";
final List<SERVICE1> customLineResult = new DefaultSERVICE1Service().getAllSERVICE1()
.execute();
final List<SERVICE2> SegmentResult = new DefaultSERVICE2Service()
.getAllSERVICE2().execute();
Map<String, SERVICE2> segmentMap = new HashMap<String, SERVICE2>();
for (SERVICE2 segment : SegmentResult) {
profitCenter = removeLeadingChar(segment.getPRCTR());
if (profitCenter != null && profitCenter.trim() != "" && segment.getSEGMENT() != null
&& segment.getSEGMENT().trim() != "") {
segmentMap.put(profitCenter, segment); /*DUPLICATES OF PRCTR ARE Replaced*/
}
}
for (SERVICE1 customLines : customLineResult) {
profitCenter = removeLeadingChar(customLines.getProfitCntr());
// if (segmentMap.containsKey(profitCenter)) {// If segment not mapped profit
// center will not add in result
if (profitCenter != null && profitCenter!="") {
CUSTOM resultDto = new CUSTOM();
resultDto.setCompanyCode(customLines.getCompanyCode() != null ? customLines.getCompanyCode() : "");
resultDto.setGLAccount(customLines.getGLAccount() != null ? customLines.getGLAccount() : "");
resultDto.setCustomer(customLines.getCustomer() != null ? customLines.getCustomer() : "");
resultDto.setAccountingDocument(
customLines.getAccountingDocument() != null ? customLines.getAccountingDocument() : "");
resultDto.setAccountingDocumentItem(
customLines.getAccountingDocumentItem() != null ? customLines.getAccountingDocumentItem() : "");
resultDto.setFiscalYear(customLines.getFiscalYear() != null ? customLines.getFiscalYear() : "");
resultDto.setProfitCntr(customLines.getProfitCntr() != null ? customLines.getProfitCntr() : "");
if (segmentMap.containsKey(profitCenter)) {
resultDto.setSEGMENT(segmentMap.get(profitCenter).getSEGMENT());
}
resultDto.setAccountingDocumentType(
customLines.getAccountingDocumentType() != null ? customLines.getAccountingDocumentType() : "");
resultDto.setFiscalYearPeriod(
customLines.getFiscalYearPeriod() != null ? customLines.getFiscalYearPeriod() : "");
resultDto.setNetDueDate(customLines.getNetDueDate());
resultDto.setNetDueArrearsDays(
customLines.getNetDueArrearsDays() != null ? customLines.getNetDueArrearsDays()
: new BigDecimal(0));
resultDto.setAmountInTransactionCurrency(customLines.getAmountInTransactionCurrency() != null
? customLines.getAmountInTransactionCurrency()
: new BigDecimal(0));
resultDto.setCompanyCodeCurrency(
customLines.getCompanyCodeCurrency() != null ? customLines.getCompanyCodeCurrency() : "");
resultDto.setCustomerName(customLines.getCustomerName() != null ? customLines.getCustomerName() : "");
resultDto.setClearingStatus(
customLines.getClearingStatus() != null ? customLines.getClearingStatus() : "");
results.add(resultDto);
}
}
return QueryResponse.setSuccess().setData(results).response();
}
public String removeLeadingChar(String profitCenter) {
if (profitCenter != null && profitCenter.trim() != "") {
for (int i = 0; i < profitCenter.length(); ++i) {
char c = profitCenter.charAt(i);
if (c != '0') {
return profitCenter.substring(i);
}
}
}
return ""; // or return "0";
}
}
Here I want to apply OData VDM query filter in List<CUSTOM> results. Is it possible using cloud sdk?
Please suggest me.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.