Hello,

Sign up to join our community!

Welcome Back,

Please sign in to your account!

Forgot Password,

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask a question.

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

SAP EWM Help Latest Questions

  • 0
  • 0
DPM125
Beginner

Generating SAP Smart Form PDFs and Serving Them to Fiori/UI5 via OData

Scenario:

  • Business wants to generate an invoice Smart Form (based on VBAK/VBAP) and send the PDF to an SAPUI5/Fiori frontend via OData.

  • The frontend should receive the Smart Form PDF as binary content to display or download.

High level flow

Frontend (Fiori/UI5) → OData Service → ABAP Backend → Call Smart Form → Convert to PDF → Return Binary to Frontend

Step 1: Create Smart Form

  • Transaction SMARTFORMS → Create form (e.g., Z_INVOICE_SF)

  • Define nodes for header (VBAK) and items (VBAP)

  • Activate form

Step 2: Create ABAP Class / Function Module

  • This module will call the Smart Form and capture output as PDF

DATA: lv_formname TYPE tdsfname VALUE ‘Z_INVOICE_SF’,
lv_fm_name TYPE rs38l_fnam,
lv_pdf TYPE solix_tab,
lv_pdf_size TYPE so_obj_len.

” Get generated function module for Smart Form
CALL FUNCTION ‘SSF_FUNCTION_MODULE_NAME’
EXPORTING
formname = lv_formname
IMPORTING
fm_name = lv_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.

IF sy-subrc = 0.
” Call Smart Form
CALL FUNCTION lv_fm_name
EXPORTING
control_parameters = VALUE ssfctrlop( device = ‘PRINTER’ )
user_settings = space
vbak = ls_vbak
TABLES
vbap = lt_vbap
pdfoutput = lv_pdf
EXCEPTIONS
OTHERS = 1.
ENDIF.

 

Step 3: Return PDF via OData

  • Create an OData Service (Transaction SEGW)

  • Define an Entity Type (e.g., InvoicePDF) with a Binary Stream property

  • In DPC_EXT class, map the Smart Form PDF to the property:

METHOD invoicepdf_get_entity.
” Call Smart Form as shown above
io_data_provider->read_entry_data( )->* ” fetch data from backend tables

es_entity-pdf_data = lv_pdf. ” SOLIX table converted to xstring
ENDMETHOD.

  • The frontend will receive PDF as binary (xstring)

  • Fiori/UI5 can display with PDF.js or offer download

 

Related Questions

Leave an answer

Leave an answer