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

Replacing a string format with values in a file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
picus_mf
Warnings : 1

New User


Joined: 09 Jun 2006
Posts: 52

PostPosted: Tue Sep 16, 2008 2:56 pm
Reply with quote

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
View user's profile Send private message
vicky11121982

New User


Joined: 21 Jun 2007
Posts: 9
Location: gurgaon

PostPosted: Tue Sep 16, 2008 4:31 pm
Reply with quote

Declare the file record structure in File section and read your file in that record and replace date variables
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Sep 16, 2008 7:16 pm
Reply with quote

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
View user's profile Send private message
picus_mf
Warnings : 1

New User


Joined: 09 Jun 2006
Posts: 52

PostPosted: Tue Sep 16, 2008 7:34 pm
Reply with quote

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
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Tue Sep 16, 2008 9:10 pm
Reply with quote

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
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
Search our Forums:

Back to Top