Skip to main content
CodeSpeedTest
Languages
Start TypingJump into a test — pick any languageAdaptive TrainingUnlock chars as you master themPractice DrillsFocused sessions targeting weak spotsDaily ChallengesNew coding challenges every dayRace ModeCompete against others in real timeAI OpponentRace against an AI at your WPM levelTournamentsLive coding speed tournamentsArcade GamesZType, Overkill Survival, Glyphica & moreGamificationXP, coins, badges & quests
LeaderboardGlobal rankings for every languageCertificatesEarn verifiable Bronze / Silver / Gold certsActivityDaily streaks & historical analyticsProfileYour stats, badges & achievements
Browse Languages500+ languages with real code examplesBlogTips, guides & deep divesFree ToolsWPM calculator, typing speed report & moreFAQCommon questions answeredGetting StartedNew to CodeSpeedTest?AboutOur story & missionSupportGet help — Pro users get priorityContactGet in touch with the team
Pricing
  1. Home
  2. /
  3. Learn
  4. /
  5. Natural-scripting

Learn Natural-scripting - 10 Code Examples & CST Typing Practice Test

Natural Scripting refers to the use of the Natural programming language (from Software AG) to create applications, automate business logic, and interact with databases, especially within mainframe and enterprise environments.

View all 10 Natural-scripting code examples →
Simple Natural ProgramNatural Loop ExampleNatural Database Read ExampleNatural Conditional ExampleNatural Input and Display ExampleNatural Arithmetic ExampleNatural Loop with DatabaseNatural Subroutine ExampleNatural String ManipulationNatural Exit Condition in Loop

Learn NATURAL-SCRIPTING with Real Code Examples

Updated Nov 27, 2025

Explain

Natural is a 4GL (Fourth Generation Language) designed for rapid application development.

It provides procedural constructs and some modularization capabilities.

Widely used for database-driven business applications on mainframes and server environments.

Supports event-driven and batch processing tasks.

Ideal for enterprises needing maintainable, database-integrated solutions.

Core Features

Strong support for database access and record handling

Procedural programming constructs (IF, PERFORM, LOOP)

Error handling and transaction management

Callable subprograms for reusable logic

Integration with batch and online environments

Basic Concepts Overview

Natural Objects: variables, arrays, and structures

Subprograms and functions for modularity

Database access via direct read/write or view definitions

Control flow: IF, PERFORM, LOOP, GOTO

Error handling via ON ERROR or transaction rollback

Project Structure

Source Natural programs (.NAT or .PRG files)

Subprograms and modules for reusable logic

Database definitions and views

Job control or scheduling scripts for batch processing

Documentation of logic and data flow

Building Workflow

Identify business process to automate

Design database schema or map to existing structure

Develop Natural programs using modular subprograms

Test in batch or online environment

Deploy to production with appropriate scheduling or triggers

Difficulty Use Cases

Beginner: simple data entry or report generation

Intermediate: conditional logic and simple batch processing

Advanced: database transactions and multi-step processes

Expert: complex business logic and integration with legacy systems

Architect: enterprise-scale application design and modernization

Comparisons

Natural vs COBOL: Natural is higher-level and faster to develop

Natural vs Java: Natural is database-centric, Java is general-purpose

Natural vs RPG: Natural is procedural 4GL, RPG often tied to IBM i systems

Batch vs Online Natural programs: batch for reports, online for real-time interaction

Natural vs modern scripting: Natural excels in legacy enterprise environments

Versioning Timeline

1970s - Natural developed by Software AG

1980s - Enhanced database integration and procedural features

1990s - Client-server support and Natural Studio IDE

2000s - Modernization for web and server environments

2010s - Integration with middleware and APIs

2020s - Ongoing maintenance and modernization in enterprise environments

Glossary

Adabas - high-performance database often used with Natural

Subprogram - reusable module of logic

Program library - storage location for Natural programs

Batch job - scheduled process for processing data

Natural IDE - development environment for writing Natural code

Installation Setup

Install Natural development environment on mainframe or server

Set up runtime libraries and system modules

Configure Adabas or other supported databases

Ensure proper access rights for developers

Test sample Natural programs to validate environment

Environment Setup

Install Natural development environment and libraries

Configure Adabas or other target databases

Set access rights for development and execution

Test sample programs to verify setup

Prepare batch job and scheduling scripts if needed

Config Files

Program library definitions

Database view definitions

Job scheduling scripts for batch runs

Natural configuration files for runtime environment

Security and access control settings

Cli Commands

Natural -> run programs interactively

NATTEST -> test Natural programs

NATBATCH -> execute batch jobs

NATADMIN -> manage environment and libraries

Debug -> step through programs and monitor variables

Internationalization

Supports multiple character encodings (EBCDIC, ASCII, Unicode)

Date, number, and currency formats can be localized

Reports can be translated for different locales

Online applications may adapt UI language dynamically

Integration supports region-specific data formats

Accessibility

Mainly terminal-based; compatible with accessibility tools

Reports can be exported for external consumption

Online Natural applications can follow standard UI accessibility practices

Batch jobs maintain consistent outputs for audit purposes

Data access governed by user roles

Ui Styling

Typically console or terminal output

Modern Natural Studio supports GUI development

Reports formatted for readability

Online applications may leverage screens and forms

Styling minimal; focus on data presentation

State Management

Program variables manage runtime state

Database records reflect persistent state

Subprograms isolate logic and local state

Transaction management ensures data integrity

Error handling controls rollback or retries

Data Management

Record-based database access for transactional data

Derived data handled in working variables

Batch processing allows sequential data updates

Online programs provide real-time access

Integration with external systems synchronizes state

Architecture

Modular program structure using subprograms and macros

Batch or online execution models

Database-centric execution with strong integration to Adabas

State management via program variables and database records

Control flow primarily procedural with loops, conditions, and exception handling

Rendering Model

Procedural execution flow

Batch or online transaction processing

Subprogram calls for modularity

Database read/write operations integrated

Event-driven triggers in online environment

Architectural Patterns

Procedural batch-oriented

Modular subprogram architecture

Database-centric business logic

Integration with middleware for external systems

Legacy mainframe compatibility

Real World Architectures

Banking transaction processing

Insurance claims management

Payroll and HR management

Government administrative systems

Inventory and logistics management

Design Principles

Readable, English-like syntax

Database-centric and procedural

Modularization for maintainable code

Rapid development of business applications

Compatibility with legacy mainframe and server systems

Scalability Guide

Optimize database access with indexes and views

Split large batch jobs into smaller units

Use subprograms and modularization to manage complexity

Monitor performance metrics on mainframe or server

Batch and online tasks tuned for efficient throughput

Migration Guide

Review legacy Natural programs for modernization

Refactor subprograms and database access logic

Replace deprecated constructs with supported alternatives

Test thoroughly on target environments

Document logic and maintain version control

Performance Notes

Optimize database reads and writes using indexes

Minimize nested loops for large datasets

Batch processing preferred for large-scale updates

Use efficient subprogram calls to reduce overhead

Leverage database-specific features for faster access

Security Notes

Restrict access to sensitive database tables

Ensure proper user roles in Natural and Adabas

Audit changes made by batch or online programs

Encrypt sensitive data where applicable

Implement error handling to prevent data leaks

Monitoring Analytics

Check batch job execution logs

Monitor database transactions and performance

Audit online program executions

Review subprogram call efficiency

Identify bottlenecks in procedural flow

Code Quality

Use clear, English-like naming conventions

Comment logic and data transformations

Encapsulate reusable logic in subprograms

Follow database access best practices

Test modules independently before integration

Practical Examples

Generating daily banking transaction reports

Validating insurance claims in batch

Updating master customer records in Adabas

Automating payroll calculations and data transfers

Integrating with legacy ERP systems for inventory updates

Troubleshooting

Check syntax and compile errors in Natural IDE

Validate database connection and access rights

Monitor batch job logs for runtime errors

Debug subprogram logic and conditional flow

Ensure proper transaction handling to prevent data inconsistencies

Testing Guide

Unit test subprograms individually

Validate database transactions with test data

Simulate batch runs in controlled environment

Check integration with other systems

Review error handling and rollback mechanisms

Deployment Options

Compile Natural programs and deploy to production libraries

Schedule batch jobs via mainframe scheduler

Integrate subprograms with larger workflows

Monitor execution logs for errors

Maintain version control of program sources and modules

Tools Ecosystem

Natural Development Environment (NDE)

Natural Studio for Eclipse

Adabas database tools

Natural Debugger and Profiler

Batch scheduling and job control systems

Integrations

Adabas databases for transactional data

Legacy ERP and financial systems

Middleware like EntireX for client-server communication

Batch workflow orchestration tools

Reporting and BI systems for output consumption

Productivity Tips

Use subprograms for reusable logic

Keep database operations efficient

Document business rules clearly

Test incrementally in batch or online environment

Optimize loops and conditional processing

Challenges

Understanding legacy mainframe environments

Database integration and transaction handling

Debugging complex multi-step processes

Optimizing performance for large datasets

Migrating or modernizing legacy Natural applications

Learning Path

Learn Natural syntax and program structure

Understand database integration with Adabas

Practice writing modular subprograms

Explore batch and online processing

Master enterprise integration patterns and workflow automation

Skill Improvement Plan

Week 1: Basic syntax, variables, and control flow

Week 2: Database reads, writes, and simple reports

Week 3: Subprograms and modular coding

Week 4: Batch processing and transaction management

Week 5: Integration, optimization, and best practices

Interview Questions

Explain the core features of Natural.

How do you interact with databases in Natural?

Describe modularization using subprograms.

How would you optimize a large batch process in Natural?

What are challenges in maintaining legacy Natural applications?

Cheat Sheet

READ/WRITE -> database operations

IF/ELSE -> conditional logic

PERFORM -> call subprogram

DEFINE DATA -> declare variables

ON ERROR -> error handling

Books

Natural Language Programming: The Complete Guide

Software AG Natural: Practical Development

Mastering Natural and Adabas

Enterprise Application Development with Natural

Legacy System Modernization with Natural

Tutorials

Natural Language Basics and Syntax

Database Integration with Natural

Batch Processing in Natural

Subprograms and Modular Development

Integration and Workflow Automation with Natural

Official Docs

https://documentation.softwareag.com/natural

https://www.softwareag.com/en_corporate/products/natural.html

https://techcommunity.softwareag.com

Community Links

Software AG Community

LinkedIn Natural user groups

Stack Overflow Natural tag

Reddit mainframe development forums

Professional meetups and user groups

Community Support

Software AG community forums

Stack Overflow Natural tag

LinkedIn Software AG user groups

Natural DevGroups and professional meetups

Vendor-provided training and support portals

Monetization

Legacy Natural application support

Enterprise system integration consulting

Workflow automation for mainframe systems

Reporting and analytics development

Modernization and migration services

Future Roadmap

Enhanced integration with web services and APIs

Better development tools and IDEs

Support for modern server and cloud environments

Improved debugging and monitoring capabilities

Continued maintenance for legacy enterprise systems

When Not To Use

New web applications or microservices

High-performance computing tasks

Non-database-centric scripting

Applications requiring modern GUI frameworks

Rapid prototyping outside mainframe or Natural ecosystem

Final Summary

Natural Scripting is a 4GL language for database-driven enterprise applications.

Supports batch, online, and event-driven processing.

Highly readable and modular for rapid business logic development.

Integrated with Adabas and other enterprise databases.

Still relevant for legacy system maintenance and enterprise automation.

Faq

Is Natural still used today? -> Yes, in enterprise and mainframe environments.

Can Natural integrate with modern systems? -> Yes, via EntireX or APIs.

Is Natural object-oriented? -> Mostly procedural, some modularization.

Can I run Natural outside mainframes? -> Yes, server-based environments supported.

Is learning Natural useful today? -> Valuable for maintaining legacy enterprise applications.

Code Sample Descriptions

1

Simple Natural Program

DEFINE DATA LOCAL
    END-DEFINE
WRITE 'Hello, Natural World!'
END

Print a greeting message.

Let’s Try →
2

Natural Loop Example

DEFINE DATA LOCAL
    1 I (N)
END-DEFINE
FOR I = 1 TO 5
    WRITE 'Number: ' I
END-FOR
END

Loop through numbers 1 to 5 and display them.

Let’s Try →
3

Natural Database Read Example

DEFINE DATA LOCAL
    1 CUSTOMER-VIEW VIEW OF CUSTOMER
        2 CUST-ID
        2 CUST-NAME
END-DEFINE
FIND CUSTOMER-VIEW BY CUST-ID = 10001
    DISPLAY CUST-NAME
END-FIND
END

Read records from an Adabas file and display a field.

Let’s Try →
4

Natural Conditional Example

DEFINE DATA LOCAL
    1 AGE (N)
END-DEFINE
READ 'Enter age: ' AGE
IF AGE >= 18
    WRITE 'Adult'
ELSE
    WRITE 'Minor'
END-IF
END

Check a value and print messages based on condition.

Let’s Try →
5

Natural Input and Display Example

DEFINE DATA LOCAL
    1 NAME (A20)
END-DEFINE
INPUT 'Enter your name: ' NAME
WRITE 'Welcome, ' NAME
END

Prompt user for name and display a welcome message.

Let’s Try →
6

Natural Arithmetic Example

DEFINE DATA LOCAL
    1 A (N)
    1 B (N)
    1 SUM (N)
    1 PROD (N)
END-DEFINE
INPUT 'Enter A: ' A
INPUT 'Enter B: ' B
SUM := A + B
PROD := A * B
WRITE 'Sum: ' SUM
WRITE 'Product: ' PROD
END

Compute sum and product of two numbers.

Let’s Try →
7

Natural Loop with Database

DEFINE DATA LOCAL
    1 CUSTOMER-VIEW VIEW OF CUSTOMER
        2 CUST-ID
        2 CUST-NAME
END-DEFINE
FIND CUSTOMER-VIEW WITH CUST-ID NE 0
    DISPLAY CUST-ID CUST-NAME
END-FIND
END

Loop through all customer records and display names.

Let’s Try →
8

Natural Subroutine Example

DEFINE DATA LOCAL
    1 USERNAME (A20)
END-DEFINE
INPUT 'Enter your name: ' USERNAME
PERFORM GREET(USERNAME)
END
DEFINE SUBROUTINE GREET(NAME)
    WRITE 'Hello, ' NAME
END-SUBROUTINE

Call a subroutine to greet a user.

Let’s Try →
9

Natural String Manipulation

DEFINE DATA LOCAL
    1 INPUT-STR (A20)
    1 UPPER-STR (A20)
END-DEFINE
INPUT 'Enter string: ' INPUT-STR
UPPER-STR := CONVERT(INPUT-STR, 'UPPER')
WRITE 'Uppercase: ' UPPER-STR
END

Convert input string to uppercase and display.

Let’s Try →
10

Natural Exit Condition in Loop

DEFINE DATA LOCAL
    1 NUM (N)
END-DEFINE
DO
    INPUT 'Enter number (0 to quit): ' NUM
    IF NUM = 0
        EXIT
    ENDIF
    WRITE 'You entered: ' NUM
END-DO
END

Loop until user enters 0.

Let’s Try →

Frequently Asked Questions about Natural-scripting

What is Natural-scripting?

Natural Scripting refers to the use of the Natural programming language (from Software AG) to create applications, automate business logic, and interact with databases, especially within mainframe and enterprise environments.

What are the primary use cases for Natural-scripting?

Automating enterprise business processes. Building database-centric applications on mainframes. Creating batch jobs for reporting and transaction processing. Rapid prototyping of business logic applications. Integrating with legacy systems and middleware

What are the strengths of Natural-scripting?

Rapid development for business applications. Readable and maintainable syntax. Efficient database operations for large datasets. Mature, stable language with decades of use. Compatible with legacy mainframe and server systems

What are the limitations of Natural-scripting?

Proprietary, mainly tied to Software AG ecosystem. Limited modern IDE and tooling support compared to contemporary languages. Steep learning curve for newcomers unfamiliar with 4GLs. Less community support than mainstream languages. Primarily suited for database-centric applications, not general-purpose programming

How can I practice Natural-scripting typing speed?

CodeSpeedTest offers 10+ real Natural-scripting code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.

Learn Other Programming Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypherGremlinPartiqlHaskellElixirFsharpView all languages →
CodeSpeedTest

Improve your coding speed, code accuracy, and programming syntax WPM with practice sessions across 500+ programming languages.

Quick Links

HomeAboutFeaturesGetting StartedLanguages

Legal & Support

Pro ⚡ PricingContactPrivacy PolicyTerms of Service

Connect

CodeSpeedTest on GitHubCodeSpeedTest on TwitterEmail CodeSpeedTest

© 2026 CodeSpeedTest. All rights reserved.