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

replace word 'MONTH' with current month name in input file


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jaganmoni1

New User


Joined: 31 Oct 2008
Posts: 35
Location: CANADA

PostPosted: Mon Jun 19, 2023 9:08 pm
Reply with quote

Hi,

I have following input file with record length of 132 bytes. I want to replace word MONTH with current month name i.e. June or July or August etc.. based on current month.

Input File:
HELLO GUYS
TO: <ram@gmail.com>
FROM: <jagan@gmail.com>

SUBJECT: file has been received for MONTH successfully

Do NOT respond to this email. It is being sent from a machine.

Output File: MONTH should be replaced with June as current month is June
HELLO GUYS
TO: <ram@gmail.com>
FROM: <jagan@gmail.com>

SUBJECT: file has been received for June successfully

Do NOT respond to this email. It is being sent from a machine.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1211
Location: Bamberg, Germany

PostPosted: Mon Jun 19, 2023 9:20 pm
Reply with quote

See FINDREP, it should be of help.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2000
Location: USA

PostPosted: Mon Jun 19, 2023 9:23 pm
Reply with quote

There are two independent issues:

1) how to get the current month name?

2) how to replace the word “month” with the month name from #1?

Try to resolve two issues separately, one by one.
Which of them is causing a problem?
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2000
Location: USA

PostPosted: Mon Jun 19, 2023 10:19 pm
Reply with quote

Requirement #0:
Learn how to make your questions attractive to volunteers who may decide to help you.
jaganmoni1 wrote:
Hi,

I have following input file with record length of 132 bytes. I want to replace word MONTH with current month name i.e. June or July or August etc.. based on current month.

Input File:
Code:
HELLO GUYS
TO: <ram@gmail.com>
FROM: <jagan@gmail.com>

SUBJECT: file has been received for MONTH successfully

Do NOT respond to this email. It is being sent from a machine.


Output File: MONTH should be replaced with June as current month is June
Code:
HELLO GUYS
TO: <ram@gmail.com>
FROM: <jagan@gmail.com>

SUBJECT: file has been received for June successfully

Do NOT respond to this email. It is being sent from a machine.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1211
Location: Bamberg, Germany

PostPosted: Tue Jun 20, 2023 10:21 am
Reply with quote

You might want to try this (assuming your input is FB80):
Code:
OPTION COPY                                                       
INREC IFTHEN=(WHEN=(1,8,CH,EQ,C'SUBJECT:'),                       
  OVERLAY=(81:DATE2,                                               
           81:85,2,CHANGE=(09,C'01',C'January',                   
                              C'02',C'February',                   
                              C'03',C'March',                     
                              C'04',C'April',                     
                              C'05',C'May',                       
                              C'06',C'June',                       
                              C'07',C'July',                       
                              C'08',C'August',                     
                              C'09',C'September',                 
                              C'10',C'October',                   
                              C'11',C'November',                   
                              C'12',C'December')),HIT=NEXT),       
  IFTHEN=(WHEN=ANY,                                               
    BUILD=(C'SUBJECT: File has been received for ',               
           81,9,SQZ=(SHIFT=LEFT,TRAIL=C' successfully',LENGTH=44)))
END
Back to top
View user's profile Send private message
jaganmoni1

New User


Joined: 31 Oct 2008
Posts: 35
Location: CANADA

PostPosted: Tue Jun 20, 2023 12:00 pm
Reply with quote

Thank you so much Joerg. I will let you know if I have any further questions on same.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2000
Location: USA

PostPosted: Tue Jun 20, 2023 4:58 pm
Reply with quote

Joerg.Findeisen wrote:
You might want to try this (assuming your input is FB80):
Code:
OPTION COPY                                                       
INREC IFTHEN=(WHEN=(1,8,CH,EQ,C'SUBJECT:'),                       
  OVERLAY=(81:DATE2,                                               
           81:85,2,CHANGE=(09,C'01',C'January',                   
                              C'02',C'February',                   
                              C'03',C'March',                     
                              C'04',C'April',                     
                              C'05',C'May',                       
                              C'06',C'June',                       
                              C'07',C'July',                       
                              C'08',C'August',                     
                              C'09',C'September',                 
                              C'10',C'October',                   
                              C'11',C'November',                   
                              C'12',C'December')),HIT=NEXT),       
  IFTHEN=(WHEN=ANY,                                               
    BUILD=(C'SUBJECT: File has been received for ',               
           81,9,SQZ=(SHIFT=LEFT,TRAIL=C' successfully',LENGTH=44)))
END


Instead of the requirement:
Quote:
MONTH should be replaced with June as current month is June

actually
Quote:
The whole SUBJECT line has been replaced with completely new content; the original content has been eliminated.


For instance: the input message template like this one
Code:
SUBJECT: Unsuccessful file transfer for MONTH processing.
will be replaced with
Code:
SUBJECT: File has been received for June successfully

To say nothing about possible month substitution to other lines of message body, about hardcoded fixed positions of the replaced text, etc. etc.

The worst of all is: the TS has not a minor intention to learn something for his own future career. Only: "Do my job for me, from start to finish". Nothing else.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1211
Location: Bamberg, Germany

PostPosted: Tue Jun 20, 2023 5:09 pm
Reply with quote

It was not part of the requirement, simple as that.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2000
Location: USA

PostPosted: Tue Jun 20, 2023 5:23 pm
Reply with quote

Joerg.Findeisen wrote:
It was not part of the requirement, simple as that.

If so, it should be much easier and more clear just to generate the new message from scratch, rather than: using a message template text, but completely replace its content...
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2000
Location: USA

PostPosted: Wed Jun 21, 2023 1:12 am
Reply with quote

The word “ MONTH “ to be replaced anywhere, any number of instances.

Code:
 INREC IFTHEN=(WHEN=INIT,
               BUILD=(1,72,8X,&DATE2,160:X)),
       IFTHEN=(WHEN=(1,72,SS,EQ,C’ MONTH ‘),
               PARSE=(%01=(ENDBEFR=C’ MONTH ‘,FIXLEN=72),
                      %02=(FIXLEN=72)),
               BUILD=(%01,C’ ~’,85,2,C’~ ‘,%02,160:X)),
       IFTHEN=(WHEN=ANY,
               BUILD=(2,159,SQZ=(SHIFT=LEFT,MID=C’ ‘))),
       IFTHEN=(WHEN=ANY,
               FINDREP=(INOUT=(C’~01~’,C’January’,
                               . . . . . . . . . .
                               C’~12~’,C’December’),
                        OVERRUN=TRUNC))
 OUTREC BUILD=(1,80)
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1211
Location: Bamberg, Germany

PostPosted: Wed Jun 21, 2023 9:41 am
Reply with quote

This will possibly render the message body invalid. That's why I have limited the change to the Subject line only.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1211
Location: Bamberg, Germany

PostPosted: Thu Jun 22, 2023 12:53 am
Reply with quote

Minor update for changing SUBJECTs (word MONTH should be present however):
Code:
OPTION COPY                                             
INREC IFTHEN=(WHEN=(1,8,CH,EQ,C'SUBJECT:'),             
  PARSE=(%01=(ENDBEFR=C'MONTH',FIXLEN=72),               
         %02=(FIXLEN=72)),                               
  OVERLAY=(%01,DATE2,                                   
           73:77,2,CHANGE=(10,C'01',C'January',         
                              C'02',C'February',         
                              C'03',C'March',           
                              C'04',C'April',           
                              C'05',C'May',             
                              C'06',C'June',             
                              C'07',C'July',             
                              C'08',C'August',           
                              C'09',C'September',       
                              C'10',C'October',         
                              C'11',C'November',         
                              C'12',C'December'),%02,   
           1:1,154,SQZ=(SHIFT=LEFT,MID=C' ',LENGTH=80)))
END
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 8
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top