How to via JCO Call RFC upload file to the SAP DMS.
HI ,ALL :
NOW i want to upload file via JCO,but i upload in sap gui is success ,but jco call RFC is error ,this is my code:
excute this code is not error ,but the data not write to SAP,
//连接SAP
Client client = com.hipfung.jco.JCOFactory.getInstance().getClient();
JCO.Repository repo = new JCO.Repository("ZOA01", client);
//调用RFC函数
IFunctionTemplate ft = repo.getFunctionTemplate("CVAPI_DOC_CHECKIN");
JCO.Function f = ft.getFunction();
IFunctionTemplate ft2 = repo.getFunctionTemplate("BAPI_TRANSACTION_COMMIT");
JCO.Function commitFunction = ft2.getFunction();
//设置传入参数值(注意类型)
//1.传入参数为Field
f.getImportParameterList().setValue("TXB", "PF_DOKAR"); //
f.getImportParameterList().setValue("0000010101010101020000000","PF_DOKNR"); //文档类型
f.getImportParameterList().setValue("01","PF_DOKVR"); //文档版本
f.getImportParameterList().setValue("000","PF_DOKTL");
f.getImportParameterList().setValue("SAPFTPA","PF_FTP_DEST");
f.getImportParameterList().setValue("SAPHTTPA","PF_HTTP_DEST");
// Get content as table
f.getImportParameterList().setValue("TBL", "PF_CONTENT_PROVIDE");
//read file and trans to byte
byte b[]=null;
File inf = new File("d:
test.jpg");
InputStream in;
try {
in = new FileInputStream(inf);
b =new byte[(int)inf.length()]; //创建合适文件大小的数组
in.read(b); //读取文件中的内容到b[]数组
in.close();
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
//set byte to internal table
JCO.Table poItem = f.getTableParameterList().getTable("PT_CONTENT");
poItem.appendRow(); //增加空行
poItem.setValue(b, "ORBLK");
poItem.nextRow();
//运行RFC函数
try
client.execute(f);
client.execute(commitFunction);
catch(JCO.AbapException ae)
System.err.println("JCO.AbapException: < DMS > " + ae);
ae.printStackTrace();
catch(JCO.Exception e)
System.err.println("JCO.Exception: < DMS > " + e);
e.printStackTrace();
//返回参数
JCO.Structure struct = f.getExportParameterList().getStructure("PSX_MESSAGE");
String te = struct.getString("MSG_TYPE");
System.out.println("RFC Error Type is :"+te);
String pr = struct.getString("MSG_TXT");
System.out.println("RFC get Data is :"+pr);
com.hipfung.jco.JCOFactory.getInstance().release(client);
i can get file via CVAPI_DOC_CHECKoutView
Edited by: pan qiaoming on Mar 15, 2011 3:05 PM
HI ,ALL :
NOW i want to upload file via JCO,but i upload in sap gui is success ,but jco call RFC is error ,this is my code:
excute this code is not error ,but the data not write to SAP,
//连接SAP
Client client = com.hipfung.jco.JCOFactory.getInstance().getClient();
JCO.Repository repo = new JCO.Repository("ZOA01", client);
//调用RFC函数
IFunctionTemplate ft = repo.getFunctionTemplate("CVAPI_DOC_CHECKIN");
JCO.Function f = ft.getFunction();
IFunctionTemplate ft2 = repo.getFunctionTemplate("BAPI_TRANSACTION_COMMIT");
JCO.Function commitFunction = ft2.getFunction();
//设置传入参数值(注意类型)
//1.传入参数为Field
f.getImportParameterList().setValue("TXB", "PF_DOKAR"); //
f.getImportParameterList().setValue("0000010101010101020000000","PF_DOKNR"); //文档类型
f.getImportParameterList().setValue("01","PF_DOKVR"); //文档版本
f.getImportParameterList().setValue("000","PF_DOKTL");
f.getImportParameterList().setValue("SAPFTPA","PF_FTP_DEST");
f.getImportParameterList().setValue("SAPHTTPA","PF_HTTP_DEST");
// Get content as table
f.getImportParameterList().setValue("TBL", "PF_CONTENT_PROVIDE");
//read file and trans to byte
byte b[]=null;
File inf = new File("d:
test.jpg");
InputStream in;
try {
in = new FileInputStream(inf);
b =new byte[(int)inf.length()]; //创建合适文件大小的数组
in.read(b); //读取文件中的内容到b[]数组
in.close();
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
//set byte to internal table
JCO.Table poItem = f.getTableParameterList().getTable("PT_CONTENT");
poItem.appendRow(); //增加空行
poItem.setValue(b, "ORBLK");
poItem.nextRow();
//运行RFC函数
try
client.execute(f);
client.execute(commitFunction);
catch(JCO.AbapException ae)
System.err.println("JCO.AbapException: < DMS > " + ae);
ae.printStackTrace();
catch(JCO.Exception e)
System.err.println("JCO.Exception: < DMS > " + e);
e.printStackTrace();
//返回参数
JCO.Structure struct = f.getExportParameterList().getStructure("PSX_MESSAGE");
String te = struct.getString("MSG_TYPE");
System.out.println("RFC Error Type is :"+te);
String pr = struct.getString("MSG_TXT");
System.out.println("RFC get Data is :"+pr);
com.hipfung.jco.JCOFactory.getInstance().release(client);
i can get file via CVAPI_DOC_CHECKoutView
Edited by: pan qiaoming on Mar 15, 2011 3:05 PM
Similar Messages
-
How to open files from the SAP DMS (DOC Mgt. System) ?
Hello All,
I making the Transaction CV04N in BSP.
When I execute this CV04N I should give a DOC Nr and the list is generated for this DOC.Now in the List if I select one Record and then Press Display Icon then the content of this list is opened in a new window in it's respective format (PDF,Word,GIF,Image file etc).These are stored in the SAP DMS.
I want to open a file from this SAP DMS .
This can be done in ABAP using the standard FMs. But in BSP we can't use these FMs as it will call a screen.
The Fm which I'm using is " DOCUMENT_SHOW_DIRECT ".
In Report prog. To this FM I'll pass the
a, DOC Type
b, DOC Number
c, Document part and
d, Document version.
then It'll directly open a PDF file in a new window.
But in BSP how should I acheive this as the FM calls a screen internally.
The content of the documents are stored in the DMS. Is there any TCODE or Table to get the files from the DMS ?
How should I proceed ? can any one help me out.....
Regards,
Deepu.KHello All,
I found the FM : <b>CVAPI_DOC_OPEN_CAD</b> which wil return the file path.
But when I execute this in my BSP since the FM internally calls a screen it fails.
But can anyone tell me the alternative for this.
Should I create a FM omitting the GUI code ?
I found one more thread which says that I can use classes starting with cl_gos*.
But all the classes use a gui.
Dowload a document from R/3 DMS to BSP page
Am I wrong in the interpretation of the logic from the above thread ?
Please suggest me .
I too went thru the BSP Applications <b>CVAW_ENTIRE, CVAW_DOCUMENT_DISPLAY.</b>
But these are used to display only the <b>thumbnails.</b>
There is no code for displaying other formats like PDF,XLS etc.
Please correct me if I'm wrong and let me know the correct path to solve my problem.
Regards,
Deepu.K -
How to list the uploaded files on the server with a jsp page
hi every body , iam stuck up with yhis problem . I a have use Random Access File to upload files to the web server , now i want the user can see the files he /she has uploaded or the the files uploaded by others . plese help me how to implement this .
Message was edited by:
joshiashutoshhi every body , iam stuck up with yhis problem . I a
have use Random Access File to upload files to the
web server ,Huh?
now i want the user can see the files he
/she has uploaded or the the files uploaded by others
. plese help me how to implement this .So get the directory using the File class the files are in and list the files inside, showing the result to the user... how difficult would that be? -
How to store a JSP file in the SAP Application server ?
Hello All,
My reqt. is as follows :
1. I need to store a JSP File on the SAP Application server .
How can I do this ?
2. I want to call the uploaded jsp file from the server and call this jsp from abap to view the result of it .
How can I achieve this ?
First of all is this possible ?
Regards,
Deepu.KHello Mike,
Thanks for ur reply.
I've imported the JSP as a mime object into the BSP.
Now I've created the page to show that Mime Object as an image.
But nothing is coming as an output.
But then,there is an option for that mime object. i.e when I right click on the mime object there is an option called " convert to BSP".
I selected that option and it created a view in my BSP .( My BSP is a page with flow logic application )
Now how should i make this view to be an output ?
I guess this shud be posted in the BSP Forum ...but still taking a chance here :)-
Regards,
Deepu.K -
How to save 4 versions of a file in the application server
Hi,
I have to write a program which will extract few data from SAP and write it in a file in the SAP application server. This program will be run once every month.
I need to save 4 versions of the files, current and 3 prior. These versions should cycle off the oldest once a new version has been created.
Could anyone help me how to do this?
Thank you!
Regards,
Sunitha.Hi Sunitha,
The best way is to write a unix script in the unix server to do the job for you. Once The file is written in the server then leave the job from the unix side to get this done.
This is the best option i think. Writing a script is not a big task. You can call the script from ABAP or from an external daemon in the unix server. We have many such programs in our org.
Hope this helps
Cheers
VJ -
Uploading file to the servelet and write directly into database
i want client to upload file to the server (using servlet for that) and i just don't want to store it to the hard disk, but i want to write it
into the the ms sql database (that i m using).
TIAHere is a good site for learning how to upload a file using a servlet:
http://www.servlets.com/cos/index.html
Once you get the file in the servlet you shouldn't have any problem storing it to a DB. -
Why do I get error -17500 when calling a batch file using the call executable step type?
I am calling a batch file using the call executable step type. If the path to the batch file contains a space I get error -17500 and a message stating there was an error in "Post". For example the path to the batch file is "c:\TestWin\Test Files\...\Program.bat" When I run this I get the above mentioned error, however if I change my directory structure so the path is now "c:\TestWin\TestFiles\...\Program.bat" it runs fine. I use the browse feature to find my batch file so it is not me typing in a path incorrectly. I have removed the batch file and I get a different error stating that it couldn't find the file so it appears that for my error it can find the file but can't run it. I am
sure that this has something to do with the fact that batch files are written in DOS but really don't want to resort to changing my directory structure on all my test stations. Is there any way to fix this problem so I can leave a space in my path?It appears I have figured it out. This was on another computer so I was unaware of how they used their computer. I like you got it to work in the temp directory and in fact got the program.bat file to work as long as I put it under the temp directory, but when I switched out to my TestWin directory it wouldn't work, so I removed everything from the directory except the batch file it self and it work. What I found out after adding files in one at a time is that the person had a file called "Test" with no file extension in there "c:\TestWin\" directory. Removing this file made it work. Putting the file back broke it. So it appeares that when teststand was running it followed the path saw a space and attempted to grab the "Test" file instead of bro
wsing into the "Test Files" directory. If you create a file in your temp directory called "temp" with no file extension you will see the same problem. Thank you for your help. -
(RFC vs files), where Sender SAP and receiver multiple system
Publish and Subscribe using BPM or Without BPM (RFC vs files), where Sender SAP and receivers multiple system,.
This is my 1st BPM scenario in sandbox system
For this scenario
I Created 2 Data types
2 MT,
Service interface:
Request interface Mode:Asynchronous
Abstract Req interface,Mode:Asynchronous
Response Interface,Mode:Asynchronous
Abstract Respomse Interface ,Mode:Aysnchronous
Synchronous Interface ,Mode:Synchronous
2 Message mapping for Req and Resp
1 Operation Mapping
BPM design: Plz find the attatchement
Can anyone please help me how many Interface determinations,receiver determinations ,sender agreements,receiver agreements need to create for this.......
It will be good if anyone send the BPM design flow for this.........
can we do this scenario without BPM?
Regards
A.Muni kumar
Edited by: Muni 1234 on Jan 31, 2012 10:24 AMHi
Receiver is FTP only.....
SAP side is RFC.........
RFC sender will be initiating the scenario, and there is receiver is File, PI should go to file directory and take the file then send it back to RFC as response.
Sender: RFC
Receiver: File
1. is this scenario with condition based routing.. so that each time outof many receiver systems it will trigger any specific system.
if above is the case then you can achive this without BPM also..
Yes...its condition based routing...
I Used async in this scenario.....sender side configurations also done....
But when when I am triggering BAPI from SE37 I am getting an error
Exception SYSTEM_FAILURE
Message ID: 00 Message number: 341
Message:
Runtime error CALL_FUNCTION_NOT_FOUND has occurred
How to Solve this????
I checked the RFC destination which i created in TCP/IP..a nd i mentioned the same in se37 RFC target system..
Connection is Ok
Or we need to create proxy for MI and report for this?
Edited by: Muni 1234 on Feb 1, 2012 8:38 AM -
When "Upload File" , show the IE error page
question: when "Upload File" , show the IE error page. How to soluve the problem?
Duplicate post.
when "Upload File" , show the IE error page
when "Upload File" , show the IE error page -
How do I access my back up files from the time machine if my computer was stolen?
Hi, how do I access my back up files from the time machine if my mac book pro was stolen? I have a mac book air and mac too. But not sure how I can get back all the files from the stolen computer from my time capsule
On the Mac Book Air or other Mac that you have, use Migration Assistant to transfer files from the Time Machine backups of the Mac that was taken.
Macintosh HD > Applications > Utilities > Migration Assistant -
How can I run a a class file on the Apache server?
Hi Guys and Gurus,
I am seeking some favor all of experienced gurus, i.e.
How can I run a a class file on the Apache server?
Actually, I want to extract some records from a MySQL Database running on Apache Server. I wrote a program just to select the columns and show them. It is now a Class file, Now how can I run this class file from the Server???
Please advise...
VJcross posted
http://forum.java.sun.com/thread.jsp?thread=299137&forum=31&message=1184025 -
How do I setup permission to transfer files to the MacMini Server. I thought I had it setup to do such but apparently not as I get an error message that I don't have permission?
Both the Mac and Windows units we are usinghave connectivity to the MacMiniServer (on the same network) to open and edit files but cannot transfer new files to the MacMini. FileSharing is on. I went to File Sharing on the MacMini and added the appropriate users and checked FileSharing. Is there something else I needed to do?
-
URGENT PLEASE:How can I run a a class file on the Apache server?
Hi Guys and Gurus,
I am seeking some favor all of experienced gurus, i.e.
How can I run a a class file on the Apache server? Can I run through an Applet?
How can I set Environment variables in Windows2000 Professional Environment?
Actually, I want to extract some records from a MySQL Database running on Apache Server. I wrote a program just to select the columns and show them. It is now a Class file, Now how can I run this class file from the Server???
The code is here
import java.sql.*;
public class RecordShow {
public static void main(String args[]) {
String url = "jdbc:mysql://localhost/myhost";
Connection con;
String query = "select mytable.column," +
"from mytable " +
"where mytable.column = 1";
Statement stmt;
try {
Class.forName("com.mysql.jdbc.Driver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
try {
con = DriverManager.getConnection(url,
"myuser", "mypassword");
stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
int rowCount = 1;
while (rs.next()) {
System.out.println("Row " + rowCount + ": ");
for (int i = 1; i <= numberOfColumns; i++) {
System.out.print(" Column " + i + ": ");
System.out.println(rs.getString(i));
System.out.println("");
rowCount++;
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.print("SQLException: ");
System.err.println(ex.getMessage());
Please advise... THANKS
VJEhm, I wasn't referring to you at all... read up,
there's a comment by jschell saying that CGI might be
easier/better for his purposes.
Yep.
I know PHP/Perl/whatever might be easier for some
purposes, but only if you happen to know them and want
to/are able to use them. Ok. But you aren't the one asking the question are you. And the person who asked the question seems to have absolutely no familiarity with Apache or applets.
So whatever they do they are going to have to learn a lot.
And that does indeed suggest that in all likelyhood they have not investigated the alternatives.
And for the vast majority of internet applications, especially with smaller projects (obvious this person is not working with a large team), using perl, or something besides java, is going to be the best business solution. It is simpler, and more secure (probably due to the fact that it is simpler.)
Since this is a Java forum, I
answer under the assumption that people have made a
choice one way or another to use a Java solution to
their problem, so I try to solve it in Java first, and
only when that fails (very seldom) do I turn to other
solutions.You approach problems by arbritrarily deciding to try to solve it in java first and only if you fail do you then look to other solutions?
My first step is to try to figure out which of the various avenues is going to cost less. (And a secondary, but non-trivial concern, is then to convince the customer that just because they have heard of a buzz word like 'enterprise bean' that it doesn't mean that is a cost effective solution.) We must come from different worlds. -
How to run a remote windows dll files and the drivers of the system using j
Dear Friends,
I need some valuable info regd how to run a remote windows dll files and the drivers of the system using java
reply regd thanking youPlease don't make duplicate posts like this.
-
How we can restrict record in CTL file on the basis of other table ?
Hello all,
How we can restrict record in CTL file on the basis of other table ?
Eg.
I have following control file to load the records in the table through the sql loader.
LOAD DATA
INTO TABLE THIST APPEND
FIELDS TERMINATED BY "|" TRAILING NULLCOLS
LNUM POSITION(1) Char "substr(:LOAN_NUM, 4, 13)",
TSRNUM Char "rtrim:TRAN_SR_NUM)" ,
TPROCDT Char "to_char(to_date rtrim:TRAN_PROC_DT), 'MMDDYYYY'), 'YYYYMMDD')"
I have another table c all TFILE in which I have LNUM. I want to import only those records from input text file using the control file and sql loader in which LNUM is exist in the TFILE.
So how i can restrict it in the Control File.
Thanks
Kamlesh Gujarathi
[email protected]Hello Satyaki De.
Thank you very much for your suggestion but my Private information is totally apart from this question & I already I have changed each and every information from the question.
Thanks
Kamlesh Gujarathi
[email protected]
Maybe you are looking for
-
Latest MediaSource Plugins for various Creative MP3 Players are now available for downl
Just went to the product support site. Guess what? The latest MediaSource plugins for the various Creative MP3 Players are now available for download. I am sure the latest plugins should have fixed several problems. Don't forget to download the lates
-
Cannot have execute_query in post-change but can have it when-radio-changed
why is it possible to put execute_query in a when-radio-changed trigger but one cannot put it in a post-change or post-text-item trigger? (11.1.1.4) For example I want to ask for a year, and a month. I don't much feel like creating radio items for al
-
Hi, Can we have account assignment model in FB60 & FB65. I am not getting this in the screen. How to call the model while posting in FB60 Regards John
-
Grayed out in State View SCOM 2012 R2
I want to display only the following items in a state view: Critical Warning Unmonitored Grayed out Computers/Servers How do I do this?
-
Problem with Oracle Thin Driver
I use the Thin Oracle Driver (ojdbc14.jar) in my project and execute the code below. import java.sql.*; class dbAccess public static void main(String args[]) throws SQLException DriverManager.registerDriver(new oracle.jdbc.driver.Oracl