Vous êtes sur la page 1sur 7

Want to validate field in Table...

vamshi g 26 posts since Sep 22, 2010


Want to validate field in Table Maintenance Generator Events Dec 6, 2010 10:15 AM
Hi:

While maintaining entries in custom table through SM30, I want to check if couple fields(they are not part of
primary keys) has any value. If user has not entered any value in them then I have to show them a message
and doesn't allow to save. I tried below methods to achieve it.

1. I used Event 05 and gave an error message if the field values are empty. The problem is that the fields
got greyed out and doesn't allow to input any value.
2. I used combination of events 21 and 01 (with the same code in both of them). In both the events I am
checking if field values are initial, then I am giving information message and before the information message
I am setting VIM_ABORT_SAVING = 'X'. The problem is that the entry is getting saved though the the fields I
am checking for are empty.

I want to show the user an E or I or S message (which ever is suitable in this scenario) if couple of fields are
empty and not allow them to save and also allow them to enter some value in those fields with out getting them
greyed out.

Is there any better way to achieve it other than the ones I tried above?

Thanks.
Tags: abap

Raghavender Momula 311 posts since Feb 2, 2009


Re: Want to validate field in Table Maintenance Generator Events Dec 6, 2010 10:22 AM
Hi

Use the event '01'.

Regards,
Raghu.

vamshi g 26 posts since Sep 22, 2010


Re: Want to validate field in Table Maintenance Generator Events Dec 6, 2010 10:33 AM
Hi,

Generated by Jive on 2016-01-27+01:00


1
Want to validate field in Table...

I tried following code in EVENT01 but the fields with empty data is getting is saved.

form field_validation.
if ztest-saknr is initial.
vim_abort_saving = 'X'.
message i003(zmessage).
endform.

Thanks.

Praveen Kumar 384 posts since Jun 30, 2006


Re: Want to validate field in Table Maintenance Generator Events Dec 6, 2010 10:41 AM
HI,

If you set vim_abort_saving = 'X' then the record wont save in the table.

Regards
Praveen

vamshi g 26 posts since Sep 22, 2010


Re: Want to validate field in Table Maintenance Generator Events Dec 6, 2010 10:49 AM
Hi Praveen,

Unfortunatley the entry is getting saved. Am I missing anything here. Am I using the wrong event?

Shiva Tirumalasetty 1,083 posts since Jul 13, 2006


Re: Want to validate field in Table Maintenance Generator Events Dec 6, 2010 11:26 AM
Hi,
Use the event -01 - Before save and also 05-Create new entry.
If you dont want the user to save entries, use an Error message so that the record will not be saved in case of
validation failure.

Thanks,
Shiva

vamshi g 26 posts since Sep 22, 2010


Re: Want to validate field in Table Maintenance Generator Events Dec 6, 2010 1:07 PM
Hi Shiva,

Generated by Jive on 2016-01-27+01:00


2
Want to validate field in Table...

I am giving the error message in EVENT05 if the field value is empty and once the error message is triggered
the field is getting greyed out (since it is not a primary key) and is not allowing to enter any value. I want to give
the user the flexibility to enter the value after the message on the same screen.

Any idea how to do it?

Thanks.

Vijyeta Aharwar 19 posts since Feb 20, 2008


Re: Want to validate field in Table Maintenance Generator Events Dec 7, 2010 10:13 AM
hi,
use information message instead of error message and also write a statement 'STOP' after message.
this will help u.

Regards,
Vijeta

VIJAY SHARMA 3 posts since Dec 30, 2010


Re: Want to validate field in Table Maintenance Generator Events Jan 12, 2011 10:24 AM
Try following code in EVENT05.

form field_validation.
if ztest-saknr is initial.
message e003(zmessage).
LEAVE TO CURRENT TRANSACTION.
endif.
endform.

Darshana Dube 149 posts since Jul 20, 2007


Re: Want to validate field in Table Maintenance Generator Events Jan 12, 2011 11:37 AM
Hi Vamshi,

Go to table maintainance generator then screen flow logic , Then

PROCESS AFTER INPUT.


MODULE liste_exit_command AT EXIT-COMMAND.
MODULE liste_before_loop.
LOOP AT extract.
MODULE liste_init_workarea.
CHAIN.

Generated by Jive on 2016-01-27+01:00


3
Want to validate field in Table...

FIELD zco_objif-zgjahr .
FIELD zco_objif-zperio .
FIELD zco_objif-zwerks .
FIELD zco_objif-zflg_vaprod .
FIELD zco_objif-zflg_vaent .
FIELD zco_objif-zflg_vavente .
FIELD zco_objif-zkostl .
FIELD zco_objif-zvalue .
FIELD zco_objif-zpvstd .
FIELD zco_objif-zpvreel .
FIELD zco_objif-zdivers .
FIELD zco_objif-zaffair .

****Added modules for performing checks and validation.


Enable/disable field depending on check box selected

MODULE change_field ON CHAIN-REQUEST. "Here you can make the fields as editable
Check fields corresponding to check box

MODULE check_fields ON CHAIN-REQUEST. * Check if entry already maintain in table.


MODULE check_entry ON CHAIN-REQUEST.
****Added modules for performing checks and validation.

Regards,
Darshana

Prabhuranjan Kalimuthu 18 posts since Jun 12, 2007


Re: Want to validate field in Table Maintenance Generator Events Dec 8, 2010 6:31 AM
Hi,

Go to the Table Maintenance Generator Function group in SE80.


Go to the Screen flow logic .

Write your Code in PAI event


e.g
PROCESS AFTER INPUT.
MODULE LISTE_EXIT_COMMAND AT EXIT-COMMAND.
MODULE LISTE_BEFORE_LOOP.
LOOP AT EXTRACT.
MODULE LISTE_INIT_WORKAREA.
CHAIN.

Generated by Jive on 2016-01-27+01:00


4
Want to validate field in Table...

FIELD ZTABLENAME-ERDAT .
FIELD ZTABLENAME-ERZET .
FIELD ZTABLENAME-ERNAM .
FIELD ZTABLENAME-AEDAT .
FIELD ZTABLENAME-AEZET .
FIELD ZTABLENAME-AENAM .
MODULE SET_UPDATE_FLAG ON CHAIN-REQUEST.
MODULE UPDATE_TIMESTAMP. " This is my custom Module . write your validation logic with in this
module.
ENDCHAIN.
FIELD VIM_MARKED MODULE LISTE_MARK_CHECKBOX.
CHAIN.
MODULE LISTE_UPDATE_LISTE.
ENDCHAIN.
ENDLOOP.
MODULE LISTE_AFTER_LOOP.

By this way you can achieve your requirement.

Best regards,
Prabhuranjan

vamshi g 26 posts since Sep 22, 2010


Re: Want to validate field in Table Maintenance Generator Events Mar 9, 2011 2:11 AM
I forgot to close the thread. The solution to write logic in PAI worked for me. Thanks for the responses.

prasad balan 9 posts since Nov 26, 2012


Re: Want to validate field in Table Maintenance Generator Events Nov 26, 2012 1:48 AM
Hi Vamshi,

Kindly let me know how to validate the fields in the table control which I created by using table maintenance
generator.

For Example I have 2 fields one is deptno and deptname. I want to validate the Deptname which should not be
blank.The above screens I created via Table Maintenance generator.

Thanks
Prasad

Generated by Jive on 2016-01-27+01:00


5
Want to validate field in Table...

Sourav Sinha 4 posts since Jan 1, 1970


Re: Want to validate field in Table Maintenance Generator Events Jan 14, 2011 1:24 PM
Hi
Just use the Event 21

VINAYAKA SANGAPALLAR JAYAPPA 118 posts since Jan 16, 2007


Re: Want to validate field in Table Maintenance Generator Events Jan 24, 2011 3:01 PM
Hi Vamshi,

In order to make the input Ready, the thumb rule in ABAP screen programming is writing the code in Chain and
Endchain.

so in the Function Group in the table maintenance generator screen, write the logic of your validation by
creating modules for the corresponding fields.

Thanks,
Vinayaka SJ

Deepthi Kancharthi 11 posts since Jan 25, 2011


Re: Want to validate field in Table Maintenance Generator Events Jan 28, 2011 11:37 AM
VIM_ABORT_SAVING has to work . Make sure you are setting this at the right place. You could also try
setting sy-subrc explcitly.

if condition not satisfied.


message S(000) with 'Enter values for field xxx'.
VIM_ABORT_SAVING = 'X'.
sy-subrc = 4.
EXIT.
endif.

Regards,
Deepthi

Antnio Freitas 27 posts since Dec 10, 2009


Re: Want to validate field in Table Maintenance Generator Events Mar 30, 2011 1:25 PM
I managed to use event 01 and stay in screen with an error message.
This worked for me:

Generated by Jive on 2016-01-27+01:00


6
Want to validate field in Table...

MESSAGE S000(XXX) DISPLAY LIKE 'E'. vim_abort_saving = 'X'.

Regards,

Generated by Jive on 2016-01-27+01:00


7

Vous aimerez peut-être aussi