|
View previous topic :: View next topic
|
| Author |
Message |
kshkumar2231
New User
Joined: 26 Jul 2017 Posts: 2 Location: India
|
|
|
|
Hi,
There is a requirement where i am trying to pull the segments present in IMS database on the few conditions, and has to be formatted in the required format. All the segments it is pulling up correctly, however there is an requirement where all the fields have to be formatted as per one file layout, where in one field is having three occurrences, below is the sample sort card with the expected outcome and the output i got.
Please help me with the sort card.
Input:
| Code: |
----+----0----+----
01 A134 B7154 C8796
05 A135 B7890 C0987
07 A136 B5469 C2564
07 A137 B4567 C2130
07 A138 B6545 C3654 |
Output:
| Code: |
----+----1----+----2----+----3----+----4
01 A134 B7154 C8796 A134
05 A135 B7890 C0987 A134 A135
07 A136 B5469 C2564 A134 A135 A136
07 A137 B4567 C2130 A134 A135 A137 A137
07 A138 B6545 C3654 A134 A135 A138 A138
|
Expected Output:
| Code: |
----+----1----+----2----+----3----+----4----+----5
01 A134 B7154 C8796 A134
05 A135 B7890 C0987 A134 A135
07 A136 B5469 C2564 A134 A135 A136
07 A137 B4567 C2130 A134 A135 A136 A137
07 A138 B6545 C3654 A134 A135 A136 A137 A138 |
Sort Card:
| Code: |
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'01'),
PUSH=(25:4,4)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'05'),
PUSH=(31:4,4)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'07'),
PUSH=(36:4,4)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'07'),
PUSH=(42:4,4)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'07'),
PUSH=(48:4,4)) |
|
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
Please post in therelevant section of the forum - you have a sort problem, not an IMS problem. Topic moved. (If you have Syncsort then let us know and it will be moved to that forum.)
When presenting code, data, control statements please use the Code button in the Reply editor. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2276 Location: USA
|
|
|
|
| kshkumar2231 wrote: |
Sort Card:
| Code: |
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'01'),
PUSH=(25:4,4)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'05'),
PUSH=(31:4,4)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'07'),
PUSH=(36:4,4)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'07'),
PUSH=(42:4,4)),
IFTHEN=(WHEN=GROUP,
BEGIN=(1,2,CH,EQ,C'07'),
PUSH=(48:4,4)) |
|
You do not understand the idea of grouping records while sorting.
First of all, in your case you need to use WHEN=GROUP,KEYBEGIN=(1,2),PUSH=(48:SEQ=2) to differentiate between sequential lines within the same group, like multiple '07's numbered as '01', '02', '03'...
Next, you may need some sophisticated IFTHEN=(WHEN=…), but initially you need to read carefully about GROUP in SORT. |
|
| Back to top |
|
 |
kshkumar2231
New User
Joined: 26 Jul 2017 Posts: 2 Location: India
|
|
|
|
Hi Nick, Sergeyken
Thanks for your response.
My bad, I should have kept the title correctly.
Nick,
I have tried putting sequence number to differentiate the repetitive record, having multiple values, however the main challenge over here is to write all the pushed record in a single rows i. e in the last row and then by putting include condition get the last row to proceed further, where it has to be written as per file layout. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| Who is "Nick"? |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|