Integrating Legacy System: Creating Custom CDS Views for Obsolete Extractors 0PS_20

Overview

The problem of an obsolete extractor in an SAP system refers to the challenge of accessing data from a legacy system that is no longer supported or compatible with the latest version of the SAP system. This can impact decision-making, reporting, and analysis, and lead to data integrity issues. The solution is to check if SAP has provided the Standard CDS view for the obsolete extractor. If not, create a custom CDS view to map the data from the legacy system to the new SAP system using the CDS view, enabling the data to be extracted and used for reporting, analysis, and decision-making purposes.

 

SAP ECC vs SAP S4HANA

SAP ERP Central Component (SAP ECC) is an on-premises enterprise resource planning (ERP) system used by many organizations worldwide. However, with the increasing demand for modern and agile system, SAP has launched it’s next generation ERP system, SAP S4/HANA.

S/4HANA was designed to make ERP more modern, faster and easier to use through a simplified data model.

A brownfield approach to conversion allows organizations to migrate from SAP ECC to S/4HANA by converting their existing SAP environment without reimplementation or disruption to existing business processes.

While migration some challenged are faced, one of them is obsolescence of extractors in SAP. If  SAP hasn’t provided the standard CDS view for the extractor, it is recommended to build a Custom CDS view for that obsolete extractor in the S4/HANA system.

 

Extractors are important components of the SAP landscape that are required to extract data from the system and make it available for further processing. When an extractor becomes obsolete, it becomes challenging to obtain the required data, which may lead in the conversion process.

 

Solution

The First step towards this is to check if SAP has provided the Standard CDS view for the obsolete extractor. If yes than we can use that Standard CDS view directly in place of obsolete extractor. If a compatible standard extractor is available, it is recommended to use that extractor instead of creating a custom solution. This approach can help to minimize the time and effort required for data integration and ensure that the extracted data is compatible with the new system.

We can also use another standard CDS view to create a custom CDS view can be an effective approach for addressing the problem of an obsolete extractor in an SAP system. By identifying a standard CDS view in the new system that is similar to the data being extracted from the legacy system, organizations can save time and effort by leveraging the existing structure and content of the standard view. Analyzing the standard view can help to identify the relevant fields and data elements needed for the custom CDS view, which can then be modified as necessary to map the data from the legacy system to the new SAP system. Testing the custom CDS view is crucial to ensure that it is accurately extracting and mapping the data, and once validated, it can be published for use in reporting and analysis. This approach can simplify the process of integrating legacy systems with the new SAP system, while ensuring that the extracted data is compatible and usable for decision-making purposes.

** However, if a compatible standard extractor is not available, the next approach is to create a custom CDS view for the obsolete extractor. This involves mapping the data from the legacy system to the new SAP system using the CDS view, enabling the data to be extracted and used for reporting, analysis, and decision-making purposes

Core Data Service (CDS) Views are virtual data models of SAP HANA which allows direct access to underlying tables of the HANA database and streamlined view of complex data structure. We can use these custom CDS views to extract data from S4/HANA system.

 

The steps to create a CDS View for an obsolete BW extractor are as follows:

Step 1: Identify the obsolete extractor: The first step is to identify the extractor that has become obsolete. This information can be obtained from the SAP notes and release information.

2496759 – Restrictions for BW extractors relevant for S/4HANA in the area of Enterprise Portfolio and Project Management

@Analytics.dataExtraction.enabled – Using this annotation CDS view can be used in BW for extraction

 

Step 2: Analyze the obsolete extractor: The next step is to analyze the obsolete extractor to understand its data structures, field names, and data types. This information will be useful in creating the CDS View.

 

Step 3: Create a CDS View: Once the analysis of the obsolete extractor is complete, the next step is to create a CDS View in SAP S4/HANA. The CDS View can be created using the SAP HANA Studio (Eclipse)

For reference https://blogs.sap.com/2019/10/22/part2.-create-a-basic-cds-view/

IMPORTANT: If you’re Using this CDS view for the BW (Business warehouse), Then it’s necessary to include annotation

@Analytics.dataExtraction.enabled (after this CDS view can be used in BW for extraction)

 

Step 4: Map the fields: The next step is to map the fields of the CDS View with the fields of the obsolete extractor. The field names and data types should match with the obsolete extractor to ensure that the data is extracted correctly.

 

Step 5: Test the CDS View: After mapping the fields, the next step is to test the CDS View. This can be done by executing the CDS View and verifying the output data.

 

Step 7: Implement the CDS View: Once the testing of the CDS View is successful, the next step is to implement it in the SAP S4/HANA system. This can be done by activating the CDS View and using it for data extraction.

 

We have created a CDS view for 0PS_20 extractor.

About 0PS_20

The 0PS_20 extractor in SAP is a standard Business Content extractor used for extracting data related to project systems in SAP. This extractor enables the extraction of data from the project systems module in SAP, which is used for managing and tracking projects, including project planning, budgeting, and resource allocation.

The 0PS_20 extractor can be used to extract data related to various aspects of project systems in SAP, such as project definition, work breakdown structure (WBS), network activities, project planning, and cost elements. The extracted data can then be used for reporting, analysis, and decision-making purposes.

Some of the specific data elements that can be extracted using the 0PS_20 extractor includes project dates, budgeted costs, actual costs, planned and actual work hours, and status information related to projects, WBS, and network activities.

Major Tables included in CDS view: PROJ, PRPS, COSP, COSS

 

CODE 1

@AbapCatalog.sqlViewName: 'Z0PS_CDS01'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS1 view for extractor'
@VDM.private: true
@VDM.viewType: #BASIC
@ObjectModel.usageType: {
        sizeCategory: #L,
        serviceQuality: #B,
        dataClass: #MASTER
        }
@Analytics.dataCategory
@Analytics.dataExtraction.enabled
define view Z0PS_CDS1 as
select from proj
inner join  prps on proj.pspnr = prps.psphi   // joining_tables 
inner join cosp on cosp.objnr = prps.objnr
inner join t001 on t001.bukrs = proj.vbukr

//WOG001

 { key prps.psphi,
   key prps.objnr,
   prps.posid ,
   prps.pkokr ,
   proj.pspid ,
   proj.plfaz as startdate,
   proj.plsez as enddate, 
   cosp.wrttp,
   cosp.gjahr,
   cosp.kstar,
   concat(cosp.gjahr,'001') as Fiscal_period,
   '10' as curtype,
   sum(cosp.wog001) as amount,   // To sum all the values period wise for respective OBJNR and KSTAR
   t001.waers,
   '01' as period
   
   } where prps.pkokr = 'CA02' and cosp.wrttp = '04' and cosp.gjahr > '2017'   // Conditions
   group by prps.pspnr, prps.objnr,cosp.gjahr,prps.posid, prps.pkokr,prps.psphi,proj.pspid,proj.plfaz,proj.plsez,
  cosp.wrttp,cosp.gjahr,cosp.kstar, t001.waers
  
union     // union of dataset of above code with below one

//WOG002
select from proj

left outer join prps on proj.pspnr = prps.psphi
inner join cosp on cosp.objnr = prps.objnr
inner join t001 on t001.bukrs = proj.vbukr
{ key prps.psphi,
   key prps.objnr,
   prps.posid ,
   prps.pkokr ,
   proj.pspid ,
   proj.plfaz as startdate,
   proj.plsez as enddate, 
   cosp.wrttp,
   cosp.gjahr,
   cosp.kstar,
   concat(cosp.gjahr,'002') as Fiscal_period,
   '10' as curtype,
   sum(cosp.wog002) as amount,
    
   t001.waers,
   '02' as period
   
   } where prps.pkokr = 'CA02' and cosp.wrttp = '04' and cosp.gjahr > '2017'
   group by prps.pspnr, prps.objnr,cosp.gjahr,prps.posid, prps.pkokr,prps.psphi,proj.pspid,proj.plfaz,proj.plsez,
  cosp.wrttp,cosp.gjahr,cosp.kstar, t001.waers
  
  union 
//WOG003
select from proj

left outer join prps on proj.pspnr = prps.psphi
inner join cosp on cosp.objnr = prps.objnr
inner join t001 on t001.bukrs = proj.vbukr
{ key prps.psphi,
   key prps.objnr,
   prps.posid ,
   prps.pkokr ,
   proj.pspid ,
   proj.plfaz as startdate,
   proj.plsez as enddate, 
   cosp.wrttp,
   cosp.gjahr,
   cosp.kstar,
   concat(cosp.gjahr,'003') as Fiscal_period,
   '10' as curtype,
   
   sum(cosp.wog003) as amount,
    
   t001.waers,
   '03' as period
   
   } where prps.pkokr = 'CA02' and cosp.wrttp = '04' and cosp.gjahr > '2017'
   group by prps.pspnr, prps.objnr,cosp.gjahr,prps.posid, prps.pkokr,prps.psphi,proj.pspid,proj.plfaz,proj.plsez, cosp.wrttp,cosp.gjahr,cosp.kstar, t001.waers

 

CODE 2

@AbapCatalog.sqlViewName: 'Z0PS_CDS02'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS02 view for extractor'
@VDM.private: true
@VDM.viewType: #BASIC
@ObjectModel.usageType: {
        sizeCategory: #L,
        serviceQuality: #B,
        dataClass: #MASTER
        }
@Analytics.dataCategory
@Analytics.dataExtraction.enabled
define view Z0PS_CDS2 as 
select from aufk
inner join cosp on cosp.objnr = aufk.objnr
inner join t001 on t001.bukrs = cosp.bukrs

{   key aufk.objnr,
    cast(' ' as abap.numc( 8 )) as psphi,
    cast(' ' as abap.char( 24 )) as posid,
    aufk.kokrs as D5,
    cast(' ' as abap.char( 24 )) as pspid,
    cast(' ' as abap.dats( 8 )) as startdate,
    cast(' ' as abap.dats( 8 )) as enddate,
    cosp.wrttp,
    cosp.gjahr,
    cosp.kstar,
    concat(cosp.gjahr,'001') as Fiscal_period,
    '10' as curtype,
   sum(cosp.wog001) as amount,
   t001.waers,
   '01' as period
    
  
} where aufk.kokrs = 'CA02' and cosp.wrttp = '04' and cosp.gjahr > '2017'
   group by aufk.objnr,cosp.gjahr,
  cosp.wrttp,cosp.gjahr,cosp.kstar, t001.waers,aufk.kokrs
  
  
 union
  
 //WOG002
 
 select from aufk
inner join cosp on cosp.objnr = aufk.objnr
inner join t001 on t001.bukrs = cosp.bukrs

{   key aufk.objnr,
    cast(' ' as abap.char( 24 )) as posid,
    aufk.kokrs as D5,
    cast(' ' as abap.char( 24 )) as pspid,
    cast(' ' as abap.dats( 8 )) as startdate,
    cast(' ' as abap.dats( 8 )) as enddate,
    cosp.wrttp,
    cosp.gjahr,
    cosp.kstar,
    concat(cosp.gjahr,'002') as Fiscal_period,
    '10' as curtype,
   sum(cosp.wog002) as amount,
   t001.waers,
   '02' as period
    
  
} where aufk.kokrs = 'CA02' and cosp.wrttp = '04' and cosp.gjahr > '2017'
   group by aufk.objnr,cosp.gjahr,
  cosp.wrttp,cosp.gjahr,cosp.kstar, t001.waers,aufk.kokrs
  
  union
  
 //WOG003
  select from aufk
inner join cosp on cosp.objnr = aufk.objnr
inner join t001 on t001.bukrs = cosp.bukrs

{   key aufk.objnr,
    cast(' ' as abap.numc( 8 )) as psphi,
    cast(' ' as abap.char( 24 )) as posid,
    aufk.kokrs as D5,
    cast(' ' as abap.char( 24 )) as pspid,
    cast(' ' as abap.dats( 8 )) as startdate,
    cast(' ' as abap.dats( 8 )) as enddate,
    cosp.wrttp,
    cosp.gjahr,
    cosp.kstar,
    concat(cosp.gjahr,'003') as Fiscal_period,
    '10' as curtype,
   sum(cosp.wog003) as amount,
   t001.waers,
   '03' as period
   } where aufk.kokrs = 'CA02' and cosp.wrttp = '04' and cosp.gjahr > '2017'
   group by aufk.objnr,cosp.gjahr,
  cosp.wrttp,cosp.gjahr,cosp.kstar, t001.waers,aufk.kokrs
  

You can repeat the code for more WOG*** values. We have created 4 codes for extracting data from tables as OBJNRs are coming from two different tables for this extractor i.e. PRPS and AUFK. Also we we are using both COSP and COSS tables for extracting amount for respective OBJNRs.

After creating set of codes we need to create a #Composite View.

@AbapCatalog.sqlViewName: 'Z0PS_CDSFinal'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED


@VDM.viewType: #COMPOSITE
@ObjectModel.usageType: {
      sizeCategory: #L,
      serviceQuality: #B,
       dataClass: #MASTER
       }
@Analytics.dataCategory: #FACT
@Analytics.dataExtraction.enabled:true
@EndUserText.label: 'Final view for the 0ps_20 extractor'


define view Z0PS_CDS_F (phshi, objnr,  posid, kokrs, pspid, stardate, enddate, wrttp, fiscalyear, kstar,fiscal_period, Curtype,amount, currency, period ) 
as 
select from Z0PS_CDS1  {psphi, objnr, posid,pkokr, pspid, startdate, enddate, wrttp, gjahr, kstar,Fiscal_period, curtype, amount,waers, period}
union
select from Z0PS_CDS2  {psphi, objnr, posid,pkokr, pspid, startdate, enddate, wrttp, gjahr, kstar,Fiscal_period, curtype, amount,waers, period}
union
select from Z0PS_CDS3  {psphi, objnr, posid, pkokr , pspid, startdate, enddate, wrttp, gjahr, kstar,Fiscal_period, curtype, amount,waers, period}
union
select from Z0PS_CDS4  {psphi, objnr, posid, pkokr , pspid, startdate, enddate, wrttp, gjahr, kstar,Fiscal_period, curtype, amount,waers, period}

 

Conclusion

Creating a custom CDS view for an obsolete BW extractor in an S/4HANA system is a good step in integrating legacy systems with the new platform if SAP hasn’t provided the standard CDS view. By following the steps outlined in this blog, organizations can create a custom view that will enable them to seamlessly map data from the obsolete BW extractor to the S/4HANA system and take advantage of the advanced features and capabilities of the new platform.

Using the custom CDS view for BW reporting allows organizations to leverage the new reporting features in S/4HANA while still using legacy data sources where required. This approach provides a flexible and efficient way to manage data integration in the organization and enable effective decision making.

Overall, creating a custom CDS view is a crucial step in maximizing the benefits of the S/4HANA system and enabling organizations to continue using legacy data sources as needed.

 

Original Article:
https://blogs.sap.com/2023/03/15/integrating-legacy-system-creating-custom-cds-views-for-obsolete-extractors-0ps_20/

ASK SAP EXPERTS ONLINE
Related blogs

LEAVE A REPLY

Please enter your comment!
Please enter your name here