CLASS lcl_zexport_button DEFINITION DEFERRED.
CLASS cl_btsrv_advsrl_cntrl DEFINITION LOCAL FRIENDS lcl_zexport_button.
CLASS lcl_zexport_button DEFINITION.
PUBLIC SECTION.
CLASS-DATA obj TYPE REF TO lcl_zexport_button. "#EC NEEDED
DATA core_object TYPE REF TO cl_btsrv_advsrl_cntrl . "#EC NEEDED
INTERFACES IPO_ZEXPORT_BUTTON.
METHODS:
constructor IMPORTING core_object
TYPE REF TO cl_btsrv_advsrl_cntrl OPTIONAL.
ENDCLASS.
CLASS lcl_zexport_button IMPLEMENTATION.
METHOD constructor.
me->core_object = core_object.
ENDMETHOD.
METHOD ipo_zexport_button~prepare_toolbar.
*"------------------------------------------------------------------------*
*" Declaration of POST-method, do not insert any comments here please!
*"
*"methods PREPARE_TOOLBAR .
*"------------------------------------------------------------------------*
DATA: ls_button TYPE crmt_thtmlb_button.
ls_button-type = cl_thtmlb_util=>gc_icon_accept.
ls_button-on_click = 'EXPORT'.
ls_button-text = 'Export to PDF'.
ls_button-enabled = abap_true.
APPEND ls_button TO ME->CORE_OBJECT->gt_button.
ENDMETHOD.
ENDCLASS.
method EH_ONEXPORT.
cl_crm_order_2_pdf=>open_pdf( io_col_wrapper = me->typed_context->btqrsrvord->collection_wrapper
io_window_manager = me->comp_controller->window_manager ).
endmethod.
Source code of method open_pdf:
METHOD open_pdf.
DATA: lv_query TYPE string.
CHECK io_col_wrapper->size( ) > 0.
DATA(iterator) = io_col_wrapper->get_iterator( ).
DATA(bol) = iterator->get_current( ).
WHILE bol IS NOT INITIAL.
lv_query = lv_query && ',' && bol->get_property_as_string( 'GUID' ).
bol = iterator->get_next( ).
ENDWHILE.
lv_query = 'uuid=' && lv_query.
DATA(lv_url) = cl_crm_web_utility=>create_url( iv_path = '/sap/crm/order_print'
iv_query = lv_query
iv_in_same_session = 'X' ).
DATA(lv_title) = 'Service Order PDF List'.
DATA(lr_popup) = io_window_manager->create_popup( iv_interface_view_name = 'GSURLPOPUP/MainWindow'
iv_usage_name = 'CUGURLPopup'
iv_title = CONV #( lv_title ) ).
DATA(lr_cn) = lr_popup->get_context_node( 'PARAMS' ).
DATA(lr_obj) = lr_cn->collection_wrapper->get_current( ).
DATA(ls_params) = VALUE crmt_gsurlpopup_params( url = lv_url height = '1000' ).
lr_obj->set_properties( ls_params ).
lr_popup->set_display_mode( if_bsp_wd_popup=>c_display_mode_plain ).
lr_popup->set_window_width( 1000 ).
lr_popup->set_window_height( 1000 ).
lr_popup->open( ).
ENDMETHOD.
method IF_HTTP_EXTENSION~HANDLE_REQUEST.
CONSTANTS c_linelen TYPE i VALUE 255.
DATA: wa_data(c_linelen) TYPE x,
lt_data LIKE TABLE OF wa_data.
DATA: lv_pdf_length TYPE i,
lv_pdf_xstring TYPE xstring,
ls_guid_str TYPE string.
DATA(lv_uuid) = server->request->get_form_field( 'uuid' ).
CALL METHOD me->get_output_data
EXPORTING
iv_uuid = lv_uuid
IMPORTING
fpcontent = lv_pdf_xstring.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_pdf_xstring
IMPORTING
output_length = lv_pdf_length
TABLES
binary_tab = lt_data.
DATA(lv_contenttype) = 'application/pdf'.
ls_guid_str = lv_uuid.
CONCATENATE ls_guid_str '.pdf' INTO DATA(lv_filename).
server->response->append_data(
data = lv_pdf_xstring
length = lv_pdf_length ).
CONCATENATE 'inline; filename=' lv_filename
INTO DATA(lv_contentdisposition).
CALL METHOD server->response->set_header_field
EXPORTING
name = 'content-disposition'
value = lv_contentdisposition.
CALL METHOD server->response->set_header_field
EXPORTING
name = 'content-type'
value = CONV #( lv_contenttype ).
CALL METHOD server->response->set_header_field
EXPORTING
name = 'content-filename'
value = lv_filename.
server->response->delete_header_field(
name = 'Cache-Control' ).
server->response->delete_header_field(
name = 'Expires' ).
endmethod.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |