Page 1 of 1

write 'C','M','Q','Y' in out put file based on date

PostPosted: Sun Feb 03, 2019 8:37 pm
by thotlma
Hi All

iam new to cobol could you please help to get the cobol code for below requirement
i have filed in DB2 table. the filed should be update based on below requirement
the job will run every week in month. first it will read Mainframe system date then we have write below codes based on the condition

Mar Month End data - Q
June Month data - Q
September month End data - Q
December Month end data - Y
Rest of the month end data - M

example: suppose i will take January 2019
the job will run on 01/01/2019 the field value is 'Y' (it will take previous year last week data)
the job will run on 01/05/2019 the field value is 'C'
the job will run on 01/12/2019 the field value is 'C'
the job will run on 01/19/2019 the field value is 'C'
the job will run on 01/26/2019 the field value is 'C'
the job will run on 02/01/2019 the field value is 'M'(it will take previous month end data)

please help some one to get this ocde that would be appriciate?

Re: write 'C','M','Q','Y' in out put file based on date

PostPosted: Sun Feb 03, 2019 8:55 pm
by prino
Why would we help someone who's not even able to post in an appropriate forum?

What the flucking 'ell has COBOL to with Forum Rules????

Re: write 'C','M','Q','Y' in out put file based on date

PostPosted: Mon Feb 04, 2019 12:39 am
by Robert Sample
I moved the posts from Forum Rules to IBM Cobol.

Your post is quite confusing -- you state that the job will run weekly; not every month has its first day on the same day of the week (January 1st was a Tuesday while February, for example, had the 1st on a Friday). So how are you planning to accommodate that? If the job ran daily, what you want to do is trivial. With a weekly job frequency, it will take advanced (and complex) logic to be able to accomplish your goal. Perhaps you should try for a daily job frequency?

Re: write 'C','M','Q','Y' in out put file based on date

PostPosted: Mon Feb 04, 2019 4:54 pm
by NicC
Why are you making the flag 'C'? That is not in your list of flags (M, Q and Y).

Re: write 'C','M','Q','Y' in out put file based on date

PostPosted: Mon Feb 04, 2019 5:17 pm
by enrico-sorichetti
the real problem here is not the code ( whatever the language )

but the really bad description/understanding of the logic .

what really makes me wonder about the competence of the organisation ( the people )
is the poor understanding of week concept as far as the date processing is concerned

if the logic is clear the frequency of the run will be irrelevant ...

furthermore we must consider the legal point of view .

for internal use how to determine the first/last week of the year/month is really irrelevant

but when the data is shared with outside organisations there are some rules to follow ( ISO stuff )
expecially when the week crosses years
the last days of december might belong to the first week of the following year
the first days of january might belong to the last week of the previous year

there are quite many good reasons why the reference date for a process is most often given as a parameter
rather than automatically computed

remember IT is not just the lowly technicalities but understanding of the process and the constraint/rules

Re: write 'C','M','Q','Y' in out put file based on date

PostPosted: Mon Feb 04, 2019 6:31 pm
by thotlma
Robert Sample wrote:I moved the posts from Forum Rules to IBM Cobol.

Your post is quite confusing -- you state that the job will run weekly; not every month has its first day on the same day of the week (January 1st was a Tuesday while February, for example, had the 1st on a Friday). So how are you planning to accommodate that? If the job ran daily, what you want to do is trivial. With a weekly job frequency, it will take advanced (and complex) logic to be able to accomplish your goal. Perhaps you should try for a daily job frequency?


Hi Robert

Thanks for reply and sorry for making you consfused
This weekly job only but start from every Jan 1
please see the current run in production

XXSDA940 2019/01/01 06.29.28(here value will be 'Y' because it will take previous year end data)
XXSDA940 2019/01/05 02.11.49(Here value 'C')
XXSDA940 2019/01/12 01.49.31(Here value 'C')
XXSDA940 2019/01/19 00.38.52(Here value 'C')
XXSDA940 2019/01/26 00.25.00(Here value 'C')
XXSDA940 2019/02/01 03.40.02(Here value 'M' because it will take previous month end data)

Re: write 'C','M','Q','Y' in out put file based on date

PostPosted: Mon Feb 04, 2019 6:46 pm
by enrico-sorichetti
where is that You are facing problems ...
the logic or the code ?

You can ask on a forum how to fix Your bad code, You cannot ask for somebody to provide it