Skip to Content
0

SAP Archiving : zip archivefile and File does not begin with %PDF

May 19, 2017 at 10:02 AM

465

avatar image

Hello All ,

i use the cl_abap_gzip to compress an xstring buffer and after compressing i assigned the value of the compressed document to the initial one

the problem is when i go to VF03/VF02 or OAAD and when i want to display the archive i have the message

"File does not begin with %PDF"

Thank u in advance

* document is a pdfxstring 
*pdflen is a int with the length of pdfxstring CALL METHOD cl_abap_gzip=>compress_binary EXPORTING raw_in = document raw_in_len = pdflen compress_level = 6 IMPORTING gzip_out = gzip_out gzip_out_len = gzip_out_len. if sy-subrc = 0 . clear document. clear pdflen. document = gzip_out. pdflen = gzip_out_len. ENDIF.
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Sandra Rossi May 19, 2017 at 10:41 AM
0

It's not very clear, but I assume you made a custom program to gzip a PDF archive, and now when you try to open it, there's an error message which says it's not a PDF file.

The error message makes sense, if the file name has still the extension .pdf, SAP/Windows expects a PDF file, not a GZIP file.

By the way, you should better use ZIP, not GZIP ! GZIP cannot be opened from standard Windows installation. A ZIP file can. Use CL_ABAP_ZIP instead of CL_ABAP_GZIP.

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Thanks Sandra ,

yes i agree with you , the problem that i'm not in a specific code i work under the standard of SAP and if i give the extension(.ZIP) after compressing they raise an error i'm exactly , i enhaced the standard program on the top of FM ARCHIV_CREATE_OUTGOINGDOC_MULT

and if i forced the ZIP format i will have

if documentclass <> 'PDF'.
raise error_format.
endif.
* get table content of links to be created
* describe table arc_i_tab lines arc_i_tab_count.
loop at arc_i_tab.
i_arc_i_tab = arc_i_tab.
append i_arc_i_tab.
if arc_i_tab-reserve = 'COMMIT'.
sw_commit = 'X'.
endif.
endloop.

and i also try with the CL_ABAP_ZIP i have the same problem

Thanks again for ur response ,

0

If you have enhanced the standard to save the PDF as a ZIP, then you should enhance the standard to unzip when the archive is retrieved.

Don't you think it makes sense?

0

Yes , it makes sense that what i'm trying to do now but i didn't found the right location to unzip before displaying the compressed archive

that's the problem

can u have a discussion here on https://messages.sap.com/ ?

0
Sandra Rossi May 19, 2017 at 02:03 PM
0

If the question is "which standard code is to enhance to unzip the archived PDF file (zipped by your custom code) while displaying it via the GOS toolbox ?", then maybe the concerned code is the function module ARCHIVOBJECT_DISPLAY. Add an external break-point (as the display is probably asynchronous) to make sure this is the one called.

Share
10 |10000 characters needed characters left characters exceeded
rachid ankri May 19, 2017 at 02:08 PM
0

Yes , i found that FM but here i didn't found the compressed buffer to uncompress

we have just parameters in exporting and gs_connection-reserve is 'PDF'

u see ?


sandra.png (13.4 kB)
Show 16 Share
10 |10000 characters needed characters left characters exceeded

Then, you have to go further in this function module.

0

it's been a long time i'm searching into this function modul but till now i didn't found where can i put my decompression code

Thank u a lot Sandra for your time

If you can contact me on sap message that will be helpful
(i'm one of your follower )

and thanks again

0

Quite deep in the process, maybe function module SCMS_DOC_URL_READ could be called. I think it calls SCMS_AO_TABLE_GET to retrieve the document. Add an external break-point there to confirm my guess. Be careful to only unzip if it's a ZIP file (four first bytes should be hexadecimal 504B0102). I'm still not talking about GZIP that you should really avoid.

(thank you, but as per forum rules, no private discussion for discussion follow-up : other people might help, and the solution may be helpful to other people seeking for the same question)

1

Yes , i confirm for the first function module SCMS_DOC_URL_READ but for the second SCMS_AO_TABLE_GET it's not called ( and for compressing i'll use CL_ABAP_ZIP but i should search how to decompress with this class ) ,

and the question is where can i retrieve this zip archivefile ?

thank you again

0

I can't know your exact context. Which value is returned by SCMS_DOC_URL_READ please? What does it do? (in some other context, SCMS_AO_TABLE_GET reads the archive file, but it seems you're in a different case)

0

SCMS_DOC_URL_READ return an url like that " SAPR3://SAPR3CMS/get/200/ZF/005056B449321ED78F96C1BEDF12310D//.PDF"

now i'am searching for the compressed binary table or xstring buffer to decompress it ( that begin as you mentioned by 504B0102) ..

0

Okay. Do a little more debug in SCMS_DOC_URL_READ. As far as I can see, I guess there's a "data provider callback" (method dp_callback in local class LCL_CMS_DP). I can see later on from this method that there's a call to function module SCMS_DOC_READ. Maybe this is the one which retrieves the file's content.

0

Yes . when i go deeper on debug i found there is a dp_callback->GET_DATA->SCMS_DOC_READ -> DB_UNPACK_OUT..
but till now i didn't catch the information

0

SCMS_DOC_READ has a return parameter CONTENT_BIN. Doesn't it contain your ZIP file?

0

yes but i don't have the length of the content_bin !

can i unzip without length , how?

0

Oh sorry, I see. But could you please tell everything you know, since the beginning, because I feel like an adventurer discovering what you have already found.

0

The size is in return parameter ACCESS_INFO, component COMP_SIZE. Can't you see that in debug?

0

Yes . i test with that size and the content_bin but i have the same problem in displaying the archivefile , i think that the place where i enhace the standard is wrong

i enhaced the standard on the top of FM ARCHIV_CREATE_OUTGOINGDOC_MULT because i have the information which is the document on xstring that i compressed

can you suggest another place for compressing the file ?

0

Don't think. Be sure. I don't understand how you can be uncertain that it is not the right data. When you zip the file, you can see via the debugger the length and the bytes, and you can even download it to your laptop. When you're running SCMS_DOC_READ, why don't you compare them?

If your feeling is that another place is better, then do it.

I won't propose you a solution, because there are lots of places where you can do it. Anyway, my proposition is "don't do that", it sounds me very risky. Where does this requirement come from? Can't you customize the content management software to automatically zip the data?

0

i try to dowload the zip file and it's done correctly . one step that i need is to decompress it
the problem is that scms_doc_read is executed on archiving process and when i display the archive ,

i have to catch the information about the binary content before the display

0

Sandra on debug execution skip LCL_CMS_DP->dp_callback ..

0
rachid ankri May 22, 2017 at 05:00 PM
0

if i have the content_bin and the size of this binary content , how can i unzip this data with CL_ABAP_ZIP , to avoid GZIP ?

Show 1 Share
10 |10000 characters needed characters left characters exceeded

You have lots of snippets of code everywhere on the web for CL_ABAP_ZIP !

0
Sandra Rossi May 25, 2017 at 02:55 PM
0

I have the feeling that the compression should be a major feature of any Content Management System (I could see that it's the default behavior of SAP Content Server). Shouldn't you first ask if this is possible to compress automatically with your CMS ? (then, the best place is the web site of the CMS, not the SAP forums).

Show 2 Share
10 |10000 characters needed characters left characters exceeded

OK i'll do that but and how can i know my CMS ?

0

Ask the system administrator.

0