Fiori visualization apps fail to render PDF output documents after NAST output control integration in SAP PLM 2021

After integrating NAST output control with Fiori visualization apps in SAP PLM 2021, PDF documents fail to render in the browser. The Fiori app successfully retrieves the document metadata via OData, but when attempting to display the PDF content, we get a blank viewer window.

The OData service call returns data:

var oModel = this.getView().getModel();
oModel.read("/DocumentSet('DOC001')/PDFContent", {
  success: function(oData) {
    // oData contains base64 content
  }
});

Browser console shows: “Failed to load PDF document. Invalid content type.” We’ve verified NAST configuration for output type ‘ZPLM’ is active and generates PDFs correctly in standard SAP GUI transactions. This is blocking document review workflows for our engineering team. Has anyone successfully configured OData Content-Type headers for PDF streaming in Fiori?

Don’t forget the Fiori side configuration. Even if the OData service sends the correct Content-Type, your Fiori app’s manifest.json needs to declare that it handles PDF content. I’ve seen cases where the app receives the PDF correctly but the PDF.js library isn’t initialized properly. Check your Component.js initialization and make sure you’re loading the PDF viewer library with the right configuration for streaming content versus file downloads.

The issue is almost certainly with the Content-Type header in your OData service response. By default, OData services return application/json, but PDF content requires application/pdf. You need to modify the service implementation to set the correct MIME type when serving binary content. Check your DPC_EXT class implementation.

For standard SAP services, you typically need to redefine the stream handling method in your service extension. The base service doesn’t know it’s dealing with PDF content - it treats everything as generic binary. In your DPC_EXT class, override the GET_STREAM method for the PDFContent property and explicitly set the content type header there. Also verify that your NAST output is actually generating valid PDF format and not some SAP-specific format that needs conversion.

You also need to handle the NAST output control integration properly. The standard NAST processing stores output in various formats depending on configuration. Make sure your output type ZPLM has the correct device type (PDF1) and that the spool request is being converted to PDF format before the OData service tries to retrieve it. Transaction SPAD should show the device type configuration, and you may need to ensure PDF conversion is happening synchronously rather than in background processing.

Here’s the complete solution covering all three integration points:

1. NAST Output Control Integration:

First, ensure your NAST configuration generates true PDF format:

  • Transaction: NACE
  • Application: PLM (or your custom app)
  • Output Type: ZPLM
  • Processing Routine: Must use function module that generates PDF
  • Device Type: PDF1 (critical - not LP01 or other formats)

Verify the output program:

" In your NAST processing program
CALL FUNCTION 'CONVERT_OTF_TO_PDF'
  EXPORTING
    format = 'PDF'
  IMPORTING
    bin_filesize = lv_pdf_size
  TABLES
    otf = lt_otf_data
    lines = lt_pdf_data.

2. OData Content-Type Configuration:

Create or extend the OData service’s DPC_EXT class. Override the GET_STREAM method:

METHOD /plmb/if_od_document_dpc~get_stream.
  DATA: lv_document_id TYPE string,
        lv_pdf_content TYPE xstring,
        lv_mime_type TYPE string VALUE 'application/pdf',
        ls_stream TYPE ty_s_media_resource.

  " Get document ID from key
  lv_document_id = it_key_tab[ name = 'DocumentId' ]-value.

  " Retrieve PDF from NAST spool
  CALL FUNCTION 'Z_GET_NAST_PDF_CONTENT'
    EXPORTING
      iv_document_id = lv_document_id
    IMPORTING
      ev_pdf_xstring = lv_pdf_content.

  " Set response headers for PDF streaming
  ls_stream-mime_type = lv_mime_type.
  ls_stream-value = lv_pdf_content.

  " Critical: Set Content-Type header explicitly
  set_header(
    EXPORTING
      iv_name = 'Content-Type'
      iv_value = lv_mime_type ).

  set_header(
    EXPORTING
      iv_name = 'Content-Disposition'
      iv_value = |inline; filename="{lv_document_id}.pdf"| ).

  copy_data_to_ref(
    EXPORTING
      is_data = ls_stream
    CHANGING
      cr_data = er_stream ).
ENDMETHOD.

3. Fiori PDF Rendering Configuration:

Update your Fiori app’s manifest.json:

{
  "sap.app": {
    "dataSources": {
      "mainService": {
        "uri": "/sap/opu/odata/PLMB/OD_DOCUMENT_SRV/",
        "type": "OData",
        "settings": {
          "odataVersion": "2.0",
          "localUri": "localService/metadata.xml"
        }
      }
    }
  },
  "sap.ui5": {
    "resourceRoots": {
      "pdfjs": "./lib/pdfjs"
    }
  }
}

In your controller, handle PDF rendering with proper content type:

onDisplayPDF: function(sDocumentId) {
    var oModel = this.getView().getModel();
    var sPath = "/DocumentSet('" + sDocumentId + "')/PDFContent";

    // Read with proper headers
    oModel.read(sPath, {
        headers: {
            "Accept": "application/pdf"
        },
        success: function(oData, response) {
            var sContentType = response.headers["content-type"];

            if (sContentType === "application/pdf") {
                // Create blob URL for PDF viewer
                var byteCharacters = atob(oData.value);
                var byteNumbers = new Array(byteCharacters.length);
                for (var i = 0; i < byteCharacters.length; i++) {
                    byteNumbers[i] = byteCharacters.charCodeAt(i);
                }
                var byteArray = new Uint8Array(byteNumbers);
                var blob = new Blob([byteArray], {type: "application/pdf"});
                var url = URL.createObjectURL(blob);

                // Display in PDF viewer
                this.getView().byId("pdfViewer").setSource(url);
            }
        }.bind(this)
    });
}

Testing Checklist:

  1. Test NAST output directly (transaction NAST) - should generate valid PDF
  2. Test OData service in Gateway Client (/IWFND/GW_CLIENT) - verify Content-Type header
  3. Test in browser network tab - response should show application/pdf
  4. Clear browser cache before testing Fiori app

The root cause is that PDF content requires explicit Content-Type handling at all three integration points. Missing any one will cause rendering failures.