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: 

Save binary file on backend corrupted ( NUL char )

Former Member
0 Kudos

Hi all

I am having some problem while saving data from GOS.I retrieve Gos file info with BDS_GOS_CONNECTIONS_GET. Then I have succesfully saved data in frontend (SO_OBJECT_READ + SO_OBJECT_DOWNLOAD) but having problem cannot understand in background (saving on backend).

For backend, I used SO_DOCUMENT_READ_API1 and then tried to save file with " OPEN DATASET loc_path FOR OUTPUT IN BINARY MODE. ... TRANSFER line TO loc_path".

I tried as working area Char, string, Xstring, Field-symbols... without luck ..

The file generated on server is corrupted, but is almost identical to the original. Here follows a shot of text-editor of same piece of file.

This is the correct file:

/Type /FontDescriptor

/Ascent 718

/CapHeight 718

/Descent -207

/Flags 35

/FontBBox [-166 -225 1000 931]

/FontName /Helvetica

/ItalicAngle 0

/StemV 105

>>

endobj

9 0 obj

/WinAnsiEncoding

endobj

10 0 obj

<<

/Type /Font

/Subtype /Type1

/BaseFont /Helvetica

This is the corrputed one:

/Type /FontDescNULriptor

/Ascent 718

/CapHeight 718

/Descent -207

/Flags 35

/FontBBox [-166 -225 1000 931]

/FontName /Helvetica

/ItalicAngle 0

/StemV 105

>>

endobj

9 0 obj

/WinAnsiEncoding

endobj

10 0 obj

<<

/Type /Font

/Subtype /Type1

/BaseFont /HelveticNULa

The ediroe (notepad++) show NUL characters.. that corrupt the file. Any idea of how to remove them?

Any hint is welcome

Regards

Gabriele

1 ACCEPTED SOLUTION

david_liu1
Advisor
Advisor
0 Kudos

Hello,

You should use class CL_BCS_CONVERT provided by SAP note 1151257 to convert the content.

You can implement SAP note 1151258 via note assistant. SAP note 1151257 will be automatically implemented as well. SAP note 1151258 contains the mentioned example report bcs_example_7. It shows how to send an excel attachment by using the BCS send interface. To convert the content into a format that Excel accecpts, it uses a method of the new class cl_bcs_convert, which is part of the correction of SAP note 1151257.

As mentioned in one of the last sections of SAP note 1151258 we recommend to switch to the newer BCS send interface instead of using function module so_document_send_api1 - however the methods of cl_bcs_convert will also work with that function module.

Regards,

David

3 REPLIES 3

david_liu1
Advisor
Advisor
0 Kudos

Hello,

You should use class CL_BCS_CONVERT provided by SAP note 1151257 to convert the content.

You can implement SAP note 1151258 via note assistant. SAP note 1151257 will be automatically implemented as well. SAP note 1151258 contains the mentioned example report bcs_example_7. It shows how to send an excel attachment by using the BCS send interface. To convert the content into a format that Excel accecpts, it uses a method of the new class cl_bcs_convert, which is part of the correction of SAP note 1151257.

As mentioned in one of the last sections of SAP note 1151258 we recommend to switch to the newer BCS send interface instead of using function module so_document_send_api1 - however the methods of cl_bcs_convert will also work with that function module.

Regards,

David

0 Kudos

Thank you very much  .. the solution is more simple. I start working on a code piece found here on sdn. In this code snippet, SO_DOCUMENT_READ_API1 interface was not completely used: there is the contents_hex parameter that returns the file correct without above mentioned troubles. Passing line by line to tranfer data, file is created correctly. I should watch interface before  ... Thank you anyway

0 Kudos

Excelent Gabriele;

Thank you for your contribution.

I add a code for example:

CALL FUNCTION 'SO_DOCUMENT_READ_API1'

       EXPORTING

         document_id                      = doc_id_new

       TABLES

          CONTENTS_HEX                     = tl_hex

EXCEPTIONS

        DOCUMENT_ID_NOT_EXIST            = 1

        OPERATION_NO_AUTHORIZATION       = 2

        X_ERROR                          = 3

        OTHERS                           = 4.


open dataset gv_filename for output IN LEGACY BINARY MODE.

     loop at tl_hex into wa_hex.

       transfer wa_hex TO gv_filename.

     endloop.

     close dataset gv_filename.


Best regards,

Mariano