01-10-2008 10:04 AM
Hi experts,
hw can i validate extension in selection screen.
As i can put only file.txt in select option.
with regards..........
sunny
01-10-2008 10:09 AM
Hi Sunil,
U can split the Filename at '.' and consider the Extension and check it.
SPLIT fname at '.' INTO filename extension.
Filename and extension are character variables here.
Extension contains ur file extension and u can use this for ur validation.
U can validate them on 'AT SELECTION-SCREEN' event.
awrd points if helpful
Bhupal
01-10-2008 10:12 AM
Hi Sunil,
i will send a sample code 4 u check it once ok..
VALIDATIONS CAN BE USED IN "AT SELECTION-SCREEN"
EVENT.
EX:
AT SELECTION-SCREEN.
select single vbeln
from vbak
into vbak-vbeln
where vbeln in s_vbeln.
CODE:
TABLES: VBAK. "COMPULSORY WE HAVE TO MENTION
SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN.
*For Validations
AT SELECTION-SCREEN.
select single vbeln
from vbak
into vbak-vbeln
where vbeln in s_vbeln.
Reward points if helpful
Kiran Kumar.G.A
01-10-2008 10:13 AM
Hi,
Use split command to split the value in the selection screen at '.' , then check the condition in AT SELECTION SCREEN ON FIELD.
Thanks & Regards
Haritha.
01-10-2008 10:18 AM
Hi Sunil,
Bhupal is correct. If we put his words into exact ABAP Syntax then following is the way :-
At Selection-Screen On pFile.
where pFile can be defined as following in the begiining
Parameters: pFile Like rlgrap-filename Obligatory.
Data: lExt(3) Type c,
lFile Like pcfile-path.
Move pFile To lFile.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
COMPLETE_FILENAME = lFile
IMPORTING
EXTENSION = lExt.
Translate lExt to Lower Case.
If sy-subrc ne 0 Or
lExt ne 'csv' .
Message e000 With Text-004. "Display a valid message
EndIf.
Instead of using the SPLIT statement the above function module can also be used to achieve the same. The function will extract the extension in the variable 'lExt'. The above examle checks for a 'csv' extension, the same can be used for any other case by changing the comparing value of extension.