How to check if the file already exists in the application server directory
Hi all. I'm on devsuite 10g.
I transfer file from local machine to application server using webutil function webutil_file_transfer.client_to_as and I want to check if the file I'm transfering already exists on the server directory.
How can I make this?
Thanks all,
Fabrizio
use the text_io package and open the file in read-mode.
like this
declare
xFileType text_io.file_type;
begin
xFileType := text_io.fopen('c:\temp\test.txt','R'); --file on the middle tier
-- file exists;
text_io.fclose(xFileType);
exception
when others then
--file doesn't exist
end;
regards
Christian
Similar Messages
-
How to check whether the Application Server directory exits or not
Hi,
I have a selection screen in which I give the Application server file name(UNIX file) as input. Here, I would like to check whether the Server directory exists or not.
Let us say, the path I gave in the selection screen is /usr/sap/tmp/testfile.txt . Here, the file name is testfile.txt and the server directory is /usr/sap/tmp . I would like to check whether this directory /usr/sap/tmp exists in the server or not. I am not bothered about the file name as I am going to write data into the file. I am mainly concerned about whether the directory exists in the server or not. and one more thing... this is the Application Server path not the Local path.
Can anyone help me on the same how to check whether the server directory exists or not.
Thanks in advance.
Best Regards,
Pradeep.Also you can use the FM EPS_GET_DIRECTORY_LISTING for this purpose.
Store the directory name
l_dpath = p_file+0(l_no).
Validate the directory of the application server
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = l_dpath
TABLES
dir_list = l_i_dlist
EXCEPTIONS
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
OTHERS = 8.
If any problem occurs with the directory then display proper
error message
IF sy-subrc <> 0.
Display error message
MESSAGE e018 WITH 'Problem with directory entered'(008).
ENDIF. " sy-subrc <> 0
Regards,
Joy. -
How to check whether the Application Server file has already been opened?
Hi Experts,
I have a query related to Application Server file. I am using multithreading concept to process the data and write it in to a single file.
For example, I have 4 workprocesses. Each workprocess will process the data and whenever it has a record available it will access the file and write it directly.
Problem is the statements that are written in the workprocess is same and I want to check the status whether the file has been opened or not ?
Thanks in advance!!!
Thanks,
Babu KilariDepends on the structure, and whether the data needs to be sorted in some way in the final file.
In any case, I don't think there will be a significant performance difference between using OPEN DATASET again and getting funny with Unix commands.
If you don't need to sort the final file, you can use strings to read, concatenate and write the data even without line-based DO ENDDO loops, this works pretty fast.
I hope we are not talking about GBytes of data
Thomas -
How to check if a file already exists or not
javax.swing.filechooser.FileFilter filter = new FileNameExtensionFilter("CSV Files","csv");
final JFileChooser fileSelect = new JFileChooser();
fileSelect.addChoosableFileFilter(filter);
int action = fileSelect.showSaveDialog(JFrame)
try{
if (action == JFileChooser.CANCEL_OPTION)
return;
else if (action == JFileChooser.APPROVE_OPTION)
SwingUtilities.invokeLater(new Runnable()
public void run()
file = fileSelect.getSelectedFile();
JOptionPane.showMessageDialog(null,file);
if (!file.exists())
JOptionPane.showMessageDialog(null,file.isDirectory());
//fetches the file name from the file name filed in the GUI
final String fileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
if(!fileName.endsWith(".csv"))
//appends the file type to the fetched filename
((BasicFileChooserUI)fileSelect.getUI()).setFileName(fileName + ".csv");
final String newFileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
//replace the oldfile with filename.csv
String csvFile = file.getPath().replace(file.getPath().substring(file.getPath().lastIndexOf('\\') + 1,file.getPath().length()),"");
file = new File(csvFile.concat(newFileName));
if(file.exists())
JOptionPane.showMessageDialog(null,file);
int response = JOptionPane.showConfirmDialog (null,
"Overwrite existing file?","Confirm Overwrite",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.CANCEL_OPTION)
return;
else
try
writeToFile();
catch (IOException e)
e.printStackTrace();
else
try
writeToFile();
catch (IOException e)
e.printStackTrace();
catch(Exception e)
e.printStackTrace();
}Thank u very much
I got the solution for it
if(ae.getActionCommand().equals("Export"))
data= new Vector();
data.addAll(tabData);
javax.swing.filechooser.FileFilter filter = new FileNameExtensionFilter("CSV Files(*.csv)","csv");
final JFileChooser fileSelect = new JFileChooser();
fileSelect.addChoosableFileFilter(filter);
int action = fileSelect.showSaveDialog(MainFrame.getMainFrame());
try{
if (action == JFileChooser.CANCEL_OPTION)
return;
else if (action == JFileChooser.APPROVE_OPTION)
SwingUtilities.invokeLater(new Runnable()
public void run()
file = fileSelect.getSelectedFile();
//fetches the file name from the file name filed in the GUI
final String fileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
if(!fileName.endsWith(".csv"))
//appends the file type to the fetched filename
((BasicFileChooserUI)fileSelect.getUI()).setFileName(fileName + ".csv");
final String newFileName = ((BasicFileChooserUI)fileSelect.getUI()).getFileName();
//replace the oldfile with filename.csv
String csvFile = file.getPath().replace(file.getPath().substring(file.getPath().lastIndexOf('\\') + 1,file.getPath().length()),"");
JOptionPane.showMessageDialog(null,csvFile);
if (csvFile.endsWith("\\" + "\\"))
csvFile = csvFile.concat(fileName.concat("\\"));
file = new File(csvFile.concat(newFileName));
if(file.exists())
int response = JOptionPane.showConfirmDialog (null,
"Overwrite existing file?","Confirm Overwrite",
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE);
if (response == JOptionPane.CANCEL_OPTION)
return;
else
try
writeToFile();
catch (IOException e)
e.printStackTrace();
else
try
writeToFile();
catch (IOException e)
e.printStackTrace();
catch(Exception e)
e.printStackTrace();
Message was edited by:
vijaysforum -
Try to check whether a file already exists on disk by using fileExists
Hy all,
i try to check whether a file already exists on disk in my
Action scirpt.
I found this link about fileExists:
link
So i tried somethink like this in my code, but without
success...
if(fl.fileExists("file:///C|/toto.txt"))
{gotoAndPlay(2);}
else
{gotoAndPlay(3);}
Is it not the right syntax?
Thank you for your help.Did you build and application from the swf with mProjector?
The only
way this and other mProjector functions will get called is to
post
process your swf into and application (exe / app) using
mProjector.
you can get a free trial here
http://www.screentime.com/software/mprojector/demo.html
On 2007-01-08 16:02:42 -0500, "Alexis Schneider"
<[email protected]> said:
John Pattenden
Screentime Media - Flash Tools since 1997
http://www.screentime.com -
How to find out the application server info
Hi, I am wondering how to find out the application server info in Java code, just like how to find out the db platform being used. Thanks
Hi,
I am not aware of any spec defined way of finding out such info. There may be vendor specific APIs or mechanisms.
But you can use environment entries in your deployment descriptors to specify the information and make use of the entries inside your j2ee component. That will make your code platform neutral.
Sahoo -
How to run a "exe" file that is residing in application server.
Hi,
I have a requirement in which a .exe (Windows executive) file needs to be run through code, which is residing in the application server. That exe file is nothing but a pdf-excel converter that will convert a pdf file to excel. The corresponding pdf file is also in the application server. Is there any function module to make this happen? I have come across the FM GUI_EXEC, but it operates on exe and pdf files that are in the presentation server.HI Anirban
SM49 /SM69 might be of help
Could you please look into the link below.
Re: sm49/sm69 -
How to find out the application server instance name?
Hi,
I installed an Oracle application server a long long while ago and completely forgot the things about the installation, including the name of the instance (I installed single instance, not cluster). Now I am trying to create a connection to the application server and I am prompted to fill in the instance name. Where in the installation can I find out the instance name?
The version of the server as displayed when the server is started:
$ ./oc4j -start
Starting OC4J from /oraInventory/j2ee/home ...
09/10/08 16:04:39 Oracle Containers for J2EE 10g (10.1.3.2.0) initializedThis 10.1.3.2.0 number is somewhat confusing. As I understand it, right now if you download a copy of the Application server from Oracle web site, the current version is 10.1.3.1.0.
I am also reading the installation guide now and when looking at the server starting messages on the screen, I realize that installing the server in the oraInventory directory is not quite right. Does that interfere with the correct functioning of the server? I installed it but have never tried to use it until now.
Many thanks for your help!
NewmanJ. Newman wrote:
Hi,
I installed an Oracle application server a long long while ago and completely forgot the things about the installation, including the name of the instance (I installed single instance, not cluster). Now I am trying to create a connection to the application server and I am prompted to fill in the instance name. Where in the installation can I find out the instance name?If you have access to that server, then the following should give the instance name.
grep 'IASname' $ORACLE_HOME/config/ias.properties
you should also see it in the AS Control Console page.
The version of the server as displayed when the server is started:
$ ./oc4j -start
Starting OC4J from /oraInventory/j2ee/home ...
09/10/08 16:04:39 Oracle Containers for J2EE 10g (10.1.3.2.0) initializedThis 10.1.3.2.0 number is somewhat confusing. As I understand it, right now if you download a copy of the Application server from Oracle web site, the current version is 10.1.3.1.0.
Regarding the version numbers, this fourth digit refers to the Component-specific release number. The OAS documentation says this about it.
"This digit identifies a release level specific to a component. Different components can have different numbers in this position depending upon, for example, component patch sets or interim releases."
I am also reading the installation guide now and when looking at the server starting messages on the screen, I realize that installing the server in the oraInventory directory is not quite right. Does that interfere with the correct functioning of the server? I installed it but have never tried to use it until now.
Many thanks for your help!
NewmanI think Oracle software should always be installed in a separate directory. I think it may also generate errors in its functioning but it will certainly create a whole lot confusion and mess in later administration and configurations.
hope that helps!
AMN
Edited by: AMN on Oct 8, 2009 5:14 PM -
How to check if a file (picture) exists into a war?
Hello, I have made a Java/J2EE project using countries in the world and I have at my disposition a folder of flags icons.
Some countries don't have any flag icon for any reason and in my application, I'll be able to add new ones.
In my code, I want to do display the flag of the current country if available else display a default icon.
Here is what I am currently doing:
String contextPath = facesContext.getExternalContext().getRequestContextPath();
String flagUrl = contextPath + "/images/flags/"+ name.trim().toLowerCase() + ".png";
boolean exists = (new File(flagUrl)).exists();The issue is exists is always set to true no matter the existence of the flag.
Here is what my variable nammed flagUrl looks like : /images/flags/ca.png
How do you check the existence of a file into a war? Thank you
Edited by: cotede3 on Mar 11, 2010 5:32 AMUnfortunately I cannot call getRealPath on application.
application in my code is :
BBrApplication application = null;
// Searchs entity class icon
FacesContext facesContext = FacesContext.getCurrentInstance();
if (facesContext != null)
application = BBrApplication.getInstance(facesContext);So I tried
String realFilePath = application.getContextRoot();but I end up with
realFilePath = /DFP/.
so It is not the absolute path displayed...
How can I do ? -
How to check if the requested server is the same server?
Hi,
I am building a request using URL connection. Before making a connection to the server I need to check if the URL requested server is same server. If it is same then I need to call locally Instead of making URL connection.
Please help me.
Thanks in advance.
Arthik
Edited by: TNKarthikBabu on Jun 29, 2009 3:07 PMCheck what methods the HttpServletRequest you provides.
Here is its API doc: [http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html]. -
Memory or space availabilty in the application server directory
hi
i have AS path /tmp
i want to know how much space is available for the temp folder.
Please suggest any FM.Hi friend,
1. Goto to Transaction SM69.
2. Click on F5.
3. Click on F6.
4. Enter a name in Command Name box ex: z_com
5. Enter a os command in Operating system command box. ex: df -k (uinix command for disk free space of all directories)
6. Give location in application server in Parameters for operating system command box ex: /C dir
7. Click Save.
Goto SE 38 and develop a report using FM 'SXPG_COMMAND_EXECUTE' .
Ex:
REPORT zdemodownload .
data: g_out like BTCXPM occurs 0,
z_com type SXPGCOLIST-NAME value 'df -k'.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = z_com
TABLES
exec_protocol = g_out
EXCEPTIONS
NO_PERMISSION = 1
COMMAND_NOT_FOUND = 2
PARAMETERS_TOO_LONG = 3
SECURITY_RISK = 4
WRONG_CHECK_CALL_INTERFACE = 5
PROGRAM_START_ERROR = 6
PROGRAM_TERMINATION_ERROR = 7
X_ERROR = 8
PARAMETER_EXPECTED = 9
TOO_MANY_PARAMETERS = 10
ILLEGAL_COMMAND = 11
WRONG_ASYNCHRONOUS_PARAMETERS = 12
CANT_ENQ_TBTCO_ENTRY = 13
JOBCOUNT_GENERATION_ERROR = 14
OTHERS = 15.
IF sy-subrc = 0.
display table g_out..............
ENDIF.
Thanks.......
Edited by: Sap Fan on Feb 19, 2009 12:44 PM
Edited by: Sap Fan on Feb 19, 2009 1:39 PM -
How to check if file already exist in application server?
Hi there,
Does anyone know a quick way to check if a file has already exists in an application server?
Thanks in advance.
Cheers.Call the function PFL_CHECK_OS_FILE_EXISTENCE.
Best regards Jack
FUNCTION PFL_CHECK_OS_FILE_EXISTENCE.
""Lokale Schnittstelle:
*" IMPORTING
*" FULLY_QUALIFIED_FILENAME LIKE TPFHT-PFFILE
*" EXPORTING
*" FILE_EXISTS LIKE BTCH0000-CHAR1
OPEN DATASET FULLY_QUALIFIED_FILENAME FOR INPUT.
IF SY-SUBRC EQ 0.
FILE_EXISTS = 'X'.
CLOSE DATASET FULLY_QUALIFIED_FILENAME.
ELSE.
CLEAR FILE_EXISTS.
ENDIF.
ENDFUNCTION. -
Process Chain to do nothing if file does not exist in the application serve
Hi All,
We have a process chain that flows to different data targets daily if files delivered in the application server.
Process chain does works fine. But my question is do we have anyway to stop the process chain or do not run process chain if it does not find the file available any days during this time range instead of failing.*
Is there any settings to enable the check if file available then run or else do not run at all. Please help!!!
Thanks,Follow the function modules listed in :
http://wiki.sdn.sap.com/wiki/display/ABAP/Workingwithfiles
with these function modules - you can get a list of files available in the application server directory.
Pseudo code :
1. Generate the automated fiel name you want
2. Get the list of files in the directory
3. Search the list of files to see if your file exists
4. If the file exists then load the file , else load an empty file .
The code is unfortunately in a different BW system that I do not have access to at this moment... but then the procedre is the same as detailed above. -
File exist in application server directory
Hi there,
On my SAP server, i have a directory created specifically to store input files generated from other external systems.
From my ABAP program, i need to check if any file exist on that application server directory. If yes, then i will proceed to read the input file and process it.
If it's empty, then output message that file is not available.
Are there any FM to do this?you can use this code to do this...
Upload data from file
DATA: lv_filename TYPE string, "File name
lv_line TYPE string. "One line entry in a file
lv_filename = iv_file_name.
IF iv_location = gc_application.
IF iv_record_count IS SUPPLIED.
Open file
IF gv_file IS INITIAL.
OPEN DATASET lv_filename FOR INPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF sy-subrc <> 0.
RAISE file_open_error.
ENDIF.
gv_file = gc_check.
ENDIF.
Read data
DO iv_record_count TIMES.
READ DATASET lv_filename INTO lv_line.
IF sy-subrc <> 0.
Close file
CLOSE DATASET lv_filename.
IF sy-subrc NE 0.
RAISE file_close_error.
ENDIF.
CLEAR gv_file.
Exit from the loop
EXIT.
ENDIF.
IF iv_separator IS NOT INITIAL.
CALL FUNCTION 'Z_WM_SPLIT_DATA'
EXPORTING
iv_data = lv_line
iv_separator = iv_separator
CHANGING
ct_tab_data = ct_tab_data.
ELSE.
CHECK NOT lv_line IS INITIAL.
APPEND lv_line TO ct_tab_data .
ENDIF.
ENDDO.
ELSE.
Open file
OPEN DATASET lv_filename FOR INPUT IN TEXT MODE
ENCODING DEFAULT
IGNORING CONVERSION ERRORS.
IF sy-subrc <> 0.
RAISE file_open_error.
ENDIF.
Read data
DO.
READ DATASET lv_filename INTO lv_line.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF iv_separator IS NOT INITIAL.
CALL FUNCTION 'Z_WM_SPLIT_DATA'
EXPORTING
iv_data = lv_line
iv_separator = iv_separator
CHANGING
ct_tab_data = ct_tab_data.
ELSE.
CHECK NOT lv_line IS INITIAL.
APPEND lv_line TO ct_tab_data .
ENDIF.
ENDDO.
Close file
CLOSE DATASET lv_filename.
IF sy-subrc NE 0.
RAISE file_close_error.
ENDIF.
ENDIF. -
How to change the format in the application server
The following is the uploading file in the application server:
Directory: /usr/sap/tmp
Name: ZMIRACA_SD27_LIUNIN_20070109_111913.csv
,0,000,ZMAT_TERRY,,19.12.2006,test material by terry,
,0,000,ZMAT_TERRY,,19.12.2006,test material by terry,
I click the menu System->List->Save->Local file->Spreadsheet and give a name: a.csv, then I open "a.csv", I find ",0,000,ZMAT_TERRY,,19.12.2006,test material by terry,,,EXTERNAL P,1.000,000,EA,," in one cell,but I want to separate them in different cell according to comma. Do you have some idea?
Thanks in advance!
NinaHI Nina
Have created a CSV file myself on application server using the following example code:
parameters: fname type filename obligatory lower case.
data: it_t001 type table of t001.
data: str type string.
field-symbols: <wa>, <fld>.
select * into table it_t001 from t001.
open dataset fname for output in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open file.'.
else.
loop at it_t001 assigning <wa>.
clear: str.
do.
assign component sy-index of structure <wa> to <fld>.
if sy-subrc ne 0.
transfer str to fname.
exit.
elseif sy-index = 1.
move <fld> to str.
else.
concatenate str <fld> into str separated by ','.
endif.
enddo.
endloop.
endif.
After executing the program, have checked the file using following methods and i dont have any problem:
1. FTP transfer to PC.
2. AL11 -> Display -> Menupath: System->List->Save->Local File->Spread Sheet
3. Transfer via transaction: CG3Y.
In all the cases, the values are in separate cells. Please verify.
Kind Regards
Eswar
Maybe you are looking for
-
Error when connecting to form builder
When I try to connect to form builder ,I get this error message , ORA-12154:TNS: could not resolve service name What is it?
-
I am making images (song lyrics) in Keynote and placing on my iPod. I cannot view them, using an Apple composite video cable, on my TV. I can view movie files, so I know the setup is working fine. Is there a particular format that is a requirement? I
-
11gr2 installation hanging at step 7 during Processing Oracle Text 11.2.0.
Hi, I am trying to install 11gr2 software on my linux 64 bit server. I had installled the same 11gr2 software successfully on the same server without any issues. Now i want another oracle home. But the installation is hanging at step 7, 8% was comple
-
SELECT TRANS_CAT_TYPE, CUSTOMER_CODE, CUSTOMER_NAME, CUR_SHORT_NAME, OWN_BRANCH_CODE, TRANSMIT_LC_NO, --CHARGE DECODE(TRANS_CAT_TYPE,'1', CATEGORY_DESC) CHARGE_DESC , DECODE(TRANS_CAT_TYPE,'1', AMOUNT_CCY) CHARGE_AMOUNT_CCY, DECODE(TRANS_CAT_TYPE,'1'
-
Hi, PO is blocked for compliance reason's. Still system is allowing the PO output. Is there any configuration in standard SAP for blocking the Output for blocked PO or do we need to develop a custom code for it. Plz advice on this. Regards Vivek