Writing error file from app server to windows serevr in background job
Hi Gurus!
I have a program that runs in the background and updates or uploads or inserts the tables with data in background and generates an error log . I would like to write this file on the windows serevr from the application serevr during the run of the program itself automatically. I tried running several jobs with my program but its not writing to the windows serevr , it writes on the application and then stops . Is theer a fault in my coding above.
form write_err_file .
IF v_zss = 1.
case p_as.
when 'X'. "X is application server
case sy-sysid.
when 'DEV' or 'SBX'.
ltp_dir = '\\nal.local\application\SAP\ERP\ZWELL\wmigdc\error_log\uwi_error'.
concatenate ltp_dir sy-datum '.txt' into ltp_dir.
when 'QAT'.
ltp_dir = '\\nal.local\application\SAP\ERP\ZWELL\wmigdc\error_log\uwi_error'.
concatenate ltp_dir sy-datum '.txt' into ltp_dir.
when 'PRD'.
ltp_dir = '\\nal.local\application\SAP\ERP\ZWELL\wmigdc\error_log\uwi_error'.
concatenate ltp_dir sy-datum '.txt' into ltp_dir.
endcase.
open dataset p_err2 for output in text mode encoding default message ltp_mess.
if sy-subrc = 0.
loop at t_err into s_dls.
transfer s_dls to p_err2.
if sy-subrc ne 0.
message i010(ad) with p_err2 'Download Failed'.
endif.
endloop.
close dataset p_err2.
else.
message i010(ad) with p_err2 'dataset could not be found'.
sy-subrc = -1. "Maintain error condition
endif.
open dataset p_err2 for input in text mode encoding default message ltp_mess.
if sy-subrc = 0.
do.
read dataset p_err2 into fs.
if sy-subrc = 0.
append fs to itab.
else.
exit.
endif.
enddo.
close dataset p_err2.
endif.
OPEN DATASET ltp_dir FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE ltp_mess.
if sy-subrc = 0.
loop at itab into fs.
transfer fs to ltp_dir.
endloop.
close dataset ltp_dir.
else.
message i010(ad) with ltp_dir 'dataset could not be found'.
sy-subrc = -1. "Maintain error condition
endif.
Please advice.
Regards
There are lot of posts on the same issue: [please check this|https://www.sdn.sap.com/irj/scn/advancedsearch?query=localfilesbackground&cat=sdn_all]
Similar Messages
-
System exception while deleting the file from app server in background job
Hi All,
I have a issue while the deleting the file from application server.
I am using the statement DELETE DATASET in my program to delete the file from app server.
I am able to delete the file from the app server when i run the program from app server.
When i run the same report from background job i am getting the message called System exception.
Is there any secuirity which i need to get the issue.
Thank You,
TaraginiHi All,
I get all the authorization sto delete the file from application serever.
Thing is i am able to run the program sucessfully in foreground but not in the background .
It i snot giving any short dump also just JOB is cancelled with the exception 'Job cancelled after system exception ERROR_MESSAGE'.
Can anybody please give me suggestion
Thanks,
Taragini -
Problem in downloading file from app server using CG3Y in to .XLS fomat
hi All,
I have uploaded file in to application server through a program using open data set with the separater as "|" ( pipe ) . Now the user should be able to download the file from apps server to presenataion server in .XLS format using txn CG3Y. but when we download, the format appears wierd and the data is not consistent across columns in excel. i.e the data which is supposed to be in one column in the excel is in the other column. what precautaions should i take before moving data to apps server so that it will be downloaded in a good format.
Appreciate your help...
Regards,
Sreekanth.Separate each values with TAB space present in the application server .
Currently u r using | pipe character. Instead of that use CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB as delimiter.
Each value will displayed in separate cells in excel sheet when u download it frm app.server
Regards,
Lakshman. -
Transfer a file from App Server to a FTP site.
Hi, Abapers.
I need your help. Probably, this topic has already been posted in a similar way, but we need an answer to solve our problem.
We have to sent a PDF file from a directory of our app server (AIX) to a FTP directory... which would the FM sequence we should use to goal it?
Best Regards.Hi Santiago,
create fm to send file from APP server to FTP site.
if you want to Post file from desktop to Appl use Transaction - CG3Y
if you want to Post file from Appl to Desktop use Transaction - CG3Z
copy the code below....
* Author: Prabhudas Date: 02/21/2006 *
* Name: Z_FTP_FILE_TO_SERVER *
* Title: FTP File on R/3 Application Server to External Server *
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(DEST_HOST) TYPE C
*" REFERENCE(DEST_USER) TYPE C
*" REFERENCE(DEST_PASSWORD) TYPE C
*" REFERENCE(DEST_PATH) TYPE C
*" REFERENCE(SOURCE_PATH) TYPE C
*" REFERENCE(FILE) TYPE C
*" REFERENCE(BINARY) TYPE CHAR1 OPTIONAL
*" REFERENCE(REMOVE_FILE) TYPE CHAR1 OPTIONAL
*" TABLES
*" FTP_SESSION STRUCTURE ZMSG_TEXT OPTIONAL
*" EXCEPTIONS
*" CANNOT_CONNECT
*" SOURCE_PATH_UNKNOWN
*" DEST_PATH_UNKNOWN
*" TRANSFER_FAILED
*" COMMAND_FAILED
DATA: w_password TYPE zftppassword,
w_length TYPE i,
w_key TYPE i VALUE 26101957,
w_handle TYPE i,
w_command(500) TYPE c.
REFRESH ftp_session.
* Scramble password (new Unicode-compliant routine)
w_length = STRLEN( dest_password ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = dest_password
sourcelen = w_length
key = w_key
IMPORTING
destination = w_password.
* Connect to FTP destination (DEST_HOST)
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = dest_user
password = w_password
host = dest_host
rfc_destination = 'SAPFTPA'
IMPORTING
handle = w_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
RAISING cannot_connect.
ENDIF.
* Optionally, specify binary file transfer
IF binary = 'X'.
w_command = 'bin'.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = w_handle
command = w_command
TABLES
data = ftp_session
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc <> 0.
CONCATENATE 'FTP command failed:' w_command
INTO w_command SEPARATED BY space.
MESSAGE ID 'ZW' TYPE 'E' NUMBER '042'
WITH w_command
RAISING command_failed.
ENDIF.
ENDIF.
* Navigate to source directory
CONCATENATE 'lcd' source_path INTO w_command SEPARATED BY space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = w_handle
command = w_command
TABLES
data = ftp_session
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc <> 0.
CONCATENATE 'FTP command failed:' w_command
INTO w_command SEPARATED BY space.
MESSAGE ID 'ZW' TYPE 'E' NUMBER '042'
WITH w_command
RAISING source_path_unknown.
ENDIF.
* Navigate to destination directory
CONCATENATE 'cd' dest_path INTO w_command SEPARATED BY space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = w_handle
command = w_command
TABLES
data = ftp_session
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc <> 0.
CONCATENATE 'FTP command failed:' w_command
INTO w_command SEPARATED BY space.
MESSAGE ID 'ZW' TYPE 'E' NUMBER '042'
WITH w_command
RAISING dest_path_unknown.
ENDIF.
* Transfer file
CONCATENATE 'put' file INTO w_command SEPARATED BY space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = w_handle
command = w_command
TABLES
data = ftp_session
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc <> 0.
CONCATENATE 'FTP command failed:' w_command
INTO w_command SEPARATED BY space.
MESSAGE ID 'ZW' TYPE 'E' NUMBER '042'
WITH w_command
RAISING transfer_failed.
ENDIF.
* Disconnect from destination host
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = w_handle.
* Optionally, remove file from source directory
IF remove_file = 'X'.
CONCATENATE source_path '/' file INTO w_command.
CONCATENATE 'rm' w_command INTO w_command SEPARATED BY space.
OPEN DATASET '/dev/null' FOR OUTPUT FILTER w_command.
CLOSE DATASET '/dev/null'.
ENDIF.
Regards,
Prabhudas -
Download PDF file from APP server!
Hi!
Has anyone tried uplaoding and downloding a PDF table from app server as I tried from a normal method by Open dataset, Transfer but it wont work.
Please provide any inputs.
Thanks.Hi park,
1. Using open data set, transfer , close etc,
also it will work.
( it will download / upload any kind of file from app server)
2. Just make sure the
FULL PATHNAME and the FILENAME
are mentioned in EXACT CASE
(small/CAPITAL).
3. U can check thru transaction AL11, to see the file and path.
regards,
amit m. -
Issue with uploading flat file from App Server
Hi,
Im loading a flat file to an ODS.
When I try to load in from my Local Workstation, it works fine.
All data is loaded green.
However, when I try to load the file after i copied it to my App Server, it cannot load.
The error is get is:
Error 2 while splitting CSV data: see long text
Message no. RSDS_ACCESS011
Diagnosis
Error 2 occurred while splitting the CSV data string.
1 = Could not find a closing escape character
2 = Invalid escape character
3 = Conversion error
4 = OTHERS
The thing is that it worked fine (exact same file no changes) when I loaded from my Desktop.
Appreciate any help or input.
Rgds,
Gary.Gary,
You can load it from the App server. Just check the file name whther you are giving it correctly and also check the readio button from App Server.
Go to AL11 (Tcode) and cross check whther your file is there. See in which directory your file is there. Mention the same path in the extraction tab in IP.
Thanks...
Shambhu -
Problem with READ DATASET when reading file from app server
Hi,
wondering if anyone can help, I'm using the following code to read from a file on app server, the file is of type .rtf
OPEN DATASET file_rtf FOR INPUT IN TEXT MODE
ENCODING DEFAULT
WITH SMART LINEFEED.
DO.
READ DATASET file_rtf INTO string.
IF SY-SUBRC = 0.
EXIT.
ENDIF.
ENDDO.
the open dataset part works sy-subrc = 0, but the read returns sy-subrc = 8 and no data is passed to string.
Any ideas as to what is causing this problem appreciated, <removed>
Thanks
Edited by: Thomas Zloch on Mar 17, 2010 3:57 PM - please don't offer p...Hi Adam,
The source code in the below link has details about how to read/write to application server.
[Application server file operartions|http://www.divulgesap.com/blog.php?p=NDk=]
Please let us know if you have any issues.
Regards,
Ravi -
How to fetch file from app. server without complete filename?
Hi,
In my report I have to read data from txt file on application server.
My file name on App. server conatain system id and date and time stam.
my file path :- /User/IDD/S10009112007101525
here,'User' is dirctory
'IDD' is folder in directory
'S100' is system id
'09112007' is date
'101525' is time in hour,miniute,second format.
From my program I can only pass directory , Folder name,System Id,Date only. I don't have time value in my program.
So please tell me how to fetch files without having time stamp value from app. server.
Plz send me exact code.It's urgent.
Message was edited by:
Manisha Kadam
Title was edited by:
Alvaro Tejada GalindoDo you want to return the file to the user on click of button or something?
Then, use web_show_document with http link which you are speaking about.
Else download the file to client using Webutil. -
Load Flat File from App Server
HI, all.
I want load flat file from appliation server. I created CSV file and loaded it on app. server with FM ARCHIVEFILE_CLIENT_TO_SERVER. After I created datasource and tried load data in the infocube. In this procedure I encountered with two problem
1. When I look file in AL11, I doesn't see cyrillic symbols, instead this symbols I see #.
2. When I try load data with data source, I get exception RS_EXCEPTION 000 "File don't open"
Anybody can help me resolve this problem?
wbr, Fanil.Hi, kodanda pani KV.
2. File is was closed.
1. Can me you clearly explain what you meen?
wbr, Fanil -
hi, i am running a background job in bw and for that created a file on the application server.now how do i delete that file.to create the file i just gave the name in the bw and the file got created.i am not able to find how to delete it.
or
rather than deleting the file how can we delete the data it is containing.please do let me knowhi,
but using DELETE DATASET u can remove file for app server.
If u want to delete the data alone then give the same name without data it will overwrite.
U can check it in AL11.
regards
md zubair sha
U can also use the function module - EPS_DELETE_FILE
Message was edited by:
md zubair sha -
Validate the file from app. server before uploading
Hi All,
I am trying to upload the data from application server into an internal table.
My requirement is I need to validate the data before I upload the data into internal table.(i.e I open the file from application server using FM Open_Dataset.Now before I upload the data into an internal table,I need to first validate each record in the file).I have some 7-8 lakhs of records in the file.
Any input for the above requirement would be of great help
Regards,
nsp.hi Nsp,
I guess validation of data will be only possible after uploading the data in to an internal table ...
Regards,
Santosh -
Reading uploaded file from app. server
Hi All,
I am trying to upload a .csv format file to app. server thru txn CG3Z....
When i try to open the file in my code thru open dataset and read dataset ...it is giving it in the form of
30002058,1000#50055501,2000#
Now i want it to be in
30002058,1000
50055501,2000
format...
pleas suggest..
thnx
RkHi Rahul,
have you tried reading it in BINary format?
Kind regards,
Alvaro -
Sent file from app. server vie mail
Hi all,
is there any standart program/function module that can be use to sent any file from application server via mail (as attachement), or i have to write it for myself? I have tried to search for it, but without success.
Thank you,
Ondrej SustacekHi Ondrej,
Once I had the same requirement. Please feel free to use my code. I placed it for you in Wiki:
[Sending Application Server file via emial as attachement|https://wiki.sdn.sap.com/wiki/x/UwVqBg]
Small description how it works is included with the code.
Regards
Marcn -
Move file from App server to same server on different path
Hi All,
I have to move a file from Application server to a folder in the same server....
pls tell me how can i do this....
its very urgent....
Thanks...............Hi
First you read the file in output mode using Open dataset and Read dataset statement with the initial application server path.
Then write this data back to another file path by opening the file in Input mode and using Transfer statement.
Example.
open dataset <file1> mode output encding default.
if sy-subrc = 0.
do.
read dataset <file1> into wa_itab.
if sy-subrc = 0.
append wa_itab to itab.
else.
exit.
endif.
enddo.
open dataset <file2> mode input encding default.
if sy-subrc = 0.
loop at itab into wa_itab.
transfer wa_itab to <file2>.
endloop.
endif.
~ Ranganath
PS : Reward points for all useful answers ! -
Download file from application server to internal table in background
hi all,
i want to download a file from appliaction server into my internal table but in background.
i had tryed CG3Z and CG3Y t-code but screen that is coming is asking for the parameters, and i want that screen should not appear and file should be saved in the predefined path by me.
if there any way to do so,
Points will be rewarded as per the Aswers.
thaks in advance.Hi Sudeep,
Use this code to get file data from application server.
REPORT ZE0232_BDC_APPLSERVER.
DATA: FILE_PATH TYPE STRING.
FILE_PATH = 'c:\bdc_mat.prn'.
DATA: BEGIN OF ITAB OCCURS 0,
END OF ITAB.
OPEN DATASET FILE_PATH FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
DO.
READ DATASET FILE_PATH INTO ITAB.
IF ITAB-RESNO NE SPACE.
APPEND ITAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET FILE_PATH.
LOOP AT ITAB.
WRITE:/ ITAB.
ENDLOOP.
FILE PATH IS application server path.
IF USEFULL REWARD
Maybe you are looking for
-
My three children each receive iPad minis from their generous grandparents last year; all were using my Apple ID so that we could share purchased content. However, they could not play games with each other using GameCenter (all one Apple ID) and it
-
Can I share one iTunes account for my iPad and two I phones? If so, how can I get the purchased apps and music on all three devices? How do I sync all the devices to have the same music and apps?
-
Lexical Parameter in report 10g
i want to call a report with few fields on my form. i create 2 user parameter which works fine. now i want to create a lexical parameter so that if null no problem report should appear with 2 user parameters but if has values then report should be ca
-
Sorry, I should have added that I am using a Macbook 10.6.4.
-
Reporting on attr.of 0MATERIAL and 0MAT_PLANT + Trans. data in one report
Dear all, I have an issue here with a very simple requirement: I have cube that contains both infoobjects 0MATERIAL and 0MAT_PLANT as well as some Key-Figures KF1 and KF2. I want to report now on attributes from 0MATERIALand 0MAT_PLANT together with