2016 Jul 07 9:07 AM
Hi folks,
I am using Event 01 (Before saving data) to validate and trigger error message.
But once the message is triggered, it not staying the current editing screen in table maintenance.
Instead it showing a blank screen with error message. Once I press enter, going back to initial screen of table maintenance.
How to make the screen to stay there while triggering error message in Event 01.
Please suggest..
Thanks in advance,
Santosh.
2016 Jul 07 1:39 PM
It works fine for me with event 01 and below is the source code. FORM validate_entry. TABLES: tkkh1. DATA: lw_zrtr_matkl_hrkft TYPE zrtr_matkl_hrkft. LOOP AT total. CLEAR lw_zrtr_matkl_hrkft. IF IS ASSIGNED. MOVE-CORRESPONDING TO lw_zrtr_matkl_hrkft. ENDIF. IF NE 'D' AND IS NOT INITIAL AND NE 'X' AND NE 'Y'. *Material group is blank system not validating IF lw_zrtr_matkl_hrkft-matkl IS INITIAL. MESSAGE ID 'MM' TYPE 'S' NUMBER '086' WITH '' DISPLAY LIKE 'E'. vim_abort_saving = 'X'. EXIT. ENDIF. *Origin group validation SELECT SINGLE * FROM tkkh1 WHERE hrkft = lw_zrtr_matkl_hrkft-hrkft. IF sy-subrc NE 0. MESSAGE ID '00' TYPE 'S' NUMBER '058' WITH lw_zrtr_matkl_hrkft-hrkft '' '' 'TKKH1' DISPLAY LIKE 'E'. vim_abort_saving = 'X'. EXIT. ENDIF. ENDIF. ENDLOOP. ENDFORM.
2016 Jul 07 9:21 AM
Well read Event 01: Before Saving the Data in the Database, this event is not provided for check but to trigger some other update or hidden field filling.
Regards,
Raymond
2016 Jul 07 9:45 AM
Hi Raymond Giuseppi,
Thanks for the reply. Actually we are comparing two fields on the table maintenance screen.
If they have same value, need to throw error.
I have tried your first option of showing it as Success type Error message, but its not working.
Do we have any other alternatives, or do we have to try the enhancement implementation you suggested?
Thanks,
Santosh.
2016 Jul 07 9:50 AM
2016 Jul 07 1:09 PM
The only event triggered during the LOOP AT control in the PAI, is the event 21 fill hidden fields. Though, it's not planned for triggering error messages, but it does the trick. Otherwise, you should modify the generated dynpro to add your own code... (it will be lost if you regenerate the dialog)
2016 Jul 07 10:04 AM
Hi,
I am using the event '01' to validate the entry and used the message "Message id ' ' type 'S' number ' ' display like 'E'.
EXIT.
It works fine for me and it will stay in the same screen with all fields are editable mode. Have you added "EXIT" after message?
Regards,
2016 Jul 07 1:05 PM
EXIT in the form will just exit the user exit procedure, it has no impact on the dialog, it won't stop the save.
2016 Jul 07 1:39 PM
It works fine for me with event 01 and below is the source code. FORM validate_entry. TABLES: tkkh1. DATA: lw_zrtr_matkl_hrkft TYPE zrtr_matkl_hrkft. LOOP AT total. CLEAR lw_zrtr_matkl_hrkft. IF IS ASSIGNED. MOVE-CORRESPONDING TO lw_zrtr_matkl_hrkft. ENDIF. IF NE 'D' AND IS NOT INITIAL AND NE 'X' AND NE 'Y'. *Material group is blank system not validating IF lw_zrtr_matkl_hrkft-matkl IS INITIAL. MESSAGE ID 'MM' TYPE 'S' NUMBER '086' WITH '' DISPLAY LIKE 'E'. vim_abort_saving = 'X'. EXIT. ENDIF. *Origin group validation SELECT SINGLE * FROM tkkh1 WHERE hrkft = lw_zrtr_matkl_hrkft-hrkft. IF sy-subrc NE 0. MESSAGE ID '00' TYPE 'S' NUMBER '058' WITH lw_zrtr_matkl_hrkft-hrkft '' '' 'TKKH1' DISPLAY LIKE 'E'. vim_abort_saving = 'X'. EXIT. ENDIF. ENDIF. ENDLOOP. ENDFORM.
2016 Jul 07 2:29 PM
I see that you used VIM_ABORT_SAVING = 'X', which is the important information!
2016 Jul 08 4:53 AM
Thanks Athimoolam, it worked.
I have tried earlier with VIM_ABORT_SAVING parameter but the usage of EXIT command after it worked for me. Thanks.
Santosh.
2016 Jul 08 7:17 AM
Know what? I just did it without EXIT, and that's incredible it works too! (form for event 01;of course it's just for the demo, as this code always prevents from saving):
FORM event_01.
MESSAGE 'there is an error'(001) type 'S' display like 'E'.
vim_abort_saving = 'X'.
ENDFORM.
EXIT is just for leaving the form sooner (moreover, it's usage should be limited to leave a loop; instead RETURN should be used; as recommended by SAP).
2016 Jul 08 7:23 AM
Hi Santosh,
Thanks. Also note if you want to validate the individual entry when user entered you can use the event 21 with similar code (but slightly different - refer attached code). This will validate every time when user press enter key.
Regards,
Athi
2016 Jul 08 7:32 AM
Arghhh you kill me. Why do you say "press save button the invalid data will get saved because event 01 will not trigger during save"? event 01 is always triggered when you save!
2016 Jul 08 7:38 AM
Hi,
I have edited my message pls read above. I was about to tell Santhosh to use event 21 as well along with event 01 to through error immediately when user enters the value.
Regards,
Athi
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |