En SAP R/3. EJEMPLO IMPRESIÓN PDF desde llamada RFC a SAP utilizando una variable binaria SAP (XSTRING) Crear formulario Z_TEST2 con transacción SFP Entonces si tenemos function RFC function zhr1_certs_via_portal_action. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" VALUE(REQUESTOR_ID) TYPE UNAME *" VALUE(I_ACTION) TYPE CHAR10 *" VALUE(I_FORM) TYPE NUMC01 OPTIONAL *" EXPORTING *" VALUE(E_PDF) TYPE XSTRING *" EXCEPTIONS *" PERNR_NOT_FOUND *" RUT_NOT_FOUND *" CONTRACT_DATE_NOT_FOUND *" PAYMENT_NOT_FOUND *" SHIFT_NOT_FOUND *" ASSET_NOT_FOUND *"---------------------------------------------------------------------- * FUNCITON MODULE: # ZHR1_CERTS_VIA_PORTAL_ACTION * RELEASE # ECC 5.0 * DATE WRITTEN # 25.07.2008 * MODULE # HR * TYPE # Remote Function Module * AUTHOR # Wdjacn * TITLE # HR Certificates via Portal * PURPOSE # Provides required data for Web Dynpro front end * to HR Certificates * ASSOCIATED # Class: ZCL_HR_CERTS_EFORM * RESTRICTIONS # * DESCRIPTION # WD validates the user on the portal, and passes * the REQUESTOR_ID(UNAME) to retrieve data for. * AMENDMENTS # * VER DATE CHANGE # CHANGE DESCRIPTION User *====================================================================== * 1.0 25/07/08 GHDK9B0GJO New for WO992462. Wdjacn data: wo_form type ref to zcl_hr_certs_eform.
* Copy to Export Structure translate requestor_id to upper case. create object wo_form type zcl_hr_certs_eform. * Process the Action case i_action. when 'PDF'. endcase. endfunction. Donde call method wo_form->print_pdf i_get_pdf = X e_pdf = e_pdf pernr_not_found = 1 rut_not_found = 2 contract_date_not_found = 3 payment_not_found = 4 shift_not_found = 5 asset_not_found = 6. if sy-subrc ne 0. case sy-subrc. when 1. raise pernr_not_found. when 2. raise rut_not_found. when 3. raise contract_date_not_found. when 4. raise payment_not_found. when 5. raise shift_not_found. when 6. raise asset_not_found. endcase. exit. method print_pdf. data: fm_name type rs38l_fnam, fp_outputparams type sfpoutputparams, fp_docparams type sfpdocparams, fp_formoutput type fpformoutput, wc_fpname type fpname,
wstr_fields type z_csr_eform, wstr_texts type z_csr_longtext, wstr_data type z_csr_eform. fp_outputparams-getpdf = i_getpdf. fp_outputparams-device = 'PRINTER'. fp_outputparams-dest = 'LP01'. fp_outputparams-nodialog = 'X'. fp_outputparams-preview = 'X'. * Sets the output parameters and opens the spool job call function 'FP_JOB_OPEN' changing ie_outputparams = fp_outputparams cancel = 1 usage_error = 2 system_error = 3 internal_error = 4 others = 5. perform get_data changing wstr_data. *Sets formname here *wc_fpname = * Get the name of the generated function module call function 'FP_FUNCTION_MODULE_NAME' i_name = 'Z_TEST2' e_funcname = fm_name. * Call the generated function module call function fm_name /1bcdwb/docparams = fp_docparams otb_ben_detail = wstr_data /1bcdwb/formoutput = fp_formoutput usage_error = 1 system_error = 2 internal_error = 3. * Close the spool job call function 'FP_JOB_CLOSE' usage_error = 1 system_error = 2 internal_error = 3 others = 4. e_pdf = fp_formoutput-pdf. endmethod.
En NW Developer Studio. public void retrievereviewpdf( ) //@@begin retrievereviewpdf() // we only call this model if it hasn't been called before - otherwise we just relaunch the url form and if (wdcontext.currentcontextelement().getreviewpdfwebcacheurl()!= null) launchnewpdfwindow(); else // we now have two parameters - which are then used to get the status of the // the type of eform reviewpdfmodel.seti_dgs_application(getdgsapplicationcode()); reviewpdfmodel.seti_eform_id(geteformid()); //@@end try reviewpdfmodel.execute(); wdcontext.nodezhr1_certs_via_portal_action_output().invalidate(); catch (Exception e) logger.errort( Category.APPLICATIONS, e.tostring() + " : " + reviewpdfmodel.getclass().getname()); // report message fpm.getmessagemanager().reportmessage( wdcomponentapi, "LOGGED_ERROR", WDMessageType.ERROR, IMessageFcGbsHrDgsReuse.LOGGED_ERROR)); return; // now we have to open a new window with this data if (writepdftowebcache()) launchnewpdfwindow();
private void launchnewpdfwindow() reviewpdfwindow = wdcomponentapi.getwindowmanager().createnonmodalexternalwindow( wdcontext.currentcontextelement().getreviewpdfwebcacheurl(), IMessageFcGbsHrDgsReuse.REVIEW_DATA)); reviewpdfwindow.removewindowfeature(wdwindowfeature.address_bar); reviewpdfwindow.removewindowfeature(wdwindowfeature.menu_bar); reviewpdfwindow.removewindowfeature(wdwindowfeature.status_bar); reviewpdfwindow.removewindowfeature(wdwindowfeature.tool_bar); reviewpdfwindow.open(); private boolean writepdftowebcache() String filename = wdcomponentapi.gettextaccessor().gettext(imessagefcgbshrdgsreuse.review_data).concat(".pdf"); IWDCachedWebResource cachedpdfresource = null; byte[] reviewpdf; try reviewpdf = wdcontext.currentzhr1_certs_via_portal_action_outputelement().gete_pdf(); // create a cached Web Dynpro for the given byte array and filename if (reviewpdf!= null) cachedpdfresource = WDWebResource.getWebResource(reviewPDF, WDWebResourceType.PDF); cachedpdfresource.setresourcename(filename); // Store URL and file name of cached Excel resource in context. if (cachedpdfresource!= null) wdcontext.currentcontextelement().setreviewpdfwebcacheurl( cachedpdfresource.geturl()); return true; else return false; catch (Exception e) logger.errort( Category.APPLICATIONS, e.tostring() + " : " + reviewpdfmodel.getclass().getname() + " : " + IWDCachedWebResource.class.getName()); // report message fpm.getmessagemanager().reportmessage( wdcomponentapi, "LOGGED_ERROR", WDMessageType.ERROR, IMessageFcGbsHrDgsReuse.LOGGED_ERROR)); return false;. private IWDWindow reviewpdfwindow;