Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Replacing a string format with values in a file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
picus_mf
Warnings : 1

New User


Joined: 09 Jun 2006
Posts: 51

PostPosted: Tue Sep 16, 2008 2:56 pm    Post subject: Replacing a string format with values in a file
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    Post subject:
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    Post subject:
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: 51

PostPosted: Tue Sep 16, 2008 7:34 pm    Post subject: @Sambhaji
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us