Spool to excel
Hi,
Can we convert the spool into excel format and send as attachement via mail.I don't want to send spool as PDF.
Regards,
Karthik.k
Karthik,
Use the function "RSPO_DOWNLOAD_SPOOLJOB"
or use "BAPI_XBP_JOB_SPOOLLIST_READ_20 "
Message was edited by:
ANIRUDDHA DAS
Similar Messages
-
How to download data from spool to excel file
Hi,
I have requirement like....i need to download data from spool to excel file.
Please let me know the process how to download...
<removed by moderator>
<removed by moderator>
Thanks,
Khasimsa
Moderator message: please (re)search yourself before asking, do not assign priorities, do not offer re-ward
locked by: Thomas Zloch on Sep 8, 2010 1:18 PMHi try this way..
*FM called that returns the Spool Request Number data into and internal table
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = p_spool "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.
*To convert the spool data into excel format
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
"call GUI down Load by passing it_xls_spool
Prabhudas -
Send email with spool in excel attachment
Hi,
I have this function:
CALL FUNCTION 'Z_SEND_EMAIL_SPOOL_PDF'
EXPORTING
application = 'EMAIL'
emailtitle = texttitle
recextnam = email
src_spoolid = tsp01-rqident
TABLES
texttab = body.
And code:
FUNCTION z_send_email_spool_pdf .
*"*"Interfase local
*" IMPORTING
*" REFERENCE(APPLICATION) LIKE SOOD1-OBJNAM DEFAULT 'EMAIL'
*" REFERENCE(EMAILTITLE) LIKE SOOD1-OBJDES
*" VALUE(RECEXTNAM) LIKE SOOS1-RECEXTNAM
*" REFERENCE(SRC_SPOOLID) LIKE TSP01-RQIDENT
*" TABLES
*" TEXTTAB STRUCTURE SOLI
*- local data declaration
DATA: ohd LIKE sood1,
oid LIKE soodk,
to_all LIKE sonv-flag,
okey LIKE swotobjid-objkey.
DATA: g_document LIKE sood4,
g_header_data LIKE sood2,
g_authority LIKE sofa-usracc,
lt_attachments LIKE STANDARD TABLE OF sood5 WITH HEADER LINE,
l_folder_id LIKE sofdk,
l_objcont LIKE soli OCCURS 0 WITH HEADER LINE,
i_bin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
l_objhead LIKE soli OCCURS 0 WITH HEADER LINE,
folder_id LIKE soodk,
object_id LIKE soodk,
link_folder_id LIKE soodk,
hd_dat LIKE sood1.
DATA: desired_type LIKE sood-objtp,
real_type LIKE sood-objtp,
attach_type LIKE sood-objtp,
otf LIKE sood-objtp VALUE 'OTF', " SAPscript Ausgabeformat
ali LIKE sood-objtp VALUE 'ALI', " ABAP lists
pdf LIKE sood-objtp VALUE 'PDF', "PDF format
pbyte TYPE i,
t_pdf LIKE tline OCCURS 0 WITH HEADER LINE,
objtype LIKE rststype-type,
type LIKE rststype-type.
CONSTANTS: ou_fol LIKE sofh-folrg VALUE 'O',
c_objtp LIKE g_document-objtp VALUE 'RAW',
c_file_ext LIKE g_document-file_ext VALUE 'PDF'.
DATA: BEGIN OF receivers OCCURS 0.
INCLUDE STRUCTURE soos1.
DATA: END OF receivers.
* Fist part: Verify if the spool really exists
SELECT SINGLE * FROM tsp01 WHERE rqident = src_spoolid.
CHECK sy-subrc = 0.
*- fill odh
CLEAR ohd.
ohd-objla = sy-langu.
ohd-objnam = application.
ohd-objdes = emailtitle.
ohd-objpri = 3.
ohd-objsns = 'F'.
ohd-ownnam = sy-uname.
*- send Email
CONDENSE recextnam NO-GAPS.
CHECK recextnam <> space AND recextnam CS '@'.
CALL FUNCTION 'RSTS_GET_ATTRIBUTES'
EXPORTING
authority = 'SP01'
client = tsp01-rqclient
name = tsp01-rqo1name
part = 1
IMPORTING
type = type
objtype = objtype
EXCEPTIONS
fb_error = 1
fb_rsts_other = 2
no_object = 3
no_permission = 4
OTHERS = 5.
attach_type = c_objtp.
desired_type = pdf.
IF objtype(3) = 'OTF'.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = src_spoolid
IMPORTING
pdf_bytecount = pbyte
TABLES
pdf = t_pdf.
ELSE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = src_spoolid
IMPORTING
pdf_bytecount = pbyte
TABLES
pdf = t_pdf.
ENDIF.
PERFORM convertir_tabla_pdf_2 TABLES t_pdf l_objcont.
CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
EXPORTING
owner = sy-uname
region = ou_fol
IMPORTING
folder_id = l_folder_id
EXCEPTIONS
OTHERS = 5.
* fill out informations about the header of the email
CLEAR: g_document.
g_document-foltp = l_folder_id-foltp.
g_document-folyr = l_folder_id-folyr.
g_document-folno = l_folder_id-folno.
g_document-objtp = c_objtp.
g_document-objdes = emailtitle.
g_document-file_ext = c_file_ext.
g_header_data-objdes = emailtitle.
CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
EXPORTING
method = 'SAVE'
office_user = sy-uname
IMPORTING
authority = g_authority
TABLES
objcont = texttab
attachments = lt_attachments
CHANGING
document = g_document
header_data = g_header_data
EXCEPTIONS
OTHERS = 1.
object_id-objtp = c_objtp.
object_id-objyr = g_document-objyr.
object_id-objno = g_document-objno.
folder_id-objtp = l_folder_id-foltp.
folder_id-objyr = l_folder_id-folyr.
folder_id-objno = l_folder_id-folno.
link_folder_id-objtp = l_folder_id-foltp.
link_folder_id-objyr = l_folder_id-folyr.
link_folder_id-objno = l_folder_id-folno.
hd_dat-file_ext = pdf.
hd_dat-objdes = emailtitle.
CALL FUNCTION 'SO_ATTACHMENT_INSERT'
EXPORTING
object_id = object_id
attach_type = attach_type
object_hd_change = hd_dat
owner = sy-uname
TABLES
objcont = l_objcont
objhead = l_objhead
EXCEPTIONS
active_user_not_exist = 35
communication_failure = 71
object_type_not_exist = 17
operation_no_authorization = 21
owner_not_exist = 22
parameter_error = 23
substitute_not_active = 31
substitute_not_defined = 32
system_failure = 72
x_error = 1000.
* FORM SO_OBJECT_SEND_REC *
FORM so_object_send_rec
TABLES objcont STRUCTURE soli
receivers STRUCTURE soos1
USING object_hd STRUCTURE sood1
folder_id
object_id
link_folder_id.
DATA: oid LIKE soodk,
to_all LIKE sonv-flag,
okey LIKE swotobjid-objkey.
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
extern_address = 'X'
* object_hd_change = object_hd
* object_type = 'RAW'
outbox_flag = 'X'
sender = sy-uname
owner = sy-uname
folder_id = folder_id
object_id = object_id
store_flag = 'X'
link_folder_id = link_folder_id
IMPORTING
object_id_new = oid
sent_to_all = to_all
office_object_key = okey
TABLES
objcont = objcont
receivers = receivers
EXCEPTIONS
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
folder_not_exist = 4
folder_no_authorization = 5
forwarder_not_exist = 6
note_not_exist = 7
object_not_exist = 8
object_not_sent = 9
object_no_authorization = 10
object_type_not_exist = 11
operation_no_authorization = 12
owner_not_exist = 13
parameter_error = 14
substitute_not_active = 15
substitute_not_defined = 16
system_failure = 17
too_much_receivers = 18
user_not_exist = 19
x_error = 20
OTHERS = 21.
IF sy-subrc <> 0.
RAISE others.
ENDIF.
ENDFORM.
* FORM INIT_REC *
FORM init_rec TABLES receivers STRUCTURE soos1.
CLEAR receivers.
REFRESH receivers.
MOVE sy-datum TO receivers-rcdat .
MOVE sy-uzeit TO receivers-rctim.
MOVE '1' TO receivers-sndpri.
MOVE 'X' TO receivers-sndex.
MOVE 'U-' TO receivers-recnam.
MOVE 'U' TO receivers-recesc.
MOVE 'INT' TO receivers-sndart.
MOVE '5' TO receivers-sortclass.
APPEND receivers.
ENDFORM.
With this function I can send a spool in pdf format by email. But, now I need send a spool in Excel (xls) format by email. I try to disconnect 'CONVERT_OTFSPOOLJOB_2_PDF' and 'CONVERT_ABAPSPOOLJOB_2_PDF' but doesnt work.
Can you help me?
A lot of thanks in advance.
Best regards.Hi.
I do not think it is feasible to create a worthwhile Excel file from a SAP spool file.
I have reports that send output as Excel attachments to email, but the code (including function modules etc) is too much to post here.
You can use OLE to create an Excel file, but this will not generally work when the report is run in the background.
So my approach is to make the report write an Excel XML file (that's just text after all), and send that as an XLS email attachment. When the email receiver double-clicks on the attachment, it fires up Excel and brings in the data. Most users would not realise that it's not a native Excel file.
One nice touch is to have two sheets in the Excel file, one with the main report and the other with the selection criteria.
Of course there is a lot of work getting started with this.
John -
Ability to download Spool into Excel
Hi,
I have a requirement that the ALV report needs to be run in background with ability to download spool into excel .Can anyone please help in this regard.
Many Thanks,
SharathHi,
First check whether the status of the job is Completed or Cancelled.
WHILE 1 = 1.
* GET THE JOB STEPLIST WHICH HAS THE SPOOL NUMBER
CALL FUNCTION 'BP_JOB_READ'
EXPORTING
job_read_jobcount = w_jobcount
job_read_jobname = w_jobname
job_read_opcode = '35'
* JOB_STEP_NUMBER =
IMPORTING
job_read_jobhead = wa_jobhead
TABLES
job_read_steplist = i_jobsteplist
* CHANGING
* RET =
EXCEPTIONS
invalid_opcode = 1
job_doesnt_exist = 2
job_doesnt_have_steps = 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.
* IF STATUS OF JOB IS COMPLETED(F) OR CANCELLED(A)
* READ THE JOBSTEPLIST & GET THE SPOOL NUMBER
IF wa_jobhead-status = c_a OR wa_jobhead-status = c_f.
READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
CHECK wa_jobsteplist-listident space.
w_spool_number = wa_jobsteplist-listident.
EXIT.
ENDIF.
ENDWHILE.
Use FM "RSPO_DOWNLOAD_SPOOLJOB".
Best Regards,
Sunil. -
Hello All,
I have a requirement to send/export the background job spool in Excel (in MHTML format) in ECC 6.0. Please help.
Thank you.
NaliniHi Jigar,
Thanks for your response.
Anything is like download to desktop or email is fine. But in MHTML format.
We can download the ALV report in MHTML spreadsheet format when we run the program online. But the program is running for long time and going to dump.
So i scheduled it as background job and downloading the output in .HTML format. But user wants the spool/report output in .MHTML spreadsheet format.
I can write the code. Instead of changing the existing program I would like to know is there any way (from standard SAP) that I can get the background spool in MHTML spreadsheet format.
Thanks,
Nalini -
Spool to Excel or Text Conversion
Dear All,
Is it possible to convert a spool into Excel file or Text Format?Hi
Check the below links. They wil help you in converting spool to text format.
[http://www.sap-basis-abap.com/sapac016.htm]
[http://help.sap.com/saphelp_nw70/helpdata/en/30/cc154219fce12ce10000000a1550b0/content.htm]
Thanks,
Jyothi -
Spool to Excel or Text Conversion thru ABAP
Dear All,
Is it possible to convert a spool into Excel file or Text Format thru ABAP?Hi!
The function modules CONVERT_ABAPSPOOLJOB_2_PDF, CONVERT_OTFSPOOLJOB_2_PDF are converting spool to PDF.
HTH
Peter -
I'm spooling a file to Excel and all is working except for the ID field. It is a 10 character field of numbers that loses the leading zeroes. So 0000138750 appears in Excel as 138750. Is there a column format that I can use that will translate correctly?
Hi,
You aren't really spooling to Excel, you are probably spooling a comma sepearated (.csv) file. When that is opened, Excel recognized that the data are really numbers and displays as number, i.e., without leading zereos.
So, this is really an Excel issue, and I don't think you can do much about it, except from applying format in Excel.. Not so long ago, I tried foolling around with quotes and stuff. At the time, no luck, but maybe you'll do better.
Regards
Peter -
FM to down load the spool to excel file along with the deliminator
hi all,
this is regarding a downloading of spool to a excel file along with a deliminator.
Can any one suggest a function module which downloads spool to excel file with a deliminator in a proper way.Hi ram,
You can try using the BAPI_XBP_JOB_SPOOLLIST_READ_20 - to get the list from spool and then do the required formatting. You can use can use the function module mentioned in the other reply to download it into excel file.
Cheers -
How to spool in excel sheet of table with 1561828 records
how to spool in excel sheet of table with 1561828 records
i think excel got only 65l limit?
COUNT(*)
1561828
i am using windows box...any suggestions?Raman wrote:
means excel 2007 can hold 15,61,828 records ? can i give like spool filename.xls?You can name the spool file anything you want, but surely you realize that naming it 'filename.xls' doesn't make it an xls file. A name is just a name. There are industry standards on certain names indicating certain file formats, but the name doesn't make it that format. -
Spool to excel..urgent
hi frnds,
have modified a standard report to 'z' report.the output comes as like
standard abap list. when i execute the report in foreground and saves the output
in spreadsheet its fine but when i execute it in background the output is messed up.(excel)
the background needs to be executed in sm37 and spool request is created then we
can see the file type and its output.(sp01).
a standard program is attached in that report-RSBTCHH0 from where its takes
the output in excel.
help me where to make the changes..Hi,
If you are trying to create a excel sheet with data and store it in the local PC, you cannot do it in the back ground mode.
However if you want to create excel format data and store it in application server, (in back ground mode) and then an online program to read the content from application server and store it in a excel sheet in the desktop , it is possible.
Thanks
Vikranth -
Hi Friends,
How to convert the spool output to Excel format?
Thanks in advance.
Madan.Hi Madan,
In SP01, check mark your spool number and try the below path
System-> List> Save--> Local File.
Then you will get a pop-up asking for format and there you can select spread sheet.
Regards,
Shano -
Convert Report Spool to Excel or csv
Hi There
I need to convert some results that I have in spools in a excel or cvs file, is there some program to do that ? ( something similar like RSTXPDFT4 for PDF) ?
Other option that I have would be to put the spools results in a table created by me.... some idea how could achieve this?
Thanks in advance
FedeXAnswer here
Copy of RSUSR002 program ..how to proceed? -
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.SCALL 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 -
Format Excel after Transporting Spool into excel
Hi,
I successfully transported Spool data into to excel and attached the excel into mail. I used RSPO_RETURN_ABAP_SPOOLJOB to get spool data and SO_RAW_TO_RTF to convert to Excel formated data.Now i Need to colour one row in excel sheet.How do i do that ?
Thanks,
Srini.both Ido and i have suggested using export to Excel > Data Only > Typical mode. please actually try the suggestion and you will find that it does work.
here is my report....
here's the export format, Excel Data-only
then select Typical as per the suggestions above
and the result is 2 columns, one for each field, and one row, one for each record.
i know that there is only 1 column for the large text field as when i cut it from the xls and paste it elsewhere i get this.
Maybe you are looking for
-
i downloaded mountain lion for my macbook pro and i want to install it on my sisters' macbook air, my question is, how many times can i share my purchase?
-
Hi there, I have been asked by one of the moderators of the Windows 8.1 forums to post this topic here. You can see the thread relating to this post here http://answers.microsoft.com/en-us/windows/forum/windows8_1-tms/cant-change-the-cursor-pointer/
-
Issues while starting soa_server1
Hi, I have installed SOA Suite 11g following instructions at this , but get big error stack when trying to launch soa_serve1. oracle.mds.lcm.exception.MDSLCMException: ORA-06550: line 1, column 12: PLS-00201: identifier 'MDS_INTERNAL_SHREDDED.GETREPO
-
Mbp-montain lion Random crashes
Hi, i have some problems with random crashes on my macbook pro 2010... it happens pretty often and as i say its completely random. It can happen while im playing a game, writting on Words, browsing the web... Here is my last report... I hope someone
-
The song and artist name on my itunes is different to what it is on my iphone.
Ever since I've updated to the new itunes, I've encountered an annoying problem. When I change the song name by right-clicking on the song and clicking 'get info' and changing it that way, the changes don't apply to my iphone. Why is this?