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 Receive a file using PCOMM macro Harald.v.K IBM Tools 0 Thu Mar 23, 2017 6:50 pm
No new posts How to pick only YYMMDD from DATE1P (... atulbaviskar SYNCSORT 7 Wed Mar 22, 2017 11:39 am
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm


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