View previous topic :: View next topic
|
Author |
Message |
Harsha Prince
New User
Joined: 08 May 2022 Posts: 5 Location: India
|
|
|
|
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 |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
Varying length determined how? |
|
Back to top |
|
|
Harsha Prince
New User
Joined: 08 May 2022 Posts: 5 Location: India
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1335 Location: Bamberg, Germany
|
|
|
|
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. |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1335 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2141 Location: USA
|
|
|
|
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... |
|
Back to top |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
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
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2141 Location: USA
|
|
|
|
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 |
|
|
Harsha Prince
New User
Joined: 08 May 2022 Posts: 5 Location: India
|
|
|
|
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 |
|
|
Harsha Prince
New User
Joined: 08 May 2022 Posts: 5 Location: India
|
|
|
|
So most probably my output should look like this(see the attachment). |
|
Back to top |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2141 Location: USA
|
|
|
|
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 |
|
|
Harsha Prince
New User
Joined: 08 May 2022 Posts: 5 Location: India
|
|
|
|
Yes sergeyken....
I'm considering 'b' in the 7th column as garbage value. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2141 Location: USA
|
|
|
|
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"? |
|
Back to top |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
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 |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2141 Location: USA
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 420 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
Guess we were too demanding. |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1335 Location: Bamberg, Germany
|
|
|
|
dneufarth wrote: |
Guess we were too demanding. |
I don't think so. In a professional Forum one can expect qualified questions. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
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 |
|
|
|