666satan
Programmer
- Jan 1, 2009
- 18
hi guys, i have a small doubt can we increase the size of a field say i wa nt to increase the size of account no is of 6 bytes to 8bytes in both fixed length records and also variable length records,
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Identification Division.
Program-ID. JCTBL01.
Author. James C. Fairfield
Installation. JackRabbit Computer Systems
Date-Written. 12/30/2007
*>
*> Convert Brand, Class, Color and Department Tables.
*>
*> Table Number is always numeric and is converted from two bytes display
*> to two digits packed decimal (1 byte).
*>
*> Table Entry is two bytes display and is converted to four digits (two
*> bytes) packed decimal through a conversion routine.
*>
*> Desciption is expanded from 14 bytes to 30 bytes.
*>
*> An alternate key is added to enable a table search by Description.
*> As the definition for this key does not support duplicates, this
*> ensures against the addition of multiple codes for the same Description.
*>
Environment Division.
Input-Output Section.
File-Control.
Select MEW-TABLE-FILE
Assign to Dynamic NEW-TABLE-FILE-NAME
File Status is FILE-STATUS
Record Key is T01-KEY
Alternate Key is T01-KEY-1 = T01-NBR T01-DESCRIPTION
Access Mode is Sequential
Organization is Indexed
.
Select OLD-TABLE-FILE
Assign to Dynamic OLD-TABLE-FILE-NAME
Organization is Indexed
Access Mode is Dynamic
Lock Mode is Manual
Record Key is RECORD-KEY
File Status is FILE-STATUS
.
Data Division.
File Section.
FD OLD-TABLE-FILE.
01 TBL01-RECORD.
05 TBL01-KEY.
10 TBL01-NBR Pic X(02).
88 TBL01-BRAND Value '03'.
88 TBL01-CLASS Value '04'.
88 TBL01-COLOR Value '05'.
88 TBL01-DEPT Value '06'.
10 TBL01-ENTRY Pic X(02).
05 TBL01-DATA Pic X(60).
FD NEW-TABLE-FILE.
01 T01-RECORD.
05 T01-KEY.
10 T01-NBR Pic 9(02) Comp-6.
88 T01-BRAND Value 1.
88 T01-LOCATION Value 2.
88 T01-COLOR Value 3.
88 T01-DEPT Value 4.
10 T01-CODE Pic 9(04) Comp-6.
05 T01-DESCRIPTION Pic X(30).
Data Division.
Working-Storage Section.
77 CR2009 Pic X(64) Value 'Copyright 2009 by James C. Fairfield all rights reserved.'.
78 PROGRAM-NAME Value 'JCTBL01v2'.
01 FILE-STATUS Pic X(02).
01 CODE-CONVERSION-DATA.
05 CC-ALPHA-CODE Pic X(02).
05 redefines CC-ALPHA-CODE.
10 CC-ALPHA-CODE-1 Pic X(01) Comp-X.
10 CC-ALPHA-CODE-2 Pic X(01) Comp-X.
05 redefines CC-ALPHA-CODE.
10 CC-DEPARTMENT Pic 9(02).
05 CC-NUMERIC-CODE Pic 9(04) Comp-6.
05 redefines CC-NUMERIC-CODE.
10 CC-NUMERIC-CODE-1 Pic 9(02) Comp-6.
10 CC-NUMERIC-CODE-2 Pic 9(02) Comp-6.
78 CONVERSION-OFFSET Value 32.
01 NEW-TABLE-FILE-NAME Pic X(13) Value 'TBL01.ISM'.
01 OLD-TABLE-FILE-NAME Pic X(13) Value 'TABLE1.DAT'.
01.
05 WS-TBL-NBR Pic 9(02) Value Zero.
05 WS-DEPT Pic 9(02).
05 WS-T01-NBR Pic 9(02) Value Zero Comp-6.
05 WS-ENTRY-NBR Pic 9(04) Value Zero Comp-6.
05 IN-CNT Pic 9(06) Value Zero.
05 OUT-CNT Pic 9(06) Value Zero.
01 CNT-TABLE.
05 Pic X(18) Value '000000 Brands'.
05 Pic X(18) Value '000000 Locations'.
05 Pic X(18) Value '000000 Colors'.
05 Pic X(18) Value '000000 Departments'.
01 redefines CNT-TABLE.
05 CT-ENTRY occurs 4 times.
10 CT-CNT Pic 9(06).
10 Pic X(12).
Procedure Division.
000-START.
Display Space upon CRT
Display PROGRAM-NAME
Open Input OLD-TABLE-FILE
Open Output NEW-TABLE-FILE
Perform 100-CONVERT
Close OLD-TABLE-FILE
Close NEW-TABLE-FILE
Display IN-CNT ' Records in'
Display OUT-CNT ' Records out'
Display CT-ENTRY(1)
Display CT-ENTRY(2)
Display CT-ENTRY(3)
Display CT-ENTRY(4)
Stop Run
.
100-CONVERT.
Perform Until Exit
Read OLD-FILE-TABLE
If FILE-STATUS >= '10'
Exit Perform
Add 1 to IN-CNT
If TBL01-NBR < '03' or > '06'
or TBL01-NBR = '04' and TBL01-ENTRY = 'NA'
or TBL01-NBR = '05' and TBL01-ENTRY(1:1) = 'N'
and (TBL01-ENTRY(2:1) = 'A' or >= '1' and <= '9')
Exit Perform Cycle
End-If
If TBL01-NBR not = WS-TBL-NBR
Move Zero to WS-ENTRY-NBR
Move TBL01-NBR to WS-TBL-NBR
Move WS-TBL-NBR to WS-T01-NBR
Subtract 2 from WS-T01-NBR
End-If
Move WS-T01-NBR to T01-NBR
Move TBL01-ENTRY to CC-ALPHA-CODE
Evaluate T01-NBR
When 1
When 2
Perform CONVERT-CODE-TO-NUMERIC
Move CC-NUMERIC-CODE to T01-CODE
When 3
Add 1 to WS-ENTRY-NBR
Move WS-ENTRY-NBR to T01-CODE
When 4
Move CC-DEPARTMENT to T01-CODE
End-Evaluate
Move TBL01-DATA(1:14) to T01-DESCRIPTION
Write T01-RECORD
Add 1 to OUT-CNT
Add 1 to CT-CNT(WS-T01-NBR)
End-Perform
.
CONVERT-CODE-TO-NUMERIC.
Compute CC-NUMERIC-CODE-1 = CC-ALPHA-CODE-1 - CONVERSION-OFFSET
Compute CC-NUMERIC-CODE-2 = CC-ALPHA-CODE-2 - CONVERSION-OFFSET
.
CONVERT-CODE-TO-ALPHA.
Compute CC-ALPHA-CODE-1 = CC-NUMERIC-CODE-1 + CONVERSION-OFFSET
Compute CC-ALPHA-CODE-2 = CC-NUMERIC-CODE-2 + CONVERSION-OFFSET
.
Notes: Comp-6 is similar to Comp-3, except there is no sign nibble if there
is no "S" in the Picture. This makes it ideal for storing non-signed
numeric data such as dates. In this case, the month number and day
number each consist of one byte with both digits in that byte.
Even though the input file has 60 bytes allotted for the description
(TBL01-DATA), only 14 bytes are used. The output file will use all
30 bytes.
TBL01-ENTRY is numeric for Departments. As the department number is
often as meaningful to the user as the department name, this number
is retained during the conversion. This field consists of letters and
digits for the other tables. As the equivalent field in the output is
strictly numeric, each character is expanded to a two-digit value
computed from the ascii code for that character.
Although the original program had extensive file error checking code,
this code was removed for clearity.
LOL666satan said:... i want to be in top 10 cobol coders of the world ...
SEARCH table_name [VARYING index_name]
[AT END action . . .]
{WHEN condition action . . .} . . .
END-SEARCH
PERFORM VARYING index/subscript FROM initial_value BY increment UNTIL end_condition
CONTINUE/statements . . .
END-PERFORM
05 REDEFINES A.
10 B PIC X(nn) OCCURS mm TIMES.