on 10-12-2009 11:00 AM
Hi all,
I need to extract attachments from the Pdf file as separated files while the user uploades a pdf file to the SAP system.
I'm using an offline scenario (JAVA).
May be PdfObject is what I need, but I don't know how exactly I can do this.
Thanks,
Michael Beilin
the same methods of the PDf Object are available for Java and ABAP because the are accesed via a SOAP call from both stacks, so this should work
thats abap coding
Create PDF Object.
l_pdfobj = l_fp->create_pdf_object( connection = p_dest ).
Set document. l_pdf is the PDF data including the attachments
l_pdfobj->set_document( pdfdata = l_pdf ).
Set task to get attachments.
l_pdfobj->set_task_getattachments( ).
Execute, call ADS.
l_pdfobj->execute( ).
Get result.
l_attachments = l_pdfobj->get_attachments( ).
hope it helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I'm not familiar with ABAP coding, I'm using WebDynpro for Java.
I have the context attribute of binary type that is bined to data attribute of FileUpload element.
ABAP coding:
Create PDF Object.
l_pdfobj = l_fp->create_pdf_object( connection = p_dest ).
How can I do the same in Java?
Thanks
Micahel Beilin
hi,
Michael Chytracek, one of our java developers has given me the following hint:
Important:use the "new!" API u201CPDFDocumentu201D because the old u201CPDFObjectu201D API can not handle attachments. Attachment API for the Interactive form have been made available with the following:
NW04s SP09 Web Dynpro Runtime + hotfix release (Note: 982023)
NW04s SP10 Web Dynpro Runtime + hotfix release (Note: 984868)
SP11 onwards > Base SAP release
IWDPDFDocumentAccessibleContext pdfContext = WDPDFDocumentFactory.getDocumentHandler().getDocumentAccessibleContext();
pdfContext.setPDF(pdf);
IWDPDFDocument pdfDocument = pdfContext.execute();
IWDPDFDocumentAttachment[] attachments = pdfDocument.getAllAttachments();
for(int i = 0; i < attachments.length; i++){
IWDPDFDocumentAttachment att = attachments<i>;
.......
}
br norbert
Hi Norbert,
Thanks for your help. I have try your solution, but without success.
In method
pdfContext.setPDF(pdf);
"pdf" parameter is of type "binary" that is binded to FileUpload Element also.
But in attachments.length I get 0 value(the pdf file has 2 attachments).
Have any idea what may be the problem?
Thanks,
Michael Beilin
Hi Norbert,
I have that structure in every att (attachments instance), but attachments is empty!
I see in debugger that pdfContext.setPDF(my binary source) is filled correctly with data from pdf file.
And after
IWDPDFDocument pdfDocument = pdfContext.execute();
IWDPDFDocumentAttachment[] attachments = pdfDocument.getAllAttachments();
commands I see that attachments.length = 0.
May be something missing?
Thanks
Michael Beilin
See if below blog helps:-
[Demystifying Attachments with SAP Interactive Forms|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/8498] [original link is broken] [original link is broken] [original link is broken];
Chintan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Chintan
Nice blog.But, here you need to go to the backend R/3 to extract the attachemnts from the pdf.
PDFObjects are available in webdynpro for Java as well. So, there has to be a way to replicate the attachment-extracting functionality (that was achieved in R/3), in webdynpro for java too.
Thanks,
Michael Beilin
there is a mthod for the PDF object - must be the same for java --> get_attachments()
you get an array of the attachments
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
have a look at report FP_PDF_TEST_15 in your system...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.