
define view I_MatlStkAtKeyDateInAltUoM
with parameters
P_KeyDate : vdm_v_key_date
as select from P_MatlStkAtKeyDateInAltUoM( P_KeyDate : $parameters.P_KeyDate )
...
{
// Stock Identifier
@ObjectModel.foreignKey.association: '_Product'
key Material as Product,
@ObjectModel.foreignKey.association: '_Plant'
key Plant,
@ObjectModel.foreignKey.association: '_StorageLocation'
key StorageLocation,
key Batch,
@ObjectModel.foreignKey.association: '_Supplier'
// Units
@Semantics.unitOfMeasure
key MaterialBaseUnit,
@Semantics.unitOfMeasure
key AlternativeUnit,
// Quantities in Base Unit of Measure
@Semantics.quantity.unitOfMeasure: 'MaterialBaseUnit'
@DefaultAggregation : #SUM
MatlWrhsStkQtyInMatlBaseUnit,
// Quantities in Alternative Unit of Measure
@Semantics.quantity.unitOfMeasure: 'AlternativeUnit'
@DefaultAggregation : #SUM
cast( fltp_to_dec( MatlWrhsStkQtyInAltUoM as abap.dec(31,14) ) as nsdm_stock_qty_auom ) as MatlWrhsStkQtyInAltUoM,
....
P_KEYDATE parameter
I_MATSTKATKEYDATEINALTUOM results
Custom Smart Filter and smart table like Fiori Elements List Report
Smart table with results from query
Call to Backend S/4 HANA OData service
GET MaterialStock(P_KeyDate=datetime%272022-09-27T12%3a00%3a00%27)/Set?sap-client=100&$skip=0&$top=100&$filter=Plant%20eq%20%27USA1%27%20and%20StorageLocation%20eq%20%271000%27&$select=Plant%2cStorageLocation%2cProduct%2cBatch%2cKeyDate%2cQuantityInBaseUoM%2cMaterialBaseUnit%2cQuantityInAltUoM%2cAlternativeUnit%2cThreePLQuantity%2cThreePLUnitOfMeasure%2cDifferenceQuantity%2cDifferenceUnitOfMeasure&$inlinecount=allpages HTTP/1.1
GETMaterialStock(P_KeyDate=datetime'2022-09-27T12:00:00')/Set?sap-client=100&$skip=0&$top=100&$filter=Plant eq 'USA1' and StorageLocation eq '1000'&$select=Plant,StorageLocation,Product,Batch,KeyDate,QuantityInBaseUoM,MaterialBaseUnit,QuantityInAltUoM,AlternativeUnit,ThreePLQuantity,ThreePLUnitOfMeasure,DifferenceQuantity,DifferenceUnitOfMeasure&$inlinecount=allpagesHTTP/1.1
<mvc:View
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m"
xmlns:smartFilterBar="sap.ui.comp.smartfilterbar"
xmlns:smartTable="sap.ui.comp.smarttable"
xmlns:customData="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"
xmlns:core="sap.ui.core"
controllerName="com.********.ztplstockcustom.controller.Stock"
displayBlock="true"
>
<Page id="page" title="{i18n>title}">
<!-- use this to make the table occupy the available screen height -->
<VBox id="_IDGenVBox1" fitContainer="true">
<!-- smartFilterBar -->
<smartFilterBar:SmartFilterBar id="smartFilterBar" entitySet="MaterialStockSet" persistencyKey="SmartFilter_Explored" enableBasicSearch="false">
<smartFilterBar:controlConfiguration>
<!--<smartFilterBar:ControlConfiguration id="_IDGenControlConfiguration1" mandatory="true" key="P_KeyDate" visibleInAdvancedArea="true" preventInitialDataFetchInValueHelpDialog="false"/>-->
<smartFilterBar:ControlConfiguration id="_IDGenControlConfiguration2" key="Plant" visibleInAdvancedArea="true" preventInitialDataFetchInValueHelpDialog="false" />
<smartFilterBar:ControlConfiguration id="_IDGenControlConfiguration3" key="StorageLocation" visibleInAdvancedArea="true" preventInitialDataFetchInValueHelpDialog="false" />
<smartFilterBar:ControlConfiguration id="_IDGenControlConfiguration4" key="Product" visibleInAdvancedArea="true" preventInitialDataFetchInValueHelpDialog="false" />
<smartFilterBar:ControlConfiguration id="_IDGenControlConfiguration5" key="Batch" visibleInAdvancedArea="true" preventInitialDataFetchInValueHelpDialog="false" />
</smartFilterBar:controlConfiguration>
<!-- layout data used to make the table growing but the filter bar fixed -->
<smartFilterBar:layoutData>
<FlexItemData id="_IDGenFlexItemData1" shrinkFactor="0" />
</smartFilterBar:layoutData>
</smartFilterBar:SmartFilterBar>
<!-- smartTable -->
<smartTable:SmartTable
id="smartTable"
width="100%"
direction="Column"
fitContainer="true"
tableType="ResponsiveTable"
header="Stock Inventory"
enableAutoBinding="true"
beforeRebindTable="onBeforeRebindTable"
useTablePersonalisation="true"
smartFilterId="smartFilterBar"
entitySet="MaterialStockSet"
fieldChange="onFieldChange"
editable="false"
editTogglable="false"
customData:useSmartToggle="true"
requestAtLeastFields="Product,Plant,StorageLocation,Batch,KeyDate,QuantityInBaseUoM,QuantityInAltUoM,AlternativeUnit"
initiallyVisibleFields="Product,Plant,StorageLocation,Batch,KeyDate,QuantityInBaseUoM,QuantityInAltUoM,AlternativeUnit"
>
<smartTable:customToolbar>
<OverflowToolbar id="_IDGenOverflowToolbar1" design="Transparent">
<ToolbarSpacer id="_IDGenToolbarSpacer1" />
<Button id="_IDGenButton1" text="Upload Excel" type="Transparent" icon="sap-icon://upload" press="UploadExcel" activeIcon="sap-icon://upload" />
</OverflowToolbar>
</smartTable:customToolbar>
<Table id="_IDGenTable1" alternateRowColors="true" >
<columns>
<Column id="_IDGenColumn1">
<customData>
<core:CustomData key="p13nData" value="\{"columnKey": "ThreePLQuantity", "leadingProperty": "ThreePLQuantity", "columnIndex":"9"}" />
</customData>
<Text id="_IDGenText1" text="ThreePLQuantity" />
</Column>
<Column id="_IDGenColumn2">
<customData>
<core:CustomData key="p13nData" value="\{"columnKey": "ThreePLUnitOfMeasure", "leadingProperty": "ThreePLUnitOfMeasure", "columnIndex":"10"}" />
</customData>
<Text id="_IDGenText2" text="ThreePLUnitOfMeasure" />
</Column>
</columns>
<items>
<ColumnListItem id="_IDGenColumnListItem1">
<cells>
<Input id="_IDGenInput1" value="{ThreePLQuantity}" type="Number" editable="true" submit=".processInput" />
<ComboBox xmlns="sap.m" id="box0" change=".onChange" items="{ path: 'to_MaterialUnitOfMeasure'}" selectedKey="{DifferenceUnitOfMeasure}">
<items>
<core:Item xmlns:core="sap.ui.core" id="coreitem" key="{AlternativeUnit}" text="{AlternativeUnit}" />
</items>
</ComboBox>
</cells>
</ColumnListItem>
<ColumnListItem id="_IDGenColumnListItem2">
<cells>
<Input id="_IDGenInput2" value="Test" type="Text" editable="true" />
</cells>
</ColumnListItem>
</items>
</Table>
</smartTable:SmartTable>
</VBox>
</Page>
</mvc:View>
onBeforeRebindTable: function (oEvent) {
var oSmartTable = oEvent.getSource();
var oSmartFilterBar = this.byId(oSmartTable.getSmartFilterId());
var vCategory;
var mBindingParams = oEvent.getParameter("bindingParams");
var that = this;
if (oSmartFilterBar instanceof sap.ui.comp.smartfilterbar.SmartFilterBar) {
//Custom filter
var oCustomControl = oSmartFilterBar.getControlByKey("P_KeyDate");
var oCustomControlPlant = oSmartFilterBar.getControlByKey("Plant");
var oCustomControlStorageLocation = oSmartFilterBar.getControlByKey("StorageLocation");
var oCustomControlProduct = oSmartFilterBar.getControlByKey("Product");
var oCustomControlBatch = oSmartFilterBar.getControlByKey("Batch");
var sPlant = oSmartFilterBar.getFilterData()['Plant'];
var sStorageLocation = oSmartFilterBar.getFilterData()['StorageLocation'];
var sProduct = oSmartFilterBar.getFilterData()['Product'];
var sBatch = oSmartFilterBar.getFilterData()['Batch'];
//Here is how to get the date from the smart filter and then pass it in the binding for the table
var sDate = oSmartFilterBar.getFilterData()['$Parameter.P_KeyDate'];
var oDate = new Date(sDate);
var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({ pattern: "yyyy-MM-ddThh:mm:ss" });
var dateStr = dateFormat.format(oDate);
var sFilter = "/MaterialStock(P_KeyDate=datetime%27" + dateStr + "%27)/Set";
sFilter = sFilter.replaceAll(":", "%3a");
oSmartTable.setTableBindingPath(sFilter);
////////// .....
}
var sDate = oSmartFilterBar.getFilterData()['$Parameter.P_KeyDate'];
var oDate = new Date(sDate);
var dateFormat = sap.ui.core.format.DateFormat.getDateInstance({ pattern: "yyyy-MM-ddThh:mm:ss" });
var dateStr = dateFormat.format(oDate);
//&27 is the URL encoded value for ' and %3a is for :
var sFilter = "/MaterialStock(P_KeyDate=datetime%27" + dateStr + "%27)/Set";
sFilter = sFilter.replaceAll(":", "%3a");
oSmartTable.setTableBindingPath(sFilter);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
17 | |
15 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |