×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

field change

field change

field change

(OP)
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,

RE: field change

Do you mean in existing files? Are these files Indexed, and if so, is the account number part of the key?  Is the account number wholly numeric?

RE: field change

And...operating system, compiler vendor?

Tom Morrison

RE: field change

(OP)
ya for existing files , ya they r indexed files and primary key is index and the operating system is mvs  

RE: field change

If the account number is numeric, you can convert it to Packed Decimal (Comp-3) for an increase to 11 digits.  If the account number consists of letters and digits, you can use a simple compression algorithm to store 8 characters in 6 bytes.  Beyond that, I can't think of any way other than to write a conversion program to copy the file and expand the keys.  If it were not the key, the precaution of always defining a record layout with extra filler bytes would have solved the problem.   

RE: field change

(OP)
hi webrabbit, thanks for giving the answer , but i want to learn more about field changes in cobol. it will be helpful to me if u suggest some link where i can get the whole information abt field change and different types of record length files

                                                   thanks

RE: field change

In COBOL, field changes generally require 1) Changing all the programs that access the file, and 2) A conversion program to read the old format and write the new format.  Even if the data can be compressed as in the examples I gave above, all programs that access the fields must be changed.  In that case though, you can avoid the conversion program if you code an algorithm to detect whether the field is compressed or non-compressed.  For replacing a Display with a Packed-Decimal, IF NUMERIC will suffice.  None-the-less, not converting all records may turn out to be unworkable.

Years ago, I maintained a payroll system where the basic code was from a vendor.  Every few years, gonvernment mandated changes required field changes.  Also, IRS requires that payroll end-of-year files be archived for seven years.  This meant that either the old system had also to be archived, or the archived files retrieved, converted, and re-archived.  The latter was what we always did.

RE: field change

(OP)
hi webrabbit, thats a great answet, cool explanation..........i'd be happy if u can post some code where u have done fieldchanges....ill be greatful to u if u can do so

RE: field change

Ok.  Here's the program.

CODE

 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.

RE: field change

(OP)
Thanks Jack, so nice of u.....I  really love mainframes , i worked hard to enhance my techncal skills, right now im in a pursuit of a job, im able to clear technical questions, but when they r giving me some real time situations im unable to give them right answers, im finding quite a difficulty in clearing especially team lead rouns, s they r asking me all time real quesstions, i want to master this technolgy, i want to be a cobol coder.....i know cobol, but i want to be in top 10 cobol coders of the world, plzz guide me, where i can get the complete notes of cobol,so that i cud learn A TO Z IN cobol.......i will ask u simpl question, but i dunno the perfect sloution for this , can u plzzz answer

 there are 2 files

1st file has      2nd file has


acnt 101            annt 102 acnt name
acnt 103            acnt 104  acnt name
acnt 106            acnt 105  acnt name
acnt 109            acnt 108  acnt name


now what we have to do is compare both files and write the files and write them to another file which file1 and file 2 doesnt have


                                        thanks & regards






























































































































































































































acnt 110




                                            thanks & regards

RE: field change

Quote (666satan):


... i want to be in top 10 cobol coders of the world ...
LOL
lol

RE: field change

This is a simple two-file match.  In psuedo code (COBOL is very close to psuedo code, that's why I like it):

Read file 1
Read file 2
Loop Until both files are at end
    Compare keys (a file that is at end is always high)
    If file 1 is low
        Process for mismatch on file 1
        Fead file 1
        Return to beginning of loop
    End If
    If file 2 is low
         Process for mismatch on file 2
         Read file 2
         Return to beginning of loop
     End If
     Process for a match
     Read file 1
     Read file 2
     Return to beginnin of loop
End loop
 

RE: field change

(OP)
thanks alot jack, i have one more doubt, can a squential file be converted to vsam file and vice-vers. post the code also and some more codes on tables and how r they searched using subscript and index......can redfines clause can be used with occurs clause?

RE: field change

To convert the format of a file, simply write a program to read the old format and write the new format.  On the mainframe, there are also a number of untilities than can be used.  Using SORT with a FIELDS=COPY control card is one.  Note that to create a VSAM file you must first define it with a utility program, I seem to recall that its name is IDECAMS.

On searching a table, you can use the SEARCH verb or the PERFORM verb.  

SEARCH requires an index.  By default, the first or only index defined for the table is used, but if there are multiple indices defined for the table, you can use the VARYING clause to select other than the first.

There are two forms of the SEARCH verb:  The sequential search and the binary search.  To invoke the binary search use the keyword ALL immediatly after the verb SEARCH.  The table must be defined with the ASCENDING/DECENDING KEY syntax.  If the keys are not in the proper order, the results are unpredictable.

For a sequential search (no ALL), the index must be intitialized prior to the SEARCH.  The index is incremented after each SEARCH cydle, but the logic is internal and otherwise need not concern the programmer.  The syntax is

CODE

SEARCH table_name [VARYING index_name]
    [AT END action . . .]
    {WHEN condition action . . .} . . .
END-SEARCH
The AT END code is invoked if none of the WHEN conditions are satisfied before the index is incremented to be greater than the number of occurances defined for the table.

To search a table using PERFORM the syntax is as follows:

CODE

PERFORM VARYING index/subscript FROM initial_value BY increment UNTIL end_condition
     CONTINUE/statements . . .
END-PERFORM
Note that the interior of the PERFORM may be null (consist of the null verb CONTINUE only).  Also, the end_condition need not reference the table at all.  This is the only way to search a table backwards, by specifying an initial_value equal to the occurance of the table and a negative (usually -1) as the increment.  Using the PERFORM verb, the incrementing and end_conditions must be coded explicity, unlike with the SEARCH verb where they are implicit.

RE: field change

(OP)
ohhh great, thanks jack, r u familiar with only cobol , do u know jcl, db2 ,vsam  too? 2 more questions, can redefines clause  be used with occurs clause, can we use internal sort to compare two files in cobol? and one more query is , what r the general changes that a progammer  can make in cobol+db2 program ?

RE: field change

I used JCL up until '83.  VSAM too.  Never used DB2.  I know there's been changes in the last 25 years.

REDEFINES can be used with OCCURS but I think it's too confusing, I always split it up:

CODE

05  REDEFINES A.
    10  B PIC X(nn) OCCURS mm TIMES.
  
If one of the files is already in the sequence you need, yes, but you cannot have two internal sorts active at the same time.  In the OUTPUT PROCEDURE, replace one of the READs with the RETURN.
 

RE: field change

(OP)
hi jack, thanks for giving answers to all my questions....what are cntrol cards in jcl, and why they are3 used? explain me with some code?

RE: field change

Although control cards are ususally included in the JCL stream, they are not JCL.  They would follow a // DD * JCL statemnt, although they also might exist in a data set, usually a member of a library (PDS).  They are application-specific parameter statements.

For the external Sort program, they include definition of sort keys, summarization data, and other parameters.

RE: field change

(OP)
thanks jack, jack one real time question, how we will get the work assigned in mainframes, i mean client request , and do u know anything abt banking project, i mean to say how we will have the access of files, give me a clear description of a banking project,



                                      thanks & regards

RE: field change

Sorry, that's not in my experience.

RE: field change

(OP)
its ok jack, jack tell me some website where i can get the clear notes of cobol , i need everything abt cobol, how shud i develop my programming skills ,plzzz guide me, i want to know abt fujitsu cobol, its cobol with asp.net right?....tell em what how many types of cobols we have...

RE: field change

The best COBOL learning tool I know of is "Teach Yourself COBOL in 21 Days" by Budlong published by SAMS Publishing.  It comes with an old DOS-based COBOL development system that works fine under Windows XP, just doesn't support Windows functions.  I believe the CD even has sample code.

RE: field change

(OP)
hey jack , i have interview in .net with cobol that is fujitsu cobol....can u guide me?

RE: field change

Fujitso COBOL runs on PCs under Windows, perhaps Linix too. I have a copy that's a little over a year old.  I would attach it but its almost half a gig.  You can download it from their websid.  It includes training videos.

RE: field change

(OP)
thanks jack, whats the url of the site, plzz post it.........is there any difference between cobol2 and fujitsu cobol....is vb.net is  used in fujitsu cobol....is there any difference in programming perspective  

RE: field change

Satan,

Are you really going to interview for a COBOL job without knowing anything about COBOL? That is a huge task. You will have to learn from the ground up. The book webrabbit suggested, "Teach Yourself COBOL in 21 Days", would be a good place to start but you may not be conversant enough in COBOL for an interview.

I would suggest taking a COBOL course at a technical school, too.

Here's a link to COBOL site with many links on it. it's a COBOL user's group and it may help you.

http://www.cobug.com/

You have a long road ahead of you. Good luck. cat2
 

RE: field change

(OP)
Thanks Jack, Im good in Vs Cobol2 , but i have never worked with fujitsu cobol.....and the company in which i have interview next week, they are looking guys who r good in cobol and they will put us in a project where we need to work in fujitsu cobol.....i will have a client round some time next week ....the interview will be on little bit in ASP.NET, COBOL and in dtatbases like db2, oracle.....i worked on db2, i have to brush up oracle,asp.net , and fujitsu cobol......yeah ur right very hard task ahead of me, what u suggest shud i go for this or continue with mainframes where i worked in for 3 yrs

RE: field change

COBOL2 just means the latest version.  Includes lots of new verbs and such that make programming easier.  Fujitsu COBOL is mostly compatible.  Micro Focus .NET COBOL is 100% compatible but very expensive.

The COBOL I started with (in '68) didn't even have END-IF.

RE: field change

I guess COBOL 2 or COBOL II means the COBOL 85 standard.

Both Compilers Micro Focus NetExpress with .NET and Fujitsu NetCOBOL for .NET are Object Oriented enhancements of COBOL, but the OOP enhancements are incompatible with each other.

I have no experience with no one of both, but IMHO using one of these for development is not without complications. You have to learn vendor specific OOP enhancements, how to work with classes and bbject references, vendor specific tricks, you have to solve vendor specific compiler issues.
The OOP enhancements are very verbosely and I doubt that you can do with one of these OO-COBOL compilers everything, what can be done with fully OOP languages such as Java or C#, and when, then this would require incomparably more programming effort as doing the same in Java or C#.

IMHO the better choice is rather to learn OOP with Java or C# then with OO-COBOL.

   

RE: field change

(OP)
thanks jack for ur sugestions,,,

RE: field change

(OP)
thnks mikrom for ur suugestions, but what is IMHO......? tell me in detail

RE: field change

RE: field change

(OP)
oops "imho".........i got it

RE: field change

(OP)
hey jack wassup...........whatz new in cobol?

RE: field change

New since when?  COBOL has been updated many times since it was invented in the 50's.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close