cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP - input data validation

Former Member
0 Kudos

I have been trying to look through the forum for means of input data validation to no vail. It is necessary to validate data before saving in database. There is an interface IF_WD_VALIDATION out there which seems to handle this task but no more information is provided on how to use it. Does anyone know more about it?

By validation, I mean verification of:

data type

data value (min value, max value)

data dependence (a<b, or a>b)

....

Your suggestion is appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

thomas_szcs
Active Contributor
0 Kudos

Hi Fred,

Type validation is done by the Web Dynpro runtime automatically. Value and dependency checks need to be done by the application.

Best regards,

Thomas

Answers (1)

Answers (1)

Former Member
0 Kudos

There is more solution to validate fields.

If you import adaptiev RFC model, Dynpro will make validation.

Secend vay is to put validation in setters function and raise exception if is not valide


public void setName(String name)
{
  if(name.length() > 100) throw new Exception("name is to loong");
  this.name = name;

}

or mabie more simpliest is to make boolean function check()

If you want stop workflow in not valide case you can do with


wdComponentAPI.getMessageManager().raiseException("message", true)

Former Member
0 Kudos

Thanks to Thomas and Vedran,

I understand there is no SAP-built class to do validation but rather need me to write code in WDDOBEFOREACTION myself.

I can use message manager to raise error message in case the input data doesn't conform to my logic. Right?

Message was edited by: Fred Zhou

Former Member
0 Kudos

Right.

And you can try play with Dictionary (in Web Dynpro Explorer, no database) and bind Structures to context. I think it is the best way but, unfortunatly I never have a time to investigate that part.

thomas_szcs
Active Contributor
0 Kudos

>I understand there is no SAP-built class to do

>validation but rather need me to write code in

>WDDOBEFOREACTION myself.

>

>I can use message manager to raise error message in case

>the input data doesn't conform to my logic. Right?

Yes. Please be aware that raising an error message in wdDoBeforeAction will prevent a validating action from being called - which is the same as if the error message came from the framework itself.

Best regards,

Thomas