Skip to Content

With the 1808 release, there is a new web service available: ‘QueryDocumentOutputRequestIn’. Using this web service, it is now possible to retrieve the output forms from ByDesign in either PDF or XML format.

While understandably since this is a new web service, and the documentation is not yet available from SAP, there is already a bit of interest from some developers (me included), so here is some basic information, based on my recent experience.

Questions posted on the forum earlier:

https://answers.sap.com/questions/565274/retrieving-customer-invoice-pdf-files-from-bydesig.html

https://answers.sap.com/questions/433046/customer-invoice-output-over-edi-possible.html

 

Let us consider the following problem statement. You have a front end web shop and backend ByDesign. The sales order is first entered in the front-end web shop, and subsequently replicated to ByDesign. The requirement is to obtain ByDesign’s invoice PDF (or XML) document on the front end.

Assumptions:

  1. front end already knows ByDesign sales order number.
  2. one sales order only maps to one invoice
  3. only preceding document type for invoice is ‘sales order’

 

Step 1: Get the invoice UUID

use web service ‘QueryCustomerInvoiceIn’ to get the invoice UUID.

example request, consider sales order ID is ‘123’:

Customer Invoice Query Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glob="http://sap.com/xi/SAPGlobal20/Global">
    <soapenv:Header/>
    <soapenv:Body>
        <glob:CustomerInvoiceByElementsQuery_sync>
            <CustomerInvoiceSelectionByElements>
                <SelectionByBaseBTDReferenceID>
                    <InclusionExclusionCode>I</InclusionExclusionCode>
                    <IntervalBoundaryTypeCode>1</IntervalBoundaryTypeCode>
                    <LowerBoundaryName>123</LowerBoundaryName>
                </SelectionByBaseBTDReferenceID>
             </CustomerInvoiceSelectionByElements>
        </glob:CustomerInvoiceByElementsQuery_sync>
    </soapenv:Body>
</soapenv:Envelope>

 

example response:

Customer Invoice Query Response

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
    <soap-env:Header/>
    <soap-env:Body>
        <n0:CustomerInvoiceByElementsResponse_sync xmlns:n0="http://sap.com/xi/SAPGlobal20/Global">
            <CustomerInvoice>
                <ID>456</ID>
                <UUID>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</UUID>
                ...etc.
            </CustomerInvoice>
        </n0:CustomerInvoiceByElementsResponse_sync>
    </soapenv:Body>
</soapenv:Envelope>

here, you see that the customer invoice ID is ‘456’.

make a note of the ‘UUID’: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Important note: see ‘Assumptions’ above.

Step 2: get the Document UUID

Use web service ‘QueryDocumentOutputRequestIn’ to get the document UUID.

operation name: FindByElements

Continuing with the example, the customer invoice UUID is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

example request:

Document Output Request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glob="http://sap.com/xi/SAPGlobal20/Global">
    <soapenv:Header/>
    <soapenv:Body>
        <glob:DocumentOutputRequestByElementsQuery_sync>
            <DocumentOutputRequestSelectionByElements>
                <SelectionByHostObjectUUID>
                    <InclusionExclusionCode>I</InclusionExclusionCode>
                    <IntervalBoundaryTypeCode>1</IntervalBoundaryTypeCode>
                    <LowerBoundaryUUID>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</LowerBoundaryUUID>
                </SelectionByHostObjectUUID>
            </DocumentOutputRequestSelectionByElements>
            <ProcessingConditions>
                <QueryHitsUnlimitedIndicator>true</QueryHitsUnlimitedIndicator>
            </ProcessingConditions>
        </glob:DocumentOutputRequestByElementsQuery_sync>
    </soapenv:Body>
</soapenv:Envelope>

 

example response:

Document Output Response

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
    <soap-env:Header/>
    <soap-env:Body>
        <n0:DocumentOutputRequestByElementsResponse_sync xmlns:n0="http://sap.com/xi/SAPGlobal20/Global">
            <DocumentOutputRequestInformation>
                ...
                <DocumentUUID>yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy</DocumentUUID> 
                ...etc.
            </DocumentOutputRequestInformation>
        </n0:DocumentOutputRequestByElementsResponse_sync>
    </soap-env:Body>
</soap-env:Envelope>

note down the document uuid: yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy

 

Step 3: Get the document in PDF

once you have the Document UUID, you can use the web service ‘QueryDocumentOutputRequestIn’ and operation ‘ReadOutputPDF’ to get the PDF file.

continuing with the example, our document UUID is yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy

example request:

PDF request

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:glob="http://sap.com/xi/SAPGlobal20/Global">
    <soapenv:Header/>
    <soapenv:Body>
        <glob:DocumentOutputRequestPdf_sync>
            <DocumentOutputRequestPDFInformation>
                <ReadByDocumentUUID>yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy</ReadByDocumentUUID>
            </DocumentOutputRequestPDFInformation>
       </glob:DocumentOutputRequestPdf_sync>
    </soapenv:Body>
</soapenv:Envelope>

the response will contain the PDF file content.

 

Step 4: Get the document in XML

Similar as step 3, but use the web service operation ‘ReadOutputXML’.

 

Thanks to SAP for closing this crucial gap. With this new web service, it is now possible to retrieve the output documents over a web service call. In my experience, the invoice PDF is of very high importance, but I can imagine several use cases which require the retrieval of other output forms too.

 

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Otfried von Geisau

    Hi Rohan,

    I like your blog post promoting the new functionality we provide.

    When it comes to the documentation, I would like to point you to our new footprint in the SAP API Business Hub. This is only available as of two weeks ago.

    When you search for “output” you will find the web service documentation.

    Best regards
    Otfried

    (2) 
    1. Rohan Arthur Post author

      Dear Otfried,

      Thank you for your input. I wasn’t aware of the API hub, and it looks really nice!
      Currently, the link leads to a documentation page that has very basic data about this service (screenshot attached). Would it be a good idea to direct this link to the API hub page?

      Thanks and regards,
      Rohan

      (0) 
      1. Knut Heusermann

        Hi Rohan,

        the link in the ByD Service Explorer should show the same content as you can see in the API Business Hub. We plan to fix that as soon as possible.

        Thanks for pointing us to the issue and best regards,
        Knut

        (1) 

Leave a Reply