View previous topic :: View next topic
|
Author |
Message |
mjgjaggu
New User
Joined: 22 Jun 2009 Posts: 8 Location: Germany
|
|
|
|
Hi all,
Is it possible to pick values from a particular dataset and put it in desired positions on a new dataset. For eg,
Existing dataset contains -
Code: |
ABC DEF GHI
JKL : 123 XYZ : 789
MNO: 456 |
Output should be -
New report
==========================
Code: |
DEF lost against ABC on GHI ground
JKL (Jersey num: 123) and MNO(Jersey
num: 456) scored for ABC.
XYZ(Jersey num: 789) scored for DEF. |
==========================
Note: This is not the orginal requirement.. I just cooked it up.
But the requirement I have is something similar.
Any help will be highly appreciated.
Thanks,
Jay
Code'd |
|
Back to top |
|
|
mjgjaggu
New User
Joined: 22 Jun 2009 Posts: 8 Location: Germany
|
|
|
|
One more point -
All the values in the new output file are either picked from the old file or hardcoded values. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If there are rules which reliably map the input to output, yes, it can be done, in general, unless the rules require going beyond existing DFSORT functionality. |
|
Back to top |
|
|
mjgjaggu
New User
Joined: 22 Jun 2009 Posts: 8 Location: Germany
|
|
|
|
Hi Bill,
Thanks for the quick reply.
Yes. There are specific rules.
1. The values to be picked from the old file are from specific position always and where it needs to be put in the new file is also fixed.
i.e. There is a mapping for each of the fields and the field positions.
2. The hardcoded values in the new file are also fixed, both for value and position.
Thanks,
Jay |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK, but I was expecting at least a bit of a hint as to what the rules might be.
So, for the "first line" is it always "winner, loser, ground"? Can there be a tie?
How do you identify the "first line"? Absence of ":"?
Then you seem to have a number of lines which indicate who scored first for winner, then loser, then next line is winner/loser, etc until no more scores?
What is the maximum number of scores?
How to identify the "scores" lines?
What if there is no score?
RECFM and LRECL of input and output.
Some more representative sample data, covering the above, in the Code tags please. |
|
Back to top |
|
|
mjgjaggu
New User
Joined: 22 Jun 2009 Posts: 8 Location: Germany
|
|
|
|
Hi Bill,
As I had mentioned in the initial post, that was only an example report. We do not have to check for conditions or derive values.
The basic requirement is to pick values from input file, from specific positions and place it in specific positions on the output file.
Along with this, I need to incorporate some static hardcoded text in the output file.
The record format is FB and LRECL is 133 for both input and output.
I am sorry if I made it more complicated :-).
Thanks,
Jay |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
I am sorry if I made it more complicated |
nope, You are just not describing things properly ?
from You description it seems that the values You describe occur only once in the file
but the <report> name seems to imply differently
data repeated according to some <grouping>
post a longer example of the input data
alonf with the relative output expected |
|
Back to top |
|
|
mjgjaggu
New User
Joined: 22 Jun 2009 Posts: 8 Location: Germany
|
|
|
|
Please find the exact requirement in the attachment.
All the labels in Black color are to be picked from the original file and put in their respective positions in the output file. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
So, use a number of IFTHEN=(WHEN=GROUP with BEGIN to identify the lines containing the data you want, and PUSH to locate a copy of that data (all that you need) into different positions.
This will mean that all records after your last WHEN-GROUP contain all the data you need, and all the previous records are useless. So arrange for an OUTFIL INCLUDE to pick up a record which now has all the data.
Use OUTFIL BUILD with the "slash operator" (/) which allows multiple output records from a single input record. Use several of these to format your new report, with a mixture of the data you have PUSHed and the new constants that you need. |
|
Back to top |
|
|
mjgjaggu
New User
Joined: 22 Jun 2009 Posts: 8 Location: Germany
|
|
|
|
Ok. Thanks. I will try this out..
In the meantime, If you could provide me with an example, it would really help my cause. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
There are examples in the manuals of WHEN=GROUP. Just use multiple ones, putting different data into different places.
There are also examples of OUTFIL INCLUDE in the same place, and of OUTFIL BUILD with the '/' operator.
Code: |
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'1'),PUSH=(81:2,5)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'2'),PUSH=(86:2,5))
OUTFIL INCLUDE=(1,1,CH,EQ,C'2'),
BUILD=(C'NEW REP',3X,86,5,/,C'2ND LINE',2X,81,5)
//SYSIN DD *
1FIRST
2LASTT |
Untested, but this should take the input "report", extract some "data" to, here, the last record (not because it is the last, but because it has '2' in the first position of the record), include only the last record, then produce a new "report" with contstants and the extracted data.
EDIT: Now "tested and tarted". |
|
Back to top |
|
|
|