Problem in placing files in server
Hello,
I am working on applet to servlet communication. I have developed the code but I have problem in placing the files in the tomcat server. these are my files
test.html
test.class (applet)
inter.class (bean implementing serializable interface)
testser.class (servlet)
I have placed test.html, test.class and inter.class in webapps/examples folder. I have placed testser.class in webapps/examples/web-inf/classes folder.
So that i can now see the applet and applet pass values to bean. But my servlet is not called. Can any one help what is going wrong or where should i place the files?
Thanks
Hello,
Here goes my source code files. All of them are working source files,
I am a bit confused in placing them in the Tomcat server. Can anyone try and post the results please?
i.e placing the files in the proper directories of the server.
// Register.java
import java.sql.*;
public class Register implements java.io.Serializable
// data members
private String firstname;
private String lastname;
private final String CR = "\n"; // carriage return
// constructors
public Register()
public Register(String afirstName, String alastName)
firstname = afirstName;
lastname = alastName;
RegistrationServlet regser = new RegistrationServlet();
public String getFirstName()
System.out.println("In getFirstName(): " + firstname);
return firstname;
public String getLastName()
return lastname;
// RegistrationApplet.html
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.awt.event.*;
import java.io.*;
public class RegistrationApplet extends Applet implements ActionListener
String browser;
public void init()
setLayout(null);
setSize(438,536);
label1.setText("First Name*:");
add(label1);
label1.setFont(new Font("Dialog", Font.BOLD, 12));
label1.setBounds(48,60,116,27);
add(textField1);
textField1.setBounds(168,60,180,30);
add(textField2);
textField2.setBounds(168,96,180,30);
label2.setText("Last Name*:");
add(label2);
label2.setFont(new Font("Dialog", Font.BOLD, 13));
label2.setBounds(48,96,94,20);
button1.setLabel("Submit");
add(button1);
button1.setBackground(java.awt.Color.lightGray);
button1.setBounds(120,444,98,30);
label11.setText("Applet to Servlet Communication");
add(label11);
label11.setFont(new Font("Dialog", Font.BOLD, 24));
label11.setBounds(108,12,288,36);
button1.addActionListener(this);
public void actionPerformed(ActionEvent ae)
if(ae.getSource().equals(button1))
firstname = textField1.getText().trim();
lastname = textField2.getText().trim();
try{
String toservlet = "http://localhost:8080/servlet/RegistrationServlet";
URL servleturl = new URL(toservlet);
URLConnection servletconnection = servleturl.openConnection();
servletconnection.setDoInput(true);
servletconnection.setDoOutput(true);
servletconnection.setUseCaches(false);
servletconnection.setDefaultUseCaches(false);
servletconnection.setRequestProperty("Content-type","application/octet-stream");
// sending the values to the serialised class "Register.java"
register = new Register(firstname,lastname);
ObjectOutputStream outputtoservlet = null;
outputtoservlet = new ObjectOutputStream(servletconnection.getOutputStream());
outputtoservlet.writeObject(register);
outputtoservlet.flush();
outputtoservlet.close();
catch(Exception e)
System.out.println("in submit "+e);
e.printStackTrace();
String firstname;
String lastname;
java.awt.Label label1 = new java.awt.Label();
java.awt.TextField textField1 = new java.awt.TextField();
java.awt.TextField textField2 = new java.awt.TextField();
java.awt.Label label2 = new java.awt.Label();
java.awt.Button button1 = new java.awt.Button();
java.awt.Label label11 = new java.awt.Label();
String parameters;
Register register = null;
// RegistrationServlet.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.net.*;
import java.io.*;
public class RegistrationServlet extends HttpServlet
public void doPost(HttpServletRequest req,HttpServletResponse res)
ObjectInputStream inputFromApplet = null;
Register aRegister = null;
try
inputFromApplet = new ObjectInputStream(req.getInputStream());
//"Reading data..."
System.out.println("Reading Data.......");
aRegister = (Register) inputFromApplet.readObject();
System.out.println("Completed Reading Data.......");
//close the connection after reading the data
inputFromApplet.close();
// getting parameters from the serilized class "Register.java"
String first = aRegister.getFirstName();
String last = aRegister.getLastName();
ServletOutputStream sos = res.getOutputStream();
sos.println("First Name:"+first);
sos.println("Last Name:"+last);
catch(Exception e)
System.out.println("in doPost() "+e);
//e.printStackTrace();
}Thanks
Similar Messages
-
Problem uploading Dreamweaver file to Server
Using CS3
I cannot get my job to upload to the server correctly. The error code says: "Dreamweaver is currently interacting with a server.
Since putting a file on save requires interaction with a server as well, DW cannot currently perform this task.
Please try again when current server task is complete."
And then it DOES save it to the remote site - but my links are not active and I am not able to access the job on internet.
When I compare the remote site info it is synchronized with the local.
My site setup has been tested and is good.
I've been doing this job for 5 years. Not had this problem before.
I have no other files/programs open and nothing is being saved that I know of. Sauve'JTANNA wrote:
VSauve\' wrote:
Thanks for your reply.
No I have not used any third-party upload files.
I have contacted my host, but they haven't gotten back to me - Dreamhost - and I'm
waiting and waiting . . . as my deadline gets later and later.
In the meantime you could start using FileZilla - a free tool to upload your files. Don't rely on Dreamhost because they could destroy your livelihood. They couldn't care less about customers. This is my experience with them.
JTANNA wrote:
1. Jan 9, 2012 7:19 PM (in response to MichaelCo)
Re: Nav Bar collapsing in Dreamweaver
MichaelCo wrote:
Not sure what I am doing wrong.Any help would be appreciated.
It is unlikely we would know either but have you uploaded/linked the relevant scripts and CSS files? I believe PVII products rely heavily on scripts so this might be the problem
I suggest repost your query to their forums as they should know what the problem could be. We don't use any third party products here.
Good luck.
Oh the irony...
VSauve\' wrote:
Using CS3
I cannot get my job to upload to the server correctly. The error code says: "Dreamweaver is currently interacting with a server.
Since putting a file on save requires interaction with a server as well, DW cannot currently perform this task.
Please try again when current server task is complete."
And then it DOES save it to the remote site - but my links are not active and I am not able to access the job on internet.
When I compare the remote site info it is synchronized with the local.
My site setup has been tested and is good.
I've been doing this job for 5 years. Not had this problem before.
I have no other files/programs open and nothing is being saved that I know of. Sauve'
From what you're describing that's happening you're syncing the whole site each time you are saving changes and there's a problem with the permission settings. I'm not saying that's the case but just from the description that's what it sounds like. -
Problems reading 2 files on server
I have the code written to upload a file to the server. I want to be able to upload 2 files to the server with the same socket connection. Any ideas how to do this? Also when i upload the file it doesn't always send the whole file. Any ideas why this is happening and how i can fix this? I'll post the code I have below.
import java.io.IOException;
import java.net.ServerSocket;
public class Server {
* @param args
* @throws IOException
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
ServerSocket serverSocket = null;
boolean listening = true;
try {
serverSocket = new ServerSocket(12345);
} catch (IOException e) {
System.err.println("Could not listen on port: 12345.");
System.exit(-1);
while (listening)
new ServerThreads(serverSocket.accept()).start();
serverSocket.close();
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Socket;
public class ServerThreads extends Thread {
private Socket socket = null;
ServerUtil archUtil = new ServerUtil();
public ServerThreads(Socket socket) {
// TODO Auto-generated constructor stub
this.socket = socket;
public void run() {
try{
BufferedReader rd = new BufferedReader(new InputStreamReader(socket.getInputStream()));
if(rd.readLine().equals("file")){
archUtil.generateTmpDir();
archUtil.uploadFile(socket,rd);
else
System.out.println("this is some crap");
catch(IOException e){
System.out.println("is this you that's given me a problem");
public class ServerUtil {
String tmpDir;
String fileName;
Process proc;
Runtime runtime = Runtime.getRuntime();
public static final int BUFFER_SIZE = 1024 * 50;
private byte[] buffer;
public ServerUtil() {
// TODO Auto-generated constructor stub
public void generateTmpDir(){
java.util.Date d = new java.util.Date();
long off = (long) Math.random();
GregorianCalendar todaysDate=new GregorianCalendar();
int hour,mins,secs;
hour=todaysDate.get(Calendar.HOUR);
mins = todaysDate.get(Calendar.MINUTE);
secs = todaysDate.get(Calendar.SECOND);
String SECS = java.lang.Integer.toString(secs);
String HOUR = java.lang.Integer.toString(hour);
String MINS = java.lang.Integer.toString(mins);
String time = HOUR + MINS + SECS;
/** Unique String Name created **/
String RANDOM_OFFSET = new String ();
RANDOM_OFFSET =time + d.hashCode() + RANDOM_OFFSET.hashCode()+ off;
setTmpDir(RANDOM_OFFSET);
boolean success = (new File("tmp/" + RANDOM_OFFSET)).mkdir();
if (!success) {
// Directory creation failed
/**try {
proc = runtime.exec("mkdir tmp/" + getTmpDir() );
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
public void uploadFile(Socket socket, BufferedReader rd){
buffer = new byte[BUFFER_SIZE];
System.out.println("accepted Socket");
try {
BufferedInputStream in = new BufferedInputStream(socket.getInputStream());
setFileName(rd.readLine());
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tmp/" + getFileName()));
int len = 0;
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
System.out.print("#");
in.close();
out.flush();
out.close();
socket.close();
System.out.println("\nDone!");
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
* @return the tmpDir
public String getTmpDir() {
return tmpDir;
* @param tmpDir the tmpDir to set
public void setTmpDir(String tmpDir) {
this.tmpDir = tmpDir;
* @return the fileName
public String getFileName() {
return fileName;
* @param fileName the fileName to set
public void setFileName(String fileName) {
this.fileName = fileName;
public class Network {
public static final int BUFFER_SIZE = 1024 * 50;
private byte[] buffer;
public Network() {
// TODO Auto-generated constructor stub
buffer = new byte[BUFFER_SIZE];
public void sendFile(String fileLocation, String filename) throws Exception {
Socket socket = new Socket("localhost", 12345);
PrintWriter pout = new PrintWriter(socket.getOutputStream(), true);
pout.println("file");
pout.println(filename);
BufferedInputStream in =
new BufferedInputStream(
new FileInputStream(fileLocation));
BufferedOutputStream out =
new BufferedOutputStream(socket.getOutputStream());
int len = 0;
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
System.out.print("#");
in.close();
out.flush();
out.close();
socket.close();
System.out.println("\nDone!");
* @param args
* @throws Exception
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
Network nw = new Network();
nw.startClient();
}Ok this is the code that I wrote in those sections and I am getting an error on the server...can you tell me what I am doing wrong. I just want to copy over 2 files and give them the same names.
Client: Network.java( up top)
public static final int BUFFER_SIZE = 1024 * 50;
private byte[] buffer;
public Network() {
// TODO Auto-generated constructor stub
buffer = new byte[BUFFER_SIZE];
public void sendFile(File f1, File f2) throws Exception {
Socket socket = new Socket("localhost", 12345);
PrintWriter pout = new PrintWriter(socket.getOutputStream(), true);
File [] files = {f1,f2};
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));
BufferedInputStream in = null;
pout.println("file");
for(int i = 0; i < files.length; i++){
out.writeUTF(files.getName());
out.writeLong(files[i].length());
in = new BufferedInputStream(new FileInputStream(files[i]));
int len = 0;
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
System.out.print("#");
in.close();
out.flush();
out.close();
socket.close();
System.out.println("\nDone!");
Server: ServerUtil.java (up top)
public void uploadFile(Socket socket, BufferedReader rd){
buffer = new byte[BUFFER_SIZE];
System.out.println("accepted Socket");
try {
BufferedOutputStream out = null;
DataInputStream in = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
for(int i = 0; i<2; i++){
setFileName(in.readUTF());
System.out.println(getFileName());
out = new BufferedOutputStream(new FileOutputStream(getFileName()));
int len = 0;
while ((len = in.read(buffer)) > 0) {
out.write(buffer, 0, len);
System.out.print("#");
in.close();
out.flush();
out.close();
socket.close();
System.out.println("\nDone!");
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}I am getting the error:
java.io.UTFDataFormatException
at java.io.DataInputStream.readUTF(DataInputStream.java:713)
at EpkgArchiveServerUtil.uploadFile(EpkgArchiveServerUtil.java:100)
at ServerThreads.run(ServerThreads.java:38) -
Problem in transferring file(presentation server) contents to internl table
Hi Experts,
My requirement is to upload a file from presentation server and get the contents into an internal table then I need to update bespoke table based on the values of the internal table. I tried using both funtion module : WS_UPLOAD and GUI_UPLOAD but the data is not getting populated properly to the correct fields of the internal table.
Hence Could you please tell me the pre requisites which needs to be done before uploading the file.I mean the format of the file and the parameters to be passed to the funtion module.
I am also confused with the file extension( i.e of the input file name . Eg. Demo.txt ) with the Filetype ( DAT / BIN/ ASC ) option provided in the funtion modules for upload.
Thanks in advance.
Regards,
Srinivasif it is .txt file follow below steps
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = gv_file
filetype = 'ASC'
TABLES
data_tab = gt_text_file
for this your text file should be
1234|field2| field3|.....
here field seperator is pipe symbol(|)
your internal table must be same as your text file
then use SPLIT command and append your internal table..
LOOP AT gt_text_file INTO wa_text_file.
CLEAR wa_text_table.
SPLIT wa_text_file-line AT gc_pipe INTO wa_text_table-objectid
wa_text_table-lifnr
Append internal table...
endloop. -
Trigger a background job immediately after a file is placed in App Server
Hi all,
I have a program ZPGM1 that needs to be executed in background when a file is placed in an application server.
I know i can schedule ZPGM1 to trigger in background after an event say ZEVENT1.
Also i know i raise the event ZEVENT1 using FM BP_EVENT_RAISE but my problem is who would raise the event.
The file is being dropped in application server at random time by 3 party vendor. I need to execute my ZPGM1 immediately after the file is placed in Application Server.
Is ther a way that this can be achieved. Let me know
Thanks
KajolYou will need to develop a custom, non-SAP "listener" program or a script. This program/script will need to check if the file is present (e.g. by using an OS-level event) and, if so, start SAPEVT.EXE program with corresponding parameters.
SAP Help on raising events externally:
http://help.sap.com/saphelp_nw04s/helpdata/en/fa/096e6b543b11d1898e0000e8322d00/frameset.htm
There is also third-party software available, but it is very expensive:
http://www.redwood.com/ -
Problem with FM SXPG_COMMAND_EXECUTE in deleting a file on server.
Hi All,
My Task is to delete a file with version number 6 and rename all other files, so that my new file will be version 0.
Am using the FM SXPG_COMMAND_EXECUTE to delete/rename a file on server.
Though, this is working fine in debugging mode I can see the file getting deleted in regular run, which is followed by renaming some files, it is NOT working in regular run.
Somehow the deletion and renaming are not happening correctly in regular run, but does happen successfully while in debugging.
Am I missing anything or any refresh or delay needed?
Here is my code for DELETE :
CONCATENATE P_PATH '\' P_TABNAME '_6.dat' INTO LF_FILE.
CONDENSE LF_FILE NO-GAPS.
*// Check if this file exists
OPEN DATASET LF_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC EQ 0.
*// Delete this file
DELETE = LF_FILE.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
ADDITIONAL_PARAMETERS = DELETE
COMMANDNAME = 'ZDELETE'
OPERATINGSYSTEM = OPSYS
STDERR = 'X'
STDOUT = 'X'
TARGETSYSTEM = EHOST
TERMINATIONWAIT = TERMWAIT
TRACE = ' '
IMPORTING
STATUS = RETCODE
TABLES
EXEC_PROTOCOL = PROT
EXCEPTIONS
COMMAND_NOT_FOUND = 01
NO_PERMISSION = 02
PARAMETERS_TOO_LONG = 03
PARAMETER_EXPECTED = 04
PROGRAM_START_ERROR = 05
PROGRAM_TERMINATION_ERROR = 06
SECURITY_RISK = 07
TOO_MANY_PARAMETERS = 08
WRONG_CHECK_CALL_INTERFACE = 09
X_ERROR = 10
OTHERS = 11.
ENDIF.
Regards
Raj
Edited by: Rajasekhar Dinavahi on Apr 14, 2010 11:45 AMHi All,
Problem resolved.
We need ensure all files which are opened [by OPEN DATASET], are CLOSED before trying any operation like DELETE or RENAME on the files.
Regards
Raj -
Hi
I have been working with a form that uses a "upload file", in my localhost computer works very well BUT in my production server doesnt, the thing is that there is no error messager .. so i cant guess the problem, i already check permissions in my folder that contains the files and all is with Write permissions.
Can you help me pleasE??
thanks in advanceMost likely a permissions issue. Check your production server to see if both the IUSR_[Machine Name] and ASPNET users have read/write/delete permissions on 1. the folder you'll be uploading images to AND 2. the includes\common\lib\file_upload\temp folder (if this doesn't exist, create it manually).
These settings are necessary in order for the ADDT file upload server behavior to function properly. -
Problem with placing of properties file
Hi all,
Iam using a properties file.
From a jsp, Iam reading the property file.....
Its giving FileNotFoundException....
I hope its problem with placing of my properties file...
I placed the properties file in WEB-INF/classes..folder.....
But still iam getting the FileNotFoundException...
PLz tell me where exactly should I place my properties file...
Thanks ....first rule of using a forum: read recent topics !
http://forum.java.sun.com/thread.jspa?threadID=668488&tstart=0 -
Problem with indesign & acrobat cannot saved files on server : file already open-
About the problem of Christina
It's the same for us with Indesign and also with Acrobat. The problem comes from Adobe. They do not understand that we work on server. They tHink that we must work in local and after save files on server. That's totally crazy when you are saverall to work on the same file at different time of the day. How could you know that you work on the right file?
Please, ADOBE, could you solved this problem?You need Adobe Drive, which helps to connect with DAM systems. AFAIK, Adobe does not supply DAM systems though.
More about it, here: http://www.adobe.com/es/products/adobedrive.html -
Problem while generating file in linux server
I am generating one text file in windows server by using UTL_FILE .after completion of line it is coming to next line properly.
When i am generating the same file in linux server by using UTL_FILE. It is not going to next line after the end of file.Instead of that it is showing one BOX symbol .After that it is not moving to next line.it is continuing with that box
for example:
I generated the file in Windows server the output is
"number name age
number name age
etc..."
If I am generating the same file LINUX server the output is
"number name age 'Box symbol' number name age'Box symbol'etc..."
please help me out.....i have to submit this job in the next 12 hours....M_FIELD_VALUE := SUBSTR(M_FIELD_VALUE,1,C6_REC.DFCS_FIELD_SIZE);
IF (NVL(LENGTH(M_ROW_VALUE),0) + NVL(LENGTH(M_FIELD_VALUE),0)) < 32000 THEN
M_ROW_VALUE := M_ROW_VALUE || M_FIELD_VALUE;
END IF;
END LOOP; End Column Loop D
UTL_FILE.PUT_LINE(M_FILE_HANDLE,M_ROW_VALUE);------here I am printing the row in text format -
How to write file to server side?
hello,
Could anyone pls help me...
I just want to see an example how can I write to a file that is placed at the server(save place as the applet).
p.s. I have been successfully read a file from there...
Suppose I have signed the applet (self-signed), anymore security problem I need to pay attention to?
Thanks a lot!!hi mandy, from the applet u can send the file to be written into the server to a servlet running in server and the servlet can in turn write the file into the servlet. by applet - servlet communication, u can easily read and write files to the server.
-
Can i development program with EDK for uploading file to server?
Can I development program with EDK for uploading file to server?How to avoid same name of files?
Thanks!Hi ,
thanks for the quick response.
but the problem is supppose i have a excel sheet with 16 rows and 13 columns(so data).
i am placing this file contents to appserver USING ABOVE fm.
after that i am reading the file from appserver to create SO(idoc),i need 1row-3column data and 2row-2c data.like that.
in unix we will get row data(after uploading to app server) as #mprn#2345# like this so easy to separate when reading.but in MS NT OS 1row data getting stored in different rows in Appserver.so difficult to read.
so the above mentioned FM is OS dependent or is there any way (any other FM) to get same kind of data in different OS.
PLEASE SUGGEST OTHER WISE I NEED TO CODE BASED ON OS.
REGARDS
SARATH -
Problems while uploading files using the FileReference API
I've built an image uploader module in Flex using the FileReference API and PHP.
While this works perfect for images upto 1 MB, What I'm noticing is that for images greater that 1 MB even after the Event.COMPLETE has triggered, the file hasn't yet been uploaded into the folder.. its only after a couple of seconds or minutes after the Event.COMPLETE, that the image actually shows up in the FTP folder. Morever I also noticed that for such files the DataEvent.UPLOAD_COMPLETE_DATA that we are using to get feedback from PHP never gets called.
I thought it would be related to the PHP script getting timed out... but the PHP script does get executed and the images do show up in the folder but thats way after the Event.Complete has been triggered and more importantly DataEvent.UPLOAD_COMPLETE_DATA doesnt get called.
Everything seems to work fine as long as the file size is under 1 MB
Did others too face similar problems and any ideas on how to fix it?
Thanks in advanceI don't believe there is, as the browse button renders out as an html input type file component, and this has no ability to get native file size from the client. The only way to do it is to check the file size server side, but that kind of defeats the purpose to some extent, as the file is required to be uploaded before the file size can be checked.
There is no way to do this on the client short of using a third party client side component - ie. java, flash or some other active component that gets file system level access.
Ben -
Delete WorkBook and Query file from Server .
Dear All Experts .
I dun know i posted in correct places or not .. (correct me if i m wrong) .. i want to ask about the BW Workbook and query.
How we going to remove the remove the workbook or query files from Server ? bc i tried to delete from Analyzer(excel 2007), the file is deleted from the view , but havent delete from the server... So how i going to remove the file from server ?
Thank.Hello I have the same problem. Can you please tell me how you finaly manage to delete the workbook.
thank's you for advance,
Akiba -
Problem with attaching file to Sales Order
Hello,
In my company we have the possibility to attach files to sales orders, e.g. pdf files with the printing details.
These files are added by the GUI user, this works fine.
Now we have an extra order creation stream in which a pdf file has to be added to the SO without user interaction.
I found a helpful link ( /people/rammanohar.tiwari/blog/2005/10/10/generic-object-services-gos--in-background )
This program creates URL links with no problem, but the file generation is not implemented yet.
I tried to add the file functions to his sample report but still have one problem. The file is uploaded, but not reported as a PDF file in sap. If I select the created attachment SAP allows only the saving of the attachment. After saving the created file is a good PDF file, it opens with PDF-viewers.
Why does SAP not know this is a PDF file and report it as such (and open the pdf viewer when selected).
Thanks, Frank.
source-code:
REPORT zzfb_brc .
* Report Z_RMTIWARI_ATTACH_DOC_TO_BO
* Written By : Ram Manohar Tiwari
* Function : We need to maintain links between Business Object and
* the attachment.Attachment document is basiclally a
* business object of type 'MESSAGE'.In order to maintain
* links, first the attachment will be crated as Business
* Object of type 'MESSAGE' using Message.Create method.
* Need to check if we can also use FM
* 'SO_DOC_INSERT_WITH_ORIG_API1' or SO_OBJECT_INSERT rather
* than using Message.Create method.
* I took this program and removed all the parts for adding URL's and
* notes.
* Include for BO macros
INCLUDE : <cntn01>.
* Load class.
CLASS cl_binary_relation DEFINITION LOAD.
CLASS cl_obl_object DEFINITION LOAD.
PARAMETERS:
* Object_a
p_botype LIKE obl_s_pbor-typeid DEFAULT 'BUS2032', "SO
p_bo_id LIKE obl_s_pbor-instid DEFAULT '0000757830', "example number
* Object_b
p_docty LIKE obl_s_pbor-typeid DEFAULT 'MESSAGE' NO-DISPLAY,
p_msgtyp LIKE sofm-doctp DEFAULT 'EXT' NO-DISPLAY,
* Relationship
p_reltyp LIKE mdoblrel-reltype DEFAULT 'ATTA'.
TYPES: BEGIN OF ty_message_key,
foltp TYPE so_fol_tp,
folyr TYPE so_fol_yr,
folno TYPE so_fol_no,
doctp TYPE so_doc_tp,
docyr TYPE so_doc_yr,
docno TYPE so_doc_no,
fortp TYPE so_for_tp,
foryr TYPE so_for_yr,
forno TYPE so_for_no,
END OF ty_message_key.
DATA : lv_message_key TYPE ty_message_key.
DATA : lo_message TYPE swc_object.
DATA : lt_doc_content TYPE STANDARD TABLE OF soli-line,
ls_doc_content TYPE soli-line.
* Create an initial instance of BO 'MESSAGE' - to call the
* instance-independent method 'Create'.
swc_create_object lo_message 'MESSAGE' lv_message_key.
* Upload the pdf file, for now from the frontend, in the future from
* the server.
DATA:
* dsn(40) TYPE C VALUE '/usr/sap/trans/convert/1.pdf', "server location
l_lines TYPE i. "filelenght
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'c:t1.pdf'
filetype = 'BIN'
IMPORTING
filelength = l_lines
TABLES
data_tab = lt_doc_content.
* no exceptions, the file is there in this example
break brouwersf.
** the coding for the server input, for later
*OPEN DATASET dsn FOR INPUT IN BINARY MODE.
*IF sy-subrc <> 0.
* EXIT.
*ENDIF.
*READ DATASET dsn INTO ls_doc_content.
*WHILE sy-subrc EQ 0.
* APPEND ls_doc_content TO lt_doc_content.
* READ DATASET dsn INTO ls_doc_content.
*ENDWHILE.
*CLEAR ls_doc_content.
*CLOSE DATASET dsn.
* define container to pass the parameter values to the method call
* in next step.
swc_container lt_message_container.
* Populate container with parameters for method
swc_set_element lt_message_container 'DOCUMENTTITLE' 'Title'.
swc_set_element lt_message_container 'DOCUMENTLANGU' 'E'.
swc_set_element lt_message_container 'NO_DIALOG' 'X'.
swc_set_element lt_message_container 'DOCUMENTNAME' p_docty.
swc_set_element lt_message_container 'DOCUMENTTYPE' p_msgtyp.
swc_set_element lt_message_container 'DocumentSize' l_lines.
swc_set_element lt_message_container 'DocumentContent' lt_doc_content.
swc_call_method lo_message 'CREATE' lt_message_container.
* Refresh to get the reference of create 'MESSAGE' object for attachment
swc_refresh_object lo_message.
* Get Key of new object
swc_get_object_key lo_message lv_message_key.
* Now we have attachment as a business object instance. We can now
* attach it to our main business object instance.
* Create main BO object_a
DATA: lo_is_object_a TYPE sibflporb.
lo_is_object_a-instid = p_bo_id.
lo_is_object_a-typeid = p_botype.
lo_is_object_a-catid = 'BO'.
* Create attachment BO object_b
DATA: lo_is_object_b TYPE sibflporb.
lo_is_object_b-instid = lv_message_key.
lo_is_object_b-typeid = p_docty.
lo_is_object_b-catid = 'BO'.
*TRY.
CALL METHOD cl_binary_relation=>create_link
EXPORTING
is_object_a = lo_is_object_a
is_object_b = lo_is_object_b
ip_reltype = p_reltyp.
* Check if everything OK...who cares!!
COMMIT WORK.Hi,
Welcome to the SDN Forums!!!
You need to supply the PC file extension in the container element 'DOCUMENTTYPE'.
swc_set_element lt_message_container 'DOCUMENTTYPE' p_msgtyp.
In your case change the above statement as below:
swc_set_element lt_message_container 'DOCUMENTTYPE' 'pdf'.
<b>OR</b> change the default value of p_msgtyp to 'PDF'.
Cheers,
Ramki Maley.
Please reward points if the answer is helpful.
For info on awarding points click on this link: https://www.sdn.sap.com/sdn/index.sdn?page=crp_help.htm
Message was edited by: Ramki Maley
Maybe you are looking for
-
Return Of goods in Third Party Process
How to Take back goods Return of Third Party Sale Process? Is Following Process Correct? 1)Third Party Order 2)Third Party Invoice(Dispatch from Vendor to Customer) 3)Return Order(with ref. to Invoice) 4)Return Delivery 5)Credit Memo what are the Ex
-
I am using Snow Leopard with a new iMac, and want to import the Address Book in my G4 Sawtooth running Tiger. How do get the content of the old address book to the new address book? Thanks. Robert
-
Why is the dictionary being changed to a language I don't want?
Despite having right clicked the dictionary of my choice it appears Firefox is automatically changed the dictionary from one language to another, it is using a dictionary contrary to the wishes of my precious setting. Is this a new feature to piss pe
-
Cannot Connect to Netflix ATV-U31
Hello Everyone, I have a 1 week old Apple tv and I was never able to watch netflix. In the beginning i thought that it had something to do with the account I was using. I made a new Netflix account and still nothing. All other apps do work Youtube, p
-
TRIED TO DOWNLOAD SOFTWARE ios7.1.2 TO MY IPAD. iPAD FROZE ON THE APPLE PICTURE AND WONT TURN OFF OR RESPOND AT ALL. IPAD MAY NEED MORE FREE MEMORY FOR THE NEW SOFTWARE BUT HOW DO I FREE UP MEMORY IF THE IPAD IS FROZEN. CAN THIS BE DONE ON iTUNES OR