A simple example of SAP List Viewer with Integrated Data Access (ALV with IDA) using CDS views.
Create a simple CDS based on table T005 and activate it.
@AbapCatalog.sqlViewName: 'ZFLICNTRY' @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: 'Country' define view ZFL_I_Country as select from t005 { key land1 as CountryKey, intca as CountryISO, waers as Currency }
Hint: How to create CDS
In Eclipse you can right click on $TMP package and select New->Other ABAP Repository Object
then select CDS->Data Definition
Enter Name and Description and finish. Now you can copy paste code if you like.
Now create a new executable program (SE38) with following code.
REPORT zpwtest_alv. DATA : iv_cds_view_name TYPE dbtabl, lo_alv_gui_table_ida TYPE REF TO if_salv_gui_table_ida. START-OF-SELECTION . iv_cds_view_name = 'ZFL_I_COUNTRY' . lo_alv_gui_table_ida = cl_salv_gui_table_ida=>create_for_cds_view( iv_cds_view_name = iv_cds_view_name ). lo_alv_gui_table_ida->fullscreen( )->display( ) .
Class method cl_salv_gui_table_ida=>create_for_cds_view is used to call CDS and prepare ALV based on data returned.
And you will get the result of CDS view in ALV when you execute.
Let spice things up a little.
In CDS view, added associations to table T005T and TCURT to get text field for country and currency. Used Annotation (the thing that starts with @) to specify column labels. Added parameter @P_LANGUAGE to specify which language to consider when retriving text for country and currency from tables T005T and TCURT.
@AbapCatalog.sqlViewName: 'ZFLICNTRY' @AbapCatalog.compiler.compareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: 'Country' define view ZFL_I_Country with parameters @Environment.systemField: #SYSTEM_LANGUAGE P_Language : sylangu as select from t005 association [0..1] to t005t as _TextCountry on _TextCountry.land1 = $projection.CountryKey association [0..1] to tcurt as _TextCurrency on _TextCurrency.waers = $projection.Currency { @EndUserText.label: 'Country' key land1 as CountryKey, @EndUserText.label: 'Country Name' _TextCountry[1: spras = $parameters.P_Language ].landx50 as CountryName, @EndUserText.label: 'Country ISO' intca as CountryISO, @EndUserText.label: 'Currency' waers as Currency, @EndUserText.label: 'Currency Name' _TextCurrency[1: spras = $parameters.P_Language].ltext as CurrencyName }
Change program to specify value of parameter P_LANGUAGE.
REPORT zpwtest_alv. DATA : iv_cds_view_name TYPE dbtabl, lo_alv_gui_table_ida TYPE REF TO if_salv_gui_table_ida, lt_parameters TYPE if_salv_gui_types_ida=>yt_parameter. START-OF-SELECTION . iv_cds_view_name = 'ZFL_I_COUNTRY' . lo_alv_gui_table_ida = cl_salv_gui_table_ida=>create_for_cds_view( iv_cds_view_name = iv_cds_view_name ). lt_parameters = VALUE #( ( name = 'P_LANGUAGE' value = sy-langu ) ) . lo_alv_gui_table_ida->set_view_parameters( lt_parameters ) . lo_alv_gui_table_ida->fullscreen( )->display( ) .
Reference
You can find the following program in SAP which demonstrate IDA.
SALV_IDA_AVAILABLE_COLUMNS | IDA ALV Sample: Definition of Available Columns |
SALV_IDA_CALC_FIELDS_1 | IDA ALV Sample: Example for Calculated fields |
SALV_IDA_CALC_FIELDS_2 | IDA ALV Sample: Example for Calculated fields > status |
SALV_IDA_CHANGE_DATA_ELEMENT | SALV IDA sample: Change technical definition via DataElement |
SALV_IDA_CHANGE_TEXTS | IDA ALV Sample: Change Header Texts |
SALV_IDA_COMPLEX_CONDITIONS | IDA ALV Sample: Selection Screen |
SALV_IDA_DATA_CONDITIONS_FS | IDA ALV Fullscreen: Complex Conditions |
SALV_IDA_DB_CAPABILITIES | IDA ALV Sample: Capabilites with DDIC table |
SALV_IDA_DISPLAY_CDS_SIMPLE | Display data from a CDS view |
SALV_IDA_DOUBLE_CLICK_FS | IDA ALV Sample: Fullscreen Double Click |
SALV_IDA_SET_CURRENCY_FIELD | IDA ALV Sample: Set alternative Currency Field |
SALV_IDA_SET_FIXED_CURRENCY | IDA ALV Sample: Set alternative Currency Field |
SALV_IDA_TEST_CDS_DATATYPES | SALV IDA Test for different data types |
SALV_IDA_TEST_CDS_VIEW_FEATURE | SALV IDA Test of CDS view features like SQL Functions, Outer |
SALV_IDA_TEST_SELECT_COND_FS | ALV IDA features (Integrated Data Access) |
Hi I want to display the output of my report using ALV IDA and on a button click i want to send an email but as we know we dont have an internal table for ALV IDA, how do we do this requirement
Hi, i have a question i need change the colors of the columns in my alv ida but i dont know how i dot it.
Is there any way to execute ALV with IDA in background?