View previous topic :: View next topic
|
Author |
Message |
sivasree03
New User
Joined: 12 Sep 2008 Posts: 8 Location: chennai
|
|
|
|
Hi,
I have to change few dates in hexa decimal format in a sequential file. We will have the dates in different positions. I have to search and replace them.
For example we will have the dates from FEB 01 to FEB 28. We need to change all these dates to MAR 15.
Currently we are using C ALL command for each date and changing all dates to MAR 15. The dates will be from x'1110201c' to x'1110228c'
If anybody of you know logic for this, could you please help me? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
What sort of logic? Business logic? Program algorithm?
Why are you changing it to x'1110228c' when you say you want to change it to 15th of March which is x'1110315c'?
Are the dates in fixed places? If so you could write a small COBOL, or other language, program to read in each record, change the date and write the record out again.
If the dates are not in fixed positions you could write an ISPF edit macro to do what you do manually. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Quote: |
...will have the dates from FEB 01 to FEB 28 |
I think the poster meant: "...will have the dates from FEB 01 through FEB 28' |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Here is the logic:
1. create editor macro in rexx, that includes this line:
Code: |
"C ALL x'1110201c' x'1110315c' " |
2. repeat the line 27 times
3. use the mouse to copy the sequence numbers (01 through 28) that are shown in the left margin of the editor. Copy a tall but thin area that includes the last two digits of the sequence number and for 28 lines deep.
4. Paste that over the day position in the editor change commands so that each one will now have a different date value (01 through 28).
The point being that sometimes a low tech approach is faster. |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
Since the "from" value is all possible values of the DAY portion (excluding Feb 29th ) it might be easier to just use the Picture clause of the Editor Change Command - i.e. C P'11102==' C'1110315' ALL |
|
Back to top |
|
|
Michael Jakob
New User
Joined: 13 Mar 2011 Posts: 17 Location: Switzerland
|
|
|
|
Hi, do you expect anything like this?
Edit-Macro
Member CHGDAT
/* REXX */
ADDRESS 'ISPEXEC'
"ISREDIT MACRO (fromDate1 fromDate2 toDate pos)"
ix1 = right(fromDate1,2);
ix2 = right(fromDate2,2);
do ix=ix1 to ix2;
myDate = left(Date1,4)!!right(ix,2);
"isredit" "change x'"myDate"' x'"toDate"' ALL "pos
end;
"ISREDIT" "MEND"
EXIT 0
The call should work like this
COMMAND ==> CHGDAT 110201 28 110315 117
CHGDAT: Edit-Macro
110201: From Date - Feb 01 2011
28: Last From Date for Feb 28 2011
110315: Change to Date
117: Position |
|
Back to top |
|
|
sivasree03
New User
Joined: 12 Sep 2008 Posts: 8 Location: chennai
|
|
|
|
Thanks all for your reply.
Michael,
The FROM date position is not constant, it can be any where in sequential file. |
|
Back to top |
|
|
|