1.9 KiB
1.9 KiB
1. Goal
Check the format and the checksum of an IBAN. A payment program calls the check before it sends a payment. The program needs one reason code for each IBAN.
2. Open questions
None.
3. Context
- Interface {{P}}IF_IBAN_CHECK exists in package $TMP. It is active.
- The interface has the type TY_REASON (CHAR 10), the constant structure C_REASON (OK, EMPTY, CHARS, COUNTRY, LENGTH, CHECKSUM), and one method: CHECK IMPORTING iv_iban TYPE string RETURNING VALUE(rv_reason) TYPE ty_reason.
4. Contract
- Create the class {{P}}IBAN_VALIDATOR in package $TMP.
- The class is public, final, and has a public constructor without parameters.
- The class implements {{P}}IF_IBAN_CHECK.
- Do not add other public methods.
5. Business rules
Apply the rules in this sequence. Return the reason of the first rule that fails.
- Remove all spaces. Convert all letters to upper case.
- If the result is empty, return EMPTY.
- The result must contain only the letters A to Z and the digits 0 to 9. Positions 1 and 2 must be letters. Positions 3 and 4 must be digits. If not, return CHARS.
- Positions 1 and 2 are the country code. Use this list of codes and lengths: DE 22, GB 22, TR 26, FR 27, NL 18, AT 20, CH 21. If the code is not in the list, return COUNTRY.
- If the length is not the length of the country, return LENGTH.
- Calculate the checksum: move the first 4 characters to the end. Replace each letter with a number (A = 10, B = 11, ..., Z = 35). Calculate the remainder of this number divided by 97. If the remainder is not 1, return CHECKSUM.
- Else return OK.
6. Constraints
- Release target: 7.58.
- Coding standards: Clean ABAP. Method length below 40 statements. No global variables. No comment that restates the code.
- Out of scope: do not change {{P}}IF_IBAN_CHECK.
7. Acceptance
- The class is active and has no syntax error.
- The hidden tests pass.
- Write your own ABAP Unit tests for the class.