report ztest_sc_3 no standard page heading.
*Include
include: rmcs0f0m.
*Types & data: For dropdownlist
parameter:
p_file type rlgrap-filename, "file parameter
p_monat type spmon default sy-datum+0(6),
p_week type scal-week,
p_carrid type spfli-carrid default '%',
p_car2 type spfli-carrid default '%'.
*1. Value help for p_file
at selection-screen on value-request for p_file.
*1-1. call File FM
call function 'KD_GET_FILENAME_ON_F4'
exporting
program_name = syst-repid
dynpro_number = syst-dynnr
static = 'X' "field_name = 'c:\'
mask = '*.*'
changing
file_name = p_file
exceptions
mask_too_long = 1
others = 2.
if sy-subrc <> 0.
"value-help error
message 'value-help error' type 'E'.
endif.
*2. Value help for p_monat
at selection-screen on value-request for p_monat.
*2-1. call standard F4-help FM for MONAT
perform monat_f4. "from the include
*3. Value help for p_week
at selection-screen on value-request for p_week.
*3-1. call standard F4-help FM for p_week
perform f4_for_week.
*4. Value help for p_connid,call F4 Help using Internal table
at selection-screen on value-request for p_carrid.
data:
ls_dyn_field type dynpread, "very important
lt_dyn_field type table of dynpread,
lt_spfli type table of spfli.
ls_dyn_field-fieldname = 'P_CARRID'.
append ls_dyn_field to lt_dyn_field. " carrid
*4-1. get the values in the dynpro
call function 'DYNP_VALUES_READ'
exporting
dyname = sy-repid
dynumb = sy-dynnr
tables
dynpfields = lt_dyn_field
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
others = 11.
if sy-subrc <> 0.
write:/ 'error occurs in read_value.'.
leave list-processing.
endif.
read table lt_dyn_field into ls_dyn_field with key fieldname = 'P_CARRID'.
*4-2. get the table-value from BD
select * from spfli into table lt_spfli
where carrid like ls_dyn_field-fieldvalue.
*4-3. form the F4Help
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'CARRID'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_CARRID'
value_org = 'S' "s:structure;default(c):cell by cell
tables
value_tab = lt_spfli
exceptions
parameter_error = 1
no_values_found = 2
others = 3.
*5. Value help for p_connid,call F4 Help using Internal table
at selection-screen on value-request for p_car2.
data:
ls_dyn_field type dynpread, "very important
lt_dyn_field type table of dynpread.
data:
ls_fields type help_value,
lt_fields type table of help_value.
types:
begin of typ_value,
carrid type spfli-carrid,
connid type spfli-connid,
end of typ_value.
data:
ls_value type typ_value,
lt_value type table of typ_value.
*5-1. For the fields and value
ls_fields-tabname = 'SPFLI'.
ls_fields-fieldname = 'CARRID'.
ls_fields-selectflag = 'X'.
append ls_fields to lt_fields.
*5-2. Dynpro
ls_dyn_field-fieldname = 'P_CAR2'.
append ls_dyn_field to lt_dyn_field. " carrid
*5-3. get the values in the dynpro
call function 'DYNP_VALUES_READ'
exporting
dyname = sy-repid
dynumb = sy-dynnr
tables
dynpfields = lt_dyn_field
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
others = 11.
if sy-subrc <> 0.
write:/ 'error occurs in read_value.'.
leave list-processing.
endif.
read table lt_dyn_field into ls_dyn_field with key fieldname = 'P_CAR2'.
*5-4. get the table-value from BD
select carrid connid from spfli into table lt_value
where carrid like ls_dyn_field-fieldvalue.
*5-5. form the F4Help
call function 'HELP_VALUES_GET_WITH_TABLE'
exporting
title_in_values_list = 'carrid-selection'
titel = 'carrid-selection-internal'
importing
select_value = p_car2
tables
fields = lt_fields
valuetab = lt_value
exceptions
field_not_in_ddic = 1
more_then_one_selectfield = 2
no_selectfield = 3
others = 4.
if sy-subrc <> 0.
"do nothing
endif.
*&———————————————————————*
*& Form F4_FOR_WEEK
*&———————————————————————*
* call standard F4-help FM for p_week
*———————————————————————-*
form f4_for_week .
data:
lv_date type d.
*6-1. Get the date
call function 'F4_DATE'
exporting
date_for_first_month = sy-datum
importing
select_date = lv_date
exceptions
calendar_buffer_not_loadable = 1
date_after_range = 2
date_before_range = 3
date_invalid = 4
factory_calendar_not_found = 5
holiday_calendar_not_found = 6
parameter_conflict = 7
others = 8.
if sy-subrc <> 0.
"do nothing
endif.
*6-2. Get the week 返回值是一年中的第几周
call function 'DATE_GET_WEEK'" f4_for_week
exporting
date = lv_date
importing
week = p_week
exceptions
date_invalid = 1
others = 2.
if sy-subrc <> 0.
"do nothing
endif.
endform. "F4_FOR_WEEK
评论