COBOL utility program for validating Chilean RUT (Rol Único Tributario) numbers and calculating their verification digit.
This project demonstrates how to implement Chilean RUT validation logic in COBOL, commonly used in legacy enterprise environments such as IBM Mainframe and IBM iSeries systems.
The program allows two main operations:
- Validate a RUT number using its verification digit.
- Calculate the correct verification digit for a given RUT number.
The validation is based on the Modulo 11 algorithm, the standard method used in Chile to verify RUT numbers.
- RUT validation
- Verification digit calculation
- COBOL procedural implementation
- Suitable for legacy system integration
PGMCVALRUT.cbl # Main COBOL program
README.md # Project documentation
The program expects the following input variables:
| Variable | Length | Description |
|---|---|---|
| WS-OPCION | 1 | Operation type: 1 = Validate RUT, 2 = Calculate verification digit |
| WS-E-RUT | 10 | RUT number (must be left padded with zeros) |
| WS-E-DIG | 1 | Verification digit (only required for validation) |
Example:
WS-OPCION = 1
WS-E-RUT = 0017953789
WS-E-DIG = 5
| Variable | Description |
|---|---|
| WS-S-RETORNO | Execution result code |
| WS-S-VAR-ERROR | Error description |
| WS-S-DIG | Calculated verification digit |
Return codes:
| Code | Meaning |
|---|---|
| 0 | Successful execution |
| 1 | Missing input parameters |
| 2 | Invalid RUT |
The RUT verification digit is calculated using the Modulo 11 algorithm, which multiplies the digits of the RUT by a repeating sequence of factors and calculates a remainder to determine the check digit.
The resulting verification digit can be:
- A number between 0 and 9
- The letter K
WS-OPCION = 2
WS-E-RUT = 0017953789
WS-S-DIG = 5
WS-S-RETORNO = 0
The COBOL program can be compiled and executed in any compatible COBOL environment such as:
- IBM Mainframe
- IBM iSeries
- Micro Focus COBOL
- Online COBOL compilers
This utility can be integrated into:
- Legacy enterprise systems
- Data validation processes
- Financial systems requiring RUT validation
- Educational COBOL examples
Sergio Marín Boza
Software Architect | Backend & Enterprise Systems
GitHub
https://github.com/Gazu
Website
https://smb-tech.cl