Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
suraaj

New User

Joined: 16 Apr 2009
Posts: 69

Posted: Tue May 28, 2013 12:25 am    Post subject: Replace date field

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.

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?

Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

Posted: Tue May 28, 2013 12:45 am    Post subject: Reply to: Replace date field

I don't understand your second question. If ADDDAYS will work, why do you want to break it down like that?
suraaj

New User

Joined: 16 Apr 2009
Posts: 69

Posted: Tue May 28, 2013 12:57 am    Post subject: Reply to: Replace date field

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:

which is not working.
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Tue May 28, 2013 2:07 am    Post subject: Reply to: Replace date field You'll need to show what is "not working" about it.
suraaj

New User

Joined: 16 Apr 2009
Posts: 69

 Posted: Tue May 28, 2013 2:16 am    Post subject: Reply to: Replace date field Meanwhile if someone could help me with my first question
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Tue May 28, 2013 3:42 am    Post subject: Reply to: Replace date field 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.
suraaj

New User

Joined: 16 Apr 2009
Posts: 69

 Posted: Tue May 28, 2013 7:21 pm    Post subject: Reply to: Replace date field Thanks Bill. For my second question, I am getting SOC7 when I use the said sort card.
dick scherrer

Site Director

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

 Posted: Tue May 28, 2013 7:28 pm    Post subject: Hello, Then the data is incorrect or the position(s) are . . . Show (in Hex) a record that causes the 0c7.
Skolusu

Senior Member

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

Posted: Tue May 28, 2013 11:49 pm    Post subject: Re: Replace date field

 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.
suraaj

New User

Joined: 16 Apr 2009
Posts: 69