View previous topic :: View next topic
|
Author |
Message |
Pinchoo
New User
Joined: 22 Nov 2005 Posts: 8 Location: hyderabad
|
|
|
|
Hi,
I need urgent help in reformatting the records of input file.
Eg:(INPUT FILE)
H01
A1
B1
A2
B2
A3
B3
H02
C1
D1
C2
D2
C3
D3
i NEED OUTPUT FILE AS
H01 A1 B1
H01 A2 B2
H01 A3 B3
H02 C1 D1
H02 C2 D2
H02 C3 D3
Hope i am clear in explaining my problem.
Please let me know if any other details are required
Thanks!
Pinchoo |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
Will the header will have 6 records under it? Is it fixed? Can the below scenario possible?
Eg:(INPUT FILE)
H01
A1
B1
A2
A3
B3
H02
C1
D1
C2 |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
Hope i am clear in explaining my problem. |
Unfortunately, you're not clear.
Please show a better example of the records in each input file with all possible cases and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input file. If the input file can have duplicates within it, show that in your example. |
|
Back to top |
|
|
Pinchoo
New User
Joined: 22 Nov 2005 Posts: 8 Location: hyderabad
|
|
|
|
Both the input and output are FB flat files with rec length 80
there's a header rec at the top and below the header there are number of other records associated with the header. i want to prefix the header with every record.
EG.
Head1
Rec1
Rec2
Rec3
Rec4
Head2
Rec1
Rec2
Rec3
Head3
Rec1
Rec2
I need the output as"
Head1 Rec1
Head1 rec2
Head1 rec3
Head1 rec3
Head2 Rec1
Head2 Rec2
Head2 Rec3
Head3 Rec1
Head3 Rec2 |
|
Back to top |
|
|
gylbharat
Active Member
Joined: 31 Jul 2009 Posts: 565 Location: Bangalore
|
|
|
|
I think there is a typo error in the output
I need the output as"
Head1 Rec1
Head1 rec2
Head1 rec3
Head1 rec3 should be Head1 rec4
Head2 Rec1
Head2 Rec2
Head2 Rec3
Head3 Rec1
Head3 Rec2
Can you please clarify that the rec1, rec2 etc needs to be sorted ? |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hello,
Quote: |
Eg:(INPUT FILE)
H01
A1
B1
A2
B2
A3
B3
H02
C1
D1
C2
D2
C3
D3
i NEED OUTPUT FILE AS
H01 A1 B1
H01 A2 B2
H01 A3 B3
H02 C1 D1
H02 C2 D2
H02 C3 D3 |
Quote: |
EG.
Head1
Rec1
Rec2
Rec3
Rec4
Head2
Rec1
Rec2
Rec3
Head3
Rec1
Rec2
I need the output as"
Head1 Rec1
Head1 rec2
Head1 rec3
Head1 rec3
Head2 Rec1
Head2 Rec2
Head2 Rec3
Head3 Rec1
Head3 Rec2 |
Looks like the two requirements are different from two of your posts.
Which one you require? |
|
Back to top |
|
|
vasanthz
Global Moderator
Joined: 28 Aug 2007 Posts: 1742 Location: Tirupur, India
|
|
|
|
Hello,
Quote: |
EG.
Head1
Rec1
Rec2
Rec3
Rec4
Head2
Rec1
Rec2
Rec3
Head3
Rec1
Rec2
I need the output as"
Head1 Rec1
Head1 rec2
Head1 rec3
Head1 rec3
Head2 Rec1
Head2 Rec2
Head2 Rec3
Head3 Rec1
Head3 Rec2 |
If this is your requirement you could use the below sort card
Code: |
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'HEAD'),
PUSH=(81:1,5))
OUTFIL BUILD=(81,5,X,1,74),INCLUDE=(1,5,CH,NE,81,5,CH) |
Hope it helps. |
|
Back to top |
|
|
Pinchoo
New User
Joined: 22 Nov 2005 Posts: 8 Location: hyderabad
|
|
|
|
Thanks! a ton...
it worked perfect and resolved my issue..
Though i am still trying to understand it working line by line |
|
Back to top |
|
|
|