IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Replace date field


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

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Tue May 28, 2013 12:25 am
Reply with quote

I have a file with lrecl=80. There is date field at position 20 in yyyymmdd format. I am trying to encrypt the records with everything except the date as below (it contains only alphabets and numeric data).

Code:

SORT FIELDS=COPY                                                 
INREC IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=1,ENDPOS=19,           
       INOUT=(C'A',C'Z',C'B',C'Y',C'C',C'X',C'D',C'W',C'E',C'V', 
             C'F',C'U',C'G',C'T',C'H',C'S',C'I',C'R',C'J',C'Q',   
             C'K',C'P',C'L',C'O',C'M',C'N',C'N',C'M',C'O',C'L',   
             C'P',C'K',C'Q',C'J',C'R',C'I',C'S',C'H',C'T',C'G',   
             C'U',C'F',C'V',C'E',C'W',C'D',C'X',C'C',C'Y',C'B',   
             C'Z',C'A',                                           
             C'0',C'9',C'1',C'8',C'2',C'7',C'3',C'6',C'4',C'5',   
             C'5',C'4',C'6',C'3',C'7',C'2',C'8',C'1',C'9',C'0'))),
      IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=28,ENDPOS=80,           
       INOUT=(C'A',C'Z',C'B',C'Y',C'C',C'X',C'D',C'W',C'E',C'V', 
             C'F',C'U',C'G',C'T',C'H',C'S',C'I',C'R',C'J',C'Q',   
             C'K',C'P',C'L',C'O',C'M',C'N',C'N',C'M',C'O',C'L',   
             C'P',C'K',C'Q',C'J',C'R',C'I',C'S',C'H',C'T',C'G',   
             C'U',C'F',C'V',C'E',C'W',C'D',C'X',C'C',C'Y',C'B',   
             C'Z',C'A',                                           
             C'0',C'9',C'1',C'8',C'2',C'7',C'3',C'6',C'4',C'5',   
             C'5',C'4',C'6',C'3',C'7',C'2',C'8',C'1',C'9',C'0'))),


Then I am again sorting the dataset in the next step for changing the date by adding 385 to the number of days as mentioned below.

Code:

SORT FIELDS=COPY                                     
INREC OVERLAY=(20:20,8,Y4T,ADDDAYS,+395,TOGREG=Y4T)



Now I have 2 questions:

Can I merge these 2 sortcards into one because when I tried overlay isnt working if I put it alongwith the first sort card.
Can I use ADDDAYS, ADDMONS, ADDYEARS in the second sortcard together if I want to change +395 to years, months, days as 1 year, 1 month, 5 days in case of non-leap year?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 28, 2013 12:45 am
Reply with quote

Code:
  IFTHEN=(WHEN=INIT,OVERLAY=(20:20,8,Y4T,ADDDAYS,+395,TOGREG=Y4T))


I don't understand your second question. If ADDDAYS will work, why do you want to break it down like that?
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Tue May 28, 2013 12:57 am
Reply with quote

I was meaning that instead of 395 I just could mention it as 1 year, 1 month. The requirement is for 1 year and 1 month which I had calculated it as 395. It would be simpler if I just put it as 1 year and 1 month as below:

Code:

SORT FIELDS=COPY                                     
INREC OVERLAY=(20:20,8,Y4T,ADDYEARS,+1,TOGREG=Y4T,
                           20:20,8,Y4T,ADDMONS,+1,TOGREG=Y4T)


which is not working.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 28, 2013 2:07 am
Reply with quote

You'll need to show what is "not working" about it.
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Tue May 28, 2013 2:16 am
Reply with quote

Meanwhile if someone could help me with my first question
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue May 28, 2013 3:42 am
Reply with quote

I've answered your first question :-)

On INREC, if you use OVERLAY (or if you use BUILD), then you can't use IFTHEN.

BUT if you use IFTHEN, the IFTHEN can contain OVERLAY (or build).

So to put your two steps together, you take the line I've shown and add it to the IFTHENs you already have. It can be before, or after, as the results are not dependent on each other in this case.
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Tue May 28, 2013 7:21 pm
Reply with quote

Thanks Bill.

For my second question, I am getting SOC7 when I use the said sort card.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue May 28, 2013 7:28 pm
Reply with quote

Hello,

Then the data is incorrect or the position(s) are . . .

Show (in Hex) a record that causes the 0c7.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue May 28, 2013 11:49 pm
Reply with quote

suraaj wrote:

Now I have 2 questions:

Can I merge these 2 sortcards into one because when I tried overlay isnt working if I put it alongwith the first sort card.
Can I use ADDDAYS, ADDMONS, ADDYEARS in the second sortcard together if I want to change +395 to years, months, days as 1 year, 1 month, 5 days in case of non-leap year?


1. You are using the same FINDREP INOUT values. I suggest that you Move the date field to the end at pos 81 and then perform the FINDREP with endpos=80. You will be done with 1 FINDREP statement.

2. You can perform Addyears, addmons, adddays on the temp field at pos 81 and finally you can overlay it back again to position 20.

You are probably getting an error because conversion involving an input date with an invalid digit (A-F) will result in a data exception (0C7 ABEND) or an incorrect output value. so try to fix the invalid dates.
Back to top
View user's profile Send private message
suraaj

New User


Joined: 16 Apr 2009
Posts: 69
Location: Canada

PostPosted: Wed May 29, 2013 8:05 pm
Reply with quote

Thanks Skolusu....
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Need to convert date format DFSORT/ICETOOL 20
Search our Forums:

Back to Top