SAPUI5 Custom Data Type: IBAN

SAP’s web technology SAPUI5 allows the definition of custom data types. They can be used to format and validate input fields. This example defines an IBAN data type which validates an IBAN checksum using JavaScript code. The second section of this post explains how an IBAN checksum is computed.

IBAN Data Type

Below is a demo that you can try in your browser: An IBAN input field takes any arbitrary text from the user and validates it. Unless the input is a valid German IBAN, an error will be shown. You can play with it by hitting the Result tab in the JSFiddle below and entering valid and invalid IBANs. At there is an extended introduction to Custom Data Types in SAPUI5.

Computing an IBAN Checksum

An IBAN consist of three parts: country code (two characters), checksum (two digits), and the remaining digits. In order to compute the checksum, conduct the following steps:

  1. Convert both country characters into digits. An “A” corresponds to 10, “B” to 11 and so forth. This gives two numbers $c_1$ and $c_2$. The IBAN body, i.e. the long number starting at the fifth place, is called $b$.
  2. Create a temporary number $t$ by computing
    Note that $t$ can not be represented with the JavaScript data type Number, because it has 24 digits. A workaround using strings instead, does the job in the snippet above.
  3. Retrieve the checksum $s$ with

Published by

Timo Denk

Software developer at SAP and Denk Development, student of Applied Computer Science at Baden-Württemberg Cooperative State University. Interested in programming, math, microcontrollers, and sports.

One thought on “SAPUI5 Custom Data Type: IBAN”

Leave a Reply

Your email address will not be published. Required fields are marked *