{"id":7839,"date":"2025-09-13T01:43:22","date_gmt":"2025-09-12T20:13:22","guid":{"rendered":"https:\/\/www.sapewmhelp.com\/?question=generating-sap-smart-form-pdfs-and-serving-them-to-fiori-ui5-via-odata"},"modified":"2025-09-13T01:43:22","modified_gmt":"2025-09-12T20:13:22","slug":"generating-sap-smart-form-pdfs-and-serving-them-to-fiori-ui5-via-odata","status":"publish","type":"question","link":"https:\/\/www.sapewmhelp.com\/?question=generating-sap-smart-form-pdfs-and-serving-them-to-fiori-ui5-via-odata","title":{"rendered":"Generating SAP Smart Form PDFs and Serving Them to Fiori\/UI5 via OData"},"content":{"rendered":"<h3 data-start=\"186\" data-end=\"205\"><strong>Scenario:<\/strong><\/h3>\n<ul>\n<li>\n<p>Business wants to <strong>generate an invoice Smart Form<\/strong> (based on VBAK\/VBAP) and <strong>send the PDF to an SAPUI5\/Fiori frontend<\/strong> via OData.<\/p>\n<\/li>\n<li>\n<p>The frontend should receive the <strong>Smart Form PDF as binary content<\/strong> to display or download.<\/p>\n<\/li>\n<\/ul>\n<p><strong>High level flow<\/strong><\/p>\n<p>Frontend (Fiori\/UI5) \u2192 OData Service \u2192 ABAP Backend \u2192 Call Smart Form \u2192 Convert to PDF \u2192 Return Binary to Frontend<\/p>\n<p><strong>Step 1: Create Smart Form<\/strong><\/p>\n<ul>\n<li>\n<p>Transaction <strong>SMARTFORMS<\/strong> \u2192 Create form (e.g., <code>Z_INVOICE_SF<\/code>)<\/p>\n<\/li>\n<li>\n<p>Define nodes for <strong>header (VBAK)<\/strong> and <strong>items (VBAP)<\/strong><\/p>\n<\/li>\n<li>\n<p>Activate form<\/p>\n<\/li>\n<\/ul>\n<p><strong>Step 2: Create ABAP Class \/ Function Module<\/strong><\/p>\n<ul>\n<li>\n<p>This module will <strong>call the Smart Form and capture output as PDF<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>DATA: lv_formname TYPE tdsfname VALUE &#8216;Z_INVOICE_SF&#8217;,<br \/>\nlv_fm_name TYPE rs38l_fnam,<br \/>\nlv_pdf TYPE solix_tab,<br \/>\nlv_pdf_size TYPE so_obj_len.<\/p>\n<p>&#8221; Get generated function module for Smart Form<br \/>\nCALL FUNCTION &#8216;SSF_FUNCTION_MODULE_NAME&#8217;<br \/>\nEXPORTING<br \/>\nformname = lv_formname<br \/>\nIMPORTING<br \/>\nfm_name = lv_fm_name<br \/>\nEXCEPTIONS<br \/>\nno_form = 1<br \/>\nno_function_module = 2<br \/>\nOTHERS = 3.<\/p>\n<p>IF sy-subrc = 0.<br \/>\n&#8221; Call Smart Form<br \/>\nCALL FUNCTION lv_fm_name<br \/>\nEXPORTING<br \/>\ncontrol_parameters = VALUE ssfctrlop( device = &#8216;PRINTER&#8217; )<br \/>\nuser_settings = space<br \/>\nvbak = ls_vbak<br \/>\nTABLES<br \/>\nvbap = lt_vbap<br \/>\npdfoutput = lv_pdf<br \/>\nEXCEPTIONS<br \/>\nOTHERS = 1.<br \/>\nENDIF.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step 3: Return PDF via OData<\/strong><\/p>\n<ul>\n<li>\n<p>Create an <strong>OData Service<\/strong> (Transaction SEGW)<\/p>\n<\/li>\n<li>\n<p>Define an <strong>Entity Type<\/strong> (e.g., InvoicePDF) with a <strong>Binary Stream property<\/strong><\/p>\n<\/li>\n<li>\n<p>In <strong>DPC_EXT class<\/strong>, map the Smart Form PDF to the property:<\/p>\n<\/li>\n<\/ul>\n<p>METHOD invoicepdf_get_entity.<br \/>\n&#8221; Call Smart Form as shown above<br \/>\nio_data_provider-&gt;read_entry_data( )-&gt;* &#8221; fetch data from backend tables<\/p>\n<p>es_entity-pdf_data = lv_pdf. &#8221; SOLIX table converted to xstring<br \/>\nENDMETHOD.<\/p>\n<ul>\n<li>\n<p>The frontend will receive <strong>PDF as binary<\/strong> (<code>xstring<\/code>)<\/p>\n<\/li>\n<li>\n<p>Fiori\/UI5 can display with <strong>PDF.js<\/strong> or offer download<\/p>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","question-category":[172],"question_tags":[178,221,177,420],"class_list":["post-7839","question","type-question","status-publish","hentry","question-category-odata","question_tags-abap","question_tags-odata","question_tags-sap","question_tags-smartforms"],"_links":{"self":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/question\/7839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/question"}],"about":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7839"}],"wp:attachment":[{"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7839"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion-category&post=7839"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/www.sapewmhelp.com\/index.php?rest_route=%2Fwp%2Fv2%2Fquestion_tags&post=7839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}