OK, I have a solution for my needs. Modified your suggestion as follows:
[wpv-filter-start]
[wpv-filter-controls]
<div class="form-group">
<label for="wpv-wpcf-berichtsjahr">[wpml-string context="wpv-views"]Berichtsjahr[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-berichtsjahr" type="select" source="custom" url_param="filter-year" values="[annrep_year option='values']" display_values="[annrep_year option='labels']" ]
</div>
[/wpv-filter-controls]
[wpv-filter-end]
shortcode annrep_year registered with Toolset Views settings.
Script for shortcode annrep_year:
function generate_year_list( $atts ) {
// Get current year
$current_year = date('Y');
// Start year
$start_year = 2022;
// Parse the attributes
$attributes = shortcode_atts( array(
'output' => 'labels',
), $atts );
// Initialize the output string
$output = '';
// Generate the year list
for ( $year = $start_year; $year <= $current_year; $year++ ) {
// For 'labels', include "Please Select," at the beginning
if ( $attributes['output'] === 'labels' && $year == $start_year ) {
$output .= "Please Select,";
}
// Append the year to the output
$output .= $year;
// If not the last year, append a comma
if ( $year < $current_year ) {
$output .= ',';
}
}
// For 'values', prepend a comma at the beginning
if ( $attributes['output'] === 'values' ) {
$output = ',' . $output;
}
return $output;
}
// Add the shortcode to WordPress
add_shortcode( 'annrep_year', 'generate_year_list' );