Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Outrec IFTHEN builds data in wrong position

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
saikarthik94

New User


Joined: 04 Sep 2019
Posts: 5
Location: India

PostPosted: Sun Mar 01, 2020 2:14 pm    Post subject: Outrec IFTHEN builds data in wrong position
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: 5
Location: India

PostPosted: Sun Mar 01, 2020 2:20 pm    Post subject:
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: 292
Location: Bamberg, Germany

PostPosted: Sun Mar 01, 2020 3:44 pm    Post subject:
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: 292
Location: Bamberg, Germany

PostPosted: Sun Mar 01, 2020 4:03 pm    Post subject:
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: 2378
Location: Hampshire, UK

PostPosted: Sun Mar 01, 2020 5:52 pm    Post subject: Reply to: Outrec IFTHEN builds data in wrong position
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: 5
Location: India

PostPosted: Sun Mar 01, 2020 7:35 pm    Post subject:
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: 292
Location: Bamberg, Germany

PostPosted: Sun Mar 01, 2020 8:24 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IFTHEN : Is there a better way? kushkush DFSORT/ICETOOL 7 Fri Jul 31, 2020 1:32 pm
No new posts Extract part of data from file and wr... sathyajes DFSORT/ICETOOL 9 Thu Jul 16, 2020 10:49 am
No new posts SEQNUM with TRA=ETOA in OUTREC juares castro SYNCSORT 5 Sat May 30, 2020 5:40 am
No new posts Position BSAM file on multi volume lbjerges PL/I & Assembler 3 Thu May 07, 2020 8:13 pm
No new posts Write 9(07) comp-3 data into output file clearskynot DFSORT/ICETOOL 4 Thu Apr 16, 2020 11:00 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us