Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

PDF File corrupted in app server

0 Kudos

Hi ,

I am uploading the PDF forms in the appserver AL11, I get the PDF string and convert that string to Binary and transfer the data to AL11 specified Folder, This is working fine and PI middleware can access this PDF files, However the PDF file is corrupted only for two of the customers.

The same above logic applies for all , out of 116 files processed only 2 of them were determined as corrupted.

Does anyone has experience with such issues? Experts suggestions are more appreciable.

Thanks,

Sailaja
,

12 REPLIES 12

Sandra_Rossi
Active Contributor
0 Kudos

People have posted many issues in that forum because they don't master the conversions, so I advise you to upload the PDF directly in binary (OPEN DATASET IN BINARY MODE).

PS: Your issue may happen for instance because you had extra blank characters added at the end of the PDF during your conversion. It's possible that the laptops/PDF readers of the two of your customers are different from others. Anyway, the primary issue is probably your abap code.

0 Kudos

Hello,

Yes I am already using Open data set in Binary mode only..

Sailaja

0 Kudos

But then, why do you store into a string, and "convert that string to Binary"?

0 Kudos

Hi Janaje,

you said you are

"uploading the PDF forms in the appserver AL11" ... "get the PDF string ".

"uploading"  usually means upload (through SAP GUI) from frontend into memory of active server program.

Sorry. There is no such thing like an "appserver AL11".


Also, I never heard of a "PDF string".

Why do you hide all necessary information enabling people to help you? Are you working for the secret service, is everything (including your ABAP code) top secret?

Please!!!

Regards Clemens

0 Kudos

you may need this:

*-- Upload file data

  CALL METHOD cl_gui_frontend_services=>gui_upload

    EXPORTING

      filename                = l_filename

      filetype                = 'BIN'

    IMPORTING

      filelength              = l_file_len

    CHANGING

      data_tab                = lt_raw

    EXCEPTIONS

      file_open_error         = 1

      file_read_error         = 2

      no_batch                = 3

      gui_refuse_filetransfer = 4

      invalid_type            = 5

      no_authority            = 6

      unknown_error           = 7

      bad_data_format         = 8

      header_not_allowed      = 9

      separator_not_allowed   = 10

      header_too_long         = 11

      unknown_dp_error        = 12

      access_denied           = 13

      dp_out_of_memory        = 14

      disk_full               = 15

      dp_timeout              = 16

      not_supported_by_gui    = 17

      error_no_gui            = 18

      OTHERS                  = 19.

  CHECK sy-subrc = 0.

*-- Convert data to xstring

  CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

    EXPORTING

      input_length = l_file_len

    IMPORTING

      buffer       = l_pdf_xstring

    TABLES

      binary_tab   = lt_raw

    EXCEPTIONS

      failed       = 1

      OTHERS       = 2.

  CHECK sy-subrc = 0.

0 Kudos

I precise more below:

This is related to Customer statements SAP08, std.prgm RKFORD11_PDF.

I have written an enhancement under form CLOSE_PDF It will take the PDF value obtained from structure LS_FORMOUT-PDF (This LS_FORMOUT will be filled when we generate the Function module) , Then I used function SCMS_XSTRING_TO_BINARY by passing LS_FORMOUT-PDF

and convert into BINARY .

Using OPENDATA SET in BINARY MODE, I will TRANSFER this binary data to some file path under Transaction AL11.

This is my logic for the program , However when files are placed in AL11, PI will transfer this Files from AL11 to some third party system, the issue is the PDF file is able to open for all the customers except two of them. not sure why only these two customer PDF file are get corrupting always.

Please help...Let me know if you need any additional info.

Sailaja

0 Kudos

Hi,

It can be corrupted because of the addition of a space or any special character. Did you check the file contents by opening in AL11?

0 Kudos

Thanks for the reply,

Agreed there are special characters because these forms are for Canada, Standard texts are created for such texts and the same texts are available for all the customers. And PDF contents are actually not in readable format it will include with some junk chars like # and HTML code.

Sailaja

0 Kudos

After converting it to binary with function module SCMS_XSTRING_TO_BINARY , what is the output contents of the function module. Try searching for the junk character before transferring it to AL11.

Replace those junk characters with space and check.

0 Kudos

Are you using any code page in OPEN DATASET. If not, try with the CODE PAGE addition to it.

Search in SCN about code page for more details. Refer to below link for syntax.

https://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_MODE.htm

0 Kudos

Binary code page - what's that?

@Janaje What lenght do yo give to SCMS_XSTRING_TO_BINARY?

Regards Clemens

0 Kudos

Thank you for this detailed answer, I think we all understand better, but some of the latest answers add confusion.

If you display a PDF file using AL11, it won't work well because it displays the PDF as if it was a text file. So AL11 is of no help for displaying a binary file.

Attempting to open a PDF file (it's binary) with a CODE PAGE is consequently no sense, as a code page is for converting the code page of a text file (for instance 'A' in ASCII is represented by hex 41, and if it's converted to EBCDIC it becomes hex C1.

Let's now look at the different steps of your conversion:

ABAP custom code is most probably the culprit, rather than PI (that's an experimented guess).

As you the PDF as a XSTRING, you might write it directly to the server, without SCMS_XSTRING_TO_BINARY. Just OPEN DATASET IN BINARY MODE, and TRANSFER the XSTRING once, CLOSE, and that's all.

If you still want to use SCMS_XSTRING_TO_BINARY (followed by a loop at the internal table to transfer it line by line), that's not really a conversion, rather a "kind of casting" from type XSTRING to an internal table of type X. No harm at this point. But the point, is that you must write a file with exactly the length that has XSTRING, as Clemens says ; when you write the last line of the internal table, there is a problem, because you write the whole line with extra 00 bytes. You should shorten this last line so that the file length matches the length of the XSTRING. You may shorten it by using TRANSFER line TO file LENGTH the length you want. Another solution is to use TRUNCATE DATASET file AT POSITION file_length.