Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

COBOL RUT Validator

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.

Overview

The program allows two main operations:

  1. Validate a RUT number using its verification digit.
  2. 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.

Features

  • RUT validation
  • Verification digit calculation
  • COBOL procedural implementation
  • Suitable for legacy system integration

Repository Structure

PGMCVALRUT.cbl # Main COBOL program
README.md # Project documentation

Input Parameters

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

Output Parameters

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

Algorithm

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

Example

Input

WS-OPCION = 2
WS-E-RUT = 0017953789

Output

WS-S-DIG = 5
WS-S-RETORNO = 0

Execution

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

Use Cases

This utility can be integrated into:

  • Legacy enterprise systems
  • Data validation processes
  • Financial systems requiring RUT validation
  • Educational COBOL examples

Author

Sergio Marín Boza
Software Architect | Backend & Enterprise Systems

GitHub
https://github.com/Gazu

Website
https://smb-tech.cl

About

COBOL utility for validating Chilean RUT numbers and calculating verification digits.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages