Spool to HTML using an FM
Hi Experts,
Please help me. I need an HTML function module that will convert the graphical display of a spool into an HTML format. Please help me how I can go about it step by step. tHanks.
Hello Anna
Basically your report executed as batch job needs to exectue an external OS command (i.e. a FTP put or mput command).
The details for executing the FTP command depend on your OS. For a customer whose SAP system was running on a Windows server the batch job created a small FTP script which was then executed by the external OS command (FTP command of Windows server) using fm SXPG_COMMAND_EXECUTE.
Regards
Uwe
Similar Messages
-
Error in converting Spool to HTML format.
Hi Gurus,
I am reading SPool and converting that into HTML formt. Please do find below code for the same.
Submit report to convert the spool to HTML format
SUBMIT rspolst2 EXPORTING LIST TO MEMORY AND RETURN
WITH rqident = p_spoolno.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = gt_listobj
EXCEPTIONS
not_found = 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.
Convert the spool to HTML format
CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
EXPORTING
REPORT_NAME =
template_name = 'WEBREPORTING_REPORT'
TABLES
html = p_html_tab
listobject = gt_listobj.
>>>>>>>>>>>>>>>>>>>
And i send p_html_tab as attachement to email.
When I opened the attachement, i can view only half page in htm.
How can i get the full page in htm.First convert the spool to internal table by using FM
RSPO_RETURN_ABAP_SPOOLJOB
Next from internal table to HTML....
Link: /people/rammanohar.tiwari/blog/2006/01/29/abap-utility-print-screen-to-html
or try the following
Please try the follwoing:
1. define HTML internal table with ref to type W3HTML
2. download it as BIN type and give total lenght of the strings as a parameter in the down load.
See the code extract below:
describe table html lines entries.
read table html into w_html index entries.
size = ( entries - 1 ) * 255 + strlen( w_html ).
concatenate p_path file into file.
call function 'WS_DOWNLOAD'
exporting
bin_filesize = size
filename = file
filetype = 'BIN'
tables
data_tab = html -
Hi Experts,
Can anyone help me please. Is there any FM that can convert spool to HTML? Just like converting spool to PDF but only I need it in HTML. I can't use spool to PDF because I'm having problems when it comes to massive pages, but if it's only 5 pages it actually works but not with 100 pages or more. So please, if anyone can help me with spool to html. Points will be given and also to those who tried. Thanks.
AnnaHi again. Thanks for your reply. But I'm actually having a problem with the list variable. My dilemma actually is how I can transfer the jtab grabphical spool to the abaplist. Please, please help me and check what went wrong. I'm actually trying to download the graphical spool to an html format. Thanks.
TABLES: TBTCO, TBTCP, TSP01.
TYPE-POOLS: truxs.
DATA: BEGIN OF itab OCCURS 0,
sp_name TYPE tbtco-jobname,
br_code(1),
dumon(7),
sp_numb TYPE TSP01-rqident,
ofc(7),
END OF itab.
DATA: BEGIN OF btab OCCURS 5,
fld1(24),
fld2(12),
END OF btab.
DATA: htmllines TYPE TABLE OF w3html WITH HEADER LINE,
w_jtab TYPE TABLE OF ABAPLIST WITH HEADER LINE.
DATA: BEGIN OF jtab OCCURS 0,
fld1(11),
fld2(41),
fld3(21),
fld4(11),
fld5(10),
fld6(22),
fld7(72),
END OF jtab.
INITIALIZATION.
START-OF-SELECTION.
PERFORM download_html.
*& Form download_html
text
FORM download_html.
DATA: lv_file TYPE string,
lv_string TYPE string,
lt_conv TYPE truxs_t_text_data.
SORT itab BY sp_name br_code dumon.
LOOP AT itab.
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = itab-sp_numb "Spool Number
TABLES
BUFFER = btab.
LOOP AT btab WHERE fld1 = 'BROKER REPORT ID'.
PERFORM get_month.
MOVE: btab-fld2+4(1) TO itab-br_code,
date TO itab-dumon.
MODIFY itab.
ENDLOOP.
Move to jtab for Conversion HTML
CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'
EXPORTING
rqident = itab-sp_numb "Spool Number
TABLES
BUFFER = jtab.
****SPOOL TO HTML
CALL FUNCTION 'SAVE_LIST'
TABLES
listobject = jtab
EXCEPTIONS
list_index_invalid = 1
others = 2.
CALL FUNCTION 'WWW_LIST_TO_HTML'
TABLES
html = htmllines.
AT NEW sp_name.
CONCATENATE: p_file itab-sp_name '\' INTO p_file.
ENDAT.
AT NEW br_code.
PERFORM get_brcode.
CONCATENATE: p_file brc '\' INTO p_file.
ENDAT.
AT NEW dumon.
CONCATENATE: p_file itab-dumon '\' INTO p_file.
ENDAT.
CONCATENATE: p_file itab-ofc '.HTML' INTO p_file.
IF sy-subrc = 0.
IF p_pres EQ 'X'.
MOVE p_file TO lv_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_file
filetype = 'BIN'
TABLES
data_tab = it_pdf_output.
IF sy-subrc <> 0.
MESSAGE e398(00) WITH 'Error creating file' p_file.
ELSE.
MESSAGE i398(00) WITH 'File Created' p_file.
ENDIF.
ELSE.
APPEND LINES OF it_pdf_output TO lt_conv.
IF lt_conv[] IS NOT INITIAL.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
LOOP AT lt_conv INTO lv_string.
TRANSFER lv_string TO p_file.
ENDLOOP.
CLOSE DATASET p_file.
IF sy-subrc EQ 0.
MESSAGE i398(00) WITH 'File Created' p_file.
ELSE.
MESSAGE e398(00) WITH 'Error closing file' p_file.
ENDIF.
ELSE.
MESSAGE e398(00) WITH 'Error creating file' p_file.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. "convert_spool_to_pdf
Edited by: Anna Bechayda on Apr 23, 2008 10:18 AM -
Hi!
Would it be possible to convert print spool to html file in ABAP?
Need your help.
Thanks,
CherrieHi,
I think that it's possible anyway.
Use dialog module source 'DISPLAY_OTF' and modify it. The dialog module(SE35) displays the OTF data of a form in abap list format. When you transfer the sapscript form to abap list, use the following functions.
call function 'SAVE_LIST'
EXPORTING
LIST_INDEX = SY-LSIND
TABLES
LISTOBJECT = ZABAPLIST
EXCEPTIONS
others = 9.
call function 'WWW_HTML_FROM_LISTOBJECT'
TABLES
HTML = ZW3HTML
LISTOBJECT = ZABAPLIST
EXCEPTIONS
others = 9.
call function 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\myhtml.html'
TABLES
DATA_TAB = ZW3HTML
EXCEPTIONS
OTHERS = 9.
Regards,
Svetlin -
FM for conversion of graphical display of spool to html
Hi abapers,
Please help. This is the scenario, what I need is to convert the graphical display of spool to html. The html output has to be the same with the graphical display of the spool with all the colors, fonts etc without using the shortcut in the system menu. Please, please, help. I need to know how. It's really, really urgent. Points will be given to the person who can help me. Thanks.Hi,
First convert the spool to internal table by using FM
RSPO_RETURN_ABAP_SPOOLJOB
Next from internal table to HTML....
Link: /people/rammanohar.tiwari/blog/2006/01/29/abap-utility-print-screen-to-html
or try the following
Please try the follwoing:
1. define HTML internal table with ref to type W3HTML
2. download it as BIN type and give total lenght of the strings as a parameter in the down load.
See the code extract below:
describe table html lines entries.
read table html into w_html index entries.
size = ( entries - 1 ) * 255 + strlen( w_html ).
concatenate p_path file into file.
call function 'WS_DOWNLOAD'
exporting
bin_filesize = size
filename = file
filetype = 'BIN'
tables
data_tab = html
Regards,
Raj. -
Hi,
I've got two scripts that spool two lists of data in html format.
--- First sql ---
set pagesize 1000
set scan off
set feedback off
set markup html on spool on head ' - ' BODY 'bgcolor="WHITE" text="BLUE"' -
SPOOL report_1.html
SELECT *
from TABLE_1;
spool off;
exit;
--- Second sql ---
set pagesize 1000
set scan off
set feedback off
set markup html on spool on head ' - ' BODY 'bgcolor="SILVER" text="BLACK"' -
SPOOL report_2.html
SELECT *
from TABLE_2;
spool off;
exit;
As you can see the background and text colors of the two scripts are different (white/blue and silver/black) but if I try to concat the two html by using the CAT function on UNIX Server where Oracle is installed (cat report_1.html report_2.html > report.html), I get a new html file where the two spools have got the colors of the first spool that is white/blue I'd like to get a new script whit the two lists of data in different colors.
Can you help me?
Thanks!
Edited by: Mark1970 on 23-mar-2010 2.04
Edited by: Mark1970 on 23-mar-2010 2.05Thanks everyone, wonderful.
if i want to clear all set commands which i had executed in this session , what should i do?
i dont want to do a verify on feedback on etc.. ( i may not be knowing what all such commands i had executed previously , moreover i would have done cl scr in sql ) -
Extracting a Report from SAP Spool into a Useful Excel 2010 Format
Hi All,
Extracting a Report from SAP Spool into a Useful Excel 2010 Format. I'm currently running the following report in SAP and would like the
ability to set this report up as a recurring report running weekly and
subsequently access this report in a useable Excel 2010 format without
much data manipulation. Can you please assist me. Below, I've tried to
provide an example of what I'm encountering. Thanks, beforehand for
your assistance.
Here goes:
Step one: Run 62 Report in SAP S_P99_41000062- Material List Price and
Inventory
Step 2. Select stored Variant "Weekly KPI", ok. Enter the enter the
desired company code and period I want thre report to run for and update
the currency, if necessary. Having input my desired criteria, I believe
I can either execute immediately, run in the background, preset to run
at date in the future. For this example let's just execute, immediately.
This is where the difference originates. Given, I run this report
immediately, I'm able to simply extract the result to Excel via the list
selection noted in the tool bar below. The result is a data friendly
excel 2007 report is automatically generated.
Export to Excel via list:
Select save and Excel 2007 opens automatically:
That said, the method outlined above works perfectly fine if you want
the report immediately. Now let go back and run the exact same report
with exceptoin of running it in the background and having to retrieve it
from the Spool (SP01) uisng my user ID. Given the report generated in
the background, I would now access the report via the spool and make
the following selections:
SP01 + execute to see my report
I would hit the sunglasses to see the actual report, then want to
extract this report to Excel by selecting the export option.
I would at this point select spreadsheet and be given an option to save
the spreadsheet to local file. However, upon trying to open the
spreadsheet I will receive an error messageindicating that the format is
different than that which the file I am currently trying to open it
with. I'm currently running Excel 2010 on my computer. The currency
format and other issues arrise with this extract. Please help.
Thanks,
Chowadary.Update to Latest GUI.
Use List -> Export -> Spreadsheet to get the output to excel.
I remember in ALV max length allowed is 1023 characters and the max no of columns supported is 90. Issue occurs when row size of exported data gets more than 1023 character. (This includes if Long/Medium Header Text used ) If it exceed 1023 character the columns splits and moves to next row.
Check your fieldcatog for header lengths.
-Satya -
Email SPOOL as HTML ..
Hi !!
We are planning to schedule certain reports in background and then want to read its spool and convert those spool to HTML and send it as aattachment to email .
I check the forum and the library there are example of submitting report to abap memorya nd then creating html from that memory and email it . But for this i will end up having two programs one the original report program and another program to submit it .I want to avoid taht situation.
Please mail back with code sasmples .check these threads
print spool to html
Re: how to send the spool content as a body to email id (ans by max) -
Code to translate xml data into html using jaxp ?
Hi all !!
Could you please send me code to translate xml data into html using jaxp
i am sending my xml file and xsl file
its urgent
my xml file is :
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="scenario.xsl"?>
<scenarioReport>
<node name="node1">
<netObjId>124 </netObjId>
<result>undefined</result>
<report>The cell is 124.</report>
<action>qsdsqdqsd </action>
</node>
<node name="node 3">
<netObjId>124 </netObjId>
<result>undefined</result>
<report>Result is unresolved because ...</report>
<action>No action</action>
</node>
<node name="node 2">
<netObjId>124 </netObjId>
<result>undefined</result>
<report>qsdqsdqs </report>
<action>qsdsqd</action>
</node>
<node name="node 5">
<netObjId>124 </netObjId>
<result></result>
<report> </report>
<action> </action>
</node>
<node name="node 4">
<netObjId>124 </netObjId>
<result></result>
<report> </report>
<action></action>
</node>
</scenarioReport>
my xsl file is::
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<h2> Scenario Report</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Nodename</th>
<th align="left">netObjId</th>
<th align="left">Result</th>
<th align="left">Report</th>
<th align="left">Action</th>
</tr>
<xsl:for-each select="scenarioReport/node">
<tr>
<td><xsl:value-of select="@name"/></td>
<td><xsl:value-of select="netObjId"/></td>
<td bgcolor="#ffffff "><xsl:value-of select="result"/></td>
<td><xsl:value-of select="report"/></td>
<td><xsl:value-of select="action"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>Must be something wrong with your XSL.
However apparently it was so urgent that you didn't have the time to look at what you posted. They just "fixed" the forum software and apparently it doesn't escape HTML that you type in any more. Or stuff that looks like HTML, either. So your post was unreadable.
If your deadline hasn't passed, try reposting that code surrounded by [pre] and [/pre]. -
Dear all,
I have the following issue.
Correct situation:
- Run a report that generates a ALV or list
- Export the ALV into a HTML file
- The generated HTML file as the correct information
Incorrect situation
- Run a report that generates a ALV or list in background
- Export the spool into a HTML file
- The generated HTML is totally incorrect with collumns missing and other being repeated several times
Can anyone help me on this?
Thank you
Nuno SilvaHi,
Check this link how to convert HTML from Spool
Spool to HTML Function Module
[Spool to Html|https://www.sdn.sap.com/irj/scn/advancedsearch?query=spooltoHtml&cat=sdn_all]
Edited by: Avinash Kodarapu on Mar 2, 2009 11:03 PM -
How to Create Test Sequence Document in HTML using command line
How to Create Test Sequence Document in HTML using command line
I have lot of sequences and I want to create Test Sequence Documentation in HTML format using Command Line automatically, is there a way to automate this task using .bat file or using C# .NetIf you aren't able to figure out how to call a C++ DLL in .net then there may be another option. Unfortunately I don't know how to do this off the top of my head and I don't have an example.
The other option would be to change docgen.seq a little bit to the dialog doesn't display and you just hardcode the options. Then you can use a command line to call testexec.exe: http://zone.ni.com/reference/en-XX/help/370052K-01/tsfundamentals/infotopics/startup_opt/
Hope this helps,
jigg
CTA, CLA
teststandhelp.com
~Will work for kudos and/or BBQ~ -
How validate HTML using PL/SQL
Hi,
I try validate HTML using PL/SQL that user inputs.
I did create below function for that purpose
CREATE OR REPLACE
FUNCTION validate_html(
p_html IN VARCHAR2
) RETURN BOOLEAN
AS
l_comment XMLTYPE;
xml_parse_err EXCEPTION;
PRAGMA EXCEPTION_INIT (xml_parse_err , -31011);
BEGIN
l_comment := xmlType.createXML('<root><row>' || p_html || '</row></root>');
RETURN TRUE;
EXCEPTION WHEN xml_parse_err THEN
RETURN FALSE;
END;
Function works ok and return true if I run e.g.
BEGIN
IF validate_html('<p>Hello</p>') THEN
dbms_output.put_line('OK');
ELSE
dbms_output.put_line('Not valid HTML');
END IF;
END;
And return false if I enter not valid HTML like
BEGIN
IF validate_html('<p>Hello') THEN
dbms_output.put_line('OK');
ELSE
dbms_output.put_line('Not valid HTML');
END IF;
END;
But it return false also if I run below
BEGIN
IF validate_html('<p>Hello  </p>') THEN
dbms_output.put_line('OK');
ELSE
dbms_output.put_line('Not valid HTML');
END IF;
END;
Problem seems to be that   (there is ; in end but do not know how post it without forum convert that to space) witch is valid HTML for me.
I know that HTML is not XML, but can I use Oracle database XML functions for validating HTML?
How I should validate user inputted HTML?
I'm currently developing this using Oracle XE 11G database.
Regards,
JariNot an elegant way:
But try this.........
CREATE OR REPLACE FUNCTION validate_html (p_html IN VARCHAR2)
RETURN BOOLEAN AS
l_comment XMLTYPE;
xml_parse_err EXCEPTION;
PRAGMA EXCEPTION_INIT (xml_parse_err, -31011);
BEGIN
l_comment :=
xmlType.createXML (
'<root><row>'
|| CASE
WHEN INSTR (p_html, '&') > 0 THEN
UTL_I18N.escape_reference (p_html)
ELSE
p_html
END
|| '</row></root>');
RETURN TRUE;
EXCEPTION
WHEN xml_parse_err THEN
RETURN FALSE;
END;
SET DEFINE OFF
SET SERVEROUTPUT ON
BEGIN
IF validate_html ('<p>Hello') THEN
DBMS_OUTPUT.put_line ('OK');
ELSE
DBMS_OUTPUT.put_line ('Not valid HTML');
END IF;
END;
SET DEFINE OFF
SET SERVEROUTPUT ON
BEGIN
IF validate_html ('<p>Hello  </p>') THEN
DBMS_OUTPUT.put_line ('OK');
ELSE
DBMS_OUTPUT.put_line ('Not valid HTML');
END IF;
END;
Cheers,
Manik. -
Parsing HTML using Swing's HTMLEditorKit
Hi all,
I posted this question on the "Java programming", but I think I posted on the wrong forum. So, please let me know if I have posted on the wrong forum, again.
Anyway, I have read an article on parsing HTML using the Swing HTML Parser (http://java.sun.com/products/jfc/tsc/articles/bookmarks/index.html). However, I find that the HTMLEditorKit is unable to understand the <Meta> tag under the <Head> tag? Is this true? I am getting an error message:
javax.swing.text.ChangedCharSetException
at javax.swing.text.html.parser.DocumentParser.handleEmptyTag(DocumentParser.java:172)
at javax.swing.text.html.parser.Parser.startTag(Parser.java:327)
at javax.swing.text.html.parser.Parser.parseTag(Parser.java:1786)
at javax.swing.text.html.parser.Parser.parseContent(Parser.java:1821)
at javax.swing.text.html.parser.Parser.parse(Parser.java:1980)
at javax.swing.text.html.parser.DocumentParser.parse(DocumentParser.java:109)
at javax.swing.text.html.parser.ParserDelegator.parse(ParserDelegator.java:74)
at URLReader.main(URLReader.java:58)
Below is a simple code to write out the html file it reads in:
public static void main(String[] args) throws Exception {
HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback () {
public void handleText(char[] data, int pos) {
try {
System.out.println(data);
} catch (Exception e) {
System.out.println("IOE: " + e);
Reader reader = new FileReader("myFile.html");
new ParserDelegator().parse(reader, callback, false);
The html file that is having a problem reading in is:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>NWS WSR-88D Radar System Transmit/Receive Status</title>
</head>
<p>A <foo>xx</foo>link</html>
If I take away <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">, there is no problem.
Any suggestions? Thanks in advance.Hi,
Setting the third argument really works!!! Yee..... haa....!!!
WORKING SOLUTION: new ParserDelegator().parse(reader, callback, TRUE);
MANY... MANY THANKS for looking at the problem!!!
Send third argument in parse method as true. -
I have problem sending a email ..spool not created using custom FM
Hi experts,
i have problem sending a email ..spool not created using custom FM...this the custom FM
* Send email notification
lv_subject = text-037.
lv_attachment = text-038.
CALL FUNCTION 'Z_SEND_EMAIL_FROM_SPOOL'
EXPORTING
email1 = lv_email1
email2 = lv_email2
email3 = lv_email3
subject = lv_subject
attachment_name = lv_attachment
EXCEPTIONS
spool_not_created = 1
OTHERS = 2.
Source code
this is the source code for this FM
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf.
IF sy-subrc IS NOT INITIAL.
MESSAGE e040(zhrcd) RAISING spool_not_created.
ENDIF.
PERFORM process_email USING email1
email2
email3
subject
attachment_name.
WAIT UP TO 5 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.....
Please let me know
Edited by: Thomas Zloch on Nov 16, 2010 5:53 PM - please use code tagsHi srinivas ,
Could you please Check
FORM summary_report .
DATA: lv_success TYPE i,
lv_error TYPE i,
lv_total TYPE i.
DESCRIBE TABLE gt_data LINES lv_success.
DESCRIBE TABLE gt_error LINES lv_error.
DESCRIBE TABLE gt_message LINES lv_error.
lv_total = lv_success + lv_error.
lv_total = lv_success.
gwa_summary-record = text-008."Number of Successful records.
gwa_summary-number = lv_success.
APPEND gwa_summary TO gt_summary.
gwa_summary-record = text-009."Number of error records'.
gwa_summary-number = lv_error.
APPEND gwa_summary TO gt_summary.
gwa_summary-record = text-010."Total number of records processed.
gwa_summary-number = lv_total.
APPEND gwa_summary TO gt_summary.
CLEAR gt_fieldcat.
gwa_fieldcat_summ-col_pos = 1 .
gwa_fieldcat_summ-fieldname = 'RECORD'.
gwa_fieldcat_summ-tabname = 'GT_SUMMARY'.
gwa_fieldcat_summ-seltext_l = text-011."Records
gwa_fieldcat_summ-outputlen = '70'.
APPEND gwa_fieldcat_summ TO gt_fieldcat_summ.
gwa_fieldcat_summ-col_pos = 2 .
gwa_fieldcat_summ-fieldname = 'NUMBER'.
gwa_fieldcat_summ-tabname = 'GT_SUMMARY'.
gwa_fieldcat_summ-seltext_l = text-012."Number
gwa_fieldcat_summ-outputlen = '10'.
APPEND gwa_fieldcat_summ TO gt_fieldcat_summ.
ENDFORM. " SUMMARY_REPORT
*& Form ERROR_REPORT
FORM error_report .
gt_fieldcat_err[] = gt_fieldcat[].
gv_fieldcat_err-col_pos = 1.
gv_fieldcat_err-fieldname = 'PERNR'.
gv_fieldcat_err-tabname = 'GT_MESSAGE'.
gv_fieldcat_err-seltext_l = text-070."Employee Number
gv_fieldcat_err-outputlen = '20'.
APPEND gv_fieldcat_err TO gt_fieldcat_err.
gv_fieldcat_err-col_pos = 2.
gv_fieldcat_err-fieldname = 'MESSAGE'.
gv_fieldcat_err-tabname = 'GT_MESSAGE'.
gv_fieldcat_err-seltext_l = text-071."Error Message
gv_fieldcat_err-outputlen = '80'.
APPEND gv_fieldcat_err TO gt_fieldcat_err.
ENDFORM. " ERROR_REPORT
*& Form FINAL_REPORT
FORM final_report .
DATA:lv_layout TYPE slis_layout_alv,
lt_events_summ TYPE slis_t_event,
lv_events_summ LIKE LINE OF lt_events_summ,
lt_events_det TYPE slis_t_event,
lv_events_det LIKE LINE OF lt_events_det,
lt_events_err TYPE slis_t_event,
lv_events_err LIKE LINE OF lt_events_det,
lt_events_msg TYPE slis_t_event,
lv_events_msg LIKE LINE OF lt_events_det.
lv_events_summ-name = 'TOP_OF_PAGE'.
lv_events_summ-form = 'TOP_OF_PAGE1'.
APPEND lv_events_summ TO lt_events_summ.
lv_events_det-name = 'TOP_OF_PAGE'.
lv_events_det-form = 'TOP_OF_PAGE2'.
APPEND lv_events_det TO lt_events_det.
lv_events_err-name = 'TOP_OF_PAGE'.
lv_events_err-form = 'TOP_OF_PAGE3'.
APPEND lv_events_err TO lt_events_err.
lv_events_msg-name = 'TOP_OF_PAGE'.
lv_events_msg-form = 'TOP_OF_PAGE4'.
APPEND lv_events_msg TO lt_events_msg.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = sy-repid.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = lv_layout
it_fieldcat = gt_fieldcat_summ
i_tabname = 'IT_SUMMARY'
it_events = lt_events_summ
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = gt_summary
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
IF CHK_DTL IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = lv_layout
it_fieldcat = gt_fieldcat
i_tabname = 'gt_data'
it_events = lt_events_det
IT_SORT =
I_TEXT = ' '
TABLES
t_outtab = gt_data
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = lv_layout
it_fieldcat = gt_fieldcat_err
i_tabname = 'gt_error'
it_events = lt_events_err
TABLES
t_outtab = gt_error.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = lv_layout
it_fieldcat = gt_fieldcat_msg
i_tabname = 'gt_message'
it_events = lt_events_msg
TABLES
t_outtab = gt_error.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = lv_layout
it_fieldcat = gt_fieldcat_err
i_tabname = 'gt_message'
it_events = lt_events_err
TABLES
t_outtab = gt_message.
IF GT_MESSAGE[] IS NOT INITIAL.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = lv_layout
it_fieldcat = gt_fieldcat_msg
i_tabname = 'gt_message'
it_events = lt_events_msg
TABLES
t_outtab = gt_message.
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXPORTING
i_interface_check = ' '
IS_PRINT =
i_screen_start_column = 0
i_screen_start_line = 0
i_screen_end_column = 0
i_screen_end_line = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
ENDFORM. " FINAL_REPORT
*& Form top_of_page
text
FORM top_of_page1. "#EC CALLED
WRITE text-013."SUMMARY REPORT.
ENDFORM. "top_of_page
*& Form top_of_page2
text
FORM top_of_page2. "#EC CALLED
WRITE text-014."DETAIL REPORT.
ENDFORM. "top_of_page
*& Form top_of_page3
text
FORM top_of_page3. "#EC CALLED
WRITE text-015."ERROR REPORT
ENDFORM. "top_of_page
*& Form EMAIL_NOTIFICATION
FORM email_notification .
DATA: lv_email1 TYPE somlreci1-receiver,
lv_email2 TYPE somlreci1-receiver,
lv_email3 TYPE somlreci1-receiver,
lv_subject TYPE char200,
c_flag TYPE c VALUE 'X',
lv_attachment TYPE char50.
CLEAR: lv_email1,
lv_email2,
lv_email3,
lv_subject,
lv_attachment.
SELECT SINGLE email1
email2
email3
FROM zhr_interface_pr
INTO (lv_email1,lv_email2,lv_email3)
WHERE zinterfaceid EQ gc_objectid.
IF sy-subrc EQ 0.
IF sy-batch EQ 'X'.
Send email notification
lv_subject = text-037.
lv_attachment = text-038.
CALL FUNCTION 'Z_SEND_EMAIL_FROM_SPOOL'
EXPORTING
email1 = lv_email1
email2 = lv_email2
email3 = lv_email3
subject = lv_subject
attachment_name = lv_attachment
EXCEPTIONS
spool_not_created = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "
Edited by: katewinslate@SAP on Nov 17, 2010 12:50 PM -
How to covert Spool to HTML and then send it via email
Hi
I have a report that runs in the background and then converts the ALV report to PDF and emails it as attachment. I need it to convert in HTML instead of PDF.
Here is my code...
* CALL_ALV
form call_alv.
perform build_field_catalog using field_tab[].
perform build_eventtab using events[].
perform comment_build using header_alv[].
perform build_sorttab using gt_sort[].
perform build_layout.
* Call ABAP List Viewer
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_repid
i_callback_user_command = 'ALV_USER_COMMAND'
i_structure_name = 'REC'
it_fieldcat = field_tab[]
it_special_groups = gt_sp_group[]
it_sort = gt_sort[]
i_save = v_save
is_variant = v_variant
it_events = events[]
is_layout = gd_layout
tables
t_outtab = REC
exceptions
program_error = 1
others = 2.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
endform. "call_alv
* FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
* FORM get_job_details *
FORM get_job_details.
* Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
* FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
CHECK sy-subrc = 0.
* Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
* FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
* perform send_email using p_email2.
ENDFORM.
* FORM send_email *
* --> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
* Default subject matter
gd_subject = p_Sub.
gd_attachment_desc = p_attNm.
* CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
* it_mess_bod = 'Message Body text, line 1'.
it_mess_bod = P_line1.
APPEND it_mess_bod.
* it_mess_bod = 'Message Body text, line 2...'.
it_mess_bod = P_line2.
APPEND it_mess_bod.
* If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
* Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
gd_subject
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
* FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
* Fill the document data.
w_doc_data-doc_size = 1.
* Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
* Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
* Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
* Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
* Populate zerror return code
ld_error = sy-subrc.
* Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
Please tell me what's the code for convert_spool_to_HTML. and do i need to do anything on the PERFORM process_email. ..
I always reward points. ThanksI think that if you can get the list back from the spool in regular format, you can then use the WWW_HTML_FROM_LISTOBJECT function module to convert to HTML. HEre is a sample program where I am submitting the program and getting the list back from memory.
* This program works in the background,
report zrich_0003 .
data: maildata like sodocchgi1.
data: mailtxt like solisti1 occurs 10 with header line.
data: mailrec like somlrec90 occurs 0 with header line.
data: list type table of abaplist with header line.
data: ascilines(1024) type c occurs 0 with header line.
data: htmllines type table of w3html with header line.
parameters: p_check.
start-of-selection.
submit zrich_0004 exporting list to memory and return.
call function 'LIST_FROM_MEMORY'
tables
listobject = list
exceptions
not_found = 1
others = 2.
call function 'LIST_TO_ASCI'
tables
listobject = list
listasci = ascilines
exceptions
empty_list = 1
list_index_invalid = 2
others = 3.
call function 'WWW_HTML_FROM_LISTOBJECT'
tables
html = htmllines
listobject = list.
clear: maildata, mailtxt, mailrec.
refresh: mailtxt, mailrec.
maildata-obj_name = 'TEST'.
maildata-obj_descr = 'Test Subject'.
loop at htmllines.
mailtxt = htmllines.
append mailtxt.
endloop.
mailrec-receiver = '[email protected]'.
mailrec-rec_type = 'U'.
append mailrec.
call function 'SO_NEW_DOCUMENT_SEND_API1'
exporting
document_data = maildata
document_type = 'HTM'
put_in_outbox = 'X'
tables
object_header = mailtxt
object_content = mailtxt
receivers = mailrec
exceptions
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
commit work.
wait up to 2 seconds.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
So this works fine, but you have one more step, you need to get the LISTOBJECT from SPOOL. See if you can do it using the functino module RSPO_RETURN_ABAP_SPOOLJOB or RSPO_RETURN_ABAP_SPOOLJOB_RAW.
REgards,
RIch Heilman
Maybe you are looking for
-
Difference between .equals("") and .equals(null)
Can any one please tell me the difference between the following? String someString; someString = someMethod(someParameter); After the method call, if I am going for a check like this.. what will each check do? 1. if (someThing.equals(null)) 2. if (so
-
WIS 10901 error while refreshing report in rich client
I'm facing a strange issue while refreshing a report from Rich client. Here are details Environment: BO XI 3.1 SP3, Oracle application DB. Weu2019ve 2 BO servers (S1 and S2) on cluster and load balancer (common URL) in front. While login to S1 with 6
-
Trouble with links that contain %2C (comma) in url
I have a friend that uploaded some files to a site for her students to click on and download. They're mp3 files of classical music, many of which contain commas in their filenames. When uploading them, the site escapes these commas by replacing them
-
Problem using 2 ImageViews (one normal, one zoomed) on an image
Hi, I've a problem in using 2 imageviews on an image. Imageview A displays an image, and it has been flipped using "scaleX = -1" Imageview B displays the same image as a zoomed image using viewport with "scaleX = -1" Unfortunately, Imageview B now di
-
Plz help in installation of hyjperion planning
HyperionPlanning.ear,HspJS.jar