0% found this document useful (0 votes)
148 views5 pages

Abap Hana - 1

1. Create a dictionary database view referring to customer master fields and a CDS view with a customer number parameter. 2. Create a program that displays an interactive ALV using the dictionary view, and consumes the CDS view by passing the selected customer number when a row is double clicked. 3. The program handles exceptions, retrieves the selected customer number, sets the CDS view parameter, and displays the ALV in full screen mode.

Uploaded by

sbtakalkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views5 pages

Abap Hana - 1

1. Create a dictionary database view referring to customer master fields and a CDS view with a customer number parameter. 2. Create a program that displays an interactive ALV using the dictionary view, and consumes the CDS view by passing the selected customer number when a row is double clicked. 3. The program handles exceptions, retrieves the selected customer number, sets the CDS view parameter, and displays the ALV in full screen mode.

Uploaded by

sbtakalkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Example: Interactive ALV IDA and CDS view with parameters

1. Create a Dictionary Database View referring to customer


master fields
2. In Hana Studio, create CDS view with parameters

@AbapCatalog.sqlViewName: 'ZCDSPARAMVIEW'
@ClientDependent: false
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'CDS View with Parameter'
define view ZCDSPARAM
with parameters CUSTNO : kunnr
as select from vbak {
vbeln,
erdat,
erzet,
ernam,
kunnr
} where kunnr = $parameters.CUSTNO

Save, check and activate


3. Create a executable program for consuming above dictionary
database view and also CDS view with parameters (Interactive
Reporting using ALV IDA - double_click event)

REPORT zinteractive_alvida.

data gs_kna1 type zkna1v.

DATA o_alv TYPE REF TO if_salv_gui_table_ida.

data : t_parameters type IF_SALV_GUI_TYPES_IDA=>YT_PARAMETER,


wa_parameter like line of t_parameters.

CLASS lcl_eventreceiver DEFINITION.


PUBLIC SECTION.
METHODS handle_double_click
FOR EVENT double_click OF if_salv_gui_table_display_opt
IMPORTING ev_field_name eo_row_data.
ENDCLASS.

CLASS lcl_eventreceiver IMPLEMENTATION.


METHOD handle_double_click.
CASE ev_field_name.
WHEN 'KUNNR'.
MESSAGE 'Double clicked on customer no' TYPE 'I'.
* extract customer no from selected row
TRY.
CALL METHOD eo_row_data->get_row_data
IMPORTING
es_row = gs_kna1.
CATCH cx_salv_ida_contract_violation .
message 'IDA contract violation exception' type 'I'.
CATCH cx_salv_ida_sel_row_deleted .
message 'Sel row deleted exception' type 'I'.
ENDTRY.

if gs_kna1 is not INITIAL.


* consume CDS view by passing the selected customer
TRY.
CALL METHOD cl_salv_gui_table_ida=>create_for_cds_view
EXPORTING
iv_cds_view_name = 'ZCDSPARAM'
receiving
ro_alv_gui_table_ida = o_alv.
CATCH cx_salv_db_connection .
message 'DB connection exception' type 'I'.
CATCH cx_salv_db_table_not_supported .
message 'DB table not supported' type 'I'.
CATCH cx_salv_ida_contract_violation .
message 'IDA contract violation' type 'I'.
CATCH cx_salv_function_not_supported .
message 'Function not supported exception' type 'I'.
ENDTRY.

if o_alv is bound.
* prepare parameters for CDS view
refresh t_parameters.
clear wa_parameter.
wa_parameter-name = 'CUSTNO'.
wa_parameter-value = gs_kna1-kunnr.
append wa_parameter to t_parameters.
* set parameter for CDS view
o_alv->SET_VIEW_PARAMETERS( t_parameters ).
* activate fullscreen mode and display
o_alv->fullscreen( )->display( ).
endif.
endif.
WHEN OTHERS.
MESSAGE 'Please double click on customer no' TYPE 'I'.
ENDCASE.
ENDMETHOD.
ENDCLASS.

DATA ob TYPE REF TO lcl_eventreceiver.

START-OF-SELECTION.

* get the ALV object


TRY.
CALL METHOD cl_salv_gui_table_ida=>create
EXPORTING
iv_table_name = 'ZKNA1V'
RECEIVING
ro_alv_gui_table_ida = o_alv.
CATCH cx_salv_db_connection .
MESSAGE 'DB Connection exception' TYPE 'I'.
CATCH cx_salv_db_table_not_supported .
MESSAGE 'DB table not supported exception' TYPE 'I'.
CATCH cx_salv_ida_contract_violation .
MESSAGE 'IDA contract violation exception' TYPE 'I'.
ENDTRY.
IF o_alv IS BOUND.
* enable double click
DATA(o_alv_disp) = o_alv->display_options( ).
IF o_alv_disp IS BOUND.
o_alv_disp->enable_double_click( ).
* register the handler for handling double_click event
CREATE OBJECT ob.
SET HANDLER ob->handle_double_click FOR ALL INSTANCES.
ENDIF.
* activate the fullscreen mode and display
o_alv->fullscreen( )->display( ).
ENDIF.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy