Skip to Content

Running Mapping programs for empty payload – size of payload is 0 bytes.

Scenario: A requirement may be to process an empty file (empty payload) having no data, to run a mapping program.

In my case it is a file to JDBC scenario, where I had to insert records when file had data. If the file was empty then I had to delete all the records in the table.

We are using PO 7.5. But this solution could be used on lower versions and dual stack as well.

Why do we need this tweak?

By Default the mapping is terminated when there is no payload/ input size is 0 bytes.

Input file is empty/ 0 bytes:

Error when executing the map:

Error during Run-time:




  • Java map to alleviate the issue of empty payload. Java map provides the XML input to the graphical mapping.
  • Standard context object – SourceFileSize in Interface determination condition, to separate empty file and non-empty file.
  • ESR Mapping Objects – 2 Operation Mappings, 1 Message Mapping.

Java map for our case was a simple if condition in the transform method. When the input is empty then a default XML structure is written to output. During normal transmission (file with Data) input is passed on as output. (We can write the entire transformation logic in the Java Map – but we delegated business logic to Graphical Mapping for ease of maintenance.)

Include this line with choice of XML structure in the transform method of the mapping class – This will default assigned XML Structure when an empty payload is passed.


StringBuffer xmlStr = new StringBuffer( “<?xml version=\”1.0\” encoding=\”UTF-8\”?><ns0:Message_Type xmlns:ns0=\”XYZ\”> <Record> <Field1 /><Field2 /> </Record></ns0:Message_Type>”);


String inputContent = new String(b);


if (inputContent.trim().length() == 0) // This condition checks if the input is empty




else // When actual input is present the input is transferred as output.





Operation-Mapping for case – Empty file (size 0 bytes). (Java map before Graphical Map)

Operation- Mapping for case – File with Data

Integration Directory Configuration:


Result: Processing Empty File to run a delete operation on the database table.



SAP Note:  1883809

1 Comment
You must be Logged on to comment or reply to a post.
  • Hi all,

    a similar approach can also help on REST receiver sync scenarios where the REST service provides a binary file (it would download to the client if endpoint would be opened with a browser).

    Adam Kiwon provided the answer here: The nice part of the answer is that no separate java mapping is needed. You just overwrite the “transform” method and create your XML payload on the fly.

    It would be nice, though, if SAP would provide and “empty file” handling much the like of the FTP / File adapter where an empty file does not result in a “Premature end of file” error 🙂