‎2018 Mar 08 6:34 PM
Hello,
i basically ask my question in the subject title. I am pretty new to ABAP and programming in general. I created a program which joined some tables together and u can refine your search via select options.
*& Selectionsbildschirm
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS: bsart FOR ls_ekko-bsart,
ebeln FOR ls_ekko-ebeln,
ekgrp FOR ls_ekko-ekgrp,
banfn FOR ls_ekpo-banfn,
werks FOR ls_ekpo-werks OBLIGATORY DEFAULT '0001' TO '0004'.
SELECTION-SCREEN END OF BLOCK b1.
SKIP.
PARAMETERS: layout LIKE disvariant-variant DEFAULT '/B'.
... later in the code I have the select statement, where i select my tables, and also the join conditions and after that this comes:
So when I was correct, this is how a select-option possibility can look like. Now I am trying to implement a CDS VIEW instead. I tried some things that I get from the internet but I have basically no idea how a select option can be implemented. Have it to be in the DDL Source?
@AbapCatalog.sqlViewName:'Z_PSP_CDS'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'CDS_VIEW_PSP'
@VDM.viewType: #BASIC
@Analytics.dataExtraction.enabled: true
define view Z_PSP
as select from ekko as a left outer
join ekkn as b
on b.ebeln = a.ebeln
join ekpo as c
on a.ebeln = c.ebeln
join zs1ek_banf_tools as d
on d.banfn = c.banfn
join user_addr as e
on e.bname = d.aussteller
{
a.bsart,
a.aedat,
a.ebeln,
a.ekgrp,
b.ebelp,
b.sakto,
b.ps_psp_pnr,
c.banfn,
c.matnr,
c.txz01,
c.werks,
d.aussteller,
d.gettyp,
d.kunde,
e.name_last
}
// where a.bsart = bsart
// and a.ebeln = a.ebeln
// and a.ekgrp = ekgrp
// and c.banfn = c.banfn
or in the report somewehre itself?
**1... Declare SELECT-OPIONS
SELECT-OPTIONS: bsart FOR ekko-bsart,
ebeln FOR ekko-ebeln,
banfn FOR ekpo-banfn.
START-OF-SELECTION.
*2... Create object reference ALV with IDA
DATA(lo_alv_display) = cl_salv_gui_table_ida=>create( iv_table_name = 'EKKO' ).
*3... Build range tables
DATA(lo_range_collector) = NEW cl_salv_range_tab_collector( ).
lo_range_collector->add_ranges_for_name( iv_name = 'BSART'
it_ranges = bsart[] ).
lo_range_collector->add_ranges_for_name( iv_name = 'EBELN'
it_ranges = ebeln[] ).
lo_range_collector->add_ranges_for_name( iv_name = 'BANFN'
it_ranges = banfn[] ).
lo_range_collector->get_collected_ranges(
IMPORTING
et_named_ranges = DATA(lt_select_options) ).
*4... Set select options
lo_alv_display->set_select_options( it_ranges = lt_select_options ).
*5... Display ALV
*lo_alv_display->fullscreen( )->display( ).
cl_salv_gui_table_ida=>create_for_cds_view( 'Z_PSP' )->fullscreen( )->display( ).
I have zero clue what and how I should do. Any advice would be appreciated
greetings Dustin
‎2018 Mar 08 6:55 PM
You cannot use select options in CDS directly.
You can use select options in the WHERE condition of Open SQL when reading from CDS entities.
‎2022 Jun 14 10:34 AM
I find a problem with this code because this can not use the select options here:
cl_salv_gui_table_ida=>create_for_cds_view( 'Z_PSP' )->fullscreen( )->display( ).="<-wrong codethe code will print the ALV from the CDS but no through the select options, why? because it's not used properly the object in the declaration,
*2... Create object reference ALV with IDA
DATA(lo_alv_display) = cl_salv_gui_table_ida=>create( iv_table_name = 'EKKO' ).Then we will have to call the class object with the method that prints the data using the select options and it would be like this.
lo_alv_display=>create_for_cds_view( 'Z_PSP' )->fullscreen( )->display( ). <-- rigth codeI hope this can help everyone.
‎2022 Jun 14 10:42 AM