Date Validation using dyn_val_read Function module
METHOD if_ex_ftr_tr_time~get_time.
break abap07.
DATA :
t_dynfields TYPE STANDARD TABLE OF dynpread,
s_dynfields TYPE dynpread,
lv_diff type i,
lv_date type string,
lv_start type sy-datum,
lv_end type sy-datum.
*
data:
lv_dynname type D020S-PROG.
lv_dynname = 'SAPLTM00'.
s_dynfields-fieldname = 'VTMFHAZU-XBLFZ'.
APPEND s_dynfields TO t_dynfields.
s_dynfields-fieldname = 'VTMFHAZU-XELFZ'.
APPEND s_dynfields TO t_dynfields.
IF sy-dynnr EQ '0011'.
**
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = lv_dynname
dynumb = sy-dynnr
TABLES
dynpfields = t_dynfields
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 eq 0.
* Implement suitable error handling here
read table t_dynfields into s_dynfields index 2.
if sy-subrc eq 0.
CONCATENATE s_dynfields-fieldvalue+6(4) s_dynfields-fieldvalue+3(2) s_dynfields-fieldvalue+0(2)
into lv_date.
CONDENSE lv_date.
lv_end = lv_date.
endif.
read table t_dynfields into s_dynfields index 1.
if sy-subrc eq 0.
clear lv_date.
CONCATENATE s_dynfields-fieldvalue+6(4) s_dynfields-fieldvalue+3(2) s_dynfields-fieldvalue+0(2)
into lv_date.
CONDENSE lv_date.
lv_start = lv_date.
endif.
if lv_end is not initial and lv_start is not INITIAL.
lv_diff = lv_end - lv_start.
endif.
if lv_diff GT 29.
MESSAGE E057(ZFI).
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
No comments:
Post a Comment