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: 

spool to excel file

Former Member
0 Kudos

Hi

I need to download spool content to excel file in sap script.

It would be appreciated if any one knows fn module or any other way to solve this.

Thanks

Ragavan.S

8 REPLIES 8

Former Member
0 Kudos

CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'

EXPORTING

rqident = tsp01-rqident "Spool Request Number

first_line = 1

TABLES

buffer = it_spool_xls "Internal table that will have the Spool Request No data

EXCEPTIONS

no_such_job = 1

not_abap_list = 2

job_contains_no_data = 3

selection_empty = 4

no_permission = 5

can_not_access = 6

read_error = 7

OTHERS = 8.

CALL FUNCTION 'SO_RAW_TO_RTF'

TABLES

objcont_old = it_spool_xls "Internal table having spool data

objcont_new = it_xls_spool. "Int table having Excel format data converted from Spool data

*To convert the excel format data into string

LOOP AT it_xls_spool.

CONCATENATE xls_string it_xls_spool INTO xls_string. "xls_string will have the data as one string

ENDLOOP.

*To convert the string into xstring format for mail sending

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = xls_string "String of String data type

  • MIMETYPE = ' '

  • ENCODING =

IMPORTING

buffer = xls_str "String of XString data type

EXCEPTIONS

failed = 1

OTHERS = 2

.

IF sy-subrc <> 0.

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

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

ENDIF.

*To send mail the xstring having excel format data

TRY.

  • Create persistent send request

send_request = cl_bcs=>create_persistent( ).

  • Create and set document

pdf_content = cl_document_bcs=>xstring_to_solix( xls_str ). "String having Excel format

"Data above populated

document = cl_document_bcs=>create_document(

i_type = 'XLS'

i_hex = pdf_content

i_length = pdf_size

i_subject = 'Asset Origin Details Report' ). "#EC NOTEXT

  • Add document object to send request

send_request->set_document( document ).

  • Add recipient (e-mail address)

  • Create recipient object

recipient = cl_cam_address_bcs=>create_internet_address( p_email ).

  • Add recipient object to send request

send_request->add_recipient( recipient ).

  • Send document

sent_to_all = send_request->send( i_with_error_screen = 'X' ).

COMMIT WORK.

IF sent_to_all IS INITIAL.

MESSAGE i500(sbcoms) WITH p_email.

ELSE.

MESSAGE s022(so).

ENDIF.

  • Exception handling

  • replace this rudimentary exception handling with your own one

CATCH cx_bcs INTO bcs_exception.

MESSAGE i865 (so) WITH bcs_exception->error_type.

ENDTRY.

Edited by: I.Muthukumar on Jan 28, 2010 8:42 AM

Former Member
0 Kudos

hi

Try the following given link

[http://wiki.sdn.sap.com/wiki/display/sandbox/ToConvertSpoolDataintoPDFandExcelFormatandSenditinto+Mail]

hope this helps

Regards

Ritesh

Former Member
0 Kudos

Hi,

use FM RSPO_RETURN_ABAP_SPOOLJOB to get spool content to internal table. Than it is easy, You just need to download this table.

What exactly do You mean by "excel file in sap script"?

Regards,

Adrian

andreas_mann3
Active Contributor
0 Kudos

try fm like

RSPO_RETURN_ABAP_SPOOLJOB

A.

sorry Adrian I have'nt seen your posting!

Edited by: Andreas Mann on Jan 28, 2010 9:03 AM

Former Member
0 Kudos

Hi All

Thanks for you answer .

I tried this fn module. But I am not sure how to give input for this . .

1. **objcont_old = it_spool_xls --> Hw do I pass the parameter here*

Message: CALL FUNCTION 'SO_RAW_TO_RTF'

TABLES

objcont_old = it_spool_xls *--> Hw do I pass the parameter here

objcont_new = it_xls_spool. "Int table having Excel format data converted from Spool data

2. RSPO_RETURN_ABAP_SPOOLJOB -

If give the spool number ---RQIDENT.. I am not getting any output.

Please suggest.

Thanking you

Ragavan.S

Former Member
0 Kudos

Hi,

Please go through this link below:

https://wiki.sdn.sap.com/wiki/display/sandbox/ConversionofSpoolRequestDataintoPDFandExcelFormatandSenditintoMail

Hope it helps

Regards

Mansi

0 Kudos

Hi Al, this above link gives the uotput in only one string. I woant to spli the data into the respective columns. Please let me know if any solution is there. Thanks in advance.

0 Kudos

Hi,

Check the example program BCS_EXAMPLE_7 provided by SAP for excel conversions.

Hope this helps.

Regards,

Vijaymadhur.