# Split records based on its length

Author Message
Harsha Prince

New User

Joined: 08 May 2022
Posts: 5
Location: India

 Posted: Sun May 08, 2022 11:37 pm Hi! I have an input with 4 records of different length(8 and 9) with garbage value 'b' as shown below: INPUT: Anc25 22 02 12ab 22 01 22222222bbbbb -123.65 78 Anc25 22 1 12ab 22 01 22222222bbbbb 23.65 78 Anc25 22 02 12ab 22 2 22222222bbbbb 12.65 90 Anc25 22 02 12ab 22 01 22222222bbbbb -123.65 85 My output should not contain any garbage value 'b' and the records with length 8 has to copy in one file and records with length 9 has to copy another file..I.e; Output-1: Anc25 22 02 12ab 22 01 22222222 -123.65 78 Anc25 22 01 12ab 22 01 22222222 23.65 78 Output-2: Anc25 22 02 12ab 22 02 222222222 12.65 90 Anc25 22 02 12ab 22 01 222222222 -123.65 85 Rules: --> 3rd and 6th column should contain only data between 01 to 12 and should contain only two digits(if one digit present a zero is added in front of it) --> For 8th column the pic clause has to be 9(7)V99.
dneufarth

Active User

Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

 Posted: Mon May 09, 2022 2:08 am Varying length determined how?
Harsha Prince

New User

Joined: 08 May 2022
Posts: 5
Location: India

 Posted: Mon May 09, 2022 7:48 am Here in the input ....7th column is of 16 length,...when I remove 'b' , the remaining Characters in the 7th column is of length 8 and 9...so based on this length...records has to copy to the output files.
Joerg.Findeisen

Senior Member

Joined: 15 Aug 2015
Posts: 1297
Location: Bamberg, Germany

Posted: Mon May 09, 2022 11:24 am

 Harsha Prince wrote: I have an input with 4 records of different length(8 and 9) with garbage value 'b' as shown below: INPUT: Anc25 22 02 12ab 22 01 22222222bbbbb -123.65 78 Anc25 22 1 12ab 22 01 22222222bbbbb 23.65 78 Anc25 22 02 12ab 22 2 22222222bbbbb 12.65 90 Anc25 22 02 12ab 22 01 22222222bbbbb -123.65 85

You have not yet told what values are to be considered Garbage.
Joerg.Findeisen

Senior Member

Joined: 15 Aug 2015
Posts: 1297
Location: Bamberg, Germany

Posted: Mon May 09, 2022 2:31 pm

 Harsha Prince wrote: Here in the input ....7th column is of 16 length

Prove it!
 Code: INPUT: Anc25 22 02 12ab 22 01 22222222bbbbb -123.65 78
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 2102
Location: USA

Posted: Mon May 09, 2022 6:45 pm

 Harsha Prince wrote: Here in the input ....7th column is of 16 length,...when I remove 'b' , the remaining Characters in the 7th column is of length 8 and 9...so based on this length...records has to copy to the output files.

Please clarify for the forum: where did you find any length of 16?
 Code: Anc25 22 02 12ab 22 01 22222222bbbbb -123.65 78 Anc25 22 1 12ab 22 01 22222222bbbbb 23.65 78 Anc25 22 02 12ab 22 2 22222222bbbbb 12.65 90 Anc25 22 02 12ab 22 01 22222222bbbbb -123.65 85

Also, please make it clear: how do you distinguish "garbage" from "non-garbage"?

P.S.
dneufarth

Active User

Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

Posted: Mon May 09, 2022 7:03 pm

It appears that you want to create a fixed length column image (or record with fields) of your data in your output based upon a varying length column input; that is PARSE the input DELIMITED by SPACES.

Data examples you provided show Output-2 column 7 is inconsistent with the Input
 Code: 22222222 222222222

Is ‘garbage’ always last 5 bytes of column 7?

Joerg has a good point as to length of column 7.

Maybe a good idea to describe/visualize data as
 Code: output                input Col1 length 5      Col1 length 5 Col2 length 2      Col2 length 2 Col3 length 2      Col3 length 1-2 . . . Col9 length 2      Col9 length 2
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 2102
Location: USA

 Posted: Mon May 09, 2022 7:39 pm Remains completely unclear: WHAT IS THE GARBAGE????? In all you examples the "length of column 7" (between blank characters? or what?) is always 13 bytes. It is neither 16, nor 5, nor 7, IT IS ALWAYS 13 BYTES.
Harsha Prince

New User

Joined: 08 May 2022
Posts: 5
Location: India

 Posted: Mon May 09, 2022 10:13 pm Sorry for the late reply...I have attached a screen print of my input file The data which is in red color is of 16 length I have to remove letter 'b' from that column...so the other characters in that column...is of 8 length and 9 length....so based on these lengths the records have to split.... Records with 8 length in one file and 9 length in another file. And the data which is in blue colour has to be always in two digits only(if it contains one digit '0' has to be added infront of it). And the data which is blue colour has to be always in the range of 01 to 12...so if it contains > 12 or < 01....an abend has to occur.
Harsha Prince

New User

Joined: 08 May 2022
Posts: 5
Location: India

 Posted: Mon May 09, 2022 10:20 pm So most probably my output should look like this(see the attachment).
dneufarth

Active User

Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

 Posted: Mon May 09, 2022 10:24 pm Looks like no parsing is necessary as fields/columns are fixed length. Contents of fields need editing to conform to numeric consistency. You will need to know how to determine numeric length of 8 or 9 from trailing 'garbage'. How would you distinguish between numeric and 'garbage'? Have you written any COBOL source code yet? You can get help here by presenting code, but no one is going to write the code for you.
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 2102
Location: USA

Posted: Mon May 09, 2022 10:59 pm

 Harsha Prince wrote: Sorry for the late reply...I have attached a screen print of my input file The data which is in red color is of 16 length I have to remove letter 'b' from that column...so the other characters in that column...is of 8 length and 9 length....so based on these lengths the records have to split.... Records with 8 length in one file and 9 length in another file. And the data which is in blue colour has to be always in two digits only(if it contains one digit '0' has to be added infront of it). And the data which is blue colour has to be always in the range of 01 to 12...so if it contains > 12 or < 01....an abend has to occur.

1. Please, do not use attachments, and try not to use pictures and screenshots when presenting your data. Use copied text which is emphasized with Code, or Quote buttons.

2. It continues to remain completely unclear: WHAT DO YOU CONSIDER AS GARBAGE IN YOUR DATA??????

Your example shows the letter 'b' to be the garbage. Something else?
Harsha Prince

New User

Joined: 08 May 2022
Posts: 5
Location: India

 Posted: Tue May 10, 2022 12:02 am Yes sergeyken.... I'm considering 'b' in the 7th column as garbage value.
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 2102
Location: USA

Posted: Tue May 10, 2022 1:08 am

 Harsha Prince wrote: Yes sergeyken.... I'm considering 'b' in the 7th column as garbage value.

We are going in an unanswered loop...

What if 'c' in "column 7" is detected?
What if 'd' in "column 7" is detected?
etc. etc. etc.

What else except the letter 'b' is considered as "garbage"????

From your examples, and explanations we can only conclude that character '2' is a "good" value, but character 'b' is a "bad" value.
There are in total 256 characters available in EBCDIC code table. How would you deal with the rest 254 characters if they appeared in your "column 7"?
dneufarth

Active User

Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

 Posted: Tue May 10, 2022 4:41 am As you are a student, might this be an assigned lesson in a COBOL class or on-the-job training? Some lack of knowledge & terminology fundamentals regarding dataset/record/field and the use of columns not in a database/table is prevalent in this ongoing discussion.
sergeyken

Senior Member

Joined: 29 Apr 2008
Posts: 2102
Location: USA

 Posted: Wed May 11, 2022 1:01 am Do you know something about COBOL? Do you know something about data types, in computers generally, and in COBOL specifically? Do you know something about field and records definition in COBOL? Do you know something about data processing in computers generally, and in COBOL specifically? Do you know something about other data processing tools/utilities, except the magic word “COBOL”?
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

Posted: Wed May 11, 2022 1:48 am

 Quote: For 8th column the pic clause has to be 9(7)V99.
None of your examples use 9(7)V99 for the data -- because 9(7)V99 does not, under ANY circumstances, have a decimal point. The V in a COBOL PICTURE means that the decimal point is implied (as in, it does not actually exist).

I think you have terminology issues as well as conceptual issues with what you are attempting to explain. Based upon what you have said, I believe that UNSTRING combined with reference modification and the NUMVAL intrinsic function could achieve what you want to do. However, as has been said in this thread -- this is a HELP forum, not a WRITE-THE-CODE-FOR-YOU forum. So when you start posting code showing what you are attempting and the results this code is giving you (and where those results do not match your desired output), we will be able to help you.

As it is, you have spent two days NOT explaining things that are vital to understand (for example, is your 'b' the ONLY garbage character in your data, or can there be other values in those columns). If you don't start doing a better job of explaining what you want, I will be locking this topic before long since it is going nowhere.
dneufarth

Active User

Joined: 27 Apr 2005
Posts: 420
Location: Inside the SPEW (Southwest Ohio, USA)

 Posted: Fri May 13, 2022 10:52 pm Guess we were too demanding.
Joerg.Findeisen

Senior Member

Joined: 15 Aug 2015
Posts: 1297
Location: Bamberg, Germany

Posted: Fri May 13, 2022 11:08 pm

 dneufarth wrote: Guess we were too demanding.

I don't think so. In a professional Forum one can expect qualified questions.
Rohit Umarjikar

Global Moderator

Joined: 21 Sep 2010
Posts: 3072
Location: NYC,USA

 Posted: Sat May 14, 2022 2:27 am Let us not smash with high level stuff how things works in COBOL or in Mainframes. Its a simple requirement which was not explained neatly by TS. I would suggest to follow Robert's advise. 1. Read the record , unstring delimited by space 2. 7th variable in that Unstring , use INSPECT and count for numbers only 3. If length is <=8 then write to dataset 1 else data set 2. I am moving this to Student section of this forum. Please try this before replying further. If this is not what you need then explain little better way the requirement. Good Luck!
 View Bookmarks All times are GMT + 6 Hours

 Topic Forum Replies Similar Topics Get RECORD LENGTH, allocated space of... CLIST & REXX 7 To Omit records based n SORT condition DFSORT/ICETOOL 6 To fetch records that has Ttamp value... DFSORT/ICETOOL 5 ICETOOL returns no records JCL & VSAM 1 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
Search our Forums:

 IBMMainframes.com is not an official and/or affiliated with IBM® in anyway Board Rules | FAQ | Downloads | Wiki | SiteMap | Contact Us