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

Split records based on its length


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Harsha Prince

New User


Joined: 08 May 2022
Posts: 5
Location: India

PostPosted: Sun May 08, 2022 11:37 pm
Reply with quote

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.
Back to top
View user's profile Send private message
dneufarth

Active User


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

PostPosted: Mon May 09, 2022 2:08 am
Reply with quote

Varying length determined how?
Back to top
View user's profile Send private message
Harsha Prince

New User


Joined: 08 May 2022
Posts: 5
Location: India

PostPosted: Mon May 09, 2022 7:48 am
Reply with quote

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.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Mon May 09, 2022 11:24 am
Reply with quote

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. icon_exclaim.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Mon May 09, 2022 2:31 pm
Reply with quote

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
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Mon May 09, 2022 6:45 pm
Reply with quote

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.
I remember, I have asked already exactly the same question in your different topic. There was no response received... icon_cry.gif
Back to top
View user's profile Send private message
dneufarth

Active User


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

PostPosted: Mon May 09, 2022 7:03 pm
Reply with quote

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
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Mon May 09, 2022 7:39 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Harsha Prince

New User


Joined: 08 May 2022
Posts: 5
Location: India

PostPosted: Mon May 09, 2022 10:13 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Harsha Prince

New User


Joined: 08 May 2022
Posts: 5
Location: India

PostPosted: Mon May 09, 2022 10:20 pm
Reply with quote

So most probably my output should look like this(see the attachment).
Back to top
View user's profile Send private message
dneufarth

Active User


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

PostPosted: Mon May 09, 2022 10:24 pm
Reply with quote

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.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Mon May 09, 2022 10:59 pm
Reply with quote

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?
Back to top
View user's profile Send private message
Harsha Prince

New User


Joined: 08 May 2022
Posts: 5
Location: India

PostPosted: Tue May 10, 2022 12:02 am
Reply with quote

Yes sergeyken....
I'm considering 'b' in the 7th column as garbage value.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Tue May 10, 2022 1:08 am
Reply with quote

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

We are going in an unanswered loop... icon_rolleyes.gif

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"?
Back to top
View user's profile Send private message
dneufarth

Active User


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

PostPosted: Tue May 10, 2022 4:41 am
Reply with quote

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.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2141
Location: USA

PostPosted: Wed May 11, 2022 1:01 am
Reply with quote

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”?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed May 11, 2022 1:48 am
Reply with quote

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.
Back to top
View user's profile Send private message
dneufarth

Active User


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

PostPosted: Fri May 13, 2022 10:52 pm
Reply with quote

Guess we were too demanding.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


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

PostPosted: Fri May 13, 2022 11:08 pm
Reply with quote

dneufarth wrote:
Guess we were too demanding.

I don't think so. In a professional Forum one can expect qualified questions.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Sat May 14, 2022 2:27 am
Reply with quote

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!
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 -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts Sort based on the record type DFSORT/ICETOOL 1
No new posts Get RECORD LENGTH, allocated space of... CLIST & REXX 7
No new posts To Omit records based n SORT condition DFSORT/ICETOOL 6
No new posts To fetch records that has Ttamp value... DFSORT/ICETOOL 5
Search our Forums:

Back to Top