View previous topic :: View next topic
|
Author |
Message |
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi,
I have the data as below.
Code: |
ABV 01
BCA
CHG
DCA
SUB 02
abc
DTA 03
abc
efg |
In the above i need to add sequence nos to be written in (8:6) position when the sequence no present in (5:2) changes as shown below to be done in sort card. (5:2) will be in sorted order.
Code: |
ABV 01 01
BCA 02
CHG 03
DCA 04
SUB 02 01
abc 02
DTA 03 01
abc 02
efg 03 |
Can anyone pls provide me sample for the above.
Thanks,
Senthil Murugaan |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Hello,
I am sure it would be much helpful if you could post/edit your query (given data & expected data) in the code'd format. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Please learn to use the code tags when posting to make your post more helper friendly
Code: |
[code]
Your
stuff
goes
here
[/code] |
|
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Senthil,
For the data what you have shown here, if the requirement can also be stated like "assign a 2-byte sequence number at pos-8 and restart it whenever there is a non-blank value exists at pos-5,2", you could try this.
Code: |
//SORT01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABV 01
BCA
CHG
DCA
SUB 02
abc
DTA 03
abc
efg
//*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(5,2,CH,NE,C' '),PUSH=(8:SEQ=2)) |
SORTOUT had this:
Code: |
ABV 01 01
BCA 02
CHG 03
DCA 04
SUB 02 01
abc 02
DTA 03 01
abc 02
efg 03 |
|
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Arun,
The position (5:2) can have spaces so the above method will not work properly.
So cosider below data. If (1:3) = 'SUB' or 'DPT', then sequence no must be restarted. any way to achieve this. suppose if both SUB & DPT present continuous then SUB must be first sequence followed by DPT.
Code:
DPT 01 01
BCA 02
CHG 03
DCA 04
SUB 02 01
DPT 02
ABC 03
SUB 03 01
ABC 02
EFG 03
Output:
Code:
DPT 01 01
BCA 02
CHG 03
DCA 04
SUB 02 01
DPT 02
ABC 03
SUB 03 01
ABC 02
EFG 03 |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Hello,
Quote: |
The position (5:2) can have spaces so the above method will not work properly. |
Are you telling this based on the executed job output or with your assumption.
Did you tried executing the given snippet. If you still face issues post the used snippet & received output.
Expat has explained clearly how to use code tag on your post. Please get used with it. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
SENTHIL MURUGAAN
You have been asked to use code tags, and shown how to do this.
If you can not be bothered to help those trying to help you, why should we bother
Have you tried Aruns suggestion before saying that it will not work ,or is it just a case that you have decied to add further information to the post that should have been included initially. |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi,
The file what i have didnt hold spaces at the specified position(5:2). But it can hold values other than spaces when i noticed the copybook. The file is created by copybook that holds multiple layouts. So i am trying to say that i need to approach a different way to generate sequence no and I am not saying that arun is wrong.
Thanks,
Senthil |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Hello,
Is there any differences between input & output
Code: |
Code:
DPT 01 01
BCA 02
CHG 03
DCA 04
SUB 02 01
DPT 02
ABC 03
SUB 03 01
ABC 02
EFG 03
Output:
Code:
DPT 01 01
BCA 02
CHG 03
DCA 04
SUB 02 01
DPT 02
ABC 03
SUB 03 01
ABC 02
EFG 03 |
If you able to post your queries in detail you would get the help in return.
Post the input & expected output clearly. (Code tag it) |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Senthil,
As already pointed out, the sample input and expected output in your latest post are the SAME.
If your requirement is different from what you posted initially, please start over and post a few sample input records
covering all possible input scenarios and the expected output out of it (enclosed by "Code" tags). |
|
Back to top |
|
|
|