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: 

How to apply WWW_LIST_TO_HTML -> Open/Transfer/Close Dataset to ALV Reports

Former Member
0 Kudos
475

hello people! So far I have done some good progress regarding this thanks to many of you people. I do have some hurdles and one of them involves ALV Reports. So far I use

WWW_LIST_TO_HTML - to temporarly store the list report to a table known as ihtml.

and Open/Transfer/Close data set to send the file to the application server using the syntax below

<b>OPEN DATASET file FOR OUTPUT IN BINARY MODE.

LOOP AT ihtml.

TRANSFER ihtml TO file.

ENDLOOP.

CLOSE DATASET file.</b>

So far the program works fine in the report with the expection if its one that generates an ALV Report.

My question is that is there a way to successfully run the program the way it was mentioned above using ALV? If so what techniques do you guys suggest?

<b>Note:</b> Also please note the report and transfering/writing of the file has to be done during background processing.

Hope I get some replies soon as many of you have been most helpful thank you and good day.

1 ACCEPTED SOLUTION

jayanthi_jayaraman
Active Contributor
0 Kudos
176

Hi,

After you got the data,you just need to use an output table to populate the data.

Check these links for ALV concepts.

http://www.geocities.com/mpioud/Abap_programs.html

http://72.14.203.104/search?q=cache:NjFXTBr5lX8J:www.sap-img.com/abap/an-interactive-alv-report.htmALVInteractivereportsABAP&hl=en&gl=in&ct=clnk&cd=5

Check this tutorial for OOPS Alv.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an easy reference for alv grid control.pdf

If you need more infomration,get back.Kindly reward points if it helps.

9 REPLIES 9

Former Member
0 Kudos
176

Hi,

I am little confused as I am unable to find what exactly the problem is here.

If you want to run a ALV report in the background, just make sure you check cl_gui_alv_grid=>offline( ), then create the container.

Anything else that you are doing should work fine in the background as well.

Regards,

Ravi

Note : Please mark the helpful answer

0 Kudos
176

<b>"Hi,

I am little confused as I am unable to find what exactly the problem is here.

If you want to run a ALV report in the background, just make sure you check cl_gui_alv_grid=>offline( ), then create the container.

Anything else that you are doing should work fine in the background as well.

Regards,

Ravi"</b>

my apologies for not making it clear. Problem is that the function module WWW_LIST_TO_HTML does not work in an alv report. It would generate a runtime error. Specifying the <b>list index</b> is invalid.

If you see the code above, ususally is that after I run the report a new file will automatically generate in a particular path. With the alv it runs the report but without transfering the file, and if I click the BACK button it would execute a runtime error.

Thanks again.

0 Kudos
176

Hi,

Can you post your code here, not the entire code, whichever is giving the short dump.

Regards,

Ravi

0 Kudos
176

DATA: LD_FILENAME TYPE LOCALFILE.

...

the code below is run after the function <b>REUSE_ALV_LIST_DISPLAY</b> is called

...

CALL FUNCTION 'WWW_LIST_TO_HTML'

  • EXPORTING

  • list_index = sy-lsind

TABLES

HTML = IHTML.

CLEAR IHTML.

CONCATENATE '
HCMWEB00\SAPReport\' sy-cprog '.html'

INTO LD_FILENAME.

OPEN DATASET LD_FILENAME FOR OUTPUT IN BINARY MODE.

LOOP AT IHTML.

TRANSFER IHTML TO LD_FILENAME.

ENDLOOP.

CLOSE DATASET LD_FILENAME.

CLEAR LD_FILENAME.

....

the report runs fine but one I press Back a runtime occurs stating

<b>Exception condition "LIST_INDEX_INVALID" raised.</b>

A RAISE statement in the program "SAPLSLST " raised the exception

condition "LIST_INDEX_INVALID".

Since the exception was not intercepted by a superior program

in the hierarchy, processing was terminated.

0 Kudos
176

Hi chad,

1. yes u are right

2. it will give this error only.

3. the reason is, the www_list_to_html

is exected after list display,

4. the code comes there when

we press BACK, and at that time

no list is there in memory.

<b>5. So we have to use some workaround.

6. END_OF_LIST

7. We have to use this EVENT

and inside this event,

we have to export to HTML.</b>

8. I tried and it works FANTASTIC

9. Just copy paste this program.

(it will show a alv list of t001,

and write the HTML file also)

( i have used END_OF_LIST event)

10.

REPORT abc.

TYPE-POOLS : slis.

*----


Data

DATA : BEGIN OF itab OCCURS 0.

INCLUDE STRUCTURE t001.

DATA : END OF itab.

DATA : alvfc TYPE slis_t_fieldcat_alv.

*----


Select

SELECT * FROM t001 INTO TABLE itab.

*------- Field Catalogue

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

.

*----


DATA : alvev TYPE slis_t_event .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = alvev.

PERFORM alv_setevent USING 'END_OF_LIST' 'ITAB'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

it_fieldcat = alvfc

i_callback_program = SY-REPID

  • i_callback_user_command = alvcallback_formname

it_events = alvev[]

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

*----


form itab_end_of_list.

*----


Display

data : ht like table of W3HTML.

CALL FUNCTION 'WWW_LIST_TO_HTML'

  • EXPORTING

  • list_index = sy-lsind

TABLES

HTML = ht

.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = 'd:\my.html'

tables

data_tab = ht

.

endform.

*=============This Function Links the Event Name To The Specified Form

FORM alv_setevent USING value(eventname) value(alvitabname).

DATA: tempev TYPE slis_alv_event.

DATA : formname(30) TYPE c.

TRANSLATE eventname TO UPPER CASE.

CONCATENATE alvitabname '_' eventname INTO formname.

TRANSLATE formname TO UPPER CASE.

LOOP AT alvev INTO tempev WHERE name = eventname.

tempev-form = formname.

MODIFY alvev FROM tempev.

ENDLOOP.

ENDFORM. "alv_setevent

regards,

amit m.

0 Kudos
176

Hey Amit Mittal thanks for the help however, I do have a few questions.

Regarding form <b>itab_end_of_list</b> where is is being called? Thanks

0 Kudos
176

Hi again,

1. itab_end_of_list

is a CALL BACK command.

2. ie.

when the alv printing on screen ends,

the alv program

itself calls this

itab_end_of_list.

3. Then it executes whatever is there in this form.

4. This is nothing but EVENT concept in alv.

regards,

amit m.

0 Kudos
176

Ok i'll get back on it soon, when/if it works i'll reward you the full 10 pts. for now i just put in 6. Til' Text Time. Thank you and good day.

jayanthi_jayaraman
Active Contributor
0 Kudos
177

Hi,

After you got the data,you just need to use an output table to populate the data.

Check these links for ALV concepts.

http://www.geocities.com/mpioud/Abap_programs.html

http://72.14.203.104/search?q=cache:NjFXTBr5lX8J:www.sap-img.com/abap/an-interactive-alv-report.htmALVInteractivereportsABAP&hl=en&gl=in&ct=clnk&cd=5

Check this tutorial for OOPS Alv.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/an easy reference for alv grid control.pdf

If you need more infomration,get back.Kindly reward points if it helps.