2007 Apr 12 8:22 AM
Hi I want to convert the report output in the form of a list to a html format. But every time i execute the program is terminated.It is giving a short dump, an exception is raised : List_Index_Invalid.How to resolve the problem?
REPORT z_list_to_html.
PARAMETERS : p_matnr TYPE mara-matnr.
TYPES : BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
END OF ty_marc.
DATA : i_marc TYPE STANDARD TABLE OF ty_marc,
r_marc TYPE ty_marc,
i_html LIKE w3html OCCURS 0 WITH HEADER LINE,
f_path(200) VALUE 'c:\Ashland\test.html'.
SELECT matnr
werks
FROM marc
INTO TABLE i_marc
WHERE matnr = p_matnr.
LOOP AT i_marc INTO r_marc.
MOVE-CORRESPONDING r_marc TO i_html.
APPEND i_html.
ENDLOOP.
CALL FUNCTION 'WWW_LIST_TO_HTML'
EXPORTING
LIST_INDEX = 0
TABLES
html = i_html.
OPEN DATASET f_path FOR OUTPUT IN BINARY MODE.
LOOP AT i_html.
TRANSFER i_html TO f_path.
ENDLOOP.
CLOSE DATASET f_path.
I have also tried using the function module ws_download instead of open dataset, but it is giving the same short dump.Please help.
2007 Apr 12 8:34 AM
Hi,
you should first create a list.
For example
LOOP AT i_marc INTO r_marc.
write:/ r_marc-matnr, r_marc-werks.
ENDLOOP.
CALL FUNCTION 'WWW_LIST_TO_HTML'
EXPORTING
LIST_INDEX = 0
TABLES
html = i_html.
...
...
2007 Apr 12 8:29 AM
Hi,
Here is the code to download the HTML using 'LIST_DOWNLOAD' function module
REPORT ZKBTST31.
DATA: MTAB_REPORT_LIST LIKE ABAPLIST OCCURS 0 WITH HEADER LINE.
DATA: MTAB_REPORT_HTML LIKE W3HTML OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF MTAB_REPORT_ASCII OCCURS 0,
LINE(255) TYPE C,
END OF MTAB_REPORT_ASCII.
START-OF-SELECTION.
*-- Submit a report. This one is the chart of accounts
SUBMIT RFSKPL00
EXPORTING LIST TO MEMORY " Save list in memory
AND RETURN. " Return control to this program
END-OF-SELECTION.
*-- Get the list from memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
LISTOBJECT = MTAB_REPORT_LIST
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
*-- Write the list out
*-- This is a trivial example. A better use would be when the
*-- requirement is to have one report print out several different
*-- reports on the same list level.
CALL FUNCTION 'WRITE_LIST'
TABLES
LISTOBJECT = MTAB_REPORT_LIST
EXCEPTIONS
EMPTY_LIST = 1
OTHERS = 2.
************************************************************************
* The examples below this line do not require that the report be *
* submitted to memory when run. All that they require is that the *
* report has been written to the screen. *
************************************************************************
*-- Take the current list that has been written to screen, and format
*-- as an HTML file.
CALL FUNCTION 'WWW_LIST_TO_HTML'
TABLES
HTML = MTAB_REPORT_HTML
EXCEPTIONS
OTHERS = 1.
*-- Save the list. Same as using System->List->Save->Local File or
*-- entering %pc in the OKCODE box. This function does not need the
*-- include <%_LIST> in a program.
*-- Method can be:
*-- NOCO - No conversion
*-- RTF - Rich Text Format
*-- DAT - Tab delimited Format
*-- When no method is given, a selection screen is presented for the
*-- user to choose the method.
CALL FUNCTION 'LIST_DOWNLOAD'
EXPORTING
METHOD = 'NOCO'
EXCEPTIONS
OTHERS = 1.http://sap4.com/modules.php?name=conteni2&pa=showpagina&pid=71
2007 Apr 12 8:34 AM
Hi,
you should first create a list.
For example
LOOP AT i_marc INTO r_marc.
write:/ r_marc-matnr, r_marc-werks.
ENDLOOP.
CALL FUNCTION 'WWW_LIST_TO_HTML'
EXPORTING
LIST_INDEX = 0
TABLES
html = i_html.
...
...
2007 Apr 12 11:48 AM
I have tried this befor, but this doesn't help and it is giving the short dump inside the function module www_list_to_html.
2007 Apr 12 8:36 AM
hi
i m giving u the sample program which works fine
See below simple report to convert the internal table data to a HTML format data
REPORT Z_HTML .
include <icon>.
types: begin of msg,
type like icon-id,
text(140) type c,
end of msg.
constants: gc_marked type c value 'X',
gc_ok like icon-id value '@5B@'.
data:
gt_msg type standard table of msg,
gs_msg like line of gt_msg,
gv_msg(138) type c,
*-- html
html_container type ref to cl_gui_custom_container,
html_control type ref to cl_gui_html_viewer,
my_row_header like w3head occurs 10 with header line,
my_fields like w3fields occurs 10 with header line,
my_header like w3head,
my_html type standard table of w3html ,
ok_code like sy-ucomm.
----
Start of Selection *
----
start-of-selection.
clear gv_msg.
gv_msg = 'MESSAGES for HTML'.
do 3 times.
perform message using gc_ok gv_msg .
enddo.
----
End of Selection *
----
end-of-selection.
set screen 0100.
&----
*& Form message
&----
form message using p_type
p_text.
clear gs_msg.
gs_msg-type = p_type.
gs_msg-text = p_text.
append gs_msg to gt_msg.
endform. " MESSAGE
&----
*& Module STATUS_0100 OUTPUT
&----
module status_0100 output.
perform convert_itab_html.
set titlebar '100' .
set pf-status 'MAIN100'.
create object html_container
exporting
container_name = 'CONTAINER'.
create object html_control
exporting
parent = html_container
saphtmlp = gc_marked .
data: assigned_url type url.
call method html_control->load_data
EXPORTING
URL = url
TYPE = 'text'
SUBTYPE = 'html'
SIZE = 0
ENCODING =
CHARSET =
importing
assigned_url = assigned_url
changing
data_table = my_html
EXCEPTIONS
DP_INVALID_PARAMETER = 1
DP_ERROR_GENERAL = 2
CNTL_ERROR = 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.
call method html_control->show_url
exporting
url = assigned_url
FRAME =
IN_PLACE = ' X'
EXCEPTIONS
CNTL_ERROR = 1
CNHT_ERROR_NOT_ALLOWED = 2
CNHT_ERROR_PARAMETER = 3
DP_ERROR_GENERAL = 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.
endmodule. " STATUS_0100 OUTPUT
&----
*& Module exit INPUT
&----
module exit input.
leave program.
endmodule. " exit INPUT
&----
*& Module user_command_0100 INPUT
&----
text
----
module user_command_0100 input.
case ok_code.
when 'EXIT' or 'BACK'.
leave program.
when others.
call method cl_gui_cfw=>dispatch.
endcase.
endmodule. " user_command_0100 INPUT
&----
*& Form convert_itab_html
&----
form convert_itab_html.
data: lv_tabix like sy-tabix.
*-- table header
call function 'WWW_ITAB_TO_HTML_HEADERS'
exporting
field_nr = 1
text = 'Type'
fgcolor = 'navy'
bgcolor = 'red'
font = 'Arial'
tables
header = my_row_header.
call function 'WWW_ITAB_TO_HTML_HEADERS'
exporting
field_nr = 2
text = 'Message'
fgcolor = 'navy'
bgcolor = 'red'
font = 'Arial'
tables
header = my_row_header.
*-- table rows
clear lv_tabix.
loop at gt_msg into gs_msg.
lv_tabix = sy-tabix.
call function 'WWW_ITAB_TO_HTML_LAYOUT'
exporting
field_nr = 1
line_nr = lv_tabix
icon = gc_marked
tables
fields = my_fields.
call function 'WWW_ITAB_TO_HTML_LAYOUT'
exporting
field_nr = 2
line_nr = lv_tabix
fgcolor = 'red'
bgcolor = 'black'
font = 'Arial'
size = '2'
tables
fields = my_fields.
endloop.
*-- header
move 'Messages during program run' to my_header-text.
move 'Arial' to my_header-font.
move '2' to my_header-size.
move 'Centered' to my_header-just.
move 'red' to my_header-bg_color.
move 'blue' to my_header-fg_color.
refresh my_html.
call function 'WWW_ITAB_TO_HTML'
exporting
table_header = my_header
all_fields = ' '
tables
html = my_html
fields = my_fields
row_header = my_row_header
itable = gt_msg.
endform. "convert_itab_html
hope it will help u
regards
ravish
<b>*plz reward points if helpful</b>
2007 Apr 12 11:53 AM
2007 Apr 12 12:05 PM
Hi..,
<b>In your program you are not generating any list..
No output statement in your program..
then how can u Output the list to HTML..
thats what the error in your program...</b>
First generate a list !!!
<i>
LOOP AT i_marc INTO r_marc.
MOVE-CORRESPONDING r_marc TO i_html.
APPEND i_html.
write i_html.
ENDLOOP.</i>
Use Write statement in this loop..
then your problem will be solved..
The function module needs a list index as import parameter.. but it is not getting any list index, because you havent yet generated any list !!!
<b>reward if it helps u..
sai ramesh</b>
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |