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
=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 ***********************
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.
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.
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.
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.
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.