Application Development and Automation 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: 
Read only

Function module - 'SO_DOCUMENT_READ_API1'

vinothkumar_g
Product and Topic Expert
Product and Topic Expert
0 Likes
9,517

Hi All,

I am trying the read the attached file from delivery document and i want to download that in desktop.

So i am using the function module 'SO_DOCUMENT_READ_API1' and the data's are populate in Object content and Content_hex tables.

Using the Gui_download i am passing the object content table. But the document which was downloaded stored in some other format.. How to do this..? can anyone have sample code for this.

problem - File is downloaded to my desktop. but it stores in different format...

CALL FUNCTION 'SO_DOCUMENT_READ_API1'

EXPORTING

DOCUMENT_ID = V_DOC1

FILTER = FILTER

IMPORTING

DOCUMENT_DATA = DOCUMENT_DATA

TABLES

OBJECT_HEADER = OBJECT_HEADER

OBJECT_CONTENT = OBJECT_CONTENT

  • OBJECT_PARA =

  • OBJECT_PARB =

  • ATTACHMENT_LIST =

  • RECEIVER_LIST =

CONTENTS_HEX = CONTENTS_HEX

EXCEPTIONS

DOCUMENT_ID_NOT_EXIST = 1

OPERATION_NO_AUTHORIZATION = 2

X_ERROR = 3

OTHERS = 4

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

FILENAME = 'C:\Documents and Settings\i041492\Desktop\TEST.txt'

FILETYPE = 'DAT'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = 'X'

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = OBJECT_CONTENT[]

4 REPLIES 4
Read only

arpit_shah
Contributor
0 Likes
4,846

hi,

may be try like this it is helpful to u.

FILETYPE = 'DBF'

instead of DAT

Read only

vinothkumar_g
Product and Topic Expert
Product and Topic Expert
0 Likes
4,846

Hi Arpit,

Thanks for your reply. But still i am facing the same problem.

Any other way to solve this?

Regards

Vinoth

Read only

Former Member
0 Likes
4,846

Hi,

Try changing DAT to ASC or TXT in the below line

FILETYPE = 'DAT'

Regards,

Satish

Read only

0 Likes
4,846

hi

Can you try the following :

CALL FUNCTION 'SO_DOCUMENT_READ_API1'

EXPORTING

document_id = l_doc_id

IMPORTING

DOCUMENT_DATA = DOCUMENT_DATA

TABLES

object_header = object_header

object_content = object_content

CONTENTS_HEX = CONTENTS_HEX.

then

IF CONTENTS_HEX IS NOT INITIAL.

DESCRIBE TABLE CONTENTS_HEX LINES lin.

input_length = lin * sy-tleng .

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

EXPORTING

input_length = input_length

IMPORTING

BUFFER = FILE_CONTENT

TABLES

binary_tab = CONTENTS_HEX.

Then you will send the FILE_CONTENT to a PDF output format. Did the same using Webdynpro and it worked.

eg:

  • get element via lead selection

lo_el_context = wd_context->get_element( ).

  • get single attribute

lo_el_context->set_attribute(

EXPORTING

name = `PDF`

value = FILE_CONTENT ).

I hope it helps.