2011 Aug 11 8:47 PM
Hello everyone,
I am creating files with a program that I have created but there is something I can't seem to succeed to fix.
I have a choice of either doing a logical file, a UNIX file or a physical file.
Though, I need to check if the name in the appropriate textbox where the file name is written is something valid. For example... In a physical file, you have to write C:\MyDocuments\SAP\test.csv
But if I write "anything" instead, I would like it to say "Hey! That's not something valid!" Of course, I saw many things that check the existence of files but I don't want to see if the file exists since if it doesn't exist, it will create one. I just want to see if what is written in the textboxs for the logical file name, the UNIX file name and the Physical file name makes sense...
Is there something (or a few things) in SAP that can help me to validate those filenames for the three files types?
Thank you greatly for your help.
Edited by: SBenoit on Aug 11, 2011 9:50 PM
2011 Aug 12 2:59 AM
Hello Benoit,
For local PC file:
I believe SAP will automatically create FILE for you while downloading itself. So, what you can do is you go for the directory validation instead of File (though File existence check is also available). So you better split the input variable at last '/' and then check directory.
C:\MyDocuments\SAP\test.csv ==> Split into lv_dir and lv_file
lv_dir = C:\MyDocuments\SAP
lv_file = test.csv
Then use, CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXIST for checking if lv_dir exist, if yes, proceed to download File.
If it is not existing, use CL_GUI_FRONTEND_SERVICES=>DIRECTORY_CREATE to create it, if you get an error in creation throw error that ' "Hey! That's not something valid!" '.
-
i believe for unix file, Directory can't be created at runtime using ABAP and should pre-exist but the File is automatically created if not existing earlier. So, just use open dataset command and raise an error of invalid path if sy-subrc fails. You can also use function like EPS_GET_DIRECTORY_LISTING to validate a path (after splitting away Filename) if you need a validation firsthand. Other functions in same Fgrp might also interest you.
BR,
Diwakar
Hello everyone,
I am creating files with a program that I have created but there is something I can't seem to succeed to fix.
I have a choice of either doing a logical file, a UNIX file or a physical file.
Though, I need to check if the name in the appropriate textbox where the file name is written is something valid. For example... In a physical file, you have to write C:\MyDocuments\SAP\test.csv
But if I write "anything" instead, I would like it to say "Hey! That's not something valid!" Of course, I saw many things that check the existence of files but I don't want to see if the file exists since if it doesn't exist, it will create one. I just want to see if what is written in the textboxs for the logical file name, the UNIX file name and the Physical file name makes sense...
Is there something (or a few things) in SAP that can help me to validate those filenames for the three files types?
Thank you greatly for your help.
Edited by: SBenoit on Aug 11, 2011 9:50 PM
2011 Aug 12 1:20 AM
Hi,
Sorry, I am not getting your question. Can you please elaborate your problem?
Thanks,
2011 Aug 12 2:59 AM
Hello Benoit,
For local PC file:
I believe SAP will automatically create FILE for you while downloading itself. So, what you can do is you go for the directory validation instead of File (though File existence check is also available). So you better split the input variable at last '/' and then check directory.
C:\MyDocuments\SAP\test.csv ==> Split into lv_dir and lv_file
lv_dir = C:\MyDocuments\SAP
lv_file = test.csv
Then use, CL_GUI_FRONTEND_SERVICES=>DIRECTORY_EXIST for checking if lv_dir exist, if yes, proceed to download File.
If it is not existing, use CL_GUI_FRONTEND_SERVICES=>DIRECTORY_CREATE to create it, if you get an error in creation throw error that ' "Hey! That's not something valid!" '.
-
i believe for unix file, Directory can't be created at runtime using ABAP and should pre-exist but the File is automatically created if not existing earlier. So, just use open dataset command and raise an error of invalid path if sy-subrc fails. You can also use function like EPS_GET_DIRECTORY_LISTING to validate a path (after splitting away Filename) if you need a validation firsthand. Other functions in same Fgrp might also interest you.
BR,
Diwakar
2011 Aug 12 6:58 AM
Hi,
you can create a regular expression to check the input.
Best regards,
Oliver
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |