Upload a file from unix environment
hi
does anybody know which fm to use to upload a file from unix environment?
anjali
hi sia,
try this.
parameters: p_file like rlgrap-filename obligatory
default '/usr/sap/upload.xls'.
types: begin of t_data,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
werks like vbap-werks,
megne like vbap-zmeng,
end of t_data.
data: it_data type standard table of t_data,
wa_data type t_data.
open dataset p_file for output in text mode encoding default.
if sy-subrc ne 0.
write:/ 'Unable to open file:', p_file.
else.
do.
read dataset p_file into wa_data.
if sy-subrc ne 0.
exit.
else.
append wa_data to it_data.
endif.
enddo.
close dataset p_file.
endif.
rgds
anver
Similar Messages
-
Uploading PDF-file from unix to SAP internal table
Hi,
i have to write an abap that sends a pdf-file from a unix (SAP server) by mail to some people.
The mailing part is done, but for creating the attachment. I'm reading the pdf-file into an internal table (in a binary way). Then i'm using this int.table to send the mail.
The email is sent with an attachment, but i cannot open the pdf-file because of an error ( file damaged ). So before sending it by mail, i'm downloading the pdf file to my pc by using WS_DOWNLOAD with the same internal table. The download file gives the same error.
If i look at the size :
- originally pdf file 71743 bytes
- resulting pdf file 71665 bytes (281 lines x 255)
The creation of the internal table is as follows :
open dataset g_file for input in binary mode.
check sy-subrc eq 0.
do.
* read dataset g_file MAXIMUM LENGTH 255 into wa_pdf.
read dataset g_file into wa_pdf.
if sy-subrc ne 0. exit. endif.
append wa_pdf_hex to i_pdf.
enddo.
close dataset g_file.
where:
types: tt_pdf type table of soli, "raw 255 long
data: i_pdf type tt_pdf,
wa_pdf like line of i_pdf
Is there a better way to read in the pdf-file ? Any suggestions ?
regards,
Hans
[email protected]Hello Hans,
this is a little example from a program to send mail with picture. The problem is the same
form p_create_mail tables itab_html.
data : object_hd_change like sood1 occurs 0 with header line,
objpara like selc occurs 0 with header line,
receivers like soos1 occurs 0 with header line,
packing_list like soxpl occurs 0 with header line,
fic_attach like soli occurs 0 with header line,
struct_user_adress like usaddress ,
v_file(80) type c ,
v_buff(255) type c ,
v_num(9) type n,
v_length type i ,
v_total_length type i,
v_len(9) type n.
move : 'HTM' to object_hd_change-file_ext ,
'PIOU' to object_hd_change-objdes.
append object_hd_change.
* Find email addr for the username.
loop at s_bname.
call function 'SUSR_USER_READ'
exporting
user_name = s_bname-low
importing
user_address = struct_user_adress
exceptions
user_name_not_exists = 1
internal_error = 2
others = 3.
select single smtp_addr
into receivers-recextnam
from adr6
where addrnumber eq struct_user_adress-addrnumber
and persnumber eq struct_user_adress-persnumber.
if sy-subrc eq space.
move 'U' to receivers-recesc.
append receivers.
endif.
endloop.
* Get the picture.
move '/sap_interfaces/D27/pzr_00/data/test/logopharma.gif'
to v_file.
open dataset v_file for input in binary mode.
do.
read dataset v_file into v_buff length v_length.
v_total_length = v_length + v_total_length.
move v_buff+0(v_length) to fic_attach-line+0(v_length).
append fic_attach.
if sy-subrc ne space.
exit.
endif.
enddo.
describe table fic_attach lines v_num.
describe field fic_attach-line length v_len.
move : 'Logo' to packing_list-objdes ,
'Logo' to packing_list-objnam ,
'1' to packing_list-body_start ,
'raw' to packing_list-objtp ,
'GIF' to packing_list-file_ext .
packing_list-body_num = v_num.
packing_list-objlen = v_num * v_len.
append packing_list.
* Send mail.
call function 'SO_OBJECT_SEND'
exporting
object_hd_change = object_hd_change
object_type = 'RAW'
owner = sy-uname
tables
objcont = itab_html
objpara = objpara
receivers = receivers
packing_list = packing_list
att_cont = fic_attach
exceptions
others = 01.
endform. " P_CREATE_MAIL.
Regards
Frédéric -
Sample code to read a text file from UNIX directory.
I am using 9i Developer Suite, application server is 9.0.4. I want some help on how to read a flat file from UNIX environment. A sample code could be very helpful.
In windows, i use this kind of code:-
I declare an object & then write to a file using these sample staements:-
file_handle text_io.file_type;
filename := 'd:\ran\egs\uninvoiced.txt';
file_handle:=text_io.fopen(filename,'w');
text_io.put_line(file_handle, 'MOBILE NO '||'COUPON NO ' || 'DATE');
I hope, my question is clear. Please help in solving the doubt.
Regards.filename := 'd:\ran\egs\uninvoiced.txt';This is a Windows directory, so it won't work on Unix.
For the rest of the code: see examples in the Forms Builder Online Help. -
Upload pdf file from frontend to unix server
Hi all,
I want to upload a file from frontend to unix server.
The following coding transfers the file to the unix server. But the file is corrupted.
Any ideas whats wrong?
TYPES: BEGIN OF t_data_tab,
line TYPE x LENGTH 256,
END OF t_data_tab.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = lt_filetable
rc = lv_rc.
READ TABLE lt_filetable INTO p_file INDEX 1.
lv_filename = p_file.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = lv_filename
filetype = 'BIN'
CHANGING
data_tab = lt_data_tab
EXCEPTIONS
OTHERS = 4.
OPEN DATASET p_unix FOR OUTPUT IN BINARY MODE.
IF sy-subrc NE 0.
EXIT.
ELSE.
LOOP AT lt_data_tab INTO ls_data_tab.
TRANSFER ls_data_tab TO p_unix.
IF sy-subrc NE 0.
CONTINUE.
ENDIF.
ENDLOOP.
CLOSE DATASET p_unix.
ENDIF.
regardsFound solution by myself.
Upload
REPORT z_upload_to_unix.
TYPES: ESP1_BOOLEAN LIKE BAPISTDTYP-BOOLEAN.
DATA: i_ftfront TYPE string,
i_ftappl LIKE rcgfiletr-ftappl,
i_flg_overwrite TYPE esp1_boolean,
l_flg_open_error TYPE esp1_boolean,
l_os_message TYPE c.
i_ftfront = '<frontendpath>\test.pdf'.
i_ftappl = '<unixpath>/test.pdf'.
CALL FUNCTION 'C13Z_FILE_UPLOAD_BINARY'
EXPORTING
i_file_front_end = i_ftfront
i_file_appl = i_ftappl
i_file_overwrite = i_flg_overwrite
IMPORTING
e_flg_open_error = l_flg_open_error
e_os_message = l_os_message
EXCEPTIONS
fe_file_not_exists = 1
fe_file_read_error = 2
ap_no_authority = 3
ap_file_open_error = 4
ap_file_exists = 5
OTHERS = 6.
DOWNLOAD:
REPORT z_download_from_unix.
TYPES: ESP1_BOOLEAN LIKE BAPISTDTYP-BOOLEAN.
DATA: front TYPE string,
i_file_appl LIKE rcgfiletr-ftappl,
i_file_overwrite TYPE esp1_boolean,
e_flg_open_error TYPE esp1_boolean,
e_os_message TYPE c.
i_file_appl = '<unixpath>/test.pdf'.
front = '<frontendpath>\test.pdf'.
CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY'
EXPORTING
i_file_front_end = front
i_file_appl = i_file_appl
i_file_overwrite = i_file_overwrite
IMPORTING
e_flg_open_error = e_flg_open_error
e_os_message = e_os_message
EXCEPTIONS
fe_file_open_error = 1
fe_file_exists = 2
fe_file_write_error = 3
ap_no_authority = 4
ap_file_open_error = 5
ap_file_empty = 6
OTHERS = 7.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
How to upload pdf file from windows cell phone?
How to upload pdf file from windows cell phone?
You can do this in steps.. First use the built in method for uploading a file into the flows files object, Next you would copy the file out to an Oracle built directory on your UNIX box using utl_file.put_raw..
Here is a link to show you how to upload files in an APEX application [http://download.oracle.com/docs/cd/B31036_01/doc/appdev.22/b28839/up_dn_files.htm]
And here is a link to show you how to use utl_file.put_raw.. [http://psoug.org/reference/utl_file.html], item is towards the bottom of the screen..
Thank you,
Tony Miller
Webster, TX -
"\n" problem while downloading the file in unix environment
Hi folks,
I have some problem in uploading and downloading the file in unix environment..
This is my sample code i am using.
File userDataFile = new File("xyz".csv");
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(userDataFile),"UNICODE"));
out.write("Name"+"\t");
out.write("Age"+"\t");
out.write("Dob"+"\t");
out.write("Contact"+"\n");
for(int i=0;i<retList.size;i++){
out.write("xyz"+"\t");
out.write("22"+"\t");
out.write("300399"+"\t");
out.write("xyzzz"+"\n");
as per this i wrote code for generating the reports. Its contains some 7k records.
Its works in Windows environment.
Some times in Windows environment if the contents size is 7000 records means
i got only the headers..
I am not getting any real records.
I am not sure.. my client is using may be an unix environment..
Please give the solutions for this..
Very thanks in advance.Hi Jothi,
This is not an answer to your question. It is a question for you instead. I have tried to reach you on several forums regarding the HAP_DOCUMENT documentation you have.
Again, I am really sorry to contact you through a differente forum, but I really need the HAP_DOCUMENT documentation for my project.
Please send me a message to [email protected]
Thanks again.
JULIAN CASTRO -
Urgent - Upload a file from Client to Server.
Need to load a file from the client machine to the Server running 9iAS Rel. 1 on a HP Unix Machine.
We are using Forms 6i. We have looked into the File Upload Utility demo code provided with Forms 6i - but have been unsuccessful in reusing it. PLS HELPDuplicate post.
Upload a file from client to server by forms in E-Bussiness Suite R12
Re: Upload a file from client to server by forms in E-Bussiness Suite R12. -
Error while uploading the file from Allpcation server in LSMW-7th step
Hi Experts,
what should be the specific CODE PAGE should be maintained while uploading the file from application server in LSMW-7th Step
Thanks in advance,
KSRHi
I mean that there is any seperate CODE PAGE which comes at the bottom of screen while uploading the file from the application server in 7th step.
Is there any specific CODE PAGE to be maintained...
Thanks in advance
Oarsk -
Upload XL file from FTP server
Hi All,
Can anybady help me, how to upload Excel file from FTP server.
Thanks
Sri
Edited by: srikanthn on Apr 14, 2010 6:31 PMHello
How about using SAPFTP?
I hope SAP note 130106 will guide you on this.
Thanks
koju -
To upload a file from client machine to server machine
Hi everybody!
Could anyone plz help me. I am struck in a problem
I want to transfer a file from client's machine to server but I am not able to upload
It is tranferring the file only to the local machine
I am using orielley package It is transferring files only to my local machine but not to the server .Can anyone correct it. It's very urgent
how to write the relative path for server
I am using this path and it is not uploading
MultipartRequest multi = new MultipartRequest(request, "../<administrator>:<dev2daask>@dev2:C:/123data/", 5 * 1024 * 1024);
Here is my code:
<%@ page import="java.util.*" %>
<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.oreilly.servlet.MultipartRequest"%>
<%
try {
// Blindly take it on faith this is a multipart/form-data request
// Construct a MultipartRequest to help read the information.
// Pass in the request, a directory to saves files to, and the
// maximum POST size we should attempt to handle.
// Here we (rudely) write to the server root and impose 5 Meg limit.
MultipartRequest multi = new MultipartRequest(request, "../<administrator>:<dev2daask>@dev2:C:/123data/", 5 * 1024 * 1024);
out.println("<HTML>");
out.println("<HEAD><TITLE>UploadTest</TITLE></HEAD>");
out.println("<BODY>");
out.println("<H1>UploadTest</H1>");
// Print the parameters we received
out.println("<H3>Params:</H3>");
out.println("<PRE>");
Enumeration params = multi.getParameterNames();
while (params.hasMoreElements()) {
String name = (String)params.nextElement();
String value = multi.getParameter(name);
out.println(name + " = " + value);
out.println("</PRE>");
// Show which files we received
out.println("<H3>Files:</H3>");
out.println("<PRE>");
Enumeration files = multi.getFileNames();
while (files.hasMoreElements()) {
String name = (String)files.nextElement();
String filename = multi.getFilesystemName(name);
String type = multi.getContentType(name);
File f = multi.getFile(name);
out.println("name: " + name);
out.println("filename: " + filename);
out.println("type: " + type);
if (f != null) {
out.println("length: " + f.length());
out.println();
out.println("</PRE>");
catch (Exception e) {
out.println("<PRE>");
out.println("</PRE>");
out.println("</BODY></HTML>");
%>you have not understood my point
how does this code will run on servlet when I want to upload a file from client's
machine to server machine
what I am doing is I am giving an option to the user that he/she can browse the file and then select any file and finally it's action is post in the jsp form for which I have sent the code
All the computers are connected in LAN
So how to upload a file from client's machine to server's machine
Plz give me a solution -
Help please to Upload a file from my PC to server's KM
Hello:
I can't Upload correctly a file from my local PC to a KM of the server.
My problem is after that I've uploaded any file from my PC to KM, sometimes when I open or download it from the KM appears blank, and when I try another way to write the file (out.write()) I've uploaded a bad file that can't be downloaded or opened it. I can't get the file Data of the file for uploading, I need to set it with the fileResource (I tried with fileResource.read(false))
I use a FileUpload in my view.
<b>My Context:</b>
File (node)
|----fileResource (com.sap.ide.webdynpro.uielementdefinitions.Resource)
|----fileData (binary)
|----fileName (String)
wdDoInit(){
IPrivateUploadDownloadKMView.IFileElement fileBind = wdContext.createFileElement();
wdContext.nodeFile().bind(fileBind);
IWDAttributeInfo attInfo = wdContext.nodeFile().getNodeInfo().getAttribute("fileData");
ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
onActionSubir(){
IPrivateUploadDownloadKMView.IFileElement fileElement = wdContext.currentFileElement();
IWDResource resource = fileElement.getFileResource();
fileElement.setFileName(resource.getResourceName());
fileElement.setFileData(fileData);
byte[] fileData=new byte[resource.read(false).available()];
fileElement.setFileData(fileData);
fileName = fileElement.getFileName();
try{
File file = new File(fileName);
FileOutputStream out = new FileOutputStream(file);
out.write(fileElement.getFileData());
out.close();
fin = new FileInputStream(fileName);
fin.read();
Content content = new Content(fin,null, -1);
IResource newResource = folder.createResource(fileElement.getFileName(),null, content);
catch(Exception e){
IWDMessageManager mm = wdControllerAPI.getComponent().getMessageManager();
mm.reportWarning("error: "+e.getMessage());
Can you help me?, any sugestions to solve my problem or improve my code?
Regards
Jonatan.If you have got the permission to access <b>content management</b> in portal appliction server consle,then click on content management >select the KM Repository and clik on it.Then right click on <b>folder</b>>new-->upload.After clicking the upload option one page will be open and then you can browse your local file and upload to the KM Repository.
-
How can I upload raw files from my canon g7x to lightroom5
How can I upload raw files from my canon g7x to lightroom
See this thread in the official Adobe feedback forum: Why doesn't my version of Photoshop or Lightroom support my camera?
-
DATA TRANSFER - How to get a SINGLE SPACE in downloaded txt file from UNIX?
Hi Experts,
Am sending data from SAP to UNIX/ Application server and text file on desk top as well.
So, I am keeping a single character just SPACE at the END of each record.
Then, When I see the downloaded text file, I found a SINGLE SPACE at the end of each record, fine.
Then, by using CG3Y t code, I downloaded the UNIX file to my desk top.
But, When I see this UNIX downloaded file from UNIX, I did NOT find any SPACE at the end of each record!!!
Am doing every thing same in both cases.
So,
1 - Why its happening in case of UNIX file?
2 - How to get a SINGLE SPACE at the END in the downloaded file from UNIX?
thanqIts there, I am talking abut this -
OPEN DATASET - linefeed
Syntax
... WITH { NATIVE
| SMART
| UNIX
| WINDOWS } LINEFEED ... .
Alternatives:
1. ... WITH NATIVE LINEFEED
2. ... WITH SMART LINEFEED
3. ... WITH UNIX LINEFEED
4. ... WITH WINDOWS LINEFEED
Effect
: These additions determine which line end marker is used for text files or legacy text files. If these additions are used, the profile parameter abap/NTfmode is ignored. Simultaneous specification of the values "UNIX" or "NT" in the addition TYPE is not permitted.
If these additions are not used, the line end marker is determined as follows, depending on the operating system of the current application server:
The line end marker for Unix is "LF". Under Unix, OS390 and OS400, only "LF" is used for reading and writing.
The line end marker for MS Windows is "CRLF". Under MS Windows, however, the values of the profile parameter abap/NTfmode can also be used to set whether new files are handled according to Unix conventions or Windows conventions. If the profile parameter has the value "b", the Unix line end marker "LF" is used. If the profile parameter has the value "t" or is initial, the Windows line end marker "CRLF" is used. The setting using the profile parameter can be overridden with the addition TYPE and the value "UNIX" or "NT". If an existing file is opened without the addition TYPE, this is searched for the first line end marker ("LF" or "CRLF"), and this is used for the whole file. If no line end marker is found, the profile parameter is used. This applies particularly if an existing file is completely overwritten with FOR OUTPUT.
If an addition WITH NATIVE|SMART|UNIX|WINDOWS LINEFEED is used, this setting can be changed for the open file using the statement SET DATASET. If neither of the additions is used, the line end marker also cannot be changed using SET DATASET.
Notes
: Without the use of an addition WITH LINEFEED, the line end marker is dependent on diverse implicit factors such as the operating system of the application server, a profile parameter, and line end markings that are already used. For this reason, the explicit use of WITH LINEFEED is recommended, which renders the use of the addition TYPE for setting the line end marker obsolete.
The line end marker that is currently used can be determined for every open file using GET DATASET.
Alternative 1
... WITH NATIVE LINEFEED
Effect
: This addition defines the line end marker independently of the access type according to the operating system of the application server, i.e. "LF" for Unix OS390 or OS400, and "CRLF" for MS Windows.
The line end marker is interpreted according to the current codepage. If a code page is explicitly specified using the addition CODE PAGE, the characters of the line end marker must exist be available or be written in accordance with this code page.
Note
: The addition WITH NATIVE LINEFEED is intended for editing files on an application server that can also be accessed by other means. The addition receives the appropriate line end marker without the program needing to know the operating system.
Alternative 2
... WITH SMART LINEFEED
Effect
: This addition depends on the access type:
In files that are opened for reading using FOR INPUT, both "LF" and "CRLF are interpreted as a line end marker. When opening an EBCDIC file with the addition CODEPAGE, in addition to "LF", "CRLF", and the EBCDIC character strings, the corresponding ASCII character strings are also recognized. In addition, the EBCDIC character "NL" (line separator) is also interpreted as a line end marker.
In files opened for appending or changing with FOR APPENDING or FOR UPDATE, the program searches for a line end marker that is already used in the file. In this process, first the end of the file is identified. If no line end marker is found there, a certain number of characters at the beginning is analyzed. If a line end marker is found, this is used when writing to the file. This is also affected by the addition CODE PAGE. For example, ASCII line end markers are recognized and used in a file opened with EBCDIC, but not the other way round. If no line end marker is found or no search is possible (for example, if the file is opened with the addition FILTER), the line end marker is determined according to the operating system of the application server, as with the addition WITH NATIVE LINEFEED.
In files opened for writing using FOR OUTPUT, the line end marker is determined according the operating system of the application server, as with the addition WITH NATIVE LINEFEED.
Note
: The addition WITH SMART LINEFEED is intended for the generic editing of files in heterogeneous environments. The line end marker is recognized and set for different formats. The use of this addition is the best solution for most application cases.
Alternative 3
... WITH UNIX LINEFEED
Effect
: The line end marker is set to "LF" regardless of the access type and operating system of the application server.
The line end marker is interpreted according to the current code page. If a code page is specified explicitly using the addition CODE PAGE, the characters of the line end marker must be available or be written according to this code page.
Note
: The addition WITH UNIX LINEFEED is intended for editing Unix files in which the specific line end markers are to be retained, even if the operating system of the current application server is MS Windows.
Alternative 4
... WITH WINDOWS LINEFEED
Effect
: The line end marker is set to "CRLF" regardless of the access type and operating system of the application server.
The line end marker is interpreted according to the current code page. If a code page is specified explicitly using the addition CODE PAGE, the characters of the line end marker must be available and be written according to this code page.
Note
: The addition WITH WINDOWS LINEFEED is intended for use with MS Windows files in which the specific line end marker is to be retained, even if the operating system of the current application server is Unix, OS390 or OS400. -
DATA TRANSFER - How to get a SINGLE SPACE in the downloaded file from UNIX?
Hi Experts,
Am sending data from SAP to UNIX/ Application server and text file on desk top as well.
So, I am keeping a single character just SPACE at the END of each record.
Then, When I see the downloaded text file, I found a SINGLE SPACE at the end of each record, fine.
Then, by using CG3Y t code, I downloaded the UNIX file to my desk top.
But, When I see this UNIX downloaded file from UNIX, I did NOT find any SPACE at the end of each record!!!
Am doing every thing same in both cases.
So,
1 - Why its happening in case of UNIX file?
2 - How to get a SINGLE SPACE at the END in the downloaded file from UNIX?
thanqHi,
I don't know if this works:
perform SET_TRAIL_BLANKS(saplgrap) using 'X'.
perform SET_FIXLEN(saplgrap) using '0' '060'. "put length of your line from-to
... download ...
It will put space at the end of your line, according to the length.
Hope it works,
Chang -
How to allow the user to upload a file from their desktop to MII Server?
Hi,
Is there a way for the user to specify a file on their local computer to upload to the MII server for processing? We have a method that works for uploading from a shared network drive, but now the need/desire is to allow the user to upload a file from their desktop.
Ideally, this would be a file browser that the user would click on to browse their local desktop and select the file and click "Upload" but not sure what's possible?
This is using 12.1 SP4.
Thanks for the help.
Kerby[Uploading Documents|Uploading Documents]
Maybe you are looking for
-
Bridge cs5 won't display controls for output for pdf or web
hi, selected some images to create a contact sheet, but when i clicked on "output" nothing appeared in the window, as if this module didn't launch. any suggestions for a reset? i'm at a college, so it will be a pain if i have to reistall software (
-
Issue with TBLAST and skipmissing
Hello, We have an Essbase ASO application (v 11.1.1) that is used to show Balance type values, so we created an AmountMTD measure with TBLAST property. A new requirement appeared in our customer in order that AmountMTD for the current month should sh
-
I am having a problem relating camera roll album bugs
i am having a problem relating camera roll album bugs
-
AirParrot works fine with 10.8, but not with Bootcamp Win7
Hello! I know that this is not a problem directly linked to Apple, but maybe someone uses a similar setup. Since i have a Mid2010 iMac, i can't use the built-in AirPlay mirroring of ML and have to rely on a 3rd party product. I my case i'm using AirP
-
Hello out there; Would anyone pls help me with a few issues. #1 everytime I connect my new itouch to i-Tunes, it asks me to register it even though I have done it now like 4 times. #2 I locate a few wireless networks and even though at home I can use