Display a CDS View Using ALV with IDA
Display a CDS view in the SAP List Viewer with Integrated Data Access (IDA).
Overview
You will learn
- How to consume the CDS view in the SAP List Viewer with Integrated Data Access (ALV with IDA).
- Optional: How to improve the appearance of your SAP List Viewer using a data element and CAST statement.
Prerequisites
Prerequisites
- You have a valid instance of an on-premise AS ABAP server, version 7.51 or higher (some ABAP Development Tools may not be available in earlier versions)
- Tutorial: Create an ABAP Project in ABAP Development Tools (ADT)
- Tutorial: Create and Run an ABAP Program
Steps
Intro
ALV with IDA lets you display views and tables that contain very large quantities of data.
Open the ABAP program you created in the previous tutorial, Create and Run an ABAP Program.
Either choose Programs >
Z_INVOICE_ITEMS_EURO:
Image depicting step1-open-program Or choose Open ABAP Development Object (Ctrl+Shift+A) and enter the program name,
Z_INVOICE_ITEMS_EURO:
Image depicting step-1-ctrl-shift-a
Select the program and choose Duplicate from the context menu.

Image depicting step1-duplicate-program Enter the correct package and a name for your duplicated program, then choose Next.

Image depicting step2-program-name Assign or create a transport request and choose Finish.
You will now replace the implementation of the RUN method with a new implementation:
- Delete the existing statements in the method.

- Now create an ALV with IDA for your CDS view
Z_Invoice_Items_XXXand display the ALV in full screen. Don’t forget to changeXXXto your group number or initials:cl_salv_gui_table_ida=>create_for_cds_view( 'Z_Invoice_Items_XXX' )->fullscreen( )->display( ).

The CDS view name is the one defined in the `define view` statement:

Choose Save (Ctrl+S) and Activate (Ctrl+F3).
Execute your program by choosing Execute (F8).
The invoice items are displayed in ALV with IDA. (Ignore the Generic Node Key field. You can change the visibility of fields in a SAP List Viewer, but this is beyond the scope of this tutorial):

Try to display the tooltip information for the Paid column by positioning the cursor on the column heading. Notice that, in our case, the information is either missing or incorrect (depending on your version). We will change this information in the CDS view using an annotation. For more information, see Create a CDS view
NOTE: Write the annotation before the CASE statement.
- In the CDS view,
Z_Invoice_Items_XXXset the tooltip information for thepayment_statusto:@EndUserText.quickInfo: 'Paid'

Choose Save (Ctrl+S) and Activate (Ctrl+F3).
Run the program again. The SAP List Viewer should look like this:

You have created a tooltip for the column “Paid” but there is now no column header for it. You will now resolve this by casting the type of the transformed payment_status to a data element - zso_invoice_payment_status - by using a CAST statement.
If you have already created a data element in the tutorial Create a data element, then use this and go to step 5. If not, you will receive an error. Proceed as follows:
Create the data element
zso_invoice_payment_status: Choose File > New… > Other… > Data… > Dictionary > Data element: and enter the following: - Package, e.g.,Zxx_Tutorial(wherexx= your initials) - Name =zso_invoice_payment_status- DescriptionChoose Finish.
Enter the following values: - Type Name = Flag - Field labels: Short = Paid - Field labels, others = Invoice Paid

Now add the CAST statement. (Ignore the error):
ABAPcast( case header.payment_status when 'P' then 'X' else ' ' end as zso_invoice_payment_status ) as payment_status,Save and activate the CDS view (Ctrl+S, Ctrl+F3). If you run the program now, your SAP List Viewer should look like this:

Note: You can open the online help for the CAST statement by positioning the cursor on the cast keyword and choosing
F1
Your program code should look like this:
*&---------------------------------------------------------------------*
*& Report zjp_cds_inv_items_test
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zjp_cds_inv_items_test.
class lcl_main definition create private.
public section.
CLASS-METHODS create
RETURNING
value(r_result) TYPE REF TO lcl_main.
methods run.
protected section.
private section.
endclass.
class lcl_main implementation.
method create.
create object r_result.
endmethod.
method run.
cl_salv_gui_table_ida=>create_for_cds_view(`Z_Invoice_Items`)->fullscreen( )->display( ).
endmethod.
endclass.
start-of-selection.
lcl_main=>create( )->run( ).Your CDS view should look like this:
@AbapCatalog.sqlViewName: 'ZINVOICEITEMS'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS View for "Use-cds-view" tutorial'
define view Z_Invoice_Items
as select from sepm_sddl_so_invoice_item
{
//sepm_sddl_so_invoice_item
header.buyer.company_name,
sepm_sddl_so_invoice_item.sales_order_invoice_key,
sepm_sddl_so_invoice_item.currency_code,
sepm_sddl_so_invoice_item.gross_amount,
@EndUserText.quickInfo: 'Paid'
case header.payment_status
when 'P' then 'X'
else ' '
end
as payment_status,
//* Associations *//
header
}Execute ZCDS_INVOICE_ITEMS_EURO again by choosing Execute (F8).
The tooltip information for the Paid column has been changed:
Resources
Discussion
Share feedback on this tutorial or join the conversation in SAP Community.