to send reprot on a particular day



Software AG's platform-independent programming language with full support for open-source and Internet applications

to send reprot on a particular day

Postby diptisaini » Fri Mar 25, 2011 2:11 pm

Hi,
Currently we are using below code to send a report to the user on THURSDAY but now our requirement is to send the report on FRIDAY.Could you please let me know how we can acheive this by using below code :-

IF #KL6015P0-IN-MSG-TYPE = 535
MOVE EDITED #CAL-IN-DATE (EM=WW) TO #WEEK-NO1-A
MOVE EDITED #CAL-OUT-NEXT-WORKING-DAY (EM=WW) TO #WEEK-NO2-A
MOVE EDITED #CAL-IN-DATE (EM=O) TO #DAY-IN-WEEK1-A
MOVE EDITED #CAL-OUT-NEXT-WORKING-DAY (EM=O) TO #DAY-IN-WEEK2-A
* --- TODAY & NEXT DAY IN THE SAME WEEK AND NEXT DAY IS FRIDAY
IF ( #WEEK-NO1 = #WEEK-NO2 AND #DAY-IN-WEEK2 = 5 )
* --- NEXT DAY IN FUTURE WEEK & TODAY IS NOT FRIDAY
* ==> LAST WORKING DAY IF FRIDAY IS A HOLIDAY
IF ( #WEEK-NO1 = #WEEK-NO2 AND #DAY-IN-WEEK2 = 5 )
OR ( #WEEK-NO2 > #WEEK-NO1 AND #DAY-IN-WEEK1 NE 5 )
OR ( #WEEK-NO2 NE #WEEK-NO1 AND #DAY-IN-WEEK1 NE 5 )
END-IF
#KL6015P0-OUT-SWIFT-REQUIRED := TRUE
ELSE
#KL6015P0-OUT-SWIFT-REQUIRED := FALSE
END-IF

Note :- If it is a holiday on a THRUSDAY then it sends the on the current business day
diptisaini
 
Posts: 90
Joined: Sun Mar 14, 2010 5:12 pm
Has thanked: 0 time
Been thanked: 0 time

Re: to send reprot on a particular day

Postby BillyBoyo » Fri Mar 25, 2011 3:18 pm

IF #KL6015P0-IN-MSG-TYPE = 535
    MOVE EDITED #CAL-IN-DATE (EM=WW) TO #WEEK-NO1-A
    MOVE EDITED #CAL-OUT-NEXT-WORKING-DAY (EM=WW) TO #WEEK-NO2-A
    MOVE EDITED #CAL-IN-DATE (EM=O) TO #DAY-IN-WEEK1-A
    MOVE EDITED #CAL-OUT-NEXT-WORKING-DAY (EM=O) TO #DAY-IN-WEEK2-A
* --- TODAY & NEXT DAY IN THE SAME WEEK AND NEXT DAY IS FRIDAY
    IF ( #WEEK-NO1 = #WEEK-NO2 AND #DAY-IN-WEEK2 = 5 )
* --- NEXT DAY IN FUTURE WEEK & TODAY IS NOT FRIDAY
* ==> LAST WORKING DAY IF FRIDAY IS A HOLIDAY
        IF ( #WEEK-NO1 = #WEEK-NO2 AND #DAY-IN-WEEK2 = 5 )
        OR ( #WEEK-NO2 > #WEEK-NO1 AND #DAY-IN-WEEK1 NE 5 )
        OR ( #WEEK-NO2 NE #WEEK-NO1 AND #DAY-IN-WEEK1 NE 5 )
        END-IF
        #KL6015P0-OUT-SWIFT-REQUIRED := TRUE
    ELSE
        #KL6015P0-OUT-SWIFT-REQUIRED := FALSE
    END-IF


If you can use the "code" button when presenting code. I've done it with your code as well as I can, but it looks odd. An END-IF missing at least. The test for friday is a holiday doesn't seem to have any code in it.

Can you double-check the code and post it with the "code" button and confirm that it is the code as it is working now.

I'd guess if this is from an overnight batch, the intention was for the user to be able to receive the report on the last working day of the week. So, this requirement is changing so that the report is to be produced from the last batch run of the week, ie on a Friday if it is not a holiday, else on a Thursday. In some countries you can get consecutive holiday days. How about where this is running? What is the most number of consecutive holiday days you can have?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: to send reprot on a particular day

Postby diptisaini » Fri Mar 25, 2011 5:04 pm

If its a holiday then it should sent a report as of current-buisness date.
diptisaini
 
Posts: 90
Joined: Sun Mar 14, 2010 5:12 pm
Has thanked: 0 time
Been thanked: 0 time

Re: to send reprot on a particular day

Postby BillyBoyo » Fri Mar 25, 2011 5:59 pm

I don't understand your last comment.

One thing I would suggest is that the request for the report should be in the "schedule" of jobs for that day, or if your "cal" file is all your information for business days, is it possible to add a flag, whose value is worked out at some point, that simply tells the program when to run or not? Working out in the program that the report is needed is prone to errors. The more programs doing this, the more you get different coding in different programs.

Coding in the program also limits the possibility of running the report "ad hoc", when the user says "I need that report run today/tonight" and it isn't the usual conditions for the report to be produced.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: to send reprot on a particular day

Postby BillyBoyo » Fri Mar 25, 2011 8:10 pm

* --- NEXT DAY IN FUTURE WEEK & TODAY IS NOT FRIDAY
* ==> LAST WORKING DAY IF FRIDAY IS A HOLIDAY
        IF ( #WEEK-NO1 = #WEEK-NO2 AND #DAY-IN-WEEK2 = 5 )
        OR ( #WEEK-NO2 > #WEEK-NO1 AND #DAY-IN-WEEK1 NE 5 )
        OR ( #WEEK-NO2 NE #WEEK-NO1 AND #DAY-IN-WEEK1 NE 5 )
        END-IF


You see, you already have an example of what I'm getting at. You say it does this or that for holiday - but there is no code for the IF being true. The first part of the IF above repeats the test of the IF that it is nested within. If you know that that is already true, then the other two parts of the IF will always be false. Basically it is rubbish.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: to send reprot on a particular day

Postby BillyBoyo » Sat Mar 26, 2011 4:05 am

Assuming that the next working day part works from where it is extracted:

    IF ( #WEEK-NO2 > #WEEK-NO1)

or, alternatively, your choice

    IF ( #WEEK-NO2 NE #WEEK-NO1)



In English, if the week number of the next working day is different from the week number of today (a working day) then it is the last working day of the current week (number) and you want to kick out the data for the report. Otherwise you don't. Note that the week number of the next working day is never less than the week number of the current working day, which is why either test will work. Choose the "style" most likely to be recognised at your site.

This will automatically handle holidays, even if you have a week or more of them (noting the assumption right at the start of this post).

However, the code in the current program is confusing. I can't see how it is doing anything for holidays. If the holiday stuff is working (ie the user gets a report if there is a holiday on Friday), then there must be some other code somewhere else that relates to the production of the report in that case.

The existing code that you have shown us works something like this:


IF, and only IF, A is a Rabbit, ask the next IF, otherwise don't report
next IF, IF (A is a Rabbit)
            OR (B is a Snake)
            OR (SQRGLBING is a GARFNACK)
            OR (any other question at all that is a valid syntax)
                 Report



It is going to be important that your testing is thorough. I suggest that you include the testing of the original program as well, so that you can see what happens to that when, amongst other things, Friday is a holiday. I'd even suggest you test the original before you make your change. If the Friday holiday doesn't work, go back to the person who gave you the spec and show them. Always CYA (Cover Your Bottom) is my advice. Never, if you find an error in a program, just "fix" the error. Go back to the person who told you to look at the program. A follow-on from "if it ain't broke don't fix it" is "if it is broke, don't fix it without a spec change". If the Friday holiday does work, find out how (you have some more code to change).

When you get the "go ahead", make sure you delete the rubbish IF, and the even more rubbish "comment" associated with it. It is not a comment, it is a lie. People who put lies in programs, just because it starts with an"*" (or whatever) annoy the hell out of me (I know you didn't do it, don't worry).

I've looked at this with two different pairs of glasses, but still most important for you to test, test, test. Better luck with your next task :-)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: to send reprot on a particular day

Postby RGZbrog » Sun Mar 27, 2011 12:00 am

I, too, find the code confusing, perhaps because it's a snippet, and not the entire algorithm. Why would you determine the day is Thursday by testing for "the following day is Friday"?

In any case, I recommend replacing the weekday literal '5' with a variable, such as #REPORT-DAY. This will simplify the effort the next time you have to change the report day. Define the variable with the same format/length as #DAY-IN-WEEK1.
1 #REPORT-DAY (I1)   INIT <5>   /* 5 = Friday  (DTFORM<>U)

Then your code would look something like this:
IF   today    = #REPORT-DAY
  OR tomorrow = #REPORT-DAY AND tomorrow = holiday

Also, are you aware that a JCL change could cause your logic to fail? You test for the day of the week to be 5, indicating Friday. Here in the US, 5 indicates Thursday, because we consider the first day of the week to be Sunday, while most of the world considers Monday to be the start of the week. Natural determines the start of the week based on the DTFORM parameter. If DTFORM=U, 1=Sunday, otherwise, 1=Monday. So, if your shop allows Natural parameter overrides in JCL (as most shops do), then you could cause the logic to fail by coding DTFORM=U in your job step. I suspect that this situation is unlikely to occur, but you can guard against it by testing the DTFORM value before initializing #REPORT-DAY.
CALLNAT "USR1005N" ...
IF  DTFORM <> "U"
  THEN
    #REPORT-DAY := 5    /* Friday - international
  ELSE
    #REPORT-DAY := 6    /* Friday - USA
END-IF
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time

Re: to send reprot on a particular day

Postby BillyBoyo » Sun Mar 27, 2011 6:34 am

RGZbrog wrote:
CALLNAT "USR1005N" ...
IF DTFORM <> "U"
THEN
#REPORT-DAY := 5 /* Friday - international
ELSE
#REPORT-DAY := 6 /* Friday - USA
END-IF



Nice.

As to the code, we'll have to wait for the TS to be sure, but I think from the data names he has business days and week-in-the-year numbers in his calendar file. When the week-in-the-year numbers are different for today (business day) and next-working-day (business day) then we have the last working day of the week. Unfortunately, just from the data names we can't know for certain - the data names have to be correct :-)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: to send reprot on a particular day

Postby sochnedo » Fri Mar 13, 2015 9:58 am

If the week number of the next working day is different from the week number of today (a working day) then it is the last working day of the current week (number) and you want to kick out the data for the report. Otherwise you don't. Note that the week number of the next working day is never less than the week number of the current working day, which is why either test will work. Choose the "style" most likely to be recognised at your site.??
Try out our free learning spanish and latest comptia spanishprograms - how do you speak in spanish training courses to get high flying success in final and studyspanish exams
sochnedo
 
Posts: 1
Joined: Fri Mar 13, 2015 9:19 am
Has thanked: 0 time
Been thanked: 0 time

Re: to send reprot on a particular day

Postby enrico-sorichetti » Fri Mar 13, 2015 10:11 am

do You realize that You replied to a 4 years old topic ?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times


Return to Natural

 


  • Related topics
    Replies
    Views
    Last post