Now Customers are focusing on application which are more user friendly, responsive instead of old GUI applications/screens.
METHOD /iwbep/if_mgw_appl_srv_runtime~get_stream.
CONSTANTS: lc_entity_name TYPE c LENGTH 10 VALUE 'BILLINGDOC'.
DATA: lt_odatakeys TYPE /iwbep/t_mgw_tech_pairs,
ls_key TYPE /iwbep/s_mgw_tech_pair,
lv_billdoc TYPE vbeln,
ls_stream TYPE ty_s_media_resource.
DATA: lt_master_keys TYPE cl_somu_form_services=>ty_gt_key.
DATA: lv_content TYPE xstring.
DATA: lo_cl_somu_form_services TYPE REF TO cl_somu_form_services,
lt_keys TYPE cl_somu_form_services=>ty_gt_key.
TRY.
* Step 1-- "-------------- Fetch the billing document selected by user from frontend-----------------------------
lt_odatakeys = io_tech_request_context->get_keys( ).
lv_billdoc = VALUE #( lt_odatakeys[ name = lc_entity_name ]-value OPTIONAL ).
* Step 2 -- " ---------------------------Key Value for the Billing document content form service ---------------------------
lt_keys = VALUE #( ( name = 'BillingDocument' value = lv_billdoc )
( name = 'SenderCountry' value = 'DE' )
( name = 'Language'(040) value = 'E' ) ) .
* " --------------------------- Key Value for the master form template service ---------------------------
lt_master_keys = VALUE #( ( name = 'PrintFormDerivationRule' value = 'ZINVOICE_FORM' )
( name = 'WatermarkText' value = space )
( name = 'LocaleCountry' value = 'DE')
( name = 'LocaleLanguage' value = 'E' )
( name = 'OutputControlApplicationObjectType' value = 'BILLING_DOCUMENT' )
( name = 'OutputControlApplicationObject' value = lv_billdoc )
( name = 'OutputRequestItem' value = '000001' )
( name = 'OutputDocumentType' value = 'BILLING_DOCUMENT' )
( name = 'Recipient'(041) value = '00000001003' )
( name = 'RecipientRole' value = 'RE' )
( name = 'SenderCountry' value = 'DE' )
( name = 'ReceiverPartnerNumber' value = '00000001003' ) ).
* Step3 --" --------------------------- Call GET_DOCUMENT API ---------------------------
lo_cl_somu_form_services = cl_somu_form_services=>get_instance( ).
TRY.
lo_cl_somu_form_services->get_document( EXPORTING iv_master_form_name = 'ZZ1_OTC_INVOICE_MASTER_A4'
iv_form_name = 'ZZ1_OTC_INVOICE_OUTPUT'
it_key = lt_keys
it_master_key = lt_master_keys
iv_form_language = 'E'
iv_form_country = 'DE'
IMPORTING ev_content = lv_content
).
" --------------------------- Set the Header ---------------------------*
DATA(lv_name) = |inline; filename={ 'Billing Document ' && lv_billdoc && '.pdf' };| .
DATA(ls_header) = VALUE ihttpnvp( name = 'Content-Disposition'
value = lv_name
).
set_header( is_header = ls_header ).
" --------------------------- Set the stream data ---------------------------*
ls_stream-value = lv_content.
ls_stream-mime_type = 'application/pdf'.
CATCH cx_somu_error INTO DATA(lr_root).
MESSAGE lr_root->get_text( ) TYPE 'E'.
ENDTRY.
"Step 4----------------------------- Send the stream data to frontend ---------------------------*
copy_data_to_ref( EXPORTING
is_data = ls_stream
CHANGING
cr_data = er_stream ).
CATCH /iwbep/cx_mgw_busi_exception .
CATCH /iwbep/cx_mgw_tech_exception .
ENDTRY.
ENDMETHOD.
"extends": {
"extensions": {
"sap.ui.controllerExtensions": {
"sap.suite.ui.generic.template.ListReport.view.ListReport": {
"controllerName": "xx.sellbuybackreport.ext.controller.ListReportExt",
"sap.ui.generic.app": {
"ZC_OTC_SELLBUYBACK_DETAILS": {
"EntitySet": "ZC_OTC_SELLBUYBACK_DETAILS",
"Actions": {
"onPrint": {
"id": "printID",
"text": "Print Preview",
"press": "onPrintPreview",
"requiresSelection": true
}
}
}
}
}
}
}
}
onPrintPreview: function(oEvent) {
var opdfViewer = new PDFViewer();
this.getView().addDependent(opdfViewer);
//get selected line index
var selectedIndex = this.getView().byId('xx.sellbuybackreport::sap.suite.ui.generic.template.ListReport.view.ListReport::ZC_OTC_SELLBUYBACK_DETAILS--GridTable')
.getAggregation("plugins")[0].getSelectedIndex() ;
// get billing document from selected index
var vSelectedBillDoc = this.getView().byId('xx.sellbuybackreport::sap.suite.ui.generic.template.ListReport.view.ListReport::ZC_OTC_SELLBUYBACK_DETAILS--GridTable').
getContextByIndex(selectedIndex).getProperty('CorrectBillingDocZG2');
if (vSelectedBillDoc !== '') {
// create the path for OData Get_stream call
const path = this.getView().getModel("oERPSOModel").createKey("/GetPDFDisplaySet", {
// Key(s) and value(s) of that entity set
"BillingDoc": vSelectedBillDoc,
});
var sServiceURL = this.getView().getModel("oERPSOModel").sServiceUrl;
// Create the final URL
var sSource = sServiceURL + path + "/$value";
opdfViewer.setSource(sSource);
opdfViewer.setTitle("Billing Document ");
// Opne the PDF Viewer
opdfViewer.open();
} else {
// If billing doc is not present for selected line
sap.m.MessageBox.error("Billing Document doesn't exists");
}
}
};
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
12 | |
12 | |
11 | |
8 | |
7 | |
7 | |
5 | |
5 | |
4 | |
4 |