0% found this document useful (0 votes)
122 views6 pages

Excel To Desktop

This document discusses saving a file from the SAP Business Document Service (BDS) to the local desktop in ABAP. It provides an ABAP code example to retrieve a document from BDS using BDS_DOCUMENT_GET_TABLE, concatenate the content into a string, convert it to binary using SCMS_XSTRING_TO_BINARY, save it locally using a file dialog and filename provided by the user, and open the file.

Uploaded by

Mark Wysor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
122 views6 pages

Excel To Desktop

This document discusses saving a file from the SAP Business Document Service (BDS) to the local desktop in ABAP. It provides an ABAP code example to retrieve a document from BDS using BDS_DOCUMENT_GET_TABLE, concatenate the content into a string, convert it to binary using SCMS_XSTRING_TO_BINARY, save it locally using a file dialog and filename provided by the user, and open the file.

Uploaded by

Mark Wysor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Source: http://scn.sap.

com/thread/1661467

Excel from BDS to Desktop


This question is Not Answered.

Frank Drescher
Apr 15, 2010 3:05 PM

Dear Experts,

i want save  a File from the Business Document Service to the local Desktop.

Have you a ABAP example

Greetings

Frank

 554 Views

Average User Rating


(0 ratings)

 Re: Excel from BDS to Desktop

Frank Drescher Apr 16, 2010 9:11 AM (in response to Frank Drescher)

REPORT  ZTESTPSP.

data:  COMPONENTS type table of  BAPICOMPON WITH HEADER LINE,

       SIGNATURE  type table of  BAPISIGNAT WITH HEADER LINE,

       CONNECTIONS  type table of  BAPICONNEC With header line.

data: lt_SIGNATURE type table of  BAPISIGNAT WITH HEADER LINE,


      lt_COMPONENTS type table of  BAPICOMPON WITH HEADER LINE,

      lt_CONTENT type table of  BAPICONTEN  WITH HEADER LINE,

      lt_ASCII_CONTENT type table of  BAPIASCONT  WITH HEADER LINE.

 create pdf

DATA:

      content TYPE xstring.

 file save

DATA:

      default_extension TYPE string VALUE 'PDF',

      filename TYPE string,

      path TYPE string,

      fullpath TYPE string.

 xstring to binary

DATA:

      pdf_data_tab TYPE STANDARD TABLE OF x255.

 
DATA: lv_filename TYPE string.

DATA: lv_path     TYPE string.

DATA: lv_fullpath TYPE string.

DATA: lv_content  TYPE xstring.

DATA: lv_length   TYPE i.

DATA: lv_rc TYPE sy-subrc.

DATA: lt_file TYPE filetable.

DATA: ls_file LIKE LINE OF lt_file.

cl_gui_frontend_services=>file_open_dialog(

  CHANGING

    file_table              =  lt_file  " Table Holding Selected Files

    rc                      =  lv_rc  ). " Return Code, Number of Files or -1 If Error Occurred

READ TABLE lt_file INTO ls_file INDEX 1.

IF sy-subrc = 0.

  lv_filename = ls_file-filename.

ENDIF.

 
 

CALL FUNCTION 'BDS_DOCUMENT_GET_TABLE'

  EXPORTING

   CLIENT                = SY-MANDT

    DOC_ID                = 'BDS_LOC2  AB359E8A6553AE4586BE29E15A1F6D3F'

   BINARY_FLAG           = 'X'

  TABLES

    SIGNATURE             = lt_SIGNATURE

    COMPONENTS            = lt_COMPONENTS

   CONTENT               = lt_CONTENT

   ASCII_CONTENT         = lt_ASCII_CONTENT

EXCEPTIONS

   NOTHING_FOUND         = 1

   PARAMETER_ERROR       = 2

   NOT_ALLOWED           = 3

   ERROR_KPRO            = 4

   INTERNAL_ERROR        = 5

   NOT_AUTHORIZED        = 6

   OTHERS                = 7.

IF SY-SUBRC <> 0.

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


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

ENDIF.

  loop at lt_CONTENT.

    CONCATENATE content lt_content-LINE into content in byte mode.

  endloop.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

  EXPORTING

    buffer     = CONTENT

  TABLES

    binary_tab = pdf_data_tab.

filename =  lv_filename.

cl_gui_frontend_services=>gui_download(

  EXPORTING

    filename = filename

    filetype = 'BIN'


  CHANGING

    data_tab = pdf_data_tab ).

cl_gui_frontend_services=>execute(

  EXPORTING

    document = filename ).

You might also like