IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Using variable length, character-delimited input files


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 3156
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 1:42 am
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: 3156
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 2:40 am
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

Moderator Emeritus


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

PostPosted: Thu Jan 11, 2007 7:13 am
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
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: 3156
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 7:42 pm
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

Moderator Emeritus


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

PostPosted: Thu Jan 11, 2007 8:49 pm
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: 3156
Location: Tucson AZ

PostPosted: Thu Jan 11, 2007 10:41 pm
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

Moderator Emeritus


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

PostPosted: Thu Jan 11, 2007 11:07 pm
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
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: 3156
Location: Tucson AZ

PostPosted: Wed Jan 17, 2007 2:39 pm
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

Moderator Emeritus


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

PostPosted: Wed Jan 17, 2007 8:12 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts COBOL sorting, with input GDG base COBOL Programming 7
No new posts 3 files concatenated to 1 DFSORT/ICETOOL 2
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts Concatenate 2 input datasets and give... JCL & VSAM 2
Search our Forums:

Back to Top