cancel
Showing results for 
Search instead for 
Did you mean: 

S/4 ABAP CDS VIEW / WDA - Select option doesn't display the selected elements - IMPR

mk_mrn_wbr
Discoverer
0 Kudos
241

Hello everyone,

I am currently creating a report in IM for the Fiori frontend as a Web Dynpro application. My source is a self-developed data model based on ACDOCA with the additional information from IMPR, IMTP & IMZO.

The aim of the report is to be able to select an investment program and an approval year and then select the selection program positions that exist in the investment program. The selected actual postings are then displayed in the report.

The report and the selection of the approval year and the investment program work as expected.

My IMPR Masterdata:

 

define view ZI_IMPR_MD as select  from impr as _impr
association [0..*] to ZB_IMPR_TEXT  as _Text on $projection.posnr = _Text.Posnr and $projection.IM_GJAHR = _Text.Gjahr
association [0..*] to ZI_IMPR_HI  as _Hier on $projection.posnr = _Hier.HierarchyNode and $projection.IM_GJAHR = _Hier.IM_GNJHR
association [0..1] to ZB_IMGJAHR as _GJAHR on $projection.IM_GJAHR = _GJAHR.gjahr
{
    @Search.defaultSearchElement: true
    @Search.fuzzinessThreshold: 0.8
    @ObjectModel.hierarchy.association: '_Hier'
    @ObjectModel.text.element:  [ 'Hier_Text' ] 
    key _impr.posnr,
    @ObjectModel.foreignKey.association: '_GJAHR'
    key _impr.gjahr as IM_GJAHR,
    
    _impr.posid as IM_POSID,
    _impr.parnr as IM_PARNR,
    _impr.vernr as IM_VERNR,
    _impr.objnr as IM_OBJNR,
    
    _Text.Post1 as     Hier_Text,
 
   
//Make association public   
    _Text,
    _Hier,
    _GJAHR
} 

 

IMPR Hierarchy:

 

@ObjectModel: { dataCategory: #HIERARCHY }
@AbapCatalog.sqlViewName: 'ZIIMPRHI'
@Hierarchy.parentChild.name: 'IMPR_01'
@Hierarchy.parentChild.label: 'IM IMPR Hierarchy 01'
@Hierarchy.parentChild: 
{ recurse:          {   parent: 'ParentNode',   child:  'HierarchyNode'   },
  siblingsOrder:    {   by: 'HierarchyNode',    direction: 'ASC'   },
  directory:        '_Hierarchy',
  orphanedNode.handling: #IGNORE }
@AccessControl.authorizationCheck: #NOT_REQUIRED 
define view ZI_IMPR_HI as select from impr
association [0..1] to ZI_IMPR_MD as _IMPR on $projection.HierarchyNode = _IMPR.posnr and $projection.IM_GNJHR = _IMPR.IM_GJAHR 
association [1..1] to ZB_IMTP_MD as _Hierarchy  on  $projection.POSNRHierarchy = _Hierarchy.Prnam and $projection.IM_GNJHR = _Hierarchy.Gjahr
association [0..1] to ZB_IMGJAHR as _GJAHR on $projection.IM_GNJHR = _GJAHR.gjahr
{
    @Consumption.filter: {mandatory : true, selectionType : #SINGLE, multipleSelections : false }
    @ObjectModel.foreignKey.association: '_Hierarchy'
    key prnam  as POSNRHierarchy,   
    @ObjectModel.foreignKey.association: '_IMPR'
    key posnr as HierarchyNode,
    @ObjectModel.foreignKey.association: '_GJAHR'
    gjahr as IM_GNJHR,
    
    posid as IM_POSID,
    parnr as ParentNode,
    prnam as IM_PRNAM,

//Make association public 
   _IMPR,
   _Hierarchy,
   _GJAHR

 

Hierarchy directory IMTP

 

@ObjectModel.representativeKey: 'Prnam'
@EndUserText.label: 'Basic View for IMTP'
define view ZB_IMTP_MD as select from imtp
association [0..1] to ZB_IMTP_TEXT as _Text on $projection.Prnam = _Text.Prnam and $projection.Gjahr = _Text.Gjahr 
association [0..1] to ZB_IMGJAHR as _GJAHR on $projection.Gjahr = _GJAHR.gjahr
{
    @Search.defaultSearchElement: true
    @Search.fuzzinessThreshold: 0.8
    @ObjectModel.text.association: '_Text'
    key prnam as Prnam,
    @ObjectModel.foreignKey.association: '_GJAHR'
    key gjahr as Gjahr,

//Make association public     
    _Text,
    _GJAHR
}

 

I join my hierarchy view with my data flow:

 

association[0..*] to ZI_IMPR_MD as _POSNR on $projection.Posnr = _POSNR.posnr and $projection.Gjahr = _POSNR.IM_GJAHR

 

..and then create my selection option in the Consumtion View: 

 

@AnalyticsDetails.query.variableSequence: 5
@Consumption.filter: {  selectionType: #HIERARCHY_NODE, multipleSelections: true, mandatory: false,
                        hierarchyBinding : [  { type: #PARAMETER, value: 'p_invprog', variableSequence: 45 },   
                                              { type: #PARAMETER, value: 'p_gjahr', variableSequence: 45 } ] }                                             
@AnalyticsDetails.query.displayHierarchy: #FILTER
@AnalyticsDetails.query.axis: #ROWS
@AnalyticsDetails.query.display: #KEY_TEXT
@AnalyticsDetails.query.totals: #SHOW
    Posnr, 

 

 

As you can see, the hierarchy is displayed in the report:

mk_mrn_wbr_0-1721048639297.png

The hierarchy node parameter also shows the values in a hierarchy:

mk_mrn_wbr_1-1721048691983.png

If I now select a node and then press "Start" to run the report, I get no values.

mk_mrn_wbr_2-1721048780212.png

Although there are definitely values without the selection.
Does anyone know why no values are displayed when a node is selected?

View Entire Topic
mk_mrn_wbr
Discoverer
0 Kudos

Hi everyone,

I have actually solved the problem myself.
Instead of using the POSNR (unconverted) of the IMPR, I use the POSID (converted) for the selection and display, but the POSNR for the creation of the hierarchy.
I also transfer both the approval year and the investment program to the DimensionView.
If anyone would like to use this logic in their ABAP CDS view, here is the code:

Dimension View:

@AbapCatalog.sqlViewName: 'ZIIMPRMD2'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Investment Program Positions'
@Analytics.dataCategory: #DIMENSION
@Analytics.dataExtraction.enabled: true
@VDM.viewType: #BASIC
@ObjectModel.representativeKey: 'IM_POSID'
define view ZI_IMPR_MD_2 as select  from impr as _impr
association [0..*] to ZB_IMPR_TEXT_2  as _Text on $projection.IM_POSID = _Text.Posid and $projection.IM_GJAHR = _Text.Gjahr
association [0..*] to ZI_IMPR_HI_3  as _Hier on $projection.IM_POSID = _Hier.HierarchyNode and $projection.IM_GJAHR = _Hier.IM_GNJHR
association [0..1] to ZB_IMGJAHR as _GJAHR on $projection.IM_GJAHR = _GJAHR.gjahr
{
    @Search.defaultSearchElement: true
    @Search.fuzzinessThreshold: 0.8
    @ObjectModel.hierarchy.association: '_Hier'
    @ObjectModel.text.element:  [ 'Hier_Text' ] 
    key _impr.posid as IM_POSID,
    @ObjectModel.foreignKey.association: '_GJAHR'
    key _impr.gjahr as IM_GJAHR,
    
    _impr.posnr as IM_POSNR,
    _impr.parnr as IM_PARNR,
    _impr.vernr as IM_VERNR,
    _impr.objnr as IM_OBJNR,
    
    _Text.Post1 as     Hier_Text,
 
   
//Make association public   
    _Text,
    _Hier,
    _GJAHR
} 


Hierarchy View:

@VDM.viewType: #BASIC
@ObjectModel: { dataCategory: #HIERARCHY }
@AbapCatalog.sqlViewName: 'ZIIMPRHI3'
@Hierarchy.parentChild.name: 'IMPR_01'
@Hierarchy.parentChild.label: 'IM IMPR Hierarchy 01'
@Hierarchy.parentChild: 
{ recurse:          {   parent: 'ParentNode',   child:  'IM_POSNR'   },
  siblingsOrder:    {   by: 'IM_POSNR',    direction: 'ASC'   },
  directory:        '_Hierarchy'
  }
@AccessControl.authorizationCheck: #NOT_REQUIRED 
  
define view ZI_IMPR_HI_3 as select from impr
association [0..1] to ZI_IMPR_MD_2 as _IMPR on $projection.HierarchyNode = _IMPR.IM_POSID and $projection.IM_GNJHR = _IMPR.IM_GJAHR 
association [1..1] to ZB_IMTP_MD as _Hierarchy  on  $projection.POSNRHierarchy = _Hierarchy.Prnam and $projection.IM_GNJHR = _Hierarchy.Gjahr
association [0..1] to ZB_IMGJAHR as _GJAHR on $projection.IM_GNJHR = _GJAHR.gjahr
{
    @Consumption.filter: {mandatory : true, selectionType : #SINGLE, multipleSelections : false }
    @ObjectModel.foreignKey.association: '_Hierarchy'
    key prnam  as POSNRHierarchy,   
    @ObjectModel.foreignKey.association: '_IMPR'
    key posid as HierarchyNode,
    @ObjectModel.foreignKey.association: '_GJAHR'
    key gjahr as IM_GNJHR,
    posnr as IM_POSNR,

    parnr as ParentNode,
    prnam as IM_PRNAM,

//Make association public 
   _IMPR,
   _Hierarchy,
   _GJAHR
}  

Hierarchy Directory:

@AbapCatalog.sqlViewName: 'ZIIMTPMD'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Analytics.dataCategory: #DIMENSION
@Analytics.dataExtraction.enabled: true
@VDM.viewType: #BASIC
@ObjectModel.representativeKey: 'Prnam'
@EndUserText.label: 'Basic View for IMTP'
define view ZB_IMTP_MD as select from imtp
association [0..1] to ZB_IMTP_TEXT as _Text on $projection.Prnam = _Text.Prnam and $projection.Gjahr = _Text.Gjahr 
association [0..1] to ZB_IMGJAHR as _GJAHR on $projection.Gjahr = _GJAHR.gjahr
{
    @Search.defaultSearchElement: true
    @Search.fuzzinessThreshold: 0.8
    @ObjectModel.text.association: '_Text'
    key prnam as Prnam,
    @ObjectModel.foreignKey.association: '_GJAHR'
    key gjahr as Gjahr,

//Make association public     
    _Text,
    _GJAHR
}

POSID in Consumption View:

@AnalyticsDetails.query.variableSequence: 5
@EndUserText.label: 'InvestProgPosition'
@Consumption.filter: {  selectionType: #HIERARCHY_NODE, multipleSelections: true, mandatory: false,
                        hierarchyBinding : [  { type: #PARAMETER, value: 'p_invprog', variableSequence: 45 },   
                                              { type: #PARAMETER, value: 'p_gjahr', variableSequence: 45 } ] }                                            
@AnalyticsDetails.query.displayHierarchy: #FILTER
@AnalyticsDetails.query.axis: #ROWS
@AnalyticsDetails.query.display: #KEY_TEXT
@AnalyticsDetails.query.totals: #SHOW
    posid,