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

Using FM SO_OBJECT_DOWNLOAD

siongchao_ng
Contributor
0 Likes
2,531

Hi all,

I am having problem in using this FM. I want to download any file to my local desktop from the file attachment list of an employee in PA20/PA30. I kept on getting Access via 'NULL' object reference not possible error message.

This is how I use it. The filename is obtained through the a pop up box asking user to input a file name with a file path.

CALL FUNCTION 'SO_OBJECT_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = 0

  • DEFAULT_FILENAME = ' '

filetype = 'BIN'

path_and_file = lo_stru_output_param-file_name "C:\Users\sc\Desktop\xyz.pdf

  • EXTCT = ' '

no_dialog = ' '

  • CODEPAGE =

  • IMPORTING

  • FILELENGTH =

  • F_CANCELLED =

  • ACT_FILETYPE =

  • ACT_FILENAME =

TABLES

objcont = lt_object_cont

EXCEPTIONS

file_write_error = 1

invalid_type = 2

x_error = 3

kpro_error = 4

OTHERS = 5

.

IF sy-subrc <> 0.

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

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

ENDIF.

Hi all,

I am having problem in using this FM. I want to download any file to my local desktop from the file attachment list of an employee in PA20/PA30. I kept on getting Access via 'NULL' object reference not possible error message.

This is how I use it. The filename is obtained through the a pop up box asking user to input a file name with a file path.

CALL FUNCTION 'SO_OBJECT_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = 0

  • DEFAULT_FILENAME = ' '

filetype = 'BIN'

path_and_file = lo_stru_output_param-file_name "C:\Users\sc\Desktop\xyz.pdf

  • EXTCT = ' '

no_dialog = ' '

  • CODEPAGE =

  • IMPORTING

  • FILELENGTH =

  • F_CANCELLED =

  • ACT_FILETYPE =

  • ACT_FILENAME =

TABLES

objcont = lt_object_cont

EXCEPTIONS

file_write_error = 1

invalid_type = 2

x_error = 3

kpro_error = 4

OTHERS = 5

.

IF sy-subrc <> 0.

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

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

ENDIF.

2 REPLIES 2
Read only

Former Member
0 Likes
1,616

Have you executed in debug to see what value you're missing? Something needed is not there...thus the NULL.

Read only

siongchao_ng
Contributor
0 Likes
1,616

Use this:

DATA lr_conv TYPE REF TO cl_abap_conv_out_ce.

DATA lv_data TYPE string.

DATA lv_xfile TYPE xstring.

lv_data = 'Example text, which will be opened in MS Word.'.

cl_abap_conv_out_ce=>create( RECEIVING conv = lr_conv ).

lr_conv->convert( EXPORTING data = lv_data

IMPORTING buffer = lv_xfile ).

cl_wd_runtime_services=>attach_file_to_response(

EXPORTING i_filename = 'wd4a.doc'

i_content = lv_xfile

i_mime_type = 'application/msword' ).