03-26-2008 7:05 PM
How do you alter the selection screen options in CATS_DA? I am using the CATS_REPORT BAdI and implemented a class ZCL_IM_CATS_REPORTING_01 using the interface IF_EX_CATS_REPORTING.
The documentation states that the methods GET_SELECTION_VALUE and SET_SELECTION_VALUE should be used in BEFORE_CATS_DATA_SELECTION, but I have not found any examples.
Points will be rewarded.
03-26-2008 9:03 PM
Hello Brian
Perhaps the following sample implementation gives you an idea how to influence the selection screen of transaction CATS_DA.
BAdI CATS_REPORTING -> implementation ZUS_SDN_CATS_REPORT -> implementing class ZCL_IM_US_SDN_CATS_REPORT -> implemented method IF_EX_CATS_REPORTING~LOAD_OF_PROGRAM :
METHOD if_ex_cats_reporting~load_of_program.
* define local data
** data: ls_fieldsel like line of im_report_manager->gt_modify_selscreen.
DATA: ls_fieldsel TYPE field_selection,
ld_comp(30) TYPE c,
lo_obj TYPE REF TO object.
FIELD-SYMBOLS:
<lt_modify_selscreen> TYPE HASHED TABLE. " of field_selection
"with unique key mfeld.
" NOTE: For a more detailed explanation of the following lines of coding see
" ' Accessing the Inacessible - Local Classes within Global Classes'
" https://wiki.sdn.sap.com/wiki/display/ABAP/Accessing+ _continued
" the+Inacessible+-+Local+Classes+within+Global+Classes
lo_obj ?= im_report_manager. " casting to generic root object !!!
ld_comp = 'GT_MODIFY_SELSCREEN'.
ASSIGN lo_obj->(ld_comp) TO <lt_modify_selscreen>.
CHECK ( <lt_modify_selscreen> IS ASSIGNED ).
" Hide selection field for personnel number
CLEAR: ls_fieldsel.
ls_fieldsel-mfeld = 'PNPPERNR'. " personnel number
ls_fieldsel-visible = abap_false. " -> type-pool: ABAP
INSERT ls_fieldsel INTO TABLE <lt_modify_selscreen>.
" Make selection field for company code mandatory
CLEAR: ls_fieldsel.
ls_fieldsel-mfeld = 'PNPBUKRS'. " company code
ls_fieldsel-visible = abap_true.
ls_fieldsel-required = abap_true.
INSERT ls_fieldsel INTO TABLE <lt_modify_selscreen>.
" Make selection field for cost center read-only
CLEAR: ls_fieldsel.
ls_fieldsel-mfeld = 'PNPKOSTL'. " cost center
ls_fieldsel-visible = abap_true.
ls_fieldsel-readonly = abap_true.
INSERT ls_fieldsel INTO TABLE <lt_modify_selscreen>.
ENDMETHOD.
" NOTE: Definintion of gt_modify_selscreen in include CATS_REPORT_MANAGER:
**
** data: gt_modify_selscreen type hashed table of field_selection
** with unique key mfeld.
* Structure of FIELD_SELECTION:
**MFELD
**VISIBLE
**REQUIRED
**READONLY
Further reading:
[ Accessing the Inacessible - Local Classes within Global Classes|https://wiki.sdn.sap.com/wiki/display/ABAP/AccessingtheInacessible-LocalClasseswithinGlobalClasses]
Regards
Uwe
03-27-2008 7:20 PM
Hi Uwe,
Thank you for the response. The example and link were very helpful...and will be used.
What I am trying to do is make sure that certain selection criteria is always used - i.e. if the user does not enter their personnel ID and/or certain activity types, it will be populated for them when they execute the report. This is more important for a supervisor than it is for someone else who doesn't supervise anyone. Or if the user enters someone else's ID or an incorrect activity type, it will be removed. I already have function modules that will alter a selection parameter when it is passed to modules, but do not know how to gain access to the selection parameter variable.
Thanks,
Brian
03-27-2008 8:59 PM
Hello Brian
I have not found a simple way to manipulate the selection criteria like Personnel Number in field group Selection Criteria.
However, a crude possibility is to implement the following method:
METHOD if_ex_cats_reporting~cats_data_selected.
DELETE ch_cats_data WHERE ( pernr NE '00001000' ).
ENDMETHOD.
Obviously this is not very flexible approach. I would add a CONSTRUCTOR method to the implementing class. Within this CONSTRUCTOR I would call a factory method or factory class which returns an instance of a CATSDB modifying class. Within the factory method you could differentiate based on SY-UNAME (-> get PERNR via infotype 0105).
The method(s) of this class is then used in the interface method shown above.
Much easier is the manipulation of the CATSDB related selection criteria (field group Selection of Time Sheet ).
The following method implementation shows how to select for a specifc activity type:
METHOD if_ex_cats_reporting~start_of_selection.
* define local data
DATA: lr_lstar TYPE RANGE OF catsdb-lstar,
ls_rng like line of lr_lstar.
ls_rng-sign = 'I'.
ls_rng-option = 'EQ'.
ls_rng-low = '1410'.
APPEND ls_rng TO lr_lstar.
CALL METHOD im_dbsel_cats->set_selection_value
EXPORTING
im_fieldname = 'LDBLSTAR'
im_field_value = lr_lstar.
" NOTE: LDBLSTAR is a component of the protected instance attribute
" SELCRIT of CL_DBSEL_CATS.
" All its components can manipulated here.
ENDMETHOD.
If you find a more elegant way to set selection criteria like the personnel number I would appreciate your feedback.
Regards
Uwe
04-14-2008 7:29 PM
Hi Uwe,
The only way I found to access the selection criteria was by doing the following:
method if_ex_cats_reporting~at_selection_screen.
data: lc_stacked_var(50) type c value 'PNPPERNR[]',
lt_pnppernr_opt type range of pernr-pernr,
ls_pnppernr_opt like line of lt_pnppernr_opt.
field-symbols:
<fs_pnppernr> type table.
...
concatenate '(' calling_program ')' lc_stacked_var
into lc_stacked_var.
assign (lc_stacked_var) to <fs_pnppernr>.
lt_pnppernr_opt[] = <fs_pnppernr>.
...
endmethod.
I used an example from another network forum to develop this. If I find a different method, I will post it back here.
Thank you for all of your help,
Brian Basch
05-22-2008 11:00 PM
Hi Brian,
I am trying to update the select option for personnel number field.Could you please let me know whether the following code is working or not?
method if_ex_cats_reporting~at_selection_screen.
data: lc_stacked_var(50) type c value 'PNPPERNR[]',
lt_pnppernr_opt type range of pernr-pernr,
ls_pnppernr_opt like line of lt_pnppernr_opt.
field-symbols:
<fs_pnppernr> type table.
...
concatenate '(' calling_program ')' lc_stacked_var
into lc_stacked_var.
assign (lc_stacked_var) to <fs_pnppernr>.
lt_pnppernr_opt[] = <fs_pnppernr>.
...
endmethod.
Thanks
Vis
05-27-2008 7:26 PM
Hi Vis,
Yes, it is working in our development system and has been tested by the end-users with no problems discovered. I am waiting for approval to move it into QAS and then into our production system.
Thanks,
Brian