MainframeMaster

COBOL Tutorial

COBOL JUST and JUSTIFIED

The JUST and JUSTIFIED keywords represent specialized data alignment specifications within COBOL data definition environments, providing sophisticated right-alignment capabilities for alphanumeric fields that enable precise text positioning, formatted output generation, and controlled data presentation. These alignment modifiers embody advanced formatting principles by ensuring consistent text positioning, supporting legacy system requirements, and maintaining compatibility with external interfaces while facilitating professional report formatting, standardized data layout patterns, and comprehensive text manipulation across enterprise applications requiring precise field alignment and sophisticated data presentation capabilities with reliable formatting consistency and optimized display characteristics.

JUSTIFIED Syntax and Usage

Data Definition with Alignment
cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
*> Basic JUSTIFIED syntax 01 field-name PIC X(n) JUSTIFIED. 01 field-name PIC X(n) JUST. *> JUST is equivalent to JUSTIFIED *> Examples of JUSTIFIED fields 01 WS-RIGHT-ALIGNED-NAME PIC X(20) JUSTIFIED. 01 WS-ACCOUNT-CODE PIC X(10) JUST. 01 WS-FORMATTED-TEXT PIC X(30) JUSTIFIED. *> Without JUSTIFIED (default left alignment) 01 WS-LEFT-ALIGNED-NAME PIC X(20). *> Demonstration of alignment differences PROCEDURE DIVISION. *> Left-aligned field (default) MOVE "SMITH" TO WS-LEFT-ALIGNED-NAME *> Result: "SMITH " (left-aligned with trailing spaces) *> Right-aligned field (JUSTIFIED) MOVE "SMITH" TO WS-RIGHT-ALIGNED-NAME *> Result: " SMITH" (right-aligned with leading spaces) *> Account code right-aligned MOVE "ABC123" TO WS-ACCOUNT-CODE *> Result: " ABC123" (right-aligned) *> JUSTIFIED only applies to alphanumeric fields 01 WS-VALID-JUSTIFIED PIC X(15) JUSTIFIED. *> Valid 01 WS-INVALID-JUSTIFIED PIC 9(5) JUSTIFIED. *> Compilation error *> Group items cannot be JUSTIFIED 01 WS-GROUP-ITEM JUSTIFIED. *> Invalid 05 WS-FIELD1 PIC X(10). 05 WS-FIELD2 PIC X(10).
Data Alignment
Text Formatting
Field Positioning

Comprehensive JUSTIFIED Examples

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
IDENTIFICATION DIVISION. PROGRAM-ID. JUSTIFIED-DEMONSTRATION. DATA DIVISION. WORKING-STORAGE SECTION. *> Comparison of aligned and non-aligned fields 01 ALIGNMENT-DEMO-FIELDS. 05 WS-STANDARD-NAME PIC X(25). 05 WS-JUSTIFIED-NAME PIC X(25) JUSTIFIED. 05 WS-STANDARD-CODE PIC X(12). 05 WS-JUSTIFIED-CODE PIC X(12) JUSTIFIED. 05 WS-STANDARD-ADDRESS PIC X(40). 05 WS-JUSTIFIED-ADDRESS PIC X(40) JUSTIFIED. *> Report formatting fields 01 REPORT-FIELDS. 05 WS-REPORT-TITLE PIC X(50) JUSTIFIED. 05 WS-PAGE-NUMBER PIC X(10) JUSTIFIED. 05 WS-DATE-STAMP PIC X(15) JUSTIFIED. 05 WS-COLUMN-HEADER PIC X(20) JUSTIFIED. *> Financial data formatting 01 FINANCIAL-FIELDS. 05 WS-ACCOUNT-NUMBER PIC X(15) JUSTIFIED. 05 WS-ROUTING-NUMBER PIC X(12) JUSTIFIED. 05 WS-BANK-NAME PIC X(30) JUSTIFIED. 05 WS-CUSTOMER-ID PIC X(10) JUSTIFIED. *> Form layout fields 01 FORM-LAYOUT-FIELDS. 05 WS-LABEL-FIELD PIC X(20) JUSTIFIED. 05 WS-VALUE-FIELD PIC X(30). 05 WS-SIGNATURE-LINE PIC X(40) JUSTIFIED. 05 WS-DATE-LINE PIC X(12) JUSTIFIED. *> Demonstration arrays 01 EMPLOYEE-NAMES. 05 WS-STANDARD-NAMES OCCURS 5 TIMES PIC X(20). 05 WS-JUSTIFIED-NAMES OCCURS 5 TIMES PIC X(20) JUSTIFIED. 01 TEST-DATA-TABLE. 05 WS-TEST-ENTRIES OCCURS 10 TIMES. 10 WS-ENTRY-ID PIC X(8) JUSTIFIED. 10 WS-ENTRY-DESC PIC X(25). 10 WS-ENTRY-CODE PIC X(6) JUSTIFIED. *> Working variables 01 WS-COUNTERS. 05 WS-NAME-COUNT PIC 9(2) VALUE 0. 05 WS-DEMO-COUNT PIC 9(2) VALUE 0. 05 WS-FIELD-LENGTH PIC 9(2). 01 WS-SAMPLE-DATA. 05 FILLER PIC X(100) VALUE "JOHN JANE MICHAEL SARAH DAVID ". 05 WS-SAMPLE-NAMES REDEFINES FILLER. 10 WS-SAMPLE-NAME OCCURS 5 TIMES PIC X(8). PROCEDURE DIVISION. MAIN-PROCESSING. PERFORM DEMONSTRATE-BASIC-ALIGNMENT PERFORM DEMONSTRATE-REPORT-FORMATTING PERFORM DEMONSTRATE-FINANCIAL-FORMATTING PERFORM DEMONSTRATE-FORM-LAYOUTS PERFORM DEMONSTRATE-ARRAY-PROCESSING PERFORM DEMONSTRATE-BUSINESS-APPLICATIONS STOP RUN. DEMONSTRATE-BASIC-ALIGNMENT. DISPLAY "=== BASIC ALIGNMENT DEMONSTRATION ===" *> Test various name lengths MOVE "SMITH" TO WS-STANDARD-NAME MOVE "SMITH" TO WS-JUSTIFIED-NAME DISPLAY "Standard Name : '" WS-STANDARD-NAME "'" DISPLAY "Justified Name : '" WS-JUSTIFIED-NAME "'" DISPLAY SPACES *> Test shorter names MOVE "DOE" TO WS-STANDARD-NAME MOVE "DOE" TO WS-JUSTIFIED-NAME DISPLAY "Standard Name : '" WS-STANDARD-NAME "'" DISPLAY "Justified Name : '" WS-JUSTIFIED-NAME "'" DISPLAY SPACES *> Test longer names (truncation) MOVE "VERY-LONG-EMPLOYEE-NAME-EXAMPLE" TO WS-STANDARD-NAME MOVE "VERY-LONG-EMPLOYEE-NAME-EXAMPLE" TO WS-JUSTIFIED-NAME DISPLAY "Standard Name : '" WS-STANDARD-NAME "'" DISPLAY "Justified Name : '" WS-JUSTIFIED-NAME "'" DISPLAY SPACES *> Test codes MOVE "A123" TO WS-STANDARD-CODE MOVE "A123" TO WS-JUSTIFIED-CODE DISPLAY "Standard Code : '" WS-STANDARD-CODE "'" DISPLAY "Justified Code : '" WS-JUSTIFIED-CODE "'" DISPLAY SPACES. DEMONSTRATE-REPORT-FORMATTING. DISPLAY "=== REPORT FORMATTING WITH JUSTIFIED ===" *> Format report headers MOVE "MONTHLY SALES REPORT" TO WS-REPORT-TITLE MOVE "Page 1" TO WS-PAGE-NUMBER MOVE "12/31/2024" TO WS-DATE-STAMP DISPLAY "==================================================" DISPLAY WS-REPORT-TITLE DISPLAY "Page: " WS-PAGE-NUMBER " Date: " WS-DATE-STAMP DISPLAY "==================================================" *> Format column headers MOVE "Employee Name" TO WS-COLUMN-HEADER DISPLAY "Left Header : '" WS-COLUMN-HEADER "'" MOVE "Sales Amount" TO WS-COLUMN-HEADER DISPLAY "Right Header : '" WS-COLUMN-HEADER "'" MOVE "Department" TO WS-COLUMN-HEADER DISPLAY "Center-ish : '" WS-COLUMN-HEADER "'" DISPLAY SPACES. DEMONSTRATE-FINANCIAL-FORMATTING. DISPLAY "=== FINANCIAL DATA FORMATTING ===" *> Format banking information MOVE "123456789012345" TO WS-ACCOUNT-NUMBER MOVE "021000021" TO WS-ROUTING-NUMBER MOVE "FIRST NATIONAL BANK" TO WS-BANK-NAME MOVE "CUST001" TO WS-CUSTOMER-ID DISPLAY "BANK ACCOUNT INFORMATION" DISPLAY "========================" DISPLAY "Account Number: " WS-ACCOUNT-NUMBER DISPLAY "Routing Number: " WS-ROUTING-NUMBER DISPLAY "Bank Name : " WS-BANK-NAME DISPLAY "Customer ID : " WS-CUSTOMER-ID *> Demonstrate check formatting DISPLAY SPACES DISPLAY "CHECK FORMAT EXAMPLE:" DISPLAY "----------------------------------------" DISPLAY " " WS-DATE-STAMP DISPLAY "PAY TO THE ORDER OF: JOHN SMITH" DISPLAY "AMOUNT: $1,234.56 " WS-ACCOUNT-NUMBER DISPLAY " " WS-BANK-NAME DISPLAY "----------------------------------------" DISPLAY SPACES. DEMONSTRATE-FORM-LAYOUTS. DISPLAY "=== FORM LAYOUT FORMATTING ===" *> Create form-like layout MOVE "Name:" TO WS-LABEL-FIELD MOVE "John Smith" TO WS-VALUE-FIELD DISPLAY WS-LABEL-FIELD " " WS-VALUE-FIELD MOVE "Address:" TO WS-LABEL-FIELD MOVE "123 Main Street" TO WS-VALUE-FIELD DISPLAY WS-LABEL-FIELD " " WS-VALUE-FIELD MOVE "Phone:" TO WS-LABEL-FIELD MOVE "555-123-4567" TO WS-VALUE-FIELD DISPLAY WS-LABEL-FIELD " " WS-VALUE-FIELD *> Signature section MOVE "X" TO WS-SIGNATURE-LINE MOVE "Date" TO WS-DATE-LINE DISPLAY SPACES DISPLAY "Signature: " WS-SIGNATURE-LINE DISPLAY " Date: " WS-DATE-LINE DISPLAY SPACES. DEMONSTRATE-ARRAY-PROCESSING. DISPLAY "=== ARRAY PROCESSING WITH JUSTIFIED ===" *> Initialize arrays with sample data PERFORM VARYING WS-NAME-COUNT FROM 1 BY 1 UNTIL WS-NAME-COUNT > 5 MOVE WS-SAMPLE-NAME(WS-NAME-COUNT) TO WS-STANDARD-NAMES(WS-NAME-COUNT) MOVE WS-SAMPLE-NAME(WS-NAME-COUNT) TO WS-JUSTIFIED-NAMES(WS-NAME-COUNT) END-PERFORM DISPLAY "Standard Names (Left-aligned):" PERFORM VARYING WS-NAME-COUNT FROM 1 BY 1 UNTIL WS-NAME-COUNT > 5 DISPLAY WS-NAME-COUNT ". '" WS-STANDARD-NAMES(WS-NAME-COUNT) "'" END-PERFORM DISPLAY SPACES DISPLAY "Justified Names (Right-aligned):" PERFORM VARYING WS-NAME-COUNT FROM 1 BY 1 UNTIL WS-NAME-COUNT > 5 DISPLAY WS-NAME-COUNT ". '" WS-JUSTIFIED-NAMES(WS-NAME-COUNT) "'" END-PERFORM DISPLAY SPACES. DEMONSTRATE-BUSINESS-APPLICATIONS. DISPLAY "=== BUSINESS APPLICATION EXAMPLES ===" PERFORM INVENTORY-REPORT-FORMATTING PERFORM CUSTOMER-STATEMENT-FORMATTING PERFORM EMPLOYEE-DIRECTORY-FORMATTING. INVENTORY-REPORT-FORMATTING. DISPLAY "Inventory Report Formatting:" DISPLAY "----------------------------" *> Product information with right-aligned codes MOVE "WIDGET-A" TO WS-JUSTIFIED-CODE DISPLAY "Product Code: " WS-JUSTIFIED-CODE " Description: Premium Widget" MOVE "TOOL-B" TO WS-JUSTIFIED-CODE DISPLAY "Product Code: " WS-JUSTIFIED-CODE " Description: Professional Tool" MOVE "PART-C" TO WS-JUSTIFIED-CODE DISPLAY "Product Code: " WS-JUSTIFIED-CODE " Description: Replacement Part" DISPLAY SPACES. CUSTOMER-STATEMENT-FORMATTING. DISPLAY "Customer Statement Formatting:" DISPLAY "------------------------------" *> Statement header with right-aligned information MOVE "STMT-001" TO WS-CUSTOMER-ID MOVE "12/31/2024" TO WS-DATE-STAMP DISPLAY "CUSTOMER STATEMENT" DISPLAY "Statement ID: " WS-CUSTOMER-ID DISPLAY "Date : " WS-DATE-STAMP DISPLAY " " DISPLAY "Customer: ACME Corporation" DISPLAY "Account : " WS-ACCOUNT-NUMBER DISPLAY SPACES. EMPLOYEE-DIRECTORY-FORMATTING. DISPLAY "Employee Directory Formatting:" DISPLAY "------------------------------" *> Directory entries with consistent alignment MOVE "EMP001" TO WS-ENTRY-ID(1) MOVE "John Smith" TO WS-ENTRY-DESC(1) MOVE "IT" TO WS-ENTRY-CODE(1) MOVE "EMP002" TO WS-ENTRY-ID(2) MOVE "Jane Doe" TO WS-ENTRY-DESC(2) MOVE "HR" TO WS-ENTRY-CODE(2) MOVE "EMP003" TO WS-ENTRY-ID(3) MOVE "Bob Johnson" TO WS-ENTRY-DESC(3) MOVE "FIN" TO WS-ENTRY-CODE(3) PERFORM VARYING WS-DEMO-COUNT FROM 1 BY 1 UNTIL WS-DEMO-COUNT > 3 DISPLAY WS-ENTRY-ID(WS-DEMO-COUNT) " | " WS-ENTRY-DESC(WS-DEMO-COUNT) " | " WS-ENTRY-CODE(WS-DEMO-COUNT) END-PERFORM DISPLAY SPACES. *> Additional demonstrations for advanced JUSTIFIED usage ADVANCED-JUSTIFIED-TECHNIQUES. DISPLAY "=== ADVANCED JUSTIFIED TECHNIQUES ===" PERFORM DEMONSTRATE-MIXED-ALIGNMENT PERFORM DEMONSTRATE-DYNAMIC-FORMATTING PERFORM DEMONSTRATE-LEGACY-INTERFACE. DEMONSTRATE-MIXED-ALIGNMENT. 01 WS-MIXED-RECORD. 05 WS-LEFT-FIELD PIC X(15). 05 WS-RIGHT-FIELD PIC X(15) JUSTIFIED. 05 WS-CENTER-FIELD PIC X(15). DISPLAY "Mixed Alignment in Records:" MOVE "LEFT" TO WS-LEFT-FIELD MOVE "RIGHT" TO WS-RIGHT-FIELD MOVE "CENTER" TO WS-CENTER-FIELD DISPLAY "Left : '" WS-LEFT-FIELD "'" DISPLAY "Right : '" WS-RIGHT-FIELD "'" DISPLAY "Center: '" WS-CENTER-FIELD "'" DISPLAY SPACES. DEMONSTRATE-DYNAMIC-FORMATTING. 01 WS-FORMAT-FIELDS. 05 WS-DYNAMIC-FIELD PIC X(20) JUSTIFIED. 05 WS-INPUT-DATA PIC X(50). 05 WS-PROCESSED-DATA PIC X(20). DISPLAY "Dynamic Content Formatting:" MOVE "Short" TO WS-DYNAMIC-FIELD DISPLAY "Content: '" WS-DYNAMIC-FIELD "'" MOVE "Medium Length" TO WS-DYNAMIC-FIELD DISPLAY "Content: '" WS-DYNAMIC-FIELD "'" MOVE "Very Long Content Text" TO WS-DYNAMIC-FIELD DISPLAY "Content: '" WS-DYNAMIC-FIELD "'" DISPLAY SPACES. DEMONSTRATE-LEGACY-INTERFACE. 01 WS-LEGACY-RECORD. 05 WS-LEGACY-ID PIC X(8) JUSTIFIED. 05 WS-LEGACY-NAME PIC X(25) JUSTIFIED. 05 WS-LEGACY-CODE PIC X(6) JUSTIFIED. DISPLAY "Legacy System Interface:" MOVE "12345" TO WS-LEGACY-ID MOVE "CUSTOMER NAME" TO WS-LEGACY-NAME MOVE "ABC" TO WS-LEGACY-CODE DISPLAY "Legacy Format:" DISPLAY "ID : '" WS-LEGACY-ID "'" DISPLAY "Name: '" WS-LEGACY-NAME "'" DISPLAY "Code: '" WS-LEGACY-CODE "'" DISPLAY SPACES. FORMATTING-BEST-PRACTICES. DISPLAY "=== FORMATTING BEST PRACTICES ===" *> Demonstrate proper field sizing 01 WS-PROPER-SIZING. 05 WS-SHORT-FIELD PIC X(10) JUSTIFIED. 05 WS-MEDIUM-FIELD PIC X(20) JUSTIFIED. 05 WS-LONG-FIELD PIC X(40) JUSTIFIED. DISPLAY "Field Sizing Guidelines:" MOVE "ABC" TO WS-SHORT-FIELD MOVE "MEDIUM CONTENT" TO WS-MEDIUM-FIELD MOVE "THIS IS A LONGER FIELD WITH MORE CONTENT" TO WS-LONG-FIELD DISPLAY "Short : '" WS-SHORT-FIELD "'" DISPLAY "Medium: '" WS-MEDIUM-FIELD "'" DISPLAY "Long : '" WS-LONG-FIELD "'" *> Demonstrate consistent formatting DISPLAY SPACES DISPLAY "Consistent Report Formatting:" DISPLAY "==============================" MOVE "REPORT TITLE" TO WS-REPORT-TITLE MOVE "Page 1 of 10" TO WS-PAGE-NUMBER MOVE "Generated 12/31/2024" TO WS-DATE-STAMP DISPLAY WS-REPORT-TITLE DISPLAY WS-PAGE-NUMBER " " WS-DATE-STAMP DISPLAY "==============================" DISPLAY SPACES. COMMON-PITFALLS-AND-SOLUTIONS. DISPLAY "=== COMMON PITFALLS AND SOLUTIONS ===" *> Demonstrate truncation issues 01 WS-TRUNCATION-DEMO. 05 WS-SHORT-JUSTIFIED PIC X(8) JUSTIFIED. 05 WS-LONG-SOURCE PIC X(20) VALUE "VERY LONG TEXT STRING". DISPLAY "Truncation Demonstration:" MOVE WS-LONG-SOURCE TO WS-SHORT-JUSTIFIED DISPLAY "Original: '" WS-LONG-SOURCE "'" DISPLAY "Result : '" WS-SHORT-JUSTIFIED "'" *> Demonstrate spacing issues 01 WS-SPACING-DEMO. 05 WS-SPACED-FIELD PIC X(15) JUSTIFIED. DISPLAY SPACES DISPLAY "Spacing Considerations:" MOVE "A B C" TO WS-SPACED-FIELD DISPLAY "Spaced Text: '" WS-SPACED-FIELD "'" MOVE " LEADING SPACE" TO WS-SPACED-FIELD DISPLAY "Leading Spc: '" WS-SPACED-FIELD "'" MOVE "TRAILING SPACE " TO WS-SPACED-FIELD DISPLAY "Trailing Sp: '" WS-SPACED-FIELD "'" DISPLAY SPACES.

JUSTIFIED Characteristics

Alignment Behavior
  • • Right-alignment for alphanumeric data
  • • Leading spaces for shorter values
  • • Truncation from left for longer values
  • • Preserves trailing spaces in source
Usage Restrictions
  • • Only for alphanumeric (PIC X) fields
  • • Not applicable to numeric fields
  • • Cannot be used with group items
  • • Elementary items only

Interactive Tutorial

Hands-On Exercise: Report Formatting
Practice using JUSTIFIED for professional report layouts

Exercise 1: Employee Report Header

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
01 REPORT-LAYOUT. 05 WS-COMPANY-NAME PIC X(40) JUSTIFIED. 05 WS-REPORT-NAME PIC X(30) JUSTIFIED. 05 WS-PAGE-INFO PIC X(15) JUSTIFIED. 05 WS-DATE-INFO PIC X(12) JUSTIFIED. PROCEDURE DIVISION. PRINT-HEADER. MOVE "ACME CORPORATION" TO WS-COMPANY-NAME MOVE "EMPLOYEE LISTING" TO WS-REPORT-NAME MOVE "Page 1 of 5" TO WS-PAGE-INFO MOVE "12/31/2024" TO WS-DATE-INFO DISPLAY "==========================================" DISPLAY WS-COMPANY-NAME DISPLAY WS-REPORT-NAME DISPLAY WS-PAGE-INFO " " WS-DATE-INFO DISPLAY "==========================================" .

Exercise 2: Invoice Detail Formatting

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
01 INVOICE-LAYOUT. 05 WS-ITEM-CODE PIC X(10) JUSTIFIED. 05 WS-DESCRIPTION PIC X(25). 05 WS-QUANTITY PIC X(8) JUSTIFIED. 05 WS-UNIT-PRICE PIC X(10) JUSTIFIED. 05 WS-TOTAL-AMOUNT PIC X(12) JUSTIFIED. PROCEDURE DIVISION. FORMAT-INVOICE-LINE. MOVE "ABC123" TO WS-ITEM-CODE MOVE "Premium Widget Set" TO WS-DESCRIPTION MOVE "5" TO WS-QUANTITY MOVE "$49.99" TO WS-UNIT-PRICE MOVE "$249.95" TO WS-TOTAL-AMOUNT DISPLAY WS-ITEM-CODE " | " WS-DESCRIPTION " | " WS-QUANTITY " | " WS-UNIT-PRICE " | " WS-TOTAL-AMOUNT .

Best Practices

Common Use Cases

Report Headers
cobol
1
2
3
4
01 HEADER-FIELDS. 05 WS-TITLE PIC X(30) JUSTIFIED. 05 WS-PAGE PIC X(10) JUSTIFIED. 05 WS-DATE PIC X(12) JUSTIFIED.
Account Numbers
cobol
1
2
3
4
01 ACCOUNT-FIELDS. 05 WS-ACCOUNT-NUM PIC X(15) JUSTIFIED. 05 WS-ROUTING-NUM PIC X(12) JUSTIFIED. 05 WS-CHECK-NUM PIC X(8) JUSTIFIED.

Knowledge Check

Test Your Understanding

Question 1: Basic Concept

What does JUSTIFIED do to alphanumeric data?

Answer: JUSTIFIED right-aligns alphanumeric data within the field. If the data is shorter than the field, leading spaces are added. If longer, data is truncated from the left.

Question 2: Field Types

Can JUSTIFIED be used with numeric fields?

Answer: No, JUSTIFIED can only be used with alphanumeric (PIC X) fields. It cannot be applied to numeric fields, group items, or other data types.

Question 3: Synonyms

Is there a shorter form of JUSTIFIED?

Answer: Yes, JUST is the abbreviated form of JUSTIFIED. Both keywords are functionally identical and can be used interchangeably.

Related Pages