|
View previous topic :: View next topic
|
| Author |
Message |
saikarthik94
New User
Joined: 04 Sep 2019 Posts: 12 Location: India
|
|
|
|
Hi,
I have a record like this.
123456,AAAA,3,,,,AAAA,3
657893,BBBB,1,,,,AAAA,5
213456,CCCC,1,,,DDDD,3
Let's assume AAAA,BBBB,CCCC,DDDD are some identifiers.
My expected output is:
123456,AAAA,1,,,,AAAA,2
657893,BBBB,1,,,,AAAA,5
213456,CCCC,1,,,DDDD,3
ie. after the first occurrence of AAAA, I want '1', at the second occurrence, I want one less than existing data(3-1=2)
I want to reformat the records which have AAAA in position 8 and 17. I want test of the records as same.
I have used OUTREC IFTHEN to achieve this.
OUTREC IFTHEN=(WHEN=INIT, BUILD=(1,250)
IFTHEN=(WHEN=(8,4,CH,EQ,C'AAAA',AND,17,4,CH,EQ,C'AAAA'),
BUILD=(1,11,12:C'1',13,9,23:23,1,ADD,ZD,-1)
But I m getting the subtracted value at 38th position, like shown below.
123456,AAAA,1,,,,AAAA, 2
657893,BBBB,1,,,,AAAA,5
213456,CCCC,1,,,DDDD,3
May i know why it is happening and how to over come this ?
Note: I have used SUB,1 in the build statement, i gave me syntax error, so that i have used ADD,-1 in the build. |
|
| Back to top |
|
 |
saikarthik94
New User
Joined: 04 Sep 2019 Posts: 12 Location: India
|
|
|
|
This is the output i m getting :
123456,AAAA,1,,,,AAAA,< SPACES > 2
657893,BBBB,1,,,,AAAA,5
213456,CCCC,1,,,DDDD,3
I gave spaces in the previous post also but it dint consider. |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1429 Location: Bamberg, Germany
|
|
|
|
First of all use Code Tags.
Second, something is fishy with your input and provided SORT statements. The offsets are different to what you use. Assuming you have properly alligned input it could look like that:
Input:
| Code: |
//SORTIN DD *
;---+----1----+----2----+----3----+----4----+----5----+----6----+----7--
123456,AAAA,3,,,AAAA,3
657893,BBBB,1,,,AAAA,5
213456,CCCC,1,,,DDDD,3
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OMIT COND=(1,1,CH,EQ,C';')
OUTREC IFTHEN=(WHEN=(8,4,CH,EQ,17,4,CH),
BUILD=(1,12,13:C'1',14,8,22:13,1,ZD,SUB,+1,TO=ZD,LENGTH=1))
END
/* |
Output:
| Code: |
123456,AAAA,1,,,AAAA,2
657893,BBBB,1,,,AAAA,5
213456,CCCC,1,,,DDDD,3 |
|
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1429 Location: Bamberg, Germany
|
|
|
|
Minor Update, instead of BUILD use OVERLAY
| Code: |
OPTION COPY
OMIT COND=(1,1,CH,EQ,C';')
OUTREC IFTHEN=(WHEN=(8,4,CH,EQ,17,4,CH),
OVERLAY=(1,12,13:C'1',14,8,22:13,1,ZD,SUB,+1,TO=ZD,LENGTH=1))
END |
Start fiddling around for yourself. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| Nothing to do with JCL. This is a sort question. There are sections in the forum for DFSort and Syncsort questions. Topic moved to DFSort. |
|
| Back to top |
|
 |
saikarthik94
New User
Joined: 04 Sep 2019 Posts: 12 Location: India
|
|
|
|
Thanks, Mr.Joerg.
I have used OVERLAY as you suggested. I have got the output as expected. I have used TO=ZDF, as TO=ZD gave { in case if the data is 1.
for 22nd position, I used 22:22,1,ZD, SUB,+1, because using 13th position will give the result 0 for all the records as 1(13th position hardcoded)-1 = 0
Sure, I will use the CODE tag next post onwards. Thanks again  |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1429 Location: Bamberg, Germany
|
|
|
|
I noticed the glitch with position myself but could not edit anymore.
Glad it works so far.  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|