cancel
Showing results for 
Search instead for 
Did you mean: 

Calculation View via AMDP in CDS-View

D039507
Advisor
Advisor
0 Kudos

Hi Experts,

I have a problem: I built a Method in a Class (if_amdp_marker_hdb) where I get the data from a calculation view with a parameter (by database procedure). This is working fine.

Now I want to use this AMDP in a CDS View, but as I see I can only build a CDS Table Function on it, when the method is a database function.But in my case this is a database procedure. So this will not work.

Has anyone an idea, how I can access this AMDP in a CDS-View? Or how can I build a AMDP with database function with access to a calculation view?

Thanks in advance....

pfefferf
Active Contributor
0 Kudos

Are you asking if it is possible with a procedure (-> not it is not possible) or how to implement a CDS table function (in the CDS table function you access your calc. view the same way as in your procedure)?

D039507
Advisor
Advisor
0 Kudos

Hi Florian,

at the end i will use data from a calculation view in a CDS-Views.

Best regards

D039507
Advisor
Advisor
0 Kudos

This is my method to access the calculation view. This one I wanted to use in a CDS Table function, but that doesn't work...

CLASS zzc_gfmmethods DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC.


  PUBLIC SECTION.
  INTERFACES if_amdp_marker_hdb.


  Types:
   Begin of gty_notice,
   Client                           type sy-mandt,
   ContractInternalNumber           type char13,
   State                            type char2,
   NextEndDate                      type char10,
   LatestEndDate                    type char10,
   RenewalToDate                    type char10,
   RenewalReceiptToDate             type char10,
   PossibleTenNoticeReceiptToDate   type char10,
   PossibleLanNoticeReceiptToDate   type char10,
   PossibleTenNoticeDate            type char10,
   PossibleLanNoticeDate            type char10,
   End of gty_notice,


   gtt_notice TYPE STANDARD TABLE OF gty_notice.


   CLASS-METHODS get_noticedates


   EXPORTING
     VALUE(ex_cal_view_data)     TYPE   gtt_notice.


  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.


CLASS ZZC_GFMMETHODS IMPLEMENTATION.




METHOD get_noticedates BY database procedure
                       for hdb
                       language sqlscript
                       OPTIONS read-only.


 ex_cal_view_data
        = select
        "SAPClient" as Client,
        "REContractIntRealEstateNumber" as ContractInternalNumber,
        "REContractState" as State,
        "REContractNextEndDate_E" as NextEndDate,
        "REContractLatestEndDate_E" as LatestEndDate,
        "REContractRenewalToDate_E" as RenewalToDate,
        "REContractRenewalReceiptToDate_E" as RenewalReceiptToDate,
        "REContrPossibleTenantNoticeDate_E" as PossibleTenNoticeReceiptToDate,
        "REContrTenantNoticeReceiptToDate_E" as PossibleLanNoticeReceiptToDate,
        "REContrPossibleLandlordNoticeDate_E" as PossibleTenNoticeDate,
        "REContrLandlordNoticeReceiptToDate_E"  as PossibleLanNoticeDate
        from
         "_SYS_BIC"."gfmc.noticedates/ZCL_GFMC_NoticeDatesCalculation";
 ENDMETHOD.


ENDCLASS.
pfefferf
Active Contributor

Why does it not work to convert that logic to a CDS table function? What error do you get?

D039507
Advisor
Advisor
0 Kudos

This is my table function:

@ClientDependent: false
@EndUserText.label: 'GFM: Table Function Notice Dates'

define table function zzi_gfmnoticetf
returns 
{
 
  key 
   Client                           :char3;
   ContractInternalNumber           :char13;
   State                            :char2;
   NextEndDate                      :char10;
   LatestEndDate                    :char10;
   RenewalToDate                    :char10;
   RenewalReceiptToDate             :char10;
   PossibleTenNoticeReceiptToDate   :char10;
   PossibleLanNoticeReceiptToDate   :char10;
   PossibleTenNoticeDate            :char10;
   PossibleLanNoticeDate            :char10;
  
  }

implemented by method
  zzc_gfmmethods=>get_noticedates;

and that's the error:

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member412549
Participant
0 Kudos

Hi Thorsten Watzke,

If you want to use this AMDP for Table function as you already mentioned "METHOD get_noticedates BY database procedure" should be replaced with "METHOD get_noticedates BY database function" and moreover you have to mention for which table function you want AMDP method to be executed in method definition.

So, here is my question have you mentioned "for table function <table_function_name>" in the method definition?

Reference blog.

Please, have a look and let me know if this helps.


Thanks & Regards,

Tushar Sharma

shyam_uthaman
Participant
0 Kudos

Hi Thorsten,

Maybe this is not what you are looking for but below is the method I used to call Calc Views in CDS views. Maybe it will help.

https://blogs.sap.com/2018/05/24/abap-dictionary-external-views-for-overcoming-abap-cds-views-limiti...

Shyam

D039507
Advisor
Advisor
0 Kudos

Hi Shyam,

yes, I've found your block when I was looking for a solution. The logic about a dictionary view is known to me, I want to use the calc view directly (not directly, but now wit a dic view).

But thank you for your answer....

Best Regard