Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Using variable length, character-delimited input files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Jo Peterson

New User


Joined: 10 Jan 2007
Posts: 2
Location: New Jersey

PostPosted: Thu Jan 11, 2007 12:41 am    Post subject: Using variable length, character-delimited input files
Reply with quote

I am getting a variable length asterisk-delimited file from a vendor that does not deal with the mainframe through my client. It is not the normal variable length file that we see in COBOL - fixed fields with a variable table occurring 1 to many times at the end. This file is completely variable with asterisk delimiters - no maximum record length. He created it this way so the FTP would work more efficiently. We are dealing with 4 million records. I was looking at the Inspect and Unstring statement in the COBOL manual and it seem to say you need a fixed record length with variable length fields within it. Don't I need a maximum record length for use in the JCL and in unstringing the data in COBOL? Is there another way to do this? I haven't coding extensive in COBOL in a couple of years. I need the info in case my client needs to tell the vendor to go back to making two files using fixed length data.

Thanks Jo
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 1:42 am    Post subject:
Reply with quote

Jo,

You can read the file defined as "U", undefined (I think the file's declared max length has to match the FD's).
If the records are (in effect) unblocked, you should be able to scan across the record inspecting, unstringing, by reference modification and indexing/subscripting without any real trouble.
I had a vaguely similar situation and grew to love the unstring verb, with its counter and pointer functions and the use of linkage areas and the set pointer and set address.

Sounds like a fun challenge....

Bill
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 2:40 am    Post subject:
Reply with quote

Jo,

Quote:
I have only used unstring statement with one field like an address or name not using counter or pointer or linkage area. So I still have to ask for the maximum record length or just the maximum field length?
If you can get the record read, just start at the beginning and do it. If some of the structure is defined, set the address of an 01 (in linkage) with that structure to where you discover it in the record.
Scan along with RM until you get to data that you can "dsect" in linkage.

But judging from your circumstance, maybe getting it put (back?) to a more conventional format would be your best bet.

Bill
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jan 11, 2007 7:13 am    Post subject:
Reply with quote

Hello,

Do you have a record definition of this input? Once the file is ftp'd to your mainframe, you'll want to find the dcb information. You'll also want to if these records are terminated with a cr or cr/lf (carriage return - line feed).

While the overall record length may be unpredictable, the order of the fields should be predictable (and hopefully, some rules on the maximum size of each field). If they just sent you some undefined "stuff" it could get ugly. An early thing to do is to make sure the content is as expected. Also, we'll hope for no embedded asterisks in the data . . .

Will this file be sent to you periodically or is this a one-time exercise? If it is one-time, there may be alternatives that would not be satisfactory for regular processing that would suffice. Might also help with downstream testing of the converted data while the "real" solution is being implemented.

Let us know what you find out and more info will be sent to you.

.
Back to top
View user's profile Send private message
Jo Peterson

New User


Joined: 10 Jan 2007
Posts: 2
Location: New Jersey

PostPosted: Thu Jan 11, 2007 7:01 pm    Post subject: variable length delimited file
Reply with quote

Dick,
This is not a one-time process. It will be done 12+ times a year. I do have a layout of the data. Found people here that have worked with variable files. They say to find the biggest field and multiply it times the number of fields to get the maximum record length. Someone will then write a COBOL II program with a huge unstring statement to unstring each field into the largest field length area then move each to its correct length.
Example : max record length 100. Unstring date (8) into 100 byte date field then move to final 8 byte date field.

My only question is how to define the JCL output DD in the FTP step and the input FD in the program.

Thanks Jo
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 7:42 pm    Post subject: Re: variable length delimited file
Reply with quote

Jo,

Sounds like better news than you had the other day.... icon_smile.gif
Jo Peterson wrote:
My only question is how to define the JCL output DD in the FTP step and the input FD in the program.
Unless the file is VB, I still think you are stuck with U.....Since your FTP is defining it, it shouldn't be a problem to read it, just define the max lrecl the same.

Bill
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jan 11, 2007 8:49 pm    Post subject:
Reply with quote

Hello,

If there some existing JCL that ftp's similar data from the same source, i suggest looking at that and (other than lrecl) use the same ftp commands as well as the output DD ststement.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 10:41 pm    Post subject:
Reply with quote

Jo Peterson wrote:
Do you mean that if the max length is 9000 , for example, the lrecl and blksize on the output in the FTP step are both 9000 and recfm is U? And in the program's FD?:

FD IN-REC
LABEL RECORDS ARE STANDARD
RECORD CONTAINS 9000 CHARACTERS
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS U.
That is my understanding...I recall Bill Klein mention that the max length has to match exactly.....
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jan 11, 2007 11:07 pm    Post subject:
Reply with quote

Hello,

If you can run the ftp on the mainframe to create this file, you can look at the file specification in TSO 3.4 and code your FD accordingly.
Back to top
View user's profile Send private message
vmutyalapalli

New User


Joined: 09 Jun 2005
Posts: 5
Location: India

PostPosted: Wed Jan 17, 2007 2:19 pm    Post subject: Unstring a part of the string using reference modification
Reply with quote

Hi,

Can we unstring a part of the record as follows using refrence modification:

Working-storage Section.

01 Record Pic x(40).

Unstring Record(1:20)
into
R1, R2, R3

I tried with this. It is saying illegal operand in unstring. Can I know is there is restrictions that we cannot use like above or are there any version restrictions??? I am using cobol 74

Thanks in Advance
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Jan 17, 2007 2:39 pm    Post subject: Re: Unstring a part of the string using reference modificati
Reply with quote

vmutyalapalli wrote:
Unstring Record(1:20)
into
R1, R2, R3
I tried with this. It is saying illegal operand in unstring. Can I know is there is restrictions that we cannot use like above or are there any version restrictions??? I am using cobol 74
Is reference modification allowed in that COBOL? Delimited by?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jan 17, 2007 8:12 pm    Post subject:
Reply with quote

Hello,

If you want to unstring the first 20 bytes of "Record", redefined it and name the first 20 bytes - like
Code:
01 Record pic x(40).
01 Rec-20 redefines Record.
    05 first-20    pic x(20).
    05 filler      pic x(20).


Change your "unstring" to use first-20.

As Bill mentioned, remember to include the "delimited by" (you can usually use the "\" when you actually have no delimiter and just want to split the data into multiple fields - of course, if there is no delimiter, a more detailed redefines would work as well). . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Need input in Scheduling Benchwarmer CA Products 5 Tue Jun 06, 2017 1:44 am
No new posts getting three output files out of JOI... migusd SYNCSORT 7 Mon Jun 05, 2017 11:30 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us