View previous topic :: View next topic
|
Author |
Message |
jaganmoni1
New User
Joined: 31 Oct 2008 Posts: 35 Location: CANADA
|
|
|
|
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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1394 Location: Bamberg, Germany
|
|
|
|
See FINDREP, it should be of help. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1394 Location: Bamberg, Germany
|
|
|
|
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 |
|
 |
jaganmoni1
New User
Joined: 31 Oct 2008 Posts: 35 Location: CANADA
|
|
|
|
Thank you so much Joerg. I will let you know if I have any further questions on same. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1394 Location: Bamberg, Germany
|
|
|
|
It was not part of the requirement, simple as that. |
|
Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
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 |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2228 Location: USA
|
|
|
|
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 |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1394 Location: Bamberg, Germany
|
|
|
|
This will possibly render the message body invalid. That's why I have limited the change to the Subject line only. |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1394 Location: Bamberg, Germany
|
|
|
|
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 |
|
 |
|
|