02-25-2010 6:59 PM
Hello there ABAP'ers.
I have got a question haw to validate selection screen field.
In the selection-screen I have got two fields:
F_DATAELEMENT (Type: FIELDNAME)
F_VALUE (Type: CHAR60)
I have got a SearchHelp attached to the F_DATAELEMENT. SHelp list shows list of ADRC table fields. I obtain it using module
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = 'ADRC'
TABLES
dfies_tab = it_dfies
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3 .
where it_dfies contains detailed information about fields (datatype, control table ...)
And now my question is it possible to validate the selection screen field F_VALUE with data taken from DDIF_FIELDINFO_GET FModue?
I mean such example:
User choses a CITY_CODE value in F_DATAELEMENT field
Now I would like the F_VALUE field to be validated respecting the ADRCITY control table (CITY_CODE has got a ADRCITY control table assigned - such info I am getting from the DDIF_FIELDINFO_GET FModule)
I will be thankful for suggestions.
Greetings,
P.
02-26-2010 4:15 AM
Hi Piotr,
After passing a Value to F_VAL, now you have the Control Table which is Top most in the Heirarchy which must have the data then only other Child tables can have a relavent Value. You are obsolutely correct.
Select Single from the Control Table will work for you.
Hence you can Validate the Entry of the F_VAL field.
For Ex.
I passed SPFLI to the FM and got the data and found SCARR as the control table for CARRID field.
now if i pass 'XX' into F_VAL field this can be validated against the table SCARR.
data ; var type spflic-carrid " declare this
data : str type string.
at selection-screen. " Use this Event
select single carrid from SCARR into var where carrid = f_val.
if sy-subrc NE 0.
concatenate 'Air Line ID' f_val 'Not maintained in Control Table' into str separated by space.
MESSAGE str type 'E'
endif.
Cheerz
Ram
02-26-2010 9:39 PM
Thank you Ramchander Krishnamraju it is solving my problem but I would like to take an opportunity to continue the topic
What if I would like to validate field regarding its format?
For example ADRC table contains DATE_TO field which lies in DATUM domain.
So now how to check when User choses a DATE_TO value in F_DATAELEMENT field if F_VALUE is of a proper format? I mean situation that user enters a string value into F_VALUE field - such situation should not be permitted.
Is there some FModule or other convenience? Or do I must to check it manually by investigating the F_VALUE field string content?
Regards,
P.
02-26-2010 10:42 PM
use the below FM for date validation
SFCS_FA_PARAMETER_SET
Edited by: subas Bose on Feb 26, 2010 11:42 PM
02-27-2010 3:00 AM
Hi,
Use DESCRIBE key word which give you back the data type of the field
DATA : matnr TYPE matnr,
date TYPE sy-datum.
DATA : type1, type2.
DESCRIBE FIELD matnr TYPE type1.
DESCRIBE FIELD date TYPE type2.
"Take F1 help which give the actual meaning returned by the type1 in above code.
for Ex if type1 = C then it is Char type or Basic ABAP data type C
if type1 = D then it is Elementary type D Etc.
This info is in Key word Documentation Take F1 Help on DESCRIBE FIELD key word
IF sy-subrc = 0.
ENDIF.
Cheerz
Ram