Can someone please help on the below sort requirement
I have an requirement to compare current file with last run's file and extract only adds and modifications.
Problem is i should compare only header lines (dont compare detail lines) but my file has headers and Details.
For the extracted Header , I need all the details linked to that header from the current file irrespective of changes/adds.
Below is the sample file.
In Header, PO number starts at 5th byte ( lenght of 16 bytes)
PO status starts at 22nd byte (length of 3 bytes )
In Detail, PO number starts at 15th byte ( lenght of 16 bytes)
PO status starts at 56nd byte (length of 3 bytes )
I Guess below solution will work but is there any optimised way to reduce number of steps
1) Split the Headers and Detail records to backup files. ( MOFDSS.HDR.BKUP(+1) and MOFDSS.DTL.BKUP(+1) )
2) Compare Current MOFDSS.HDR.BKUP(+1) and Previous MOFDSS.HDR.BKUP(0) Header files to extract only New and modified Headers. (MOFDSS.HDR.NEW)
3) Merge files MOFDSS.HDR.NEW and matching details from MOFDSS.DTL.BKUP(+1) based on PO number and PO status to create MOFDSS.FINAL.EXT
Sorry Nic, Since I am using this for the first time, I was not aware how to add the code tags. Now I have modified my entire query and added the required output file.
I have an requirement to compare current file with last run's file and extract only adds and modifications.
Problem is i should compare only headers but my file has headers and Details.
For the extracted Header , I need all the details linked to that header from the current file irrespective of changes/adds.
Below is the sample file.
In Header, PO number starts at 5th byte ( lenght of 16 bytes)
PO status starts at 22nd byte (length of 3 bytes )
In Detail, PO number starts at 15th byte ( lenght of 16 bytes)
Previous File:
WE have only two PO's SS048000003114 and SS048000003115
OUTPUT file:
First PO# SS048000003114
In the previous file for the PO# SS048000003114 chill order quantity is 2222222.000
in the current file for the PO# SS048000003114 chill order quantity is 1111111.000 <-- write total set of header and detail into output file
Second PO# SS048000003115
There are no changes in the header in both the files, So skip the total set
Third PO# SS048000003116
This is newly added to the current file not exits in pervious file. <-- Write total set into output file
I Guess below solution will work but is there any optimised way to reduce number of steps
1) Split the Headers and Detail records to backup files. ( MOFDSS.HDR.BKUP(+1) and MOFDSS.DTL.BKUP(+1) )
2) Compare Current MOFDSS.HDR.BKUP(+1) and Previous MOFDSS.HDR.BKUP(0) Header files to extract only New and modified Headers. (MOFDSS.HDR.NEW)
3) Merge files MOFDSS.HDR.NEW and matching details from MOFDSS.DTL.BKUP(+1) based on PO number and PO status to create MOFDSS.FINAL.EXT[/code]
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
Not the answer you are seeking but...
in the time I spent thinking about this (not long) I could have written a small rexx program to do what you want. It is, basically, a 2-file match.
You need to consider 4 categories:
1) Newly inserted groups
2) Deleted old groups
3) Matching groups with changed data
4) Matching groups with unchanged data (plan to ignore them)
Only the COPY-AND-PASTE type of answers is working in this forum, despite of the name Expert Forum...
It's a pity, software development has changed to a sort of computer games - click the button Start, and get the result. Not even any attempt to think about the approach, or algorithm. I suspect most of TS did not even hear about words like "algorithm"