IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search Log in to check your private messages Log in
 

Outrec IFTHEN builds data in wrong position


 
IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: :: View next topic  
Author Message
saikarthik94

New User


Joined: 04 Sep 2019
Posts: 7
Location: India

PostPosted: Sun Mar 01, 2020 2:14 pm
Reply with quote

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
View user's profile Send private message
saikarthik94

New User


Joined: 04 Sep 2019
Posts: 7
Location: India

PostPosted: Sun Mar 01, 2020 2:20 pm
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 350
Location: Bamberg, Germany

PostPosted: Sun Mar 01, 2020 3:44 pm
Reply with quote

First of all use Code Tags. icon_exclaim.gif

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
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 350
Location: Bamberg, Germany

PostPosted: Sun Mar 01, 2020 4:03 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2430
Location: Hampshire, UK

PostPosted: Sun Mar 01, 2020 5:52 pm
Reply with quote

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
View user's profile Send private message
saikarthik94

New User


Joined: 04 Sep 2019
Posts: 7
Location: India

PostPosted: Sun Mar 01, 2020 7:35 pm
Reply with quote

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 icon_biggrin.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

Active User


Joined: 15 Aug 2015
Posts: 350
Location: Bamberg, Germany

PostPosted: Sun Mar 01, 2020 8:24 pm
Reply with quote

I noticed the glitch with position myself but could not edit anymore.

Glad it works so far. icon_wink.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Forum Replies
No new posts How to find which file contains my se... DFSORT/ICETOOL 6
No new posts Changing Data Type SYNCSORT 4
No new posts Copying data from prev record using SORT SYNCSORT 19
No new posts how to get total count from numeric d... SYNCSORT 9
No new posts Group selective VB records - Trailer ... DFSORT/ICETOOL 16

Back to Top