View previous topic :: View next topic
|
Author |
Message |
picus_mf Warnings : 1 New User
Joined: 09 Jun 2006 Posts: 52
|
|
|
|
Hello,
I have PS file's, some text containing in it say like,
One PS file
1. hello
my name is Mr. XYZ
My date of joining is CCYYMMDD. ---> <date>
Second file PS file
Hello
My date of joining is 20YYMMDD. ----> <date>
Third PS file
Hello, My date of joining is MMDD. ---> <date>
Like wise I will have no of PS files with different formats and date not in the same format and position. I should write only 1 cobol program which reads the data from the PS file and output it to other file substituting the dates with current day.
My query is how to recognize the position from where the date is starting and which format is used YYMMDD or MMDD or CCYYMMDD so that I substitute the dates.
Thanks. <eom> |
|
Back to top |
|
|
vicky11121982
New User
Joined: 21 Jun 2007 Posts: 9 Location: gurgaon
|
|
|
|
Declare the file record structure in File section and read your file in that record and replace date variables |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Few queries..
Quote: |
output it to other file substituting the dates with current day.
|
do you mean irrespective of date in input file you want it to be replaced by Current day (day for current system date)?
Also,
will date will be followed by literal "joining is " ?
It would be better if you give sample input and desired output.. |
|
Back to top |
|
|
picus_mf Warnings : 1 New User
Joined: 09 Jun 2006 Posts: 52
|
|
|
|
The input file will not contain any dates. Only the date format would be present. And current date has to be placed over there following 'joining is'
The input formats are the same which I mentioned in initial posts. The outputs should be the same except that date has to be replaced where ever formats appear. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi Check below code
Code: |
*WS
*01 INVAR1 PIC X(40) VALUE 'MY DATE OF JOINING IS 20YYMMDD'.
*01 INVAR1 PIC X(40) VALUE 'MY DATE OF JOINING IS CCYYMMDD'.
*01 INVAR1 PIC X(40) VALUE 'MY DATE OF JOINING IS YYMMDD'.
01 INVAR1 PIC X(40) VALUE 'MY DATE OF JOINING IS MMDD'.
01 TEMPOUT1 PIC X(40).
01 TEMPOUT2 PIC X(8).
01 CURRDATE.
05 YR1 PIC X(2).
05 YR2 PIC X(2).
05 MM PIC X(2).
05 DD PIC X(2).
*PD
MOVE FUNCTION CURRENT-DATE TO CURRDATE.
UNSTRING INVAR1 DELIMITED BY "JOINING IS "
INTO TEMPOUT1
TEMPOUT2.
INSPECT TEMPOUT2 REPLACING ALL "YY" BY YR2.
INSPECT TEMPOUT2 REPLACING ALL "MM" BY MM.
INSPECT TEMPOUT2 REPLACING ALL "DD" BY DD.
DISPLAY "REQUIRED OUTPUT IS:"
DISPLAY TEMPOUT1.
DISPLAY "JOINING IS " TEMPOUT2.
|
Output is
Code: |
REQUIRED OUTPUT IS:
MY DATE OF
JOINING IS 0916
|
Consideration: I assumed that date format (YYMMDD or MMDD or ....) is last word in the line if present
Note i have not removed trailing spaces in tempout1.
you can search forum for it or
check this link http://ibmmainframes.com/about25716.html |
|
Back to top |
|
|
|