-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example for filter on Condition Table
- Loading branch information
1 parent
97ee543
commit 40f9bc2
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
using {API_SLSPRICINGCONDITIONRECORD_SRV as external} from './external/API_SLSPRICINGCONDITIONRECORD_SRV'; | ||
|
||
service ConditionService { | ||
|
||
function getConditionValidityForTable() returns array of String; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const cds = require("@sap/cds"); | ||
const LOG = cds.log("condition-service"); | ||
|
||
const { setGlobalLogLevel } = require("@sap-cloud-sdk/util"); | ||
|
||
const { | ||
SlsPrcgCndnRecdValidity: sdkSlsPrcgCndnRecdValidity, | ||
SlsPrcgConditionRecord: sdkSlsPrcgConditionRecord, | ||
} = require("./odata-client/slspricingconditionrecord-service"); | ||
const { or, and } = require("@sap-cloud-sdk/core"); | ||
|
||
module.exports = async function () { | ||
this.on("getConditionValidityForTable", async (req) => { | ||
LOG._info && LOG.info("getConditionValidityForTable"); | ||
setGlobalLogLevel("debug"); | ||
|
||
const queryBuilderCondVal = sdkSlsPrcgCndnRecdValidity | ||
.requestBuilder() | ||
.getAll() | ||
.top(10) | ||
.select( | ||
sdkSlsPrcgCndnRecdValidity.MATERIAL, | ||
sdkSlsPrcgCndnRecdValidity.CONDITION_TYPE, | ||
sdkSlsPrcgCndnRecdValidity.CONDITION_VALIDITY_START_DATE, | ||
sdkSlsPrcgCndnRecdValidity.CONDITION_VALIDITY_END_DATE, | ||
sdkSlsPrcgCndnRecdValidity.TO_SLS_PRCG_CONDITION_RECORD.select( | ||
sdkSlsPrcgConditionRecord.CONDITION_TABLE | ||
) | ||
) | ||
.filter( | ||
and( | ||
or(sdkSlsPrcgCndnRecdValidity.MATERIAL.equals("TG11")), | ||
or(sdkSlsPrcgCndnRecdValidity.CONDITION_TYPE.equals("PPR0")), | ||
or( | ||
sdkSlsPrcgCndnRecdValidity.TO_SLS_PRCG_CONDITION_RECORD.filter( | ||
sdkSlsPrcgConditionRecord.CONDITION_TABLE.equals("304") | ||
) | ||
) | ||
) | ||
); | ||
const responseCondVal = await queryBuilderCondVal.execute({ | ||
destinationName: "APIBusinessHub", | ||
}); | ||
return responseCondVal; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### Read Condition Record Validity and filter for ConditionTable | ||
GET {{$dotenv APIBusinessHub}}/sap/opu/odata/sap/API_SLSPRICINGCONDITIONRECORD_SRV/A_SlsPrcgCndnRecdValidity | ||
?$inlinecount=allpages | ||
&$top=5 | ||
&$filter=Material eq 'TG11' and ConditionType eq 'PPR0' and to_SlsPrcgConditionRecord/ConditionTable eq '304' | ||
&$select=Material,ConditionType,ConditionValidityStartDate,ConditionValidityEndDate,to_SlsPrcgConditionRecord/ConditionTable | ||
&$expand=to_SlsPrcgConditionRecord | ||
&sap-language=en | ||
Accept: application/json | ||
Accept-Language: en | ||
APIKey: {{$dotenv APIKey}} | ||
### | ||
GET http://localhost:4004/odata/v4/condition/getConditionValidityForTable() |