Hi Abapers,
I have a simple requirement. I have a ztable with TMG created. Now i need to validate 2 fields namely date-from and date-to. If date-to - date-from is greater than 3 years i need to throw an error and block that record to get saved in the database. For that i have created an include in event 01 (before saving the data to database) with f_validate_entry and inside that i have written the below code. Now my issue is that not only its not working but TMG while entering data its going in a dump. I am sharing my complete code so that someone could help me where i am going wrong.
FORM CREATE_ENTRY .
DATA: IT_ZDATA TYPE STANDARD TABLE OF ZVEH_REG_CERTF,
LW_ZDATA TYPE ZVEH_REG_CERTF.
DATA: lv_date TYPE i.
LOOP AT TOTAL.
IF <ACTION> EQ 'N' OR <ACTION> EQ 'U'.
APPEND <VIM_TOTAL_STRUC> TO IT_ZDATA.
ENDIF.
ENDLOOP.
IF IT_ZDATA[] IS NOT INITIAL.
* Perform validation
LOOP AT IT_ZDATA INTO LW_ZDATA.
LV_DATE = LW_ZDATA-VALID_TO - LW_ZDATA-VALID_FROM.
IF LV_DATE > 1095.
MESSAGE 'Check the Validity period date range' TYPE 'S' DISPLAY LIKE 'E'.
VIM_ABORT_SAVING = 'X'.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " CREATE_ENTRY