Application Development 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: 

validations on fields

Former Member
0 Kudos

Hi  Experts,

If i use chain endchain all the fields which i put Under chain-endchain are in enable mode.  if i use FIELD---MODULE it validates first field and shows error .after correcting it it goes for second error field . If i want all the error fields only in editable(i.e AT A TIME) .and remaing fields in  noneditable MODE.

1 ACCEPTED SOLUTION

former_member424229
Participant
0 Kudos

Hai Rajendra,

   Please put the statement 'chain...endchain' in comment and try then you get the exact error fields.

17 REPLIES 17

sivaganesh_krishnan
Contributor
0 Kudos

hi rajendra ,

write the error using message .

write as

MESSAGE ' error' type 'E'.

Regards,

siva

former_member187748
Active Contributor
0 Kudos

Hi Rajendra,

please clarify your questions, and tell me what is your requirement exactly ?

0 Kudos

Hi sanjeev I only want  all the error fields to be in editable mode (i.e AT a time) and remaining fields in non editable mode.

Former Member
0 Kudos

Hi Rajendra,

let me clarify you the functioning of error messages in ABAP. at any point you are trying to populate an error message, the system stops the execution and throws te error to UI.

in your requirement it works like, if there are 2 errors in your values, at 1st error point the system stops execution and throws it. after correcting it it goes to 2nd one.

I would like to know what you are expecting from the screen in case of 2 errors.

Remember one error is nothing but an error message.

Regards,

Bhaskar

0 Kudos

Thanks baskar as i am new to abap i don't know much may be the question looks silly to you.as  you said if error message comes program flow stops there itself.so is there any other alternative for this(IF I GOT TWO ERRORS ONLY THAT BOTH ERRORS SHOULD BE IN EDITABLE MODE AND THE REMAINING ALL FIELDS IN NON EDITABLE MODE )..is this requirement possible.means atleast without error message but data should not inserted into database without validating all fields.

0 Kudos

Hi Rajendra,

This looks silly but little complicated issue you are facing.

First we need to display error message to the screen all at once like a popup.

make the error fields as editable.

we can achieve 1st one by using message display as popup using any one of below FMs

POPUP_DISPLAY_TEXT

POPUP_TO_DISPLAY_TEXT

OIRC_MR_ERROR_POPUP_WITH_TAB

select any one which suits to you and to your user.

2) keep all fields in chain end chain statement.

maintain one error flag for each field. mark this flag if the corresponding field is errored one.

make a module in the chain end chain statement which has to be executed in last.

in that module, loop at the screen and make the corresponding fields as editable. we already have the error marked flags ready right. based on those we can make the fields editable.

Try this it may work. Let us know if you find any issues.

Thanks and Regards,

bhaskar

0 Kudos

hi rajendra,

The standard flow is like , showing error messages one by one.. you can use chain endchain .. it is a good option .

It will make sure that user enters correct value also it highlights the particular field which has error.

as this error gets complete , the focus goes to next error.

0 Kudos

Dear Rajendra,

Check this demo program ... DEMO_DYNPRO_FIELD_CHAIN..

If you want the error fields in editable mode and all other in non editable mode ... put the fields in the chain.... end chain ...The fields in the chain ....end chain. will be in editable mode by making all others in non editable mode ... you will better understand by checking the above mentioned program ..

I hope it will help you ..

Regards

Shravan

former_member184569
Active Contributor
0 Kudos

I guess the hint to your answer is there in your question itself.

All the fields that are between chain and endchain will be editable mode.

If you want only one error field to be editable at a time, just do not put any chain endchain statements.

process after input.

   field fld1 module mod1.
   field fld2 module mod2.
   field fld3 module mod3.

Former Member
0 Kudos

One way is to put all the fields required for error in a chain endhain and the others outside/after the endchain.This ensures that if error is encountered all the fields inside the chain ebdchain is editable and others outside non-editable.

Example

CHAIN.

FIELD VBELN. MODULE M_CHECK_VBELN.

FIELD AUART. MODULE M_CHECK_AUART.

ENDCHAIN.

FIELD VBAK-VBTYP. MODULE M_CHECK_VBTYP.

Here , if M_CHECK_VBELN has an error message then field VBELN and AUART is editable but VBTYP is not.

Hope it Helps.


0 Kudos

Thanks Edamana for the reply but i only want error fields should be in editable others in  non editable mode.as we can't judge in which fields we got error before to put the fields in chain-endchain i think now you understand my requirement.plz provide solution  for this .

                     

                                                                                                           Thankyou,

0 Kudos

Hii Rajendra,

If you only want error field in editable mode then don't use chain and endchain processing chain.

Just validate the field individually like below,

FIELD carrid MODULE validate_carrid.

FIELD connid MODULE validate_connid.

FIELD fldate MODULE validate_fldate.

MODULE validate_carrid.

     IF carrid IS INITAIL.

          SET CURSOR FIELD 'CARRID'.

          MESSAGE 'Enter the flight carrier name' TYPE 'E'.

     ELSE.

          SELECT SINGLE COUNT(*)          "For checking the correctness of carrid

               FROM SFLIGHT    

               WHERE CARRID EQ carrid.

               IF sy-subrc NE 0.

                    MESSAGE 'Carrid is not not valid' TYPE 'E'.

               ENDIF.

     ENDIF.

ENDMODULE.

Proceed like this for other fields too.

So if any error occurred in field carrid then only this field will be in editable mode and others like connid and fldate will be in non editable mode.

For testing purpose you can also try with the conditional module call by adding ON INPUT / ON REQUEST to a module like below.

FIELD carrid MODULE validate_carrid ON INPUT.

This module will trigger only when the user enter non initail value. for example CARRID datatype is character and the default / initail value of character is space so when user enter any value to this field this module will be envoked .other wise this will not trigger.If you will hit enter without entering any value then also this module will not trigger because by default it's initial value is space.

In case of ON REQUEST the module will be trigger only when user enter some value to the field.

For complete conditional module call follow this link

Conditional Module Calls (SAP Library - ABAP Programming (BC-ABA))

regards

Syed

0 Kudos

At any point of time,irrespective of the number of fields,error will be displayed for one field at a time,I believe this is your requirement.

Although I am not sure if this is a misuse of the chain..endchain command...but if you put every field in a chain endchain...it will satisfy your requirement
Chain. field field1 module1.endchain.

Chain. field field2 module2.endchain.

former_member424229
Participant
0 Kudos

Hai Rajendra,

   Please put the statement 'chain...endchain' in comment and try then you get the exact error fields.

Former Member
0 Kudos

Hi Rajendra,

According to my knowledge, field validations doesn't take place all together.It will be validated one by one and whenever an error occurs the corresponding message will be shown in the screen, ie. the execution stops after displaying  the error message.

For example , suppose you have 3 fields and you are entering wrong values in 1st and 3rd field. During the execution the validation code for 1st field works and error will be thrown and hence the execution has stopped, validation code for 2nd and 3rd field will not get executed. Now assume that you have corrected the 1st field value and trying to run it again and in this case the execution stops with the validation of 3rd field.

So I don't think it is not possible to do a validation as you specified in your requirement. If you find any alternatives please share with us.

Regards,

Anoop

raymond_giuseppi
Active Contributor
0 Kudos

Put your control in two blocks:


PROCESS AFTER INPUT.
   " only one field input-allowed
   FIELD field1 MODULE check_field1 ON INPUT. " standalone check
   FIELD field2 MODULE check_field2 ON INPUT. " standalone check
   " both fields input-allowed
   CHAIN.
     FIELD field1.
     FIELD field2.
     MODULE check_both_field ON CHAIN-INPUT. " both fields checked
   ENDCHAIN.

Regards,

Raymond

Former Member
0 Kudos

Hi

You cant give it in chain end chain if you have make the other fields in disable mode. The option is u can give seperate validation and make the screen and editable and non editable using loop at screen.

Warm Regards

Suneesh