Thread: read cobol data files

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    3

    read cobol data files

    Hi,

    I am completely new to c programming and absolutely know nothing about it. However, I work in datastage and it accepts c code hence I have to write a program that would read cobol data files in ebcdic, COMP-3 with hex values stored in it. I would want to read and output(just print) the records in ascii.

    using a copy book read the structure and convert the data file in ebcdic to ascii with occurs and occurs depending on clauses.

    your help and time would be very much appreciated!!

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Welcome to the forum.

    I hope you're not expecting someone to start posting up code to suit your needs. The way forums like this work, is you need to show some work, and ask specific questions relative to your problems. IOW's, you need to put some "skin" into the game.

    A very small sample of challenging input data would be good to have posted up, when you post up your first question.

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Quote Originally Posted by ahmedwaseem2000 View Post
    Hi,

    I am completely new to c programming and absolutely know nothing about it. However, I work in datastage and it accepts c code hence I have to write a program that would read cobol data files in ebcdic, COMP-3 with hex values stored in it. I would want to read and output(just print) the records in ascii.

    using a copy book read the structure and convert the data file in ebcdic to ascii with occurs and occurs depending on clauses.

    your help and time would be very much appreciated!!
    I have a program that does this. I developed it for commercial purposes. I would be happy to license it to you.
    Mainframe assembler programmer by trade. C coder when I can.

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    3
    Thank you all for your replies!

    Yes, I understand the purpose of the forum I was just not sure where to start from and what all I should be considering as I have no clue at all about this.

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Until we see a sample of the data, we can't help much, in any case.

  6. #6
    Registered User
    Join Date
    May 2010
    Posts
    3
    I wouldnt be able to post the data as it is within clients network. However, here is the cobol copy book sample.

    Code:
     01 D03453.
              05  D03453-ID  PIC 9(6)V9(3) COMP-3. 
              05  D03453-NAME  PIC X(30).
              05  D03453-XC  PIC  X(1).
              05  D03453-SC  PIC S9(9) COMP-3 OCCURS 0 TO 250 TIMES
                                                                      DEPENDING ON D03453-XC.
                       10 D03453-SC-TAMT  PIC S9(9) COMP-3.
                       10 D03453-SC-TDT    PIC S9(9) COMP-3.
    I was able to find a program to convert the ebcdic data to ASCII here is the link Now I would want to learn how to unpack the packed COMP-3 decimals.

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    If that is a sample of the input, then what would be the output you want, from that input?

    A description is good, of course, but an actual sample of correct output will undoubtedly be helpful, if not essential.

    Are you confident that the data to be transformed, is similar to this sample, in data type and format? If the actual data is a completely different type of data, using a different format, then an answer for this sample, will be useless.

    See what I mean? IMO, all the little details have to be nailed down.

  8. #8
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    That's not a sample of the input, that's how the variables are declared in COBOL.

    You can see how COMP3 is stored if you google it. You've got the data; you know how it's built; that should be more than enough information to decode it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 06-15-2005, 02:38 PM
  2. read data from file
    By matth in forum C++ Programming
    Replies: 3
    Last Post: 04-21-2005, 09:37 AM
  3. C diamonds and perls :°)
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 05-16-2003, 10:19 PM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM