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 editting the file by inserting zeros ... pramodrsingh DFSORT/ICETOOL 9 Mon Aug 21, 2017 5:58 pm
No new posts Match two files using multiple keys a... santoshks1987 SYNCSORT 11 Fri Aug 18, 2017 10:50 am
No new posts change string before sertan string anatol DFSORT/ICETOOL 8 Tue Aug 15, 2017 5:43 pm
No new posts Multiple VSAM files single output fil... Mohan Kothakota DFSORT/ICETOOL 11 Wed Aug 09, 2017 7:57 pm
This topic is locked: you cannot edit posts or make replies. rexx code to create a ps file Bharath Vikraman CLIST & REXX 4 Mon Aug 07, 2017 10:30 am


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