Skip to Content

How to validate only new entries from tmg.

hi abapers,

I have a ztable. I have also created table maintenance for single screen. Now i want to validate new entries from tmg before them getting saved in the table. I have 2 date fields as valid-from and valid-to. If the difference between them is more than 1 year then system should throw an error message to correct the date fields and should not save that record. I have written code on 01 & 05 events as well as in screen pai but none of them is working. Can someone plz provide me the solution to resolve this issue.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 14, 2017 at 04:42 PM

    Hi Sandra,

    Below is the code which i used in 01 & 05 events of TMG.

    ***INCLUDE LZVEH_INSURANCEF01 .

    FORM F_VALIDATE_ENTRY.

    DATA: IT_ZDATA TYPE STANDARD TABLE OF ZVEH_INSURANCE,
    LW_ZDATA TYPE ZVEH_INSURANCE.
    DATA: LV_DATE TYPE I.

    LOOP AT TOTAL.

    IF <ACTION> EQ 'N' OR <ACTION> EQ 'U'.
    IF <VIM_TOTAL_STRUC> IS ASSIGNED.
    MOVE-CORRESPONDING <VIM_TOTAL_STRUC> TO LW_ZDATA.
    ENDIF.
    ENDIF.

    *** Perform validation

    LV_DATE = LW_ZDATA-VALID_TO - LW_ZDATA-VALID_FROM.

    IF LV_DATE > 365.

    MESSAGE 'Check the Validity period date range' TYPE 'S' DISPLAY LIKE 'E'.
    VIM_ABORT_SAVING = 'X'.
    EXIT.

    ENDIF.

    ENDLOOP.

    ENDFORM. "F_VALIDATE_ENTRY.

    In PAI of the TMG screen i have created a new module as check_entry and placed it under the date fields in chain and endchain. Here is that code.

    DATA: LV_DATE TYPE I.

    LV_DATE = ZVEH_INSURANCE-VALID_TO - ZVEH_INSURANCE-VALID_FROM.

    IF LV_DATE > 365.

    MESSAGE 'Check the Validity period date range' TYPE 'S' DISPLAY LIKE 'E'.
    VIM_ABORT_SAVING = 'X'.
    EXIT.

    ENDIF.

    Note: my validation code should work only for new entries from present date entry. It should not check previous entries which were added from tmg and already present in table.

    Add comment
    10|10000 characters needed characters exceeded