
As developer in Abap, you are looking for methods to read SAP Analytics Cloud content. You are not familiar with HTTP request and do not want to re-invent the wheels.
In this blog post I will show how we can configure the SAP Analytics Cloud Data Export API to access planning data and integrate it with SAP S/4 HANA On Premise.
I have started to develop the integration for Funds Management component but then I have decided to extend our methods to support other components. See the last chapter with the demo report.
Figure 1.1
Figure 2.1 OAuth2.0 Clients
Figure 2.2 RFC destination example
Figure 2.2.1 RFC Logon Security
Let's start with an example of a model in SAP Analytics Cloud:
Figure 3.1 Model example
Figure 3.2
CALL METHOD CL_GEN_SAC_ACCESS=>f4_help_providers
EXPORTING
im_sac_url = g_resulturl
im_oauth_profile = g_oauthprofile
im_oauth_configuration = g_oauthconfiguration
im_rfcdest = g_rfcdest
im_namespace = l_namespaceid
IMPORTING
e_providername = l_providername
e_providerid = l_providerid
* et_errors =
EXCEPTIONS
no_providers = 1
* others = 2
.
Figure 3.3 F4 Help for SAC fields
CALL METHOD CL_GEN_SAC_ACCESS=>f4_help_fieldnames
EXPORTING
im_sac_url = g_resulturl
im_oauth_profile = g_oauthprofile
im_oauth_configuration = g_oauthconfiguration
im_rfcdest = g_rfcdest
im_namespace = u_namespaceid
im_provider = u_providerid
IMPORTING
e_sacfieldname = l_sacfieldname
et_errors = lt_errors
EXCEPTIONS
no_fieldnames = 1
OTHERS = 2.
IF sy-subrc <> 0.
Figure 3.4 Mapping example
DATA: l_url TYPE string,
lt_errors TYPE tihttpnvp.
DATA l_response TYPE string.
DATA l_content_type TYPE string.
DATA: lo_data TYPE REF TO data,
ls_mapping TYPE ihttpnvp,
lt_mapping TYPE tihttpnvp.
CALL METHOD cl_gen_sac_access=>read_fact_data
EXPORTING
im_sac_url = l_result_url
IM_RFCDEST = l_rfcdest
im_namespace = i_namespace
im_provider = i_provider
im_oauth_profile = l_profile
im_filter_string = l_filter
im_oauth_configuration = l_Oauth_CONFIGURATION
IMPORTING
e_content_type = l_content_type
e_response = l_response
et_errors = lt_errors
EXCEPTIONS
OTHERS = 1.
CALL METHOD /ui2/cl_json=>deserialize
EXPORTING
json = l_response
pretty_name = /ui2/cl_json=>pretty_mode-user
assoc_arrays = abap_true
CHANGING
data = lo_data.
LOOP AT LT_GENSAC_FIELDMAP INTO DATA(ls_sacmapping).
ls_mapping-value = ls_sacmapping-sacfield.
ls_mapping-name = ls_mapping-value. "can also be another field name!
APPEND ls_mapping TO lt_mapping.
ENDLOOP.
ASSIGN lo_data->* TO <data>.
ASSIGN COMPONENT `VALUE` OF STRUCTURE <data> TO <body>.
ASSIGN <body>->* TO <table>.
LOOP AT <table> ASSIGNING <table_line>.
LOOP AT <table> ASSIGNING <table_line>.
ASSIGN <table_line>->* TO <structure>.
LOOP AT lt_mapping INTO ls_mapping.
UNASSIGN <target_field>.
ASSIGN COMPONENT ls_mapping-value OF STRUCTURE <structure> TO <field>.
READ TABLE LT_GENSAC_FIELDMAP WITH KEY tenantid = i_tenant
providerid = i_provider
namespaceid = i_namespace
sacfield = ls_mapping-name
INTO ls_sacmapping.
Figure 3.5 Value help for SAC version
DATA l_sacversionvalue TYPE string.
DATA l_sacfieldname TYPE fmsacfieldname.
l_sacfieldname = 'Version'.
CALL METHOD CL_GEN_SAC_ACCESS=>f4_help_masterdata_values
EXPORTING
im_sac_url = l_resulturl
Im_rfcdest = l_rfcdest
im_oauth_profile = l_oauthprofile
im_namespace = u_namespace
im_provider = u_providerid
im_sacfieldname = l_sacfieldname
IMPORTING
e_masterdata_id = l_sacversionvalue
* et_errors =
EXCEPTIONS
no_masterdata = 1
OTHERS = 2.
IF sy-subrc <> 0.
DATA l_filter TYPE string.
DATA(l_vnfld) = 'Version'.
IF i_sacversn IS NOT INITIAL.
l_filter = l_filter && `{VERSION_FIELD} eq '{VERSION_VALUE}'`.
REPLACE `{VERSION_FIELD}` IN l_filter WITH l_vnfld. "SAC Field name for the version, to be taken from customizing!
REPLACE `{VERSION_VALUE}` IN l_filter WITH i_sacversn.
ELSE.
* l_url = l_url && `?$select=Account`. "does not work!!! Internal server error!
ENDIF.
DATA l_T_FIELD_SELECTION TYPE bubas_t_field_selection.
DATA l_s_field_selection TYPE bubas_s_field_selection.
DATA l_f_range_for_filter TYPE rsdsselopt.
DATA l_t_range_for_filter TYPE bubas_t_selopt.
DATA g_t_rfund TYPE FMBS_T_RFUND.
IF i_s_fm01-fikrs IS NOT INITIAL.
l_s_field_selection-fieldname = 'FINANCIALMANAGEMENTAREA'.
l_f_range_for_filter-sign = 'I'.
l_f_range_for_filter-option = 'EQ'.
l_f_range_for_filter-low = i_s_fm01-fikrs.
APPEND l_f_range_for_filter TO l_t_range_for_filter.
CLEAR l_f_range_for_filter.
APPEND LINES OF l_t_range_for_filter TO l_s_field_selection-t_selopt.
APPEND l_s_field_selection TO l_t_field_selection.
CLEAR l_s_field_selection.
ENDIF.
FREE l_t_range_for_filter.
l_s_field_selection-fieldname = 'FUND'.
LOOP AT g_t_rfund ASSIGNING FIELD-SYMBOL(<l_f_rfund>).
MOVE-CORRESPONDING <l_f_rfund> TO l_f_range_for_filter.
APPEND l_f_range_for_filter TO l_t_range_for_filter.
CLEAR l_f_range_for_filter.
ENDLOOP.
APPEND LINES OF l_t_range_for_filter TO l_s_field_selection-t_selopt.
APPEND l_s_field_selection TO l_t_field_selection.
CLEAR l_s_field_selection.
CALL METHOD CL_GEN_SAC_ACCESS=>enhance_filter_option
EXPORTING
im_tenantid = i_tenant
im_namespaceid = i_namespace
im_providerid = i_provider
im_t_standard_select_options = l_T_FIELD_SELECTION
CHANGING
c_filter_query_option = l_filter
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
Note that it is not obvious to get a proper time dimension from SAP Analytics Cloud. In the SAP Analytics Cloud model, you define the date and the corresponding granularity like for example the year:
Figure 3.6 Granularity per year
Figure 3.7: Month / Year granularity
Figure 3.8
Figure 4: demo program
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
14 | |
12 | |
12 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 |