|
View previous topic :: View next topic
|
| Author |
Message |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
Hi,
I want to omit the records in the file which has incorrect data in the amount field.
For example:
0002QQ2D1126287992496592032013081420131013 120.00EAUSD
0002CCAO1126287992496592032014011120151013 2000.00EAUSD
0002CCAO1126287992457592032014012420151013 20.00 EAUSD
0002CCAO1126287992457592032014012620151013800 12000.45EAUSD
0002CCAO1126287992457592032014010220151013 111100.AAEAUSD
0002CCAO1126287992457592032014010220151013825600 .00EAUSD
Field starting from 43
Length ==> 13
I need the records in the output file:
0002CCAO1126287992496592032013081420131013 120.00EAUSD
0002CCAO1126287992496592032014011120151013 2000.00EAUSD
I have tried to omit the invalid records using sort - Zoned decimal numeric check, but i could not able to get the required output.
Kindly help me on this. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
when posting data good manners suggest the use of code tags,
to preserve the alignment and making easier to identify the columns
also a ruler would be welcome
| Code: |
1 2 3 4 5 6 7 8
....+....+....+....+....+....+....+....+....+....+....+....+....+....+....+....+
0002QQ2D1126287992496592032013081420131013 120.00EAUSD
0002CCAO1126287992496592032014011120151013 2000.00EAUSD
0002CCAO1126287992457592032014012420151013 20.00 EAUSD
0002CCAO1126287992457592032014012620151013800 12000.45EAUSD
0002CCAO1126287992457592032014010220151013 111100.AAEAUSD
0002CCAO1126287992457592032014010220151013825600 .00EAUSD
|
Field starting from 43
Length ==> 13
I need the records in the output file:
| Code: |
1 2 3 4 5 6 7 8
....+....+....+....+....+....+....+....+....+....+....+....+....+....+....+....+
0002CCAO1126287992496592032013081420131013 120.00EAUSD
0002CCAO1126287992496592032014011120151013 2000.00EAUSD
|
|
|
| Back to top |
|
 |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
| Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
****** ***************************** Top of Data ******************************
000200 0002SD HCENGINE RU0005 2013081999991231 2000.00EAAUD
000300 0002CCAO1126287992496592032013081420131013 120.00EAUSD
000320 0002CCAO1126287992457592032014012420151013 20.00 EAUSD
000330 0002CCAO1126287992457592032014012620151013800 12000.45EAUSD
000340 0002CCAO1126287992457592032014010220151013 111100.AAEAUSD
000350 0002CCAO1126287992457592032014010220151013825600 .00EAUSD
****** **************************** Bottom of Data ****************************
|
|
|
| Back to top |
|
 |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
Input field:
| Code: |
000200 0002SD HCENGINE RU0005 2013081999991231 2000.00EAAUD
000300 0002CCAO1126287992496592032013081420131013 120.00EAUSD
000320 0002CCAO1126287992457592032014012420151013 20.00 EAUSD
000330 0002CCAO1126287992457592032014012620151013800 12000.45EAUSD
000340 0002CCAO1126287992457592032014010220151013 111100.AAEAUSD
000350 0002CCAO1126287992457592032014010220151013825600 .00EAUSD
Output field
|
| Code: |
000001 0002CCAO1126287992496592032013081420131013 120.00EAUSD
000002 0002CCAO1126287992496592032014011120151013 2000.00EAUSD
000003
|
|
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
What are the rules?
Please explain |
|
| Back to top |
|
 |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
Using Sort, want only the correct amount values in the output field.
Like the below amount values should be omitted
| Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6--
****** ***************************** Top of Data ********************
000320 0002CCAO1126287992457592032014012420151013 20.00 EAUSD
000330 0002CCAO1126287992457592032014012620151013800 12000.45EAUSD
000340 0002CCAO1126287992457592032014010220151013 111100.AAEAUSD
000350 0002CCAO1126287992457592032014010220151013825600 .00EAUSD
|
In the first data, the decimal point appeared in the wrong place
second data, space appearing in mid of the amount value
third data, non-numeric value appears 54 and 55th position
fourth data, there is an space appears in the amount value.
Amount value: starts at 43th position
Length is 13
Wanted only the correct output values in the output file.
| Code: |
----+----1----+----2----+----3----+----4----+----5----+----6-
***************************** Top of Data *******************
0002SD HCENGINE RU0005 2013081999991231 2000.00EAAUD
0002CCAO1126287992496592032013081420131013 120.00EAUSD
|
|
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Your input and output doesnt match
 |
|
| Back to top |
|
 |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
Sorry.
Please find the files below.
Input file:
| Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6--
****** ***************************** Top of Data ********************
000200 0002SD HCENGINE RU0005 2013081999991231 2000.00EAAUD
000300 0002CCAO1126287992496592032013081420131013 120.00EAUSD
000320 0002CCAO1126287992457592032014012420151013 20.00 EAUSD
000330 0002CCAO1126287992457592032014012620151013800 12000.45EAUSD
000340 0002CCAO1126287992457592032014010220151013 111100.AAEAUSD
000350 0002CCAO1126287992457592032014010220151013825600 .00EAUSD
|
Ouput file:
| Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+--
****** ***************************** Top of Data *************************
000200 0002SD HCENGINE RU0005 2013081999991231 2000.00EAAUD
000300 0002CCAO1126287992496592032013081420131013 120.00EAUSD
****** **************************** Bottom of Data ***********************
|
|
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Meenakshi Selvaraj,
1. Use an INCLUDE COND looking for dot at position 53 AND check the 2 bytes at position 54 with FS format for NUM
2. Use Parse on INREC to parse the data with ABSPOS=43 and FIXLEN=10 looking for ENDAT=c' ' and OVERLAY that parse field at the LRECL+1 if the input format is FB or use BUILD with RDW, Parse field, start pos of Variable record if the input is VB
3. Use OUTFIL OMIT to check the overlay/build field Greater than spaces and use BUILD to remove the parse field which will give you the desired results. |
|
| Back to top |
|
 |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
Hi Skolusu,
Thanks.
I have tried using the details given but i couldnt able to get the desired result.
Could you please provide the syntax for this. |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
| Please post the code which you tried? |
|
| Back to top |
|
 |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
Syntax used in the Sort card as
| Code: |
SORT FIELDS=COPY
INCLUDE COND=(53,01,CH,EQ,C'.',AND,
54,02,FS,EQ,NUM)
|
i got the Output as
| Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+--
****** ***************************** Top of Data *************************
000200 0002SD HCENGINE RU0005 2013081999991231 2000.00EAAUD
000300 0002CCAO1126287992496592032013081420131013 120.00EAUSD
000330 0002CCAO1126287992457592032014012620151013800 12000.45EAUSD
000350 0002CCAO1126287992457592032014010220151013825600 .00EAUSD
****** **************************** Bottom of Data ***********************
|
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You forgot to code the 2nd and third stages. You need a PARSE, as described, and OUTFIL OMIT= as described,
Tighten up your test data as well. |
|
| Back to top |
|
 |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Hi Meenakshi,
Here is the code that Kolusu explained. I assumed your file is FB and LRECL=80.
| Code: |
//STEP0001 EXEC PGM=SORT
//SORTIN DD *
0002SD HCENGINE RU0005 2013081999991231 2000.00EAAUD
0002CCAO1126287992496592032013081420131013 120.00EAUSD
0002CCAO1126287992457592032014012420151013 20.00 EAUSD
0002CCAO1126287992457592032014012620151013800 12000.45EAUSD
0002CCAO1126287992457592032014010220151013 111100.AAEAUSD
0002CCAO1126287992457592032014010220151013825600 .00EAUSD
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(53,1,CH,EQ,C'.',AND,54,2,FS,EQ,NUM)
OUTREC PARSE=(%01=(ABSPOS=43,FIXLEN=10,ENDAT=X'40')),
OVERLAY=(81:%01)
OUTFIL OMIT=(81,1,CH,GT,X'40'),
BUILD=(1,80)
|
and output is
| Code: |
0002SD HCENGINE RU0005 2013081999991231 2000.00EAAUD
0002CCAO1126287992496592032013081420131013 120.00EAUSD
|
Kolusu,
please check if I missed anything.  |
|
| Back to top |
|
 |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
Thank you so much.
It works as per the requirement. |
|
| Back to top |
|
 |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
Hi,
Need one more clarifications
Input file:
| Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
****** ***************************** Top of Data ******************************
000001 0002GPSAR7001CART1234567892013033099991212A111111100.00PCUSD
000002 0002GPSAR7002CART1234567892013033099991212 100.00PCUSD
000003 0002GPSAR7003CART1234567892013033099991212 200.00PCUSD
000004 0002GPSAR7003CART1234567892013033099991212 300 200.00PCUSD
000005 0002GPSAR7003CART12345678920130330999912121111111100.AAPCUSD
000006 0002GPSAR7003CART1234567892013033099991212 100.00 PCUSD
000007 0002GPSAR7003CART1234567892013043099991212 5000 78 .44PCUSD
000008 0002GPSAR7003CART1234567892013011099991212995000 78 .44PCUSD
|
Using the same sort card, but i got different output
Output file:
| Code: |
=COLS> ----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
****** ***************************** Top of Data ******************************
000001 0002GPSAR7002CART1234567892013033099991212 100.00PCUSD
000002 0002GPSAR7003CART1234567892013033099991212 200.00PCUSD
000003 0002GPSAR7003CART1234567892013033099991212 300 200.00PCUSD
000004 0002GPSAR7003CART1234567892013043099991212 5000 78 .44PCUSD
****** **************************** Bottom of Data ****************************
|
Actually the 2nd and 3rd records are needed.
Apart from non-numeric,
Requirement is, if there is any spaces in between the amount value, then that record should be removed.
In the input file, 8th record is removed. Like that 4th and 7th records are also need to remove. But it is not.
Could you please explain why this sort card is not working for these records too. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The Control Cards dealt with the situation you showed.
I was suspicious, but if your test data was representative, you'd be OK. Is it yet good enough? What about multiple ".", for instance? If it is raw user-data, you have to cover everything.
With what you have been shown already, you should be able to come up with something. |
|
| Back to top |
|
 |
enrico-sorichetti
Superior Member

Joined: 14 Mar 2007 Posts: 10903 Location: italy
|
|
|
|
I wonder why people have to waste time checking over and over the data they receive
one of the first paradigms of quality is that
THE PROVIDER IS RESPONSIBLE OF THE DATA QUALITY/CORRECTNESS NOT THE RECEIVER
looks like good practices are going down the toilet nowadays
have the morons fix the data they provide You |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| Meenakshi Selvaraj wrote: |
| Could you please explain why this sort card is not working for these records too. |
Meenakshi Selvaraj,
If only you could explain as to why you haven't included the new test data earlier , we would explain as to why the other solution did not work. |
|
| Back to top |
|
 |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
Hi Skolusu,
I got the data from different team. Earlier i dont know whether we can have these types of data.
But using cobol program, i have validate all these conditions. Eager to learn whether all these are acheived by using sort card. Hence i dropped the question here. Anyhow completed using Cobol.
Thanks for your help and time. |
|
| Back to top |
|
 |
sureshpathi10
Active User

Joined: 03 May 2010 Posts: 158 Location: Kuala Lumpur
|
|
|
|
Hi,
As far I know, you've to check each and every byte for numeric and space.
Here is the code. It may be big, but as long as it works, its fine, I guess.
| Code: |
//STEP0001 EXEC PGM=SORT
//SORTIN DD *
0002GPSAR7001CART1234567892013033099991212A111111100.00PCUSD
0002GPSAR7002CART1234567892013033099991212 100.00PCUSD
0002GPSAR7003CART1234567892013033099991212 200.00PCUSD
0002GPSAR7003CART1234567892013033099991212 300 200.00PCUSD
0002GPSAR7003CART12345678920130330999912121111111100.AAPCUSD
0002GPSAR7003CART1234567892013033099991212 100.00 PCUSD
0002GPSAR7003CART1234567892013043099991212 5000 78 .44PCUSD
0002GPSAR7003CART1234567892013011099991212995000 78 .44PCUSD
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(53,1,CH,EQ,C'.',AND,54,2,FS,EQ,NUM)
INREC IFTHEN=(WHEN=(43,1,FS,NE,NUM,AND,43,1,CH,NE,X'40'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(43,1,FS,EQ,NUM,AND,81,1,CH,NE,C'I'),
OVERLAY=(81:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(43,1,CH,EQ,X'40',AND,81,1,CH,EQ,C'N'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(44,1,FS,NE,NUM,AND,43,1,CH,NE,X'40'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(44,1,FS,EQ,NUM,AND,81,1,CH,NE,C'I'),
OVERLAY=(81:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(44,1,CH,EQ,X'40',AND,81,1,CH,EQ,C'N'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(45,1,FS,NE,NUM,AND,43,1,CH,NE,X'40'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(45,1,FS,EQ,NUM,AND,81,1,CH,NE,C'I'),
OVERLAY=(81:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(45,1,CH,EQ,X'40',AND,81,1,CH,EQ,C'N'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(46,1,FS,NE,NUM,AND,43,1,CH,NE,X'40'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(46,1,FS,EQ,NUM,AND,81,1,CH,NE,C'I'),
OVERLAY=(81:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(46,1,CH,EQ,X'40',AND,81,1,CH,EQ,C'N'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(47,1,FS,NE,NUM,AND,43,1,CH,NE,X'40'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(47,1,FS,EQ,NUM,AND,81,1,CH,NE,C'I'),
OVERLAY=(81:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(47,1,CH,EQ,X'40',AND,81,1,CH,EQ,C'N'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(48,1,FS,NE,NUM,AND,43,1,CH,NE,X'40'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(48,1,FS,EQ,NUM,AND,81,1,CH,NE,C'I'),
OVERLAY=(81:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(48,1,CH,EQ,X'40',AND,81,1,CH,EQ,C'N'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(49,1,FS,NE,NUM,AND,43,1,CH,NE,X'40'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(49,1,FS,EQ,NUM,AND,81,1,CH,NE,C'I'),
OVERLAY=(81:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(49,1,CH,EQ,X'40',AND,81,1,CH,EQ,C'N'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(50,1,FS,NE,NUM,AND,43,1,CH,NE,X'40'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(50,1,FS,EQ,NUM,AND,81,1,CH,NE,C'I'),
OVERLAY=(81:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(50,1,CH,EQ,X'40',AND,81,1,CH,EQ,C'N'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(51,1,FS,NE,NUM,AND,43,1,CH,NE,X'40'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(51,1,FS,EQ,NUM,AND,81,1,CH,NE,C'I'),
OVERLAY=(81:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(51,1,CH,EQ,X'40',AND,81,1,CH,EQ,C'N'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(52,1,FS,NE,NUM,AND,43,1,CH,NE,X'40'),
OVERLAY=(81:C'I'),HIT=NEXT),
IFTHEN=(WHEN=(52,1,FS,EQ,NUM,AND,81,1,CH,NE,C'I'),
OVERLAY=(81:C'N'),HIT=NEXT),
IFTHEN=(WHEN=(52,1,CH,EQ,X'40',AND,81,1,CH,EQ,C'N'),
OVERLAY=(81:C'I'),HIT=NEXT)
OUTFIL OMIT=(81,1,CH,EQ,C'I'),BUILD(1,80)
|
Here is the output:
| Code: |
0002GPSAR7002CART1234567892013033099991212 100.00PCUSD
0002GPSAR7003CART1234567892013033099991212 200.00PCUSD
|
Really appreciate if anyone come up with simple sort. |
|
| Back to top |
|
 |
Meenakshi Selvaraj
New User
Joined: 30 Oct 2009 Posts: 36 Location: Chennai
|
|
|
|
| Thank you so much Suresh. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| sureshpathi10 wrote: |
Hi,
As far I know, you've to check each and every byte for numeric and space.
Here is the code. It may be big, but as long as it works, its fine, I guess.
Really appreciate if anyone come up with simple sort. |
Well if you are running against millions of records your performance will take a hit. You have complicated a simple task as you can validate the input with just 3 IFTHEN clause.
1. Justify(JFY) the numeric value (10 bytes from pos 43) and put it at the end(pos 81) using IFTHEN WHEN=INIT
2. Using another IFTHEN WHEN=INIT , parse the value at 81 with STARTAT=C' ' and multiple ENDAT parms for '0' thru '9'. This will get all the values that are having imbedded blanks in between the numbers and put this value at 92.
3. Using another IFTHEN WHEN=INIT , FINDREP the values at STARTPOS=81 ENDPOS=90 replacing '0' thru '9' with a space. By doing this you will eliminate any records that do not have numbers.(ex: record1)
4. Using OUTFIL omit records that have values greater than spaces at position 81 OR at position 92 and BUILD the record removing the extra bytes at end. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|