Program REXX

This forum provides the support of Dezhi Mainframe systems. Please post your questions about logon, usage of our mainframe environment.

Moderators: sysprog, prino, sfan, steve-myers, Tim001

Program REXX

Postby celsofigueiredo » Fri 04 Dec 2009, 22:58

Dear.
I have to do a REXX program to calculate how many days left until the next anniversary of the mainframe (April 7, 1964). When you run the program in REXX, it should show the current date and ask the User that between the number of days per week to be considered useful (eg if I take note that Saturday and Sunday are not working days, would come with 5 . If you consider Sunday as not only useful, would come with 6). Display an error message if the number of working days is less than 1 or greater than 7. After the performance, display the total number of days missing, according to the number of days you took a week. I do not have much knowledge in REXX, but if you can help, I thank you.
celsofigueiredo
 

Re: Program REXX

Postby prino » Sat 05 Dec 2009, 10:54

Please ask such non-Dezhi specific questions in one of the four mainframe forums mentioned in the Mainframe FAQ forum, and supply them with the code. You are much more likely to get a reply there than here.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
Some programming here :mrgreen:
prino
 
Posts: 479
Joined: Sat 06 Jun 2009, 21:41
Location: Vilnius, Lithuania

Re: Program REXX

Postby Rakesh kotha » Mon 07 Dec 2009, 17:48

Below code may help you!!

Code: Select all
/*REXX*/                                                             
current_date = DATE(s)                                               
say 'current date is:  ;'date()                                     
say 'number of days per week to be considered'                       
pull working_days                                                   
if working_days > 7 | working_days < 0 | working_days = '' then
  do   
  say 'please enter value between 0 and 7'                             
  exit                                                                 
end                                                                 

current_month = substr(current_date,5,2)                             
current_year = substr(current_date,1,4)                             
if current_month <= 4 then  /* here 4 represets April month */       
  do                                                                 
   base_day2 = date('b','7 Apr 'current_year'')                     
   base_day1 = date('b')                                             
   days_differance = base_day2 - base_day1                           
   say 'total days remaining for birth day:  ' days_differance       
   working_days_differance = days_differance/7*working_days         
   say 'working days remaining for birth day: ',                     
        format(working_days_differance,3,0)                           
  end                                                                 
else                                                                 
  do                                                                 
   current_year = current_year + 1                                   
   base_day2 = date('b','7 Apr 'current_year'')                       
   base_day1 = date('b')                                             
   days_differance = base_day2 - base_day1                           
   say 'total days remaining for birth day:  ' days_differance       
   working_days_differance = days_differance/7*working_days       
   say 'working days remaining for birth day: ',                   
       format(working_days_differance,3,0)                         
  end
Thanks
Rakesh Kotha
CICS & MQ System Programmer
Rakesh kotha
 
Posts: 33
Joined: Sat 30 May 2009, 04:46

Re: Program REXX

Postby prino » Mon 07 Dec 2009, 21:06

"Give a Man a Fish, Feed Him For a Day. Teach a Man to Fish, Feed Him For a Lifetime" - Lao Tzu


Do not post complete solutions, help people find the solution themselves, don't show off!

Robert
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
Some programming here :mrgreen:
prino
 
Posts: 479
Joined: Sat 06 Jun 2009, 21:41
Location: Vilnius, Lithuania

Re: Program REXX

Postby celsofigueiredo » Tue 08 Dec 2009, 23:44

Dear.

I changed a little more this REXX code, but still with errors in logic, is to improve more?
----------------------------------
Code: Select all
/*REXX*/                                                   
/*trace i*/                                                 
current_date = DATE(s)                                     
say 'A data de hoje eh: 'date()                             
do while working_days > 7 | working_days < 1               
   say 'numero de dias uteis a ser considerado (1 a 7): '   
   pull working_days                                       
   if working_days < 1 | working_days > 7 then             
      say 'Dias uteis tem que ser maior que 1 e menor que 7'
end                                                         
say 'Irao ser considerados 'working_days' dias uteis' 
current_month = substr(current_date,5,2)                   
current_year = substr(current_date,1,4)                     
if current_month <= 4 then /* here 4 represets April month */
 do                                                         
  base_day2 = date('b','7 Apr 'current_year'')             
  base_day1 = date('b')                                     
  days_differance = base_day2 - base_day1                   
  say 'Total de dias restantes para o dia de nascimento: ',
  days_differance                                           
  working_days_differance = days_differance/7*working_days 
  say 'dias úteis restantes para os dias de nascimento: ', 
  format(working_days_differance,3,0)                       
 end                                                       
else                                                       
 do                                                         
  current_year = current_year + 1                           
  base_day2 = date('b','7 Apr 'current_year'')             
  base_day1 = date('b')                                     
  days_differance = base_day2 - base_day1                   
  say 'Total de dias restantes para o dia de nascimento: ',
  days_differance                                           
  working_days_differance = days_differance/7*working_days 
  say 'dias úteis restantes para os dias de nascimento: ', 
  format(working_days_differance,3,0)                       
end
Last edited by prino on Wed 09 Dec 2009, 07:55, edited 1 time in total.
Reason: Added code tags
celsofigueiredo
 


Return to Dezhi systems: Mainframe

Who is online

Users browsing this forum: No registered users and 0 guests

cron