Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem in error validation in table maintenance generator events

Former Member
0 Likes
8,968

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
5,213

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.

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.

13 REPLIES 13
Read only

RaymondGiuseppi
Active Contributor
0 Likes
5,213

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.

  • Which kind of check do you perform, is it possible to implement it with some foreign key relation, check table?
  • Nevertheless you could try to trick the system, send the message a 'S'uccess message, but use DISPLAY LIKE 'E'rror message, and set sy-subrc to some not initial value like 4 so data shouldn't be updated.
  • A more tricky solution, would be usage of implicit enhancement point at end of form set_update_flag of include LSVIMIXX using the function group of the maintenance dialog as main program.

Regards,

Raymond

Read only

0 Likes
5,213

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.

Read only

0 Likes
5,213

You may look for other solution, start from analyzis of the generated dynpro PAI logic (e.g. debug )

Read only

0 Likes
5,213

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)

Read only

Former Member
0 Likes
5,213

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,

Read only

0 Likes
5,213

EXIT in the form will just exit the user exit procedure, it has no impact on the dialog, it won't stop the save.

Read only

Former Member
0 Likes
5,214

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.

Read only

0 Likes
5,213

I see that you used VIM_ABORT_SAVING = 'X', which is the important information!

Read only

0 Likes
5,213

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.

Read only

0 Likes
5,213

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).

Read only

Former Member
0 Likes
5,213

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

Read only

0 Likes
5,213

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!

Read only

0 Likes
5,213

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