*&---------------------------------------------------------------------*
*& Report zz_jre_select_enahnce
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zz_jre_select_enahnce.
Types: gty_data type mara ,
gty_tab_data TYPE STANDARD TABLE OF gty_data .
*data, solely for select-options.
data: gso_mara type mara.
*Sel-Screen:
SELECTION-SCREEN BEGIN OF BLOCK sel_opt WITH FRAME TITLE text-t01.
SELECT-Options: so_matnr for gso_mara-matnr.
SELECTION-SCREEN END OF BLOCK sel_opt.
SELECTION-SCREEN BEGIN OF BLOCK mode WITH FRAME TITLE text-t02.
PARAMETERS: pa_disp TYPE flag RADIOBUTTON GROUP mode DEFAULT 'X',
pa_proc TYPE flag RADIOBUTTON GROUP mode.
SELECTION-SCREEN END OF BLOCK mode.
CLASS lcl_report DEFINITION.
PUBLIC SECTION.
METHODS: display_data CHANGING ct_data TYPE gty_tab_data.
METHODS: process_data IMPORTING it_data TYPE gty_tab_data.
ENDCLASS. "lcl_report DEFINITION
CLASS lcl_report IMPLEMENTATION.
METHOD process_data.
FIELD-SYMBOLS: <data> LIKE LINE OF it_data.
CHECK it_data IS NOT INITIAL.
LOOP AT it_data ASSIGNING <data>.
*do something
ENDLOOP.
ENDMETHOD. "process_data
METHOD display_data.
DATA: lr_alv TYPE REF TO cl_salv_table.
DATA: lr_functions TYPE REF TO cl_salv_functions_list,
lr_layout TYPE REF TO cl_salv_layout,
ls_key TYPE salv_s_layout_key.
TRY.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = lr_alv
CHANGING
t_table = ct_data.
##NO_HANDLER.
CATCH cx_salv_msg .
ENDTRY.
lr_layout = lr_alv->get_layout( ).
ls_key-report = sy-repid.
lr_layout->set_key( ls_key ).
lr_layout->set_default( abap_true ).
lr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
lr_functions = lr_alv->get_functions( ).
lr_functions->set_all( abap_true ).
CALL METHOD lr_alv->display.
ENDMETHOD. "display_data
ENDCLASS. "lcl_report IMPLEMENTATION
START-OF-SELECTION.
PERFORM start_of_selection.
FORM start_of_selection.
DATA: lt_data TYPE gty_tab_data,
lo_report TYPE REF TO lcl_report.
*by using a form-routine to get_data we can just use paramters and
*select-options inside.
PERFORM get_data CHANGING lt_data.
check lt_data is not initial.
CREATE OBJECT lo_report.
CASE abap_true.
WHEN pa_disp.
lo_report->display_data( changing ct_data = lt_data ).
WHEN pa_proc.
lo_report->process_data( EXPORTING it_data = lt_data ).
ENDCASE.
ENDFORM. "start_of_selection
FORM get_data CHANGING PT_DATA TYPE gty_tab_data.
select
matnr,
ernam,
ersda
from mara into CORRESPONDING FIELDS OF table @pt_data UP TO 500 ROWS
where matnr in @so_matnr
.
ENDFORM.
FORM get_data_static_list CHANGING PT_DATA TYPE gty_tab_data.
select
matnr,
ernam,
ersda
*[enhancement-spot here would be nice, but is not possibel ]
from mara into CORRESPONDING FIELDS OF table @pt_data UP TO 500 ROWS
where matnr in @so_matnr
.
ENDFORM.
FORM get_data_eh_sect CHANGING PT_DATA TYPE gty_tab_data.
ENHANCEMENT-SECTION ZZ_JRE_SELECT_ENAHNCE_SEL1 SPOTS ZZ_JRE_SELECT_ENAHNCE_SEL .
select
matnr,
ernam,
ersda
from mara into CORRESPONDING FIELDS OF table @pt_data UP TO 500 ROWS
where matnr in @so_matnr
.
END-ENHANCEMENT-SECTION.
ENDFORM.
FORM get_data_dynamic_list_enhp CHANGING PT_DATA TYPE gty_tab_data.
data lt_fields type table of string.
lt_fields = value #(
( ` MATNR ,`)
( ` ERNAM ,`)
( ` ERSDA `)
).
*ENHACEMENT-Point HERE;
ENHANCEMENT-POINT ZZ_JRE_SELECT_ENAHNCE_SEL2 SPOTS ZZ_JRE_SELECT_ENAHNCE_SEL .
*ADD:
* ,
* [yourFild_1],
*....
*[yourfild_D]
select
(lt_fields)
from mara into CORRESPONDING FIELDS OF table @pt_data UP TO 500 ROWS
where matnr in @so_matnr
.
ENDFORM.
@AbapCatalog.sqlViewName: 'ZZ_MARA1'
@AbapCatalog.compiler.compareFilter : true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Select from MARA for Demo'
define view zz_jre_sel_mara as select from mara {
matnr,
ernam,
ersda
}
FORM get_data_from_cds CHANGING PT_DATA TYPE gty_tab_data.
select
*
from zz_jre_sel_mara into CORRESPONDING FIELDS OF table @pt_data UP TO 500 ROWS
where matnr in @so_matnr
.
ENDFORM.
@AbapCatalog.sqlViewAppendName: 'ZZ_MARA11'
@EndUserText.label: 'Extending zz_jre_sel_mara 1'
extend view zz_jre_sel_mara with zz_jre_sel_mara_ext1 {
mara.meins
// mara.[yy_yourfield_1]
// mara.[yy_yourfield_2]
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |