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: 

hw can validate extension in selection screen

Former Member
0 Kudos

Hi experts,

hw can i validate extension in selection screen.

As i can put only file.txt in select option.

with regards..........

sunny

4 REPLIES 4

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.