validate data in table maintenace generator event

2
Generated by Jive on 2015-11-26+01:00 1 Validate data in Table Maintenace Generator event The TMG event 01: Before Save., can be used instead of going for event 05: New Entry if you have validation process to do. The problem with event 05 is that, control goes into the include/form only on the newly created entries. So, if you have you had to change any existing data, the control wouldn't pass through the validation code and you will be stuck in awe. Here is a piece of code that you can use for your development purpose. Here, <action> is a flag that will have values as 'N' if a new entry is made or as 'U' if existing entry is modified. <vim_total_struc> is a structure that holds the current looped value on TOTAL table. it_total_zdata, internal table should be of type table z-table. LOOP AT total. IF <action> EQ 'N' OR <action> EQ 'U'. APPEND <vim_total_struc> TO it_total_zdata. ENDIF. ENDLOOP. IF it_total_zdata[] IS NOT INITIAL. * Perform validation LOOP AT it_total_zdata. IF it_total_zdata-name NE 'TESTNAME'. MESSAGE 'Name is not TESTNAME' TYPE 'S' DISPLAY LIKE 'E'. vim_abort_saving = c_abrt_save. sy-subrc = 4. EXIT. ENDIF. ENDLOOP. ENDIF. IMPORTANT POINTS !! Message should be of type 'S'. If not, the screen returns to SM30, which looks bad !! Make sure its displayed either as 'Error' or 'Warning'. vim_abort_saving has to be set to 'X' to avoid data being saved. (Since the message popped is of type 'S', control proceeds further!!) Set sy-subrc as '4' which stops further processing.

Upload: vbak24

Post on 29-Jan-2016

61 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Validate Data in Table Maintenace Generator Event

Generated by Jive on 2015-11-26+01:001

Validate data in Table Maintenace Generatorevent

The TMG event 01: Before Save., can be used instead of going for event 05: New Entry if you have validation

process to do.

The problem with event 05 is that, control goes into the include/form only on the newly created entries. So, if

you have you had to change any existing data, the control wouldn't pass through the validation code and you

will be stuck in awe.

Here is a piece of code that you can use for your development purpose.

Here,• <action> is a flag that will have values as 'N' if a new entry is made or as 'U' if existing entry is

modified.• <vim_total_struc> is a structure that holds the current looped value on TOTAL table.• it_total_zdata, internal table should be of type table z-table.

LOOP AT total.

IF <action> EQ 'N' OR <action> EQ 'U'.

APPEND <vim_total_struc> TO it_total_zdata.

ENDIF.

ENDLOOP.

IF it_total_zdata[] IS NOT INITIAL.

* Perform validation

LOOP AT it_total_zdata.

IF it_total_zdata-name NE 'TESTNAME'. MESSAGE 'Name is not TESTNAME' TYPE 'S' DISPLAY LIKE 'E'.

vim_abort_saving = c_abrt_save.

sy-subrc = 4.

EXIT.

ENDIF. ENDLOOP.

ENDIF.

IMPORTANT POINTS !!• Message should be of type 'S'. If not, the screen returns to SM30, which looks bad !! Make sure its

displayed either as 'Error' or 'Warning'.• vim_abort_saving has to be set to 'X' to avoid data being saved. (Since the message popped is of

type 'S', control proceeds further!!)• Set sy-subrc as '4' which stops further processing.

Page 2: Validate Data in Table Maintenace Generator Event

Validate data in Table Maintenace Generator event

Generated by Jive on 2015-11-26+01:002

The above points are mandatory, if you want a message to be popped and wrong data still to be seen giving an

opportunity to the user to rectify.