{"id":1429,"date":"2026-03-06T21:07:43","date_gmt":"2026-03-06T21:07:43","guid":{"rendered":"https:\/\/digitwaves.com\/?p=1429"},"modified":"2026-03-06T21:07:43","modified_gmt":"2026-03-06T21:07:43","slug":"understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals","status":"publish","type":"post","link":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/","title":{"rendered":"Understanding a Simple COBOL Payroll Program (Looping, Totals, and Grand Totals)"},"content":{"rendered":"<p data-start=\"559\" data-end=\"726\">If you&#8217;re learning COBOL, one of the best beginner exercises is building a <strong data-start=\"634\" data-end=\"653\">payroll program<\/strong>. Payroll programs demonstrate many fundamental COBOL concepts including:<\/p>\n<ul data-start=\"728\" data-end=\"906\">\n<li data-section-id=\"5u265f\" data-start=\"728\" data-end=\"762\">\n<p data-start=\"730\" data-end=\"762\">Data structures using <strong data-start=\"752\" data-end=\"762\">OCCURS<\/strong><\/p>\n<\/li>\n<li data-section-id=\"11l3lq3\" data-start=\"763\" data-end=\"797\">\n<p data-start=\"765\" data-end=\"797\">Looping with <strong data-start=\"778\" data-end=\"797\">PERFORM VARYING<\/strong><\/p>\n<\/li>\n<li data-section-id=\"bfm4b3\" data-start=\"798\" data-end=\"842\">\n<p data-start=\"800\" data-end=\"842\">Mathematical calculations with <strong data-start=\"831\" data-end=\"842\">COMPUTE<\/strong><\/p>\n<\/li>\n<li data-section-id=\"1rvv7q1\" data-start=\"843\" data-end=\"873\">\n<p data-start=\"845\" data-end=\"873\">Running totals using <strong data-start=\"866\" data-end=\"873\">ADD<\/strong><\/p>\n<\/li>\n<li data-section-id=\"1rzmfr0\" data-start=\"874\" data-end=\"906\">\n<p data-start=\"876\" data-end=\"906\">Output formatting for currency<\/p>\n<\/li>\n<\/ul>\n<p data-start=\"908\" data-end=\"1088\">In this article we will walk through a simple COBOL payroll program that processes two employees, calculates their individual totals, and then prints a final company payroll total.<\/p>\n<p data-start=\"908\" data-end=\"1088\"><pre id=\"code-snippet-source-12\" class=\"code-snippet-source\"><code class=\"language-php\">IDENTIFICATION DIVISION.\nPROGRAM-ID. PAYROL-3-6-26.\nREMARKS. PAYROLL EXAMPLE PROGRAM.\n\nENVIRONMENT DIVISION.\nCONFIGURATION SECTION.\n\nDATA DIVISION.\nWORKING-STORAGE SECTION.\n\n01 WS-EMPLOYEE-INFO OCCURS 2 TIMES INDEXED BY WS-INDEX.\n   05 WS-EMP-ID    PIC 9(4).\n   05 WS-PAY-RATE  PIC 9(2).\n   05 WS-HOURS     PIC 9(4).\n   05 WS-NAME      PIC X(50).\n\n01 WS-TOTALS           PIC 9(8)V99 VALUE 0.\n01 WS-TOTALS-ED        PIC $,$$$,$$$.99.\n01 WS-GRAND-TOTALS     PIC 9(9)V99 VALUE 0.\n01 WS-GRAND-TOTALS-ED  PIC $$,$$$,$$$.99.\n\nPROCEDURE DIVISION.\n\n000-MAIN.\n    PERFORM 100-DATA-INIT-1\n    PERFORM 200-CALC-TOTALS\n    PERFORM 300-CALC-GRAND-TOTALS\n    PERFORM 900-TERMINATE.\n\n100-DATA-INIT-1.\n    MOVE 1234   TO WS-EMP-ID(1)\n    MOVE 52.35  TO WS-PAY-RATE(1)\n    MOVE 60     TO WS-HOURS(1)\n    MOVE &#039;JOHN&#039; TO WS-NAME(1)\n\n    MOVE 1235   TO WS-EMP-ID(2)\n    MOVE 59.35  TO WS-PAY-RATE(2)\n    MOVE 640    TO WS-HOURS(2)\n    MOVE &#039;WOY&#039;  TO WS-NAME(2)\n    CONTINUE.\n\n200-CALC-TOTALS.\n    PERFORM VARYING WS-INDEX FROM 1 BY 1\n        UNTIL WS-INDEX &gt; 2\n            COMPUTE WS-TOTALS =\n                WS-PAY-RATE(WS-INDEX) * WS-HOURS(WS-INDEX)\n            MOVE WS-TOTALS TO WS-TOTALS-ED\n            DISPLAY &quot;TOTAL: &quot; WS-TOTALS-ED\n            ADD WS-TOTALS TO WS-GRAND-TOTALS\n    END-PERFORM.\n\n300-CALC-GRAND-TOTALS.\n    MOVE WS-GRAND-TOTALS TO WS-GRAND-TOTALS-ED\n    DISPLAY &quot;GRAND TOTAL: &quot; WS-GRAND-TOTALS-ED.\n\n900-TERMINATE.\n    STOP RUN.<\/code><\/pre><\/p>\n<h2 data-section-id=\"1e91poa\" data-start=\"2604\" data-end=\"2641\">Understanding the Program Structure<\/h2>\n<p data-start=\"2643\" data-end=\"2687\">COBOL programs are organized into divisions.<\/p>\n<h2 data-section-id=\"12jxd46\" data-start=\"2689\" data-end=\"2715\">Identification Division<\/h2>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\"><\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">IDENTIFICATION DIVISION.<br \/>\nPROGRAM-ID. PAYROL-3-6-26.<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p data-start=\"2783\" data-end=\"2859\">This identifies the program name used when compiling or running the program.<\/p>\n<hr data-start=\"2861\" data-end=\"2864\" \/>\n<h2 data-section-id=\"1v8z77g\" data-start=\"2866\" data-end=\"2882\">Data Division<\/h2>\n<p data-start=\"2884\" data-end=\"2954\">The <strong data-start=\"2888\" data-end=\"2915\">WORKING-STORAGE SECTION<\/strong> defines variables used by the program.<\/p>\n<h3 data-section-id=\"e6jp5p\" data-start=\"2956\" data-end=\"2974\">Employee Array<\/h3>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\"><\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">01 WS-EMPLOYEE-INFO OCCURS 2 TIMES INDEXED BY WS-INDEX.<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p data-start=\"3046\" data-end=\"3110\">This creates a small <strong data-start=\"3067\" data-end=\"3084\">table (array)<\/strong> that holds two employees.<\/p>\n<p data-start=\"3112\" data-end=\"3130\">Each employee has:<\/p>\n<ul data-start=\"3132\" data-end=\"3178\">\n<li data-section-id=\"12gz8o7\" data-start=\"3132\" data-end=\"3145\">\n<p data-start=\"3134\" data-end=\"3145\">Employee ID<\/p>\n<\/li>\n<li data-section-id=\"1a4go3m\" data-start=\"3146\" data-end=\"3156\">\n<p data-start=\"3148\" data-end=\"3156\">Pay Rate<\/p>\n<\/li>\n<li data-section-id=\"9gqhaz\" data-start=\"3157\" data-end=\"3171\">\n<p data-start=\"3159\" data-end=\"3171\">Hours worked<\/p>\n<\/li>\n<li data-section-id=\"1j3z0bz\" data-start=\"3172\" data-end=\"3178\">\n<p data-start=\"3174\" data-end=\"3178\">Name<\/p>\n<\/li>\n<\/ul>\n<hr data-start=\"3180\" data-end=\"3183\" \/>\n<h2 data-section-id=\"hyrk11\" data-start=\"3185\" data-end=\"3207\">Data Initialization<\/h2>\n<p data-start=\"3209\" data-end=\"3250\">The program manually loads employee data.<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\"><\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">MOVE 1234 TO WS-EMP-ID(1)<br \/>\nMOVE 52.35 TO WS-PAY-RATE(1)<br \/>\nMOVE 60 TO WS-HOURS(1)<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p data-start=\"3344\" data-end=\"3398\">In real production systems, this data would come from:<\/p>\n<ul data-start=\"3400\" data-end=\"3454\">\n<li data-section-id=\"e56ztg\" data-start=\"3400\" data-end=\"3416\">\n<p data-start=\"3402\" data-end=\"3416\"><strong data-start=\"3402\" data-end=\"3416\">VSAM files<\/strong><\/p>\n<\/li>\n<li data-section-id=\"eydcqy\" data-start=\"3417\" data-end=\"3436\">\n<p data-start=\"3419\" data-end=\"3436\"><strong data-start=\"3419\" data-end=\"3436\">DB2 databases<\/strong><\/p>\n<\/li>\n<li data-section-id=\"qpj2ff\" data-start=\"3437\" data-end=\"3454\">\n<p data-start=\"3439\" data-end=\"3454\"><strong data-start=\"3439\" data-end=\"3454\">Input files<\/strong><\/p>\n<\/li>\n<\/ul>\n<p>See our guide to COBOL WORKING-STORAGE variables here:<br \/>\n<a href=\"https:\/\/digitwaves.com\/cobol-working-storage-guide\">Working Storage Section<\/a><\/p>\n<hr data-start=\"3456\" data-end=\"3459\" \/>\n<h2 data-section-id=\"yckyvo\" data-start=\"3461\" data-end=\"3490\">Calculating Employee Totals<\/h2>\n<p data-start=\"3492\" data-end=\"3554\">The program loops through employees using <strong data-start=\"3534\" data-end=\"3553\">PERFORM VARYING<\/strong>.<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\"><\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">PERFORM VARYING WS-INDEX FROM 1 BY 1<br \/>\nUNTIL WS-INDEX &gt; 2<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p data-start=\"3630\" data-end=\"3641\">This means:<\/p>\n<ul data-start=\"3643\" data-end=\"3722\">\n<li data-section-id=\"141cxx5\" data-start=\"3643\" data-end=\"3666\">\n<p data-start=\"3645\" data-end=\"3666\">Start with employee 1<\/p>\n<\/li>\n<li data-section-id=\"1eo3vuz\" data-start=\"3667\" data-end=\"3698\">\n<p data-start=\"3669\" data-end=\"3698\">Increase index by 1 each loop<\/p>\n<\/li>\n<li data-section-id=\"17jl9lw\" data-start=\"3699\" data-end=\"3722\">\n<p data-start=\"3701\" data-end=\"3722\">Stop after employee 2<\/p>\n<\/li>\n<\/ul>\n<p data-start=\"3724\" data-end=\"3761\">Inside the loop we calculate payroll:<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\"><\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">COMPUTE WS-TOTALS =<br \/>\nWS-PAY-RATE(WS-INDEX) * WS-HOURS(WS-INDEX)<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p data-start=\"3844\" data-end=\"3852\">Example:<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute end-1.5 top-1 z-2 md:end-2 md:top-1\"><\/div>\n<div class=\"pt-3\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">52.35 * 60 = 3120<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<hr data-start=\"3881\" data-end=\"3884\" \/>\n<h2 data-section-id=\"1lcw4c6\" data-start=\"3886\" data-end=\"3916\">Accumulating the Grand Total<\/h2>\n<p data-start=\"3918\" data-end=\"3968\">Each employee&#8217;s total is added to a running total.<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\"><\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">ADD WS-TOTALS TO WS-GRAND-TOTALS<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p data-start=\"4017\" data-end=\"4095\">This is called an <strong data-start=\"4035\" data-end=\"4058\">accumulator pattern<\/strong>, common in financial COBOL programs.<\/p>\n<hr data-start=\"4097\" data-end=\"4100\" \/>\n<h2 data-section-id=\"18gg1we\" data-start=\"4102\" data-end=\"4138\">Displaying the Final Payroll Total<\/h2>\n<p data-start=\"4140\" data-end=\"4216\">After processing all employees, the program prints the final payroll amount.<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute inset-x-4 top-12 bottom-4\">\n<div class=\"pointer-events-none sticky z-40 shrink-0 z-1!\">\n<div class=\"sticky bg-token-border-light\"><\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">DISPLAY &#8220;GRAND TOTAL: &#8221; WS-GRAND-TOTALS-ED<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p data-start=\"4275\" data-end=\"4290\">Example output:<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute end-1.5 top-1 z-2 md:end-2 md:top-1\"><\/div>\n<div class=\"pt-3\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">TOTAL: $3,120.00<br \/>\nTOTAL: $37,760.00<br \/>\nGRAND TOTAL: $40,880.00<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<hr data-start=\"4373\" data-end=\"4376\" \/>\n<h2 data-section-id=\"bujzmj\" data-start=\"4378\" data-end=\"4419\">Why This Program Structure Is Important<\/h2>\n<p data-start=\"4421\" data-end=\"4507\">This program demonstrates a classic COBOL pattern used in many mainframe applications:<\/p>\n<div class=\"relative w-full mt-4 mb-1\">\n<div class=\"\">\n<div class=\"relative\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"h-full min-h-0 min-w-0\">\n<div class=\"border border-token-border-light border-radius-3xl corner-superellipse\/1.1 rounded-3xl\">\n<div class=\"h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse\/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback\">\n<div class=\"pointer-events-none absolute end-1.5 top-1 z-2 md:end-2 md:top-1\"><\/div>\n<div class=\"pt-3\">\n<div class=\"relative z-0 flex max-w-full\">\n<div id=\"code-block-viewer\" class=\"q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch \u037c5 \u037cj\" dir=\"ltr\">\n<div class=\"cm-scroller\">\n<div class=\"cm-content q9tKkq_readonly\">000-MAIN<br \/>\n100-INITIALIZATION<br \/>\n200-PROCESS-DETAIL<br \/>\n300-SUMMARY<br \/>\n900-TERMINATION<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"\">\n<div class=\"\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p data-start=\"4593\" data-end=\"4653\">This structure makes large COBOL systems easier to maintain.<\/p>\n<hr data-start=\"4655\" data-end=\"4658\" \/>\n<h2 data-section-id=\"1329ug4\" data-start=\"4660\" data-end=\"4676\">Final Thoughts<\/h2>\n<p data-start=\"4678\" data-end=\"4801\">Even though COBOL was created decades ago, programs like this demonstrate why it remains widely used in industries such as:<\/p>\n<ul data-start=\"4803\" data-end=\"4855\">\n<li data-section-id=\"uwl75a\" data-start=\"4803\" data-end=\"4812\">\n<p data-start=\"4805\" data-end=\"4812\">Banking<\/p>\n<\/li>\n<li data-section-id=\"aw3wb6\" data-start=\"4813\" data-end=\"4824\">\n<p data-start=\"4815\" data-end=\"4824\">Insurance<\/p>\n<\/li>\n<li data-section-id=\"12si271\" data-start=\"4825\" data-end=\"4837\">\n<p data-start=\"4827\" data-end=\"4837\">Government<\/p>\n<\/li>\n<li data-section-id=\"ft7yvf\" data-start=\"4838\" data-end=\"4855\">\n<p data-start=\"4840\" data-end=\"4855\">Payroll systems<\/p>\n<\/li>\n<\/ul>\n<p data-start=\"4857\" data-end=\"4962\">Understanding these fundamental patterns is the first step toward mastering enterprise COBOL development.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re learning COBOL, one of the best beginner exercises is building a payroll program. Payroll programs demonstrate many fundamental COBOL concepts including: Data structures [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1431,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-1429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cobol"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>COBOL Payroll Program Example | Loops and Totals<\/title>\n<meta name=\"description\" content=\"Learn how a simple COBOL payroll program works using arrays, PERFORM loops, employee totals, and a grand total calculation step by step.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"COBOL Payroll Program Example | Loops and Totals\" \/>\n<meta property=\"og:description\" content=\"Learn how a simple COBOL payroll program works using arrays, PERFORM loops, employee totals, and a grand total calculation step by step.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/\" \/>\n<meta property=\"og:site_name\" content=\"Digit Waves\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-06T21:07:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/digitwaves.com\/wp-content\/uploads\/2026\/03\/universal_upscale_0_9a2ccc54-1a0c-4652-ab23-f9efbcaba0f1_0-1024x581.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"581\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"cmartin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"cmartin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/\"},\"author\":{\"name\":\"cmartin\",\"@id\":\"https:\\\/\\\/digitwaves.com\\\/#\\\/schema\\\/person\\\/223d018061f352913b760bf9b09a8097\"},\"headline\":\"Understanding a Simple COBOL Payroll Program (Looping, Totals, and Grand Totals)\",\"datePublished\":\"2026-03-06T21:07:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/\"},\"wordCount\":371,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/digitwaves.com\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/universal_upscale_0_9a2ccc54-1a0c-4652-ab23-f9efbcaba0f1_0.jpg\",\"articleSection\":[\"COBOL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/\",\"url\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/\",\"name\":\"COBOL Payroll Program Example | Loops and Totals\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/digitwaves.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/digitwaves.com\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/universal_upscale_0_9a2ccc54-1a0c-4652-ab23-f9efbcaba0f1_0.jpg\",\"datePublished\":\"2026-03-06T21:07:43+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/digitwaves.com\\\/#\\\/schema\\\/person\\\/223d018061f352913b760bf9b09a8097\"},\"description\":\"Learn how a simple COBOL payroll program works using arrays, PERFORM loops, employee totals, and a grand total calculation step by step.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/#primaryimage\",\"url\":\"https:\\\/\\\/digitwaves.com\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/universal_upscale_0_9a2ccc54-1a0c-4652-ab23-f9efbcaba0f1_0.jpg\",\"contentUrl\":\"https:\\\/\\\/digitwaves.com\\\/wp-content\\\/uploads\\\/2026\\\/03\\\/universal_upscale_0_9a2ccc54-1a0c-4652-ab23-f9efbcaba0f1_0.jpg\",\"width\":4736,\"height\":2688,\"caption\":\"COBOL payroll program running on IBM mainframe terminal\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/digitwaves.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Understanding a Simple COBOL Payroll Program (Looping, Totals, and Grand Totals)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/digitwaves.com\\\/#website\",\"url\":\"https:\\\/\\\/digitwaves.com\\\/\",\"name\":\"Digit Waves\",\"description\":\"Just another WordPress site\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/digitwaves.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/digitwaves.com\\\/#\\\/schema\\\/person\\\/223d018061f352913b760bf9b09a8097\",\"name\":\"cmartin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2aa893c0e8a64727fc5308b3b422801ee1f800294e70ee6ac57fd6b86a104eb2?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2aa893c0e8a64727fc5308b3b422801ee1f800294e70ee6ac57fd6b86a104eb2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2aa893c0e8a64727fc5308b3b422801ee1f800294e70ee6ac57fd6b86a104eb2?s=96&d=mm&r=g\",\"caption\":\"cmartin\"},\"sameAs\":[\"http:\\\/\\\/digitwaves.com\"],\"url\":\"https:\\\/\\\/digitwaves.com\\\/index.php\\\/author\\\/cmartin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"COBOL Payroll Program Example | Loops and Totals","description":"Learn how a simple COBOL payroll program works using arrays, PERFORM loops, employee totals, and a grand total calculation step by step.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/","og_locale":"en_US","og_type":"article","og_title":"COBOL Payroll Program Example | Loops and Totals","og_description":"Learn how a simple COBOL payroll program works using arrays, PERFORM loops, employee totals, and a grand total calculation step by step.","og_url":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/","og_site_name":"Digit Waves","article_published_time":"2026-03-06T21:07:43+00:00","og_image":[{"width":1024,"height":581,"url":"https:\/\/digitwaves.com\/wp-content\/uploads\/2026\/03\/universal_upscale_0_9a2ccc54-1a0c-4652-ab23-f9efbcaba0f1_0-1024x581.jpg","type":"image\/jpeg"}],"author":"cmartin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"cmartin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/#article","isPartOf":{"@id":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/"},"author":{"name":"cmartin","@id":"https:\/\/digitwaves.com\/#\/schema\/person\/223d018061f352913b760bf9b09a8097"},"headline":"Understanding a Simple COBOL Payroll Program (Looping, Totals, and Grand Totals)","datePublished":"2026-03-06T21:07:43+00:00","mainEntityOfPage":{"@id":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/"},"wordCount":371,"commentCount":0,"image":{"@id":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/#primaryimage"},"thumbnailUrl":"https:\/\/digitwaves.com\/wp-content\/uploads\/2026\/03\/universal_upscale_0_9a2ccc54-1a0c-4652-ab23-f9efbcaba0f1_0.jpg","articleSection":["COBOL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/","url":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/","name":"COBOL Payroll Program Example | Loops and Totals","isPartOf":{"@id":"https:\/\/digitwaves.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/#primaryimage"},"image":{"@id":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/#primaryimage"},"thumbnailUrl":"https:\/\/digitwaves.com\/wp-content\/uploads\/2026\/03\/universal_upscale_0_9a2ccc54-1a0c-4652-ab23-f9efbcaba0f1_0.jpg","datePublished":"2026-03-06T21:07:43+00:00","author":{"@id":"https:\/\/digitwaves.com\/#\/schema\/person\/223d018061f352913b760bf9b09a8097"},"description":"Learn how a simple COBOL payroll program works using arrays, PERFORM loops, employee totals, and a grand total calculation step by step.","breadcrumb":{"@id":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/#primaryimage","url":"https:\/\/digitwaves.com\/wp-content\/uploads\/2026\/03\/universal_upscale_0_9a2ccc54-1a0c-4652-ab23-f9efbcaba0f1_0.jpg","contentUrl":"https:\/\/digitwaves.com\/wp-content\/uploads\/2026\/03\/universal_upscale_0_9a2ccc54-1a0c-4652-ab23-f9efbcaba0f1_0.jpg","width":4736,"height":2688,"caption":"COBOL payroll program running on IBM mainframe terminal"},{"@type":"BreadcrumbList","@id":"https:\/\/digitwaves.com\/index.php\/understanding-a-simple-cobol-payroll-program-looping-totals-and-grand-totals\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/digitwaves.com\/"},{"@type":"ListItem","position":2,"name":"Understanding a Simple COBOL Payroll Program (Looping, Totals, and Grand Totals)"}]},{"@type":"WebSite","@id":"https:\/\/digitwaves.com\/#website","url":"https:\/\/digitwaves.com\/","name":"Digit Waves","description":"Just another WordPress site","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/digitwaves.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/digitwaves.com\/#\/schema\/person\/223d018061f352913b760bf9b09a8097","name":"cmartin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2aa893c0e8a64727fc5308b3b422801ee1f800294e70ee6ac57fd6b86a104eb2?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2aa893c0e8a64727fc5308b3b422801ee1f800294e70ee6ac57fd6b86a104eb2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2aa893c0e8a64727fc5308b3b422801ee1f800294e70ee6ac57fd6b86a104eb2?s=96&d=mm&r=g","caption":"cmartin"},"sameAs":["http:\/\/digitwaves.com"],"url":"https:\/\/digitwaves.com\/index.php\/author\/cmartin\/"}]}},"_links":{"self":[{"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/posts\/1429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/comments?post=1429"}],"version-history":[{"count":8,"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/posts\/1429\/revisions"}],"predecessor-version":[{"id":1438,"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/posts\/1429\/revisions\/1438"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/media\/1431"}],"wp:attachment":[{"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/media?parent=1429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/categories?post=1429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/digitwaves.com\/index.php\/wp-json\/wp\/v2\/tags?post=1429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}