Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:13:19+00:00 2026-06-17T23:13:19+00:00

How I can read a .dat file with struct like that: ( A =

  • 0

How I can read a .dat file with struct like that: ( A = ALPHANUMERIC && N = NUMERIC )

0AAAAAAAANNNN (233 BLANK SPACES ) 999999 ( SEQUENTIAL NUMBER ONE BY ONE )
1NNNNNNNNNNNNAAAAAAAAAAAAAAAAAAA (194 BLANK SPACES) 999999 (SEQUENTIAL NUMBER ONE BY ONE)
2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA (194 BLANK SPACES) 999999 (SEQUENTIAL NUMBER ONE BY ONE)
1NNNNNNNNNNNNAAAAAAAAAAAAAAAAAAA (194 BLANK SPACES) 999999 (SEQUENTIAL NUMBER ONE BY ONE)
2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA (194 BLANK SPACES) 999999 (SEQUENTIAL NUMBER ONE BY ONE)
1NNNNNNNNNNNNAAAAAAAAAAAAAAAAAAA (194 BLANK SPACES) 999999 (SEQUENTIAL NUMBER ONE BY ONE)
2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA (194 BLANK SPACES) 999999 (SEQUENTIAL NUMBER ONE BY ONE)
1NNNNNNNNNNNNAAAAAAAAAAAAAAAAAAA (194 BLANK SPACES) 999999 (SEQUENTIAL NUMBER ONE BY ONE)
2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA (194 BLANK SPACES) 999999 (SEQUENTIAL NUMBER ONE BY ONE)
9 (245 BLANK SPACES) 999999 (SEQUENTIAL NUMBER ONE BY ONE)

So, I know, how I can make a program to read this in C/C++ or in C#, but, I try to make in Cobol, just for study….

But, I don’t know what the command I need to use to open the file with this style ( I just know the:

ORGANIZATION IS LINE SEQUENTIAL.

I think, exist a another command to open with custon instructions… i don’t know…
So, btw, how I can open the file and read the informations ??

( i just need to read the line 1 on time, and, I need to read the line 2 and 3 always paried … 4 and 5 && 6 and 7 && 8 and 9 … )
and, I whant to show that information with DISPLAY ( just for study )
Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:13:21+00:00Added an answer on June 17, 2026 at 11:13 pm

    Something like this below your FD:

    01  INPUT-RECORD.
        05  IR-RECORD-TYPE PIC X.
            88  INPUT-RECORD-IS-HEADER VALUE '0'.
            88  INPUT-RECORD-IS-DATA1 VALUE '1'.
            88  INPUT-RECORD-IS-DATA2 VALUE '2'.
            88  INPUT-RECORD-IS-TRAILER VALUE '9'.
        05  FILLER PIC X(whatever).
    

    You may need a “trailing” byte for a record-delimiter, I don’t know, and you’ll have to sort out the lengths, as they seem to vary.

    These in Working-Storage:

    01  INPUT-RECORD-HEADER.
        05  IRH-RECORD-TYPE PIC X.
        05  IRH-ITEM1 PIC X(8).
        05  IRH-ITEM2 PIC 9(4).
        05  FILLER PIC X(233).
        05  IRH-SEQUENCE PIC X(6)
    01  INPUT-RECORD-DATA1.
        05  IRD1-RECORD-TYPE PIC X.
        05  IRD1-ITEM1 PIC 9(14).
        05  IRD1-ITEM1 PIC X(19).
        05  FILLER PIC X(194).
        05  IRD1-SEQUENCE PIC X(6)
    01  INPUT-RECORD-DATA2.
        05  IRD2-RECORD-TYPE PIC X.
        05  IRD2-ITEM1 PIC X(33).
        05  FILLER PIC X(194).
        05  IRD2-SEQUENCE PIC X(6)
    01  INPUT-RECORD-TRAILER.
        05  IRT-RECORD-TYPE PIC X.
        05  FILLER PIC X(245).
        05  IRT-SEQUENCE PIC X(6).
    

    You have to read each record, one at a time. Identify it. Put it in the correct W-S definition. When you read a “2” you can process the “1” you have stored along with the “2”.

    My datanames aren’t very good, as I don’t know what your data is. Also I have not “formatted” the definitions, which will make them more readable when you do it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tab-delimited DAT file that I want to read into R. When
I need to read a .dat file which looks like this: Atask1 Atask2 Atask3
I can read settings like this, for example: final String mytest = System.getString(this.getContentResolver(), System.AIRPLANE_MODE_ON);
I can read XLS file with this code : string path =@c:\r\1.xlsx; OleDbConnection MyConnection
In main I can read my config file, and supply it as runReader (somefunc)
how to make php can read log file in /var/log/.... I tried this code
I'm going crazy, I created a file object, so it can be read with
I am reading in data in the following format: {ok,Volts} = file:open(voltage1.dat,read). In the
I can't really read PHP but I'm trying to upload a csv file in
I have a file called points.dat which reads something like: 5 2 5 -1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.