on 02-27-2006 8:12 AM
Dear experts,
I have to display the result of a SAP standard program (RPTEDT00) within a own developted BSP - but how?
Do somebody know, how I can include a such display functionality into my BSP?
Thank you in advance!
Regards
Heinz
submit the report within your event handler exporting list to memeory , read the list from memory, convert to html and display it in layout.
submit (report_name) and return exporting list to memory.
call function 'LIST_FROM_MEMORY'
tables
listobject = listobject.
call function 'WWW_HTML_FROM_LISTOBJECT'
exporting
report_name = report_name
tables
html = html
listobject = listobject.
loop at html.
concatenate output_str html_wa into output_str.
endloop .
<u>layout:</u>
<%= output_str %>
Regards
Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Raja,
again: Thank you for your answer!
But now I have a new problem - maybe do you know a solution?!
At first my coding:
*--- creation of time form
SUBMIT rptedt00 AND RETURN EXPORTING LIST TO MEMORY
USING SELECTION-SET 'KB_DEFAULT'
WITH pnptimr6 EQ 'X'
WITH pnpbegda EQ i_begda
WITH pnpendda EQ i_endda
WITH pnppernr-low EQ i_pernr.
*--- read memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_abaplist
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc NE 0.
*** Errorhandling
ENDIF.
*--- convert listobject to HTML code
CALL FUNCTION 'WWW_HTML_FROM_LISTOBJECT'
EXPORTING
report_name = 'RPTEDT00'
* template_name = 'WEBREPORTING_REPORT'
template_name = 'HR_TIME_SHEET'
* template_name = 'HR_DEFAULT_WEBREPORTING'
TABLES
html = gt_html
listobject = lt_abaplist.
My Layout:
<%@page language="abap" %>
<%
data: lv_html type W3HTML.
%>
<%
loop at gt_html into lv_html.
%>
<%= lv_html %>
<%
endloop.
%>
My Problem: The result, that means the HTML version of the HR time form (program rptedt00) is very "unsightly".
I tried some HTML templates of function module WWW_HTML_FROM_LISTOBJECT but the result was in every case unsatisfying. I think it´s not a problem of the HTML template because all lines and columns are not flush...
Do you have a idea? Maybe I have to change my layout?!
Thank you in advance!
Heinz
you dont have much control over it with the content of the list. even if you were to change the template , you can only add some extra image or somethingelse to the template as the list goes int to <b><!listbody!></b> of the template.
which version of WAS are you using? if you are on WAS6.40 check out whether you like the results of Integrated ITS for your report.
Regards
Raja
Hi Raja,
I´m on a WAS6.20 - without a integrated ITS
I did a additional test: I created a HTML template within transaction SMW0 as follow:
<html>
<head>
<title>!title!</title>
</head>
<!listbody!>
</body>
</html>
... and used this template in the context of function module WWW_HTML_FROM_LISTOBJECT - but the problem is the same!
Do you have a other idea????
Thank you!!!!
Regards
Heinz
Dear Raja,
I´m very broken-hearted!!! It isn´t working!!
But - maybe - I have a alternative solution:
Is it possilbe to create a PDF file of the (RPTEDT00) ABAP list incl. all necessary format issues and display this result within my BSP application?
What do you think? Did you such a thing in the past? Do you have a example code for me?
Thank you very very much!
Best Regards
Heinz
PDF is very much possible.
check out this thread for my answer in the second page.
steps explained in the thread in nutshell.
1. submit the report to sap-spool and return.
2. use 'CONVERT_ABAPSPOOLJOB_2_PDF' to conver the spool to pdf
3. set the return value as the reposne of your page.
(the complete code sample for all the steps are available in the thread)
do get back in case if you need clarifications.
Regards
Raja
Hi Raja!
I have some doubts about your answer... Have i to do a report to call that functions ( submit,list_from_memory,...)¿? Or i have to do in a event in my bsp..¿? In this case it could be in the inptuprocessing after click a button to generate a table ..( the results of the report i submitted)
Thanks in advanced and Regards!
Mon
Hi Raja,
OK, But i was refering to this answer:
+submit the report within your event handler exporting list to memeory , read the list from memory, convert to html and display it in layout.
submit (report_name) and return exporting list to memory.
call function 'LIST_FROM_MEMORY'
tables
listobject = listobject.
call function 'WWW_HTML_FROM_LISTOBJECT'
exporting
report_name = report_name
tables
html = html
listobject = listobject.
loop at html.
concatenate output_str html_wa into output_str.
endloop .
layout:
<%= output_str %>+
I think that is is interesting know that..and what is FM¿? (from memory¿?)
Thanks again and regards!
Mon
Hi Raja,
I tried the whole day to implement the PDF conversion - but I´ve been failed.
Steps 1 and 2 are simple - but step 3!!!
I think my problem is, that I´m on a WAS 6.20 (unicode). So far as I see, on this release the interface IF_HTTP_HEADER_FIELDS doesn´t have all descripted methods of the thread?!?
Whit other words: How can I set the return value as the reposne of my page?
Thank you very much!!!
Regards
Heinz
I forgot my current coding:
OnInitialization:
DATA: itab TYPE tline,
witab TYPE TABLE OF tline,
output TYPE string ,
wf_spono TYPE tsp01-rqident ,
wf_params TYPE pri_params,
valid_flag(1) TYPE c ,
lc_rq2name TYPE tsp01-rq2name ,
tsp01_wa TYPE tsp01 .
DATA: cached_response TYPE REF TO cl_http_response.
DATA: l_pdf_len TYPE i,
lv_guid_32 TYPE guid_32.
*--- set printer parameters (e.g. for layout) ---*
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = 'locl'
immediately = ' '
release = ' '
new_list_id = 'X'
line_size = 200
line_count = 65
layout = 'X_65_200'
sap_cover_page = 'X'
receiver = 'SAP*'
department = ''
no_dialog = 'X'
IMPORTING
out_parameters = wf_params
valid = valid_flag.
IF valid_flag EQ space.
*** Errorhandling
EXIT.
ENDIF.
*--- create a spool list of the time form ---*
SUBMIT rptedt00
USING SELECTION-SET 'HRESS_TEDT00'
WITH pnppernr-low EQ a_gs_data_pernr-employeenumber
WITH pnptimr6 EQ 'X'
WITH pnpbegda EQ a_gv_form_begda
WITH pnpendda EQ a_gv_form_endda
TO SAP-SPOOL
SPOOL PARAMETERS wf_params
WITHOUT SPOOL DYNPRO
AND RETURN.
CONCATENATE 'SAPMHTTP'
sy-uname+0(3)
INTO lc_rq2name SEPARATED BY '_'.
*--- select created spool list number ---*
SELECT * FROM tsp01 INTO tsp01_wa WHERE rq2name = lc_rq2name AND
rqowner = sy-uname
ORDER BY rqcretime DESCENDING.
wf_spono = tsp01_wa-rqident.
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR wf_spono.
ENDIF.
*--- convert spool list to PDF format ---*
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = wf_spono
no_dialog = 'X'
TABLES
pdf = witab
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 = 8
err_btcjob_submit_failed = 9
err_btcjob_close_failed = 10
OTHERS = 11.
IF sy-subrc EQ 0.
LOOP AT witab INTO itab .
TRANSLATE itab USING ' ~'.
CONCATENATE output itab INTO output IN CHARACTER MODE.
ENDLOOP.
TRANSLATE output USING '~ ' .
CREATE OBJECT cached_response TYPE cl_http_response EXPORTING
add_c_msg = 1.
l_pdf_len = STRLEN( output ).
cached_response->set_cdata( data = output
length = l_pdf_len ).
cached_response->set_header_field(
name = if_http_header_fields=>content_type
value = 'application/pdf' ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 180 ).
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = lv_guid_32.
CONCATENATE runtime->application_url '/' lv_guid_32 '.pdf' INTO a_gv_display_url.
cl_http_server=>server_cache_upload( url = a_gv_display_url
response = cached_response ).
RETURN .
ENDIF .
Layout:
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2002" >
<htmlb:page>
<iframe src="<%= a_gv_display_url %>" width="100%" height="500px">
</iframe>
</htmlb:page>
</htmlb:content>
My main problem is, that the methodes
set_status
andserver_cache_expire_rel
doesn´t exist (WAS 6.20), that means following coding isn´t working:
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 180 ).
+I become following error message if I start the BSP:
Business Server Page (BSP) Error
What happened?
Call of BSP page terminated due to error.
Note
Following error text processed in system:
BSP Exception: Das Objekt 440579BD29D7288AE100000095F403F8.pdf in der URL /sap(bD1lbiZjPTEwMA==)/bc/bsp/sap/zzh_timestamp/440579BD29D7288AE100000095F403F8.pdf ist nicht gültig.
Error Type:
Your SAP Business Server Pages Team+
Message was edited by: Heinz Müller
i don thave a 6.20 system to test this but i guess the following changes will make it work in your system.
replace all the code after statement
TRANSLATE output using '~ ' .
with the following code.
<i>
DATA: response TYPE REF TO if_http_response ,
file_length type string .
response = runtime->server->response.
l_pdf_len = STRLEN( output ).
file_length = l_pdf_len .
response->set_cdata( data = output ) .
response->set_header_field( name = if_http_header_fields=>content_type
value = 'application/pdf' ).
response->set_header_field( name = if_http_header_fields=>content_length
value = file_length ).
response->delete_header_field( name = if_http_header_fields=>cache_control ).
response->delete_header_field( name = if_http_header_fields=>expires ).
response->delete_header_field( name = if_http_header_fields=>pragma ).
navigation->response_complete( ). " signal that response is complete
</i>
Let us know how it goes.
Regards
Raja
Hello Raja,
First of all: Thank you very much for your support!
I´ve been changed my BSP coding with your coding - but unfortunately it isn´t working...
If I start the PDF generation within my BSP, I received only one line with - let´s say - "funny symbols" like this:
䅮獩䕮捯摩湧ഊ敮摯扪
(look´s like Japanese characters...)
Do you know the reason for this?
Regards from Munich (Germany)
Heinz
COMMENT: unfortunately this forum isn´t able to show that kind of symbols...
Message was edited by: Heinz Müller
Message was edited by: Heinz Müller
Hi Heinz,
The following worked for me...
In SE80, Copy the entire function group HRPADIT_REP into say Z_HRPADIT_REP. In the custom version of the function module say Z_HR_IT_DISPLAY_WITH_PDF.. replace the existing code with the following code..also create an IMPORT parameter to pass the spool id to this fm.
refresh pdf_table.
clear pdf_fsize.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = src_spoolid
no_dialog = 'X'
tables
pdf = pdf_table.
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 screen '100'.
Activate everything & call this function Z_HR_IT_DISPLAY_WITH_PDF immediately after you retrieve the spool id in your original BSP application.
The list output will automatically open in PDF. There is no need to put in any further code after this function call.
Regards,
Suresh Datti
Dear Suresh, dear Raja,
First of all: Thank you very much for your support and sorry for the delay (I was on vacation last week).
I tried your proposal with the copy of function group Z_HRPADIT_REP / function module Z_HR_IT_DISPLAY_WITH_PDF but unfortunately it
isn´t work! I receive following error message, if I start my adapted BSP application:
500 SAP Internal Server Error
Error message: Exception condition "CNTL_ERROR" raised. ( type of termination: RABAX_STATE )
The Debbuger shows me, that the error occurs in the moment, if the
call screen '100'
statement is processed...I don´t understand, why this solution is operable in your BSP application Suresh?!
Message was edited by: Heinz Müller
Message was edited by: Heinz Müller
Dear Raja,
As you requested, here my whole BSP application in the current status:
layout
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2002" >
<htmlb:page>
<iframe src="<%= a_gv_display_url %>" width="100%" height="500px">
</iframe>
</htmlb:page>
</htmlb:content>
page attributes:
OnInitialization:
* event handler for checking and processing user input and
* for defining navigation
DATA: itab TYPE tline,
witab TYPE TABLE OF tline,
output TYPE string ,
wf_spono TYPE tsp01-rqident ,
wf_params TYPE pri_params,
valid_flag(1) TYPE c ,
lc_rq2name TYPE tsp01-rq2name ,
tsp01_wa TYPE tsp01 .
DATA: cached_response TYPE REF TO cl_http_response.
DATA: l_pdf_len TYPE i,
lv_guid_32 TYPE guid_32.
*--- set printer parameters (e.g. for layout) ---*
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = 'locl'
immediately = ' '
release = ' '
new_list_id = 'X'
line_size = 200
line_count = 65
layout = 'X_65_200'
sap_cover_page = 'X'
receiver = 'SAP*'
department = ''
no_dialog = 'X'
IMPORTING
out_parameters = wf_params
valid = valid_flag.
IF valid_flag EQ space.
*** Errorhandling
EXIT.
ENDIF.
*--- create a spool list of the time form ---*
SUBMIT rptedt00
USING SELECTION-SET 'HRESS_TEDT00'
WITH pnppernr-low EQ a_gs_data_pernr-employeenumber
WITH pnptimr6 EQ 'X'
WITH pnpbegda EQ a_gv_form_begda
WITH pnpendda EQ a_gv_form_endda
TO SAP-SPOOL
SPOOL PARAMETERS wf_params
WITHOUT SPOOL DYNPRO
AND RETURN.
*--- select created spool list number ---*
CONCATENATE 'SAPMHTTP'
sy-uname+0(3)
INTO lc_rq2name SEPARATED BY '_'.
SELECT * FROM tsp01 INTO tsp01_wa WHERE rq2name = lc_rq2name AND
rqowner = sy-uname
ORDER BY rqcretime DESCENDING.
wf_spono = tsp01_wa-rqident.
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR wf_spono.
ENDIF.
*--- convert spool list to PDF format ---*
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = wf_spono
no_dialog = 'X'
TABLES
pdf = witab
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 = 8
err_btcjob_submit_failed = 9
err_btcjob_close_failed = 10
OTHERS = 11.
IF sy-subrc NE 0.
*** Errorhandling
ENDIF.
LOOP AT witab INTO itab .
TRANSLATE itab USING ' ~'.
CONCATENATE output itab INTO output IN CHARACTER MODE.
ENDLOOP.
TRANSLATE output USING '~ ' .
CREATE OBJECT cached_response TYPE cl_http_response
EXPORTING add_c_msg = 1.
l_pdf_len = STRLEN( output ).
cached_response->set_cdata( data = output
length = l_pdf_len ).
cached_response->set_header_field(
name = if_http_header_fields=>content_type
value = 'application/pdf' ).
* cached_response->set_status( code = 200 reason = 'OK' ).
* cached_response->server_cache_expire_rel( expires_rel = 180 ).
CALL METHOD cached_response->if_http_response~set_status
EXPORTING
code = 200
reason = 'OK'.
CALL METHOD cached_response->if_http_response~server_cache_expire_rel
EXPORTING
expires_rel = 180.
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = lv_guid_32.
CONCATENATE runtime->application_url '/' lv_guid_32 '.pdf'
INTO a_gv_display_url.
cl_http_server=>server_cache_upload( url = a_gv_display_url
response = cached_response ).
*navigation->response_complete( ).
" signal that response is complete
*navigation->goto_page( a_gv_display_url ).
RETURN.
If I start the PDF generation within my BSP, I received only one line with - let´s say - "funny symbols" (look´s like Japanese characters...). In my opinion something with the convertion into the PDF format or the display of the PDF format is not OK...
I tried some variants with the last two, tree code lines (with RETRUN, without RETURN, with navigation->goto_page without navigation->goto_page, and so on) but without success...
Do you know the reason for this?
Thank you for your support!
Best regards
Heinz
i just noticed that you are doing the processing in oninitialization , so that means you want your page as a PDF
do the following.
1. set the MIME type of the page (properties tab) to application/pdf
2. remove all coding from layout section.
3. place the following code in the oninitialization event.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = 'locl'
* copies = wf_copies
* list_name = wf_listname
* list_text = wf_listtext
* expiration = wf_days
immediately = ' '
release = ' '
new_list_id = 'X'
line_size = 200
line_count = 65
layout = 'X_65_200'
sap_cover_page = 'X'
receiver = 'SAP*'
department = ''
no_dialog = 'X'
IMPORTING
out_parameters = wf_params
valid = valid_flag .
IF valid_flag = 'X' AND sy-subrc = 0.
SUBMIT guilstcn TO SAP-SPOOL
SPOOL PARAMETERS wf_params
WITHOUT SPOOL DYNPRO AND RETURN .
ENDIF.
DATA:
lc_rq2name TYPE tsp01-rq2name ,
f_repid TYPE sy-repid ,
tsp01_wa TYPE tsp01 .
CONCATENATE 'SAPMHTTP'
sy-uname+0(3)
INTO lc_rq2name SEPARATED BY '_'.
SELECT * FROM tsp01 INTO tsp01_wa WHERE rq2name = lc_rq2name AND
rqowner = sy-uname
ORDER BY rqcretime DESCENDING.
wf_spono = tsp01_wa-rqident.
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR wf_spono.
ENDIF.
*move: sy-spono to wf_spono .
*MOVE: '29262' TO wf_spono .
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = wf_spono
no_dialog = 'X'
TABLES
pdf = witab
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 = 8
err_btcjob_submit_failed = 9
err_btcjob_close_failed = 10
OTHERS = 11.
IF sy-subrc EQ 0.
LOOP AT witab INTO itab .
TRANSLATE itab USING ' ~'.
CONCATENATE output itab INTO output IN CHARACTER MODE.
ENDLOOP.
TRANSLATE output USING '~ ' .
DATA: file_length TYPE string .
DATA: l_pdf_xstring TYPE xstring,
lt_lines TYPE TABLE OF tline,
ls_line TYPE tline,
l_pdf_len TYPE i.
DATA: display_url TYPE string .
response->set_cdata( data = output ) .
endif .
Regards
Raja
Hi Raja,
thank you for your last post!
I did following: I created a new BSP on a other R/3 system (WAS 6.20; Non-Unicode) and your solutions works very well!!!!!!!
Thant means, the problem that I have is the Unicode environment, because our HR system (on which I have tried afore) is a WAS 6.20 <b>Unicode</b> system!!!
Do you know something about the unicode topic in the context of the PDF convertion???
Thank you!
Regards
Heinz
Hi Heinz,
I've had a similar problem with a Unicode system that connects to a 4.6c.
This is what I did to convert them:
The parameters for this method are:
IMI_PDF Importing Type TLINETAB
RE_PDF_XSTRING Returning Type XSTRING
TYPES: BEGIN OF tw_line,
line(134) TYPE c,
END OF tw_line.
DATA lo_convout TYPE REF TO cl_abap_conv_out_ce.
DATA lw_line TYPE tw_line.
FIELD-SYMBOLS <fs> TYPE c.
* Create instance of conversion object
lo_convout = cl_abap_conv_out_ce=>create(
encoding = '1100' ).
* Get line by line in simple C format for conversion
LOOP AT imi_pdf INTO lw_line.
ASSIGN COMPONENT 1
OF STRUCTURE lw_line
TO <fs> CASTING.
* Write line in type C to converter
CALL METHOD lo_convout->write
EXPORTING
data = <fs>.
ENDLOOP.
* Get converted line
CALL METHOD lo_convout->get_buffer
RECEIVING
buffer = re_pdf_xstring.
I hope this helps.
kind regards,
Tim
Adopt the following changes for unicode compatibility
<i>
TRANSLATE output USING '~ ' .
DATA: file_length TYPE string .
DATA: l_pdf_xstring TYPE xstring,
lt_lines TYPE TABLE OF tline,
ls_line TYPE tline,
l_pdf_len TYPE i,
app_type type string .
APP_TYPE = 'APPLICATION/PDF; charset=utf-8'.
call function 'SCMS_STRING_TO_XSTRING'
exporting
text = output
MIMETYPE = APP_TYPE
IMPORTING
BUFFER = l_pdf_xstring.
l_pdf_len = xstrlen( l_pdf_xstring ).
response->set_data( data = l_pdf_xstring
length = l_pdf_len ).
</i>
Regards
Raja
Check out this weblog for more details.
/people/thomas.jung3/blog/2004/08/09/bsp-download-to-excel-in-unicode-format
Message was edited by: Durairaj Athavan Raja
Hello Raja,
I hope you are fine?!
Sorry for my delay, because I have other problems to solve....
Now I tried your proposal coding and the contant of the blog, but unfortunately it doesn´t work! :-(((
Could you help me again please??? Do you have any other idea?
Here my conding which doesn´t work:
Application class (zcl_hr_appl_timestamp, methode create_time_form):
DATA: lt_pdf_convert TYPE tline,
lt_pdf_data TYPE TABLE OF tline,
lv_outputstring TYPE string ,
lv_spono TYPE tsp01-rqident ,
ls_params TYPE pri_params,
lv_valid_flag(1) TYPE c ,
lv_rq2name TYPE tsp01-rq2name ,
ls_tsp01 TYPE tsp01 .
DATA: ref_conv_out TYPE REF TO cl_abap_conv_out_ce.
*--- Druckparameter setzen ---*
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = 'locl'
immediately = ' '
release = ' '
new_list_id = 'X'
line_size = 80
line_count = 65
layout = 'X_65_80'
sap_cover_page = 'X'
receiver = 'SAP*'
department = ''
no_dialog = 'X'
IMPORTING
out_parameters = ls_params
valid = lv_valid_flag.
IF lv_valid_flag EQ space.
*** Errorhandling
RAISE error_print_parameters.
ENDIF.
*--- Zeitnachweisformular erzeugen und im Spool ablegen ---*
SUBMIT rptedt00
USING SELECTION-SET 'HRESS_TEDT00'
WITH pnppernr-low EQ i_pernr
WITH pnptimr6 EQ 'X'
WITH pnpbegda EQ i_begda
WITH pnpendda EQ i_endda
TO SAP-SPOOL
SPOOL PARAMETERS ls_params
WITHOUT SPOOL DYNPRO
AND RETURN.
*--- Spool lesen ---*
CONCATENATE 'SAPMHTTP'
sy-uname+0(3)
INTO lv_rq2name SEPARATED BY '_'.
SELECT * FROM tsp01 INTO ls_tsp01 WHERE rq2name = lv_rq2name AND
rqowner = sy-uname
ORDER BY rqcretime DESCENDING.
lv_spono = ls_tsp01-rqident.
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR lv_spono.
ENDIF.
*--- Spool in PDF Format konvertieren ---*
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = lv_spono
no_dialog = 'X'
TABLES
pdf = lt_pdf_data
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 = 8
err_btcjob_submit_failed = 9
err_btcjob_close_failed = 10
OTHERS = 11.
IF sy-subrc NE 0.
*** Errorhandling
RAISE error_convert_spool_2_pdf.
ENDIF.
*** spezielle PDF Konvertierung vornehmen
LOOP AT lt_pdf_data INTO lt_pdf_convert .
TRANSLATE lt_pdf_convert USING ' ~'.
CONCATENATE lv_outputstring lt_pdf_convert INTO lv_outputstring IN CHARACTER MODE.
ENDLOOP.
TRANSLATE lv_outputstring USING '~ ' .
*** Datenstring in X-String umwandeln
* ref_conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
* ref_conv_out->write( EXPORTING data = lv_outputstring ).
* e_buffer = ref_conv_out->get_buffer( ).
data: app_type type char30.
APP_TYPE = 'APPLICATION/PDF; charset=utf-8'.
call function 'SCMS_STRING_TO_XSTRING'
exporting
text = lv_outputstring
MIMETYPE = APP_TYPE
IMPORTING
BUFFER = e_buffer.
concatenate cl_abap_char_utilities=>BYTE_ORDER_MARK_UTF8
e_buffer
into e_buffer in byte mode.
*l_pdf_len = xstrlen( l_pdf_xstring ).
* response->set_data( data = l_pdf_xstring
* length = l_pdf_len ).
Event OnInitialization:
* event handler for data retrieval
DATA: lv_buffer TYPE xstring,
lv_pdf_len TYPE i.
CLEAR: lv_buffer,
lv_pdf_len.
*** Zeitnachweis (RPTEDT00) in PDF umwandeln
CALL METHOD zcl_hr_appl_timestamp=>create_time_form
EXPORTING
i_pernr = a_gs_data_pernr-employeenumber
i_begda = a_gv_form_begda
i_endda = a_gv_form_endda
IMPORTING
e_buffer = lv_buffer
EXCEPTIONS
internal_error = 1
no_authority_for_pt_data = 2
OTHERS = 3.
IF sy-subrc NE 0.
**Errorhandling
page->messages->add_message(
condition = 'create_time_form'
*Fehler beim Erzeugen des Zeitnachweisformulars! Anzeige unmöglich!
otr_alias = 'ZZH_KXX_01_PT_COMMON_OBJEC/message_017'
severity = page->messages->co_severity_error ).
EXIT.
ENDIF.
*--- fill HTTP request ---*
*response->set_header_field( name = 'content-type'
* value = 'application/pdf' ).
response->set_header_field( name = 'content-type'
value = 'APPLICATION/PDF; charset=utf-8' ).
* some Browsers have caching problems when loading PDF format
response->set_header_field(
name = 'cache-control'
value = 'max-age=0' ).
* start PDF viewer either in the Browser or as a separate window
response->set_header_field(
name = 'content-disposition'
value = 'attachment; filename=timeform.pdf' ).
* finally display PDF format in Browser
lv_pdf_len = XSTRLEN( lv_buffer ).
response->set_data( data = lv_buffer
length = lv_pdf_len ).
navigation->response_complete( ).
Layout:
no layout (as you wrote afore)
I got a solution now!
This code works:
DATA: lt_pdf_convert TYPE tline,
lt_pdf_data TYPE TABLE OF tline,
lv_outputstring TYPE string ,
lv_spono TYPE tsp01-rqident ,
ls_params TYPE pri_params,
lv_valid_flag(1) TYPE c ,
lv_rq2name TYPE tsp01-rq2name ,
ls_tsp01 TYPE tsp01,
lv_len_pdf_bytes TYPE i.
DATA: ref_conv_out TYPE REF TO cl_abap_conv_out_ce.
FIELD-SYMBOLS <x> TYPE x.
*--- Druckparameter setzen ---*
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = 'locl'
immediately = ' '
release = ' '
new_list_id = 'X'
line_size = 80
line_count = 65
layout = 'X_65_80'
sap_cover_page = 'X'
receiver = 'SAP*'
department = ''
no_dialog = 'X'
IMPORTING
out_parameters = ls_params
valid = lv_valid_flag.
IF lv_valid_flag EQ space.
*** Errorhandling
RAISE error_print_parameters.
ENDIF.
*--- Zeitnachweisformular erzeugen und im Spool ablegen ---*
SUBMIT rptedt00
USING SELECTION-SET 'HRESS_TEDT00'
WITH pnppernr-low EQ i_pernr
WITH pnptimr6 EQ 'X'
WITH pnpbegda EQ i_begda
WITH pnpendda EQ i_endda
TO SAP-SPOOL
SPOOL PARAMETERS ls_params
WITHOUT SPOOL DYNPRO
AND RETURN.
*--- Spool lesen ---*
CONCATENATE 'SAPMHTTP'
sy-uname+0(3)
INTO lv_rq2name SEPARATED BY '_'.
SELECT * FROM tsp01 INTO ls_tsp01 WHERE rq2name = lv_rq2name AND
rqowner = sy-uname
ORDER BY rqcretime DESCENDING.
lv_spono = ls_tsp01-rqident.
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR lv_spono.
ENDIF.
*--- Spool in PDF Format konvertieren ---*
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = lv_spono
no_dialog = 'X'
IMPORTING
pdf_bytecount = lv_len_pdf_bytes
TABLES
pdf = lt_pdf_data
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 = 8
err_btcjob_submit_failed = 9
err_btcjob_close_failed = 10
OTHERS = 11.
IF sy-subrc NE 0.
*** Errorhandling
RAISE error_convert_spool_2_pdf.
ENDIF.
LOOP AT lt_pdf_data INTO lt_pdf_convert .
ASSIGN lt_pdf_convert TO <x> CASTING.
CONCATENATE e_buffer <x> INTO e_buffer IN BYTE MODE.
ENDLOOP.
e_buffer = e_buffer(lv_len_pdf_bytes).
Dear Raja,
As per your post, i tried to convert ALV Report in BSP but it is not working. Please confirm what should i pass in listobject.
data: listobject type standard table of abaplist,
html type standard table of w3html.
data: html_wa type w3html,
report_html type string.
submit zrej_stock
using selection-set 'ZVAR'
exporting list to memory and return.
* submit zrej_stock and return exporting list to memory.
call function 'LIST_FROM_MEMORY'
tables
listobject = listobject
exceptions
not_found = 1
others = 2.
call function 'WWW_HTML_FROM_LISTOBJECT'
exporting
report_name = 'ZREJ_STOCK'
tables
html = html
listobject = listobject.
clear: report_html , html_wa .
loop at html into html_wa.
concatenate report_html html_wa into report_html.
clear html_wa .
endloop.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.