Application Development and Automation 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: 
Read only

Comapare the string value in the selection screen

UmaArjunan
Active Participant
0 Likes
1,394

In the selection screen input field

there is an option of selecting the directory and file name and not the extension .

This is used to download the datas

Extension can be selected by using the option button

rtf

csv.

the user has to give only the filename and not the extension.

suppose if the user input is C:\temp\file1.doc.

Either i should take only the filename

or i should display the message give only the filename and not the extension . its already been selected!!!!

I want to compare the input string contains .doc

how to do the comparison and to get the above results mentiond

Thanks

ABAPer

1 ACCEPTED SOLUTION
Read only

former_member156446
Active Contributor
0 Likes
1,206

hi abap dev

generally in this sort of situation ppl generally give a parameter for the extension as well.. and concatenate in the program.. all there parameters and build the file path.....

parameters 1 for path default 'c:/temp/',

parameters 2 for file name default 'filename',

parameters 3 for extension default '.csv'.

concatenate parameter1 parameter2 parameter3 into file-name.

In the selection screen input field

there is an option of selecting the directory and file name and not the extension .

This is used to download the datas

Extension can be selected by using the option button

rtf

csv.

the user has to give only the filename and not the extension.

suppose if the user input is C:\temp\file1.doc.

Either i should take only the filename

or i should display the message give only the filename and not the extension . its already been selected!!!!

I want to compare the input string contains .doc

how to do the comparison and to get the above results mentiond

Thanks

ABAPer

8 REPLIES 8
Read only

Former Member
0 Likes
1,206

Hi,

You can use the following piece of code:

if p_file cs '.doc'.

your code here...

endif.

Regards,

Himanshu

Read only

former_member156446
Active Contributor
0 Likes
1,207

hi abap dev

generally in this sort of situation ppl generally give a parameter for the extension as well.. and concatenate in the program.. all there parameters and build the file path.....

parameters 1 for path default 'c:/temp/',

parameters 2 for file name default 'filename',

parameters 3 for extension default '.csv'.

concatenate parameter1 parameter2 parameter3 into file-name.

Read only

0 Likes
1,206

hi,

I have already done using the method given by you.

Because the requirment is there are two option buttion for selecting the download file format

But unknowingly if the user gives the filename along with the extension. I need to handle that error

giving some error message or information message

By comparing the last 4 letters of the filename.. either.doc or rtf or csv or watever

so how to do that

then after comparing that i should give the user a msg doc type is already selected give only the filename

I hope u understand my req

thanks

Read only

0 Likes
1,206

hmm.. so when ever user gives a extension there will be dot right.. so check for a dot and raise the error..



at selection-screen.

if filename CA '.'.
message text-001. "<<<<< plz dont select the extension of in the path
elseif filename CS '.doc'.
message text-002. "<<<<<file extension .doc is not allowed..
elseif.........
.........
.....
endif.

Read only

0 Likes
1,206

Friend,

I have one more doubt to be clarified in this..

Please help me

we are searching for a dot in the input field.

i.e filename along with the directory.

if the directory name contains any '.' then also it will display the same message.

whether in the directory , do v have any dot as a character in that.

Kiindly clarify this too.

Read only

0 Likes
1,206

hmm thats right.. in real world.. ppl generally use c:/temp as default path...

check out if this is FM is of any help to you..


CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
mask = ',*.txt,*.txt'
static = 'X'
CHANGING
file_name = p_pcfile.

Read only

0 Likes
1,206

ya . i have already using this functiom module to get the f4 help for the filename..

But mask uses only a single character.

i dont know how far it will be helpful for my requirement.

if any other method is there , like to retrieve the last four characters of the file path.

c:\doc\file\filename.rtf

I think then i can comparree. please correct me if i am wriong and suggest some good method also

Read only

0 Likes
1,206

Hi

Call the following function and pass the file name entered in the selection.

CALL FUNCTION 'CRM_IC_WZ_SPLIT_FILE_EXTENSION'

EXPORTING

IV_FILENAME_WITH_EXT = <Your Upload/Download file from selection>

IMPORTING

EV_FILENAME = <Your Upload/Download file without file extension is returned>

EV_EXTENSION = <Your file extension is returned here>.

Do the required comparision and display the error.

Thanks

Vijay