Find Previous Day From a Given Day
Hey guys, I'm new here and I just recently started working with Java, I am trying to figure out how to find the previous day for the 1st day and month of a year_. I.E. if passed the date (1,1,2000) in the mm/dd/yyyy format then the output would be (12,31,1999). I have everything worked out except I have to figure out how to find the last day of the previous month. I am trying to write this all from scratch to better understand Java, so i do not want to use the Calendar class or anything involved with it.
This is a handful of code that may not be formatted a bit sloppily, but if anyone has the time, I would greatly appreciate the help. (Also, I am aware that Java autmatically puts "this." if it is missing before a variable, I put mine in order to clearly see what's going on.) I made a test Class as well is anyone is interested in seeing it.
Also, how come the Java formatting does not show in the post?
* Date calculates the date and gives other information requested such as the birthday of someone, the
* previous and next days, whether the date is valid or not, and whether the year is a leap year
* @author Vlad Khmarsky
* @version 1.1
public class Date
/** The month */
int month = 00;
/** The day */
int day = 00;
/** The year */
int year = 0000;
/** First month of the year */
int firstMonth = 1;
/** Last month of the year */
int lastMonth = 12;
/** Asks for the day, month, and year upon creting an instance of dates
* @day asks for the day
* @month asks for the month
* @year asks for the year
Date( int month_, int day_, int year_) {
this.month = month_;
this.day = day_;
this.year = year_;
/** Gets the month passed in initially
* @return The month that is currently stored in the month field
int getMonth() {
return this.month;
/** Gets the day passed in initially
* @return The day that is currently stored in the month field
int getDay() {
return this.day;
/** Gets the year passed in initially
* @return The year that is currently stored in the month field
int getYear() {
return this.year;
/** Gets the number of days in the given month
* @return the number of days in the given month
int getDaysInTheMonth() {
return this.daysInTheMonth();
/** Returns the date in Gregorian format
* @return Returns the date in Gregorian format
* Test Cases:
* this.Dates(12, 10, 1989) = "12/10/1989"
* this.Dates(54, 67, 9999) = "54/67/9999"
* this.Dates(-1, -9, -900) = "-1/-9/-900"
String toPrettyString() {
return month + "/" + day + "/" + year;
/** Checks whether the passed in date is valid or not
* @return A true or false whether the date is valid
* Test Cases:
* this.Dates(12, 10, 1989) = true
* this.Dates(54, 67, 9999) = false
* this.Dates(-1, -9, -900) = false
boolean isValid() {
if (this.getDay() >= 0
&& this.getDay() <= 31
&& this.getMonth() >= 0
&& this.getMonth() <= 12) {
return true;
else {
return false;
/** Calculates the age of a person given the date
* @return The age of the person
* Test Cases:
* this.Dates(12, 10, 1990), dateMarked.Dates(12, 10, 0) = 1990
* this.Dates( 4, 25, 1000), dateMarked.Dates(12, 10, -990) = 1990
* this.Dates( 1, 1, 2578), dateMarked.Dates(12, 10, 1989) = 589
int calculateAge( Date birthday ) {
return (this.getYear() - birthday.getYear());
/** Do two dates represent the exact same day?
* @param other The date to compare this Date against.
* @return true if (and only if) this Date represents the same day as other.
* (that is, the same year, month, day-of-month).
* Test Cases:
* this.Dates(12, 10, 1989), other.Dates(12, 10, 1989) = true
* this.Dates(12, 10, 1989), other.Dates(11, 10, 1989) = false
* this.Dates(12, 10, 1989), other.Dates(12, 9, 1989) = false
* this.Dates(12, 10, 1989), other.Dates(12, 10, 1988) = false
boolean isEqualTo( Date otherDate ) {
if (this.getDay() == otherDate.getDay()
&& this.getMonth() == otherDate.getMonth()
&& this.getYear() == otherDate.getYear()) {
return true;
else {
return false;
/** Does one Date precede another?
* @param other The date to compare this Date against.
* @return true if (and only if) this Date comes before other.
* this.Dates( 5, 5, 2000), other.Dates( 5, 6, 2000) = true
* this.Dates( 5, 5, 2000), other.Dates( 6, 5, 2000) = true
* this.Dates( 5, 5, 2000), other.Dates( 5, 5, 2001) = true
* this.Dates( 5, 5, 2000), other.Dates( 5, 4, 2000) = false
* this.Dates( 5, 5, 2000), other.Dates( 5, 5, 1999) = false
* this.Dates( 5, 5, 2000), other.Dates( 4, 5, 2000) = false
boolean isBefore( Date otherDate ) {
if (this.getYear() <= otherDate.getYear()
&& this.getMonth() <= otherDate.getMonth()
&& this.getDay() < otherDate.getDay()) {
return true;
else if (this.getYear() <= otherDate.getYear()
&& this.getMonth() < otherDate.getMonth()) {
return true;
else if (this.getYear() < otherDate.getYear()) {
return true;
else {
return false;
/** Determines how many days there are in the month, given the instance's specified month and year
* @Return returns the number of days in the month
int daysInTheMonth () {
if (this.isValid() == true) {
if (this.getMonth() == 2) {
if (this.isLeapYear() == true) {
return 29;
else {
return 28;
else if (this.getMonth() == 1
|| this.getMonth() == 3
|| this.getMonth() == 5
|| this.getMonth() == 7
|| this.getMonth() == 8
|| this.getMonth() == 10
|| this.getMonth() == 12) {
return 31;
else {
return 30;
else {
return 0;
/** Return the day after `this`. (`this` must be a valid date.)
* @return the day after `this`. The result will be valid if `this` is valid.
Date nextDay() {
if (this.getDay() == this.getDaysInTheMonth() && this.getMonth() == 12) {
return new Date(1, 1, this.getYear() + 1);
else if (this.getDay() == this.getDaysInTheMonth()) {
return new Date(this.getMonth() + 1, 1, this.getYear());
else {
return new Date(this.getMonth(), this.getDay() + 1, this.getYear());
/** Return the day before `this`. (`this` must be a valid date.)
* @return the day before `this`. The result will be valid if `this` is valid.
Date previousDay() {
if (this.getDay() == 1 && this.getMonth() == 1) {
return new Date(12, this.getDaysInTheMonth(), this.getYear() - 1);
//Need to fix the days in the previous month and previous month
else if (this.getDay() == 1) {
return new Date(this.getMonth() - 1, this.getDaysInTheMonth() - 1,
this.getYear()); //need to fix the days in the previous month
else {
return new Date(this.getMonth() - 1, this.getDaysInTheMonth(), this.getYear());
/** Returns a true or false depending on whether the year is a leap year or not
* @return a true or false depending on whether the year is a leap year or not
* Test Cases:
* this.Dates( 5, 5, 2000) = true
* this.Dates(12, 6, 2004) = true
* this.Dates( 1, 1, 2001) = false
* this.Dates( 7, 9, 2006) = false
boolean isLeapYear () {
if (this.getYear() % 400 == 0) {
return true;
else if (this.getYear() % 100 == 0) {
return false;
else if (this.getYear() % 4 ==0) {
return true;
else {
return false;
null
Edited by: THE_Russian on Sep 28, 2007 4:35 PM
Yeahhhh... that's exactly what I was trying not to do, I know that method, I don't want any associations with the Calendar class, thanks though
Aw crap, you can't edit the original post? Sorry everyone for the unformatted code, here's the formatted version
* Date calculates the date and gives other information requested such as the birthday of someone, the
* previous and next days, whether the date is valid or not, and whether the year is a leap year
* @author Vlad Khmarsky
* @version 1.1
public class Date
/** The month */
int month = 00;
/** The day */
int day = 00;
/** The year */
int year = 0000;
/** First month of the year */
int firstMonthInYear = 1;
/** Last month of the year */
int lastMonthInYear = 12;
/** First day of the month */
int firstDayInMonth = 1;
/** Asks for the day, month, and year upon creting an instance of dates
* @day asks for the day
* @month asks for the month
* @year asks for the year
Date( int month_, int day_, int year_) {
this.month = month_;
this.day = day_;
this.year = year_;
/** Gets the month passed in initially
* @return The month that is currently stored in the month field
int getMonth() {
return this.month;
/** Gets the day passed in initially
* @return The day that is currently stored in the month field
int getDay() {
return this.day;
/** Gets the year passed in initially
* @return The year that is currently stored in the month field
int getYear() {
return this.year;
/** Gets the number of days in the given month
* @return the number of days in the given month
int getDaysInTheMonth() {
return this.daysInTheMonth();
/** Returns the date in Gregorian format
* @return Returns the date in Gregorian format
* Test Cases:
* this.Dates(12, 10, 1989) = "12/10/1989"
* this.Dates(54, 67, 9999) = "54/67/9999"
* this.Dates(-1, -9, -900) = "-1/-9/-900"
String toPrettyString() {
return month + "/" + day + "/" + year;
/** Checks whether the passed in date is valid or not
* @return A true or false whether the date is valid
* Test Cases:
* this.Dates(12, 10, 1989) = true
* this.Dates(54, 67, 9999) = false
* this.Dates(-1, -9, -900) = false
boolean isValid() {
if (this.getDay() >= 0
&& this.getDay() <= 31
&& this.getMonth() >= 0
&& this.getMonth() <= 12) {
return true;
else {
return false;
/** Calculates the age of a person given the date
* @return The age of the person
* Test Cases:
* this.Dates(12, 10, 1990), dateMarked.Dates(12, 10, 0) = 1990
* this.Dates( 4, 25, 1000), dateMarked.Dates(12, 10, -990) = 1990
* this.Dates( 1, 1, 2578), dateMarked.Dates(12, 10, 1989) = 589
int calculateAge( Date birthday ) {
return (this.getYear() - birthday.getYear());
/** Do two dates represent the exact same day?
* @param other The date to compare this Date against.
* @return true if (and only if) this Date represents the same day as other.
* (that is, the same year, month, day-of-month).
* Test Cases:
* this.Dates(12, 10, 1989), other.Dates(12, 10, 1989) = true
* this.Dates(12, 10, 1989), other.Dates(11, 10, 1989) = false
* this.Dates(12, 10, 1989), other.Dates(12, 9, 1989) = false
* this.Dates(12, 10, 1989), other.Dates(12, 10, 1988) = false
boolean isEqualTo( Date otherDate ) {
if (this.getDay() == otherDate.getDay()
&& this.getMonth() == otherDate.getMonth()
&& this.getYear() == otherDate.getYear()) {
return true;
else {
return false;
/** Does one Date precede another?
* @param other The date to compare this Date against.
* @return true if (and only if) this Date comes before other.
* this.Dates( 5, 5, 2000), other.Dates( 5, 6, 2000) = true
* this.Dates( 5, 5, 2000), other.Dates( 6, 5, 2000) = true
* this.Dates( 5, 5, 2000), other.Dates( 5, 5, 2001) = true
* this.Dates( 5, 5, 2000), other.Dates( 5, 4, 2000) = false
* this.Dates( 5, 5, 2000), other.Dates( 5, 5, 1999) = false
* this.Dates( 5, 5, 2000), other.Dates( 4, 5, 2000) = false
boolean isBefore( Date otherDate ) {
if (this.getYear() <= otherDate.getYear()
&& this.getMonth() <= otherDate.getMonth()
&& this.getDay() < otherDate.getDay()) {
return true;
else if (this.getYear() <= otherDate.getYear()
&& this.getMonth() < otherDate.getMonth()) {
return true;
else if (this.getYear() < otherDate.getYear()) {
return true;
else {
return false;
/** Determines how many days there are in the month, given the instance's specified month and year
* @Return returns the number of days in the month
int daysInTheMonth () {
if (this.isValid() == true) {
if (this.getMonth() == 2) {
if (this.isLeapYear() == true) {
return 29;
else {
return 28;
else if (this.getMonth() == 1
|| this.getMonth() == 3
|| this.getMonth() == 5
|| this.getMonth() == 7
|| this.getMonth() == 8
|| this.getMonth() == 10
|| this.getMonth() == 12) {
return 31;
else {
return 30;
else {
return 0;
/** Return the day after `this`. (`this` must be a valid date.)
* @return the day after `this`. The result will be valid if `this` is valid.
Date nextDay() {
if (this.getDay() == this.getDaysInTheMonth() && this.getMonth() == 12) {
return new Date(firstMonthInYear, firstDayInMonth, this.getYear() + 1);
else if (this.getDay() == this.getDaysInTheMonth()) {
return new Date(this.getMonth() + 1, firstDayInMonth, this.getYear());
else {
return new Date(this.getMonth(), this.getDay() + 1, this.getYear());
/** Return the day before `this`. (`this` must be a valid date.)
* @return the day before `this`. The result will be valid if `this` is valid.
Date previousDay() {
if (this.getDay() == 1 && this.getMonth() == 1) {
return new Date(lastMonthInYear, this.getDaysInTheMonth(), this.getYear() - 1); //Need to fix the days in the previous month and previous month
else if (this.getDay() == 1) {
return new Date(this.getMonth() - 1, this.getDaysInTheMonth() - 1, this.getYear()); //need to fix the days in the previous month
else {
return new Date(this.getMonth() - 1, this.getDaysInTheMonth(), this.getYear());
/** Returns a true or false depending on whether the year is a leap year or not
* @return a true or false depending on whether the year is a leap year or not
* Test Cases:
* this.Dates( 5, 5, 2000) = true
* this.Dates(12, 6, 2004) = true
* this.Dates( 1, 1, 2001) = false
* this.Dates( 7, 9, 2006) = false
boolean isLeapYear () {
if (this.getYear() % 400 == 0) {
return true;
else if (this.getYear() % 100 == 0) {
return false;
else if (this.getYear() % 4 ==0) {
return true;
else {
return false;
}null
Similar Messages
-
Any F.Module is there to get 'Month and day ' from the given input number
Hi experts,
I am working on Inventory withdrawl report and in the selection screen, If i enter the CHARG (Batch number) then I need to display the posting date by default in the next selection input based on the Batch number.
In the selection screen :
Batch : 7111WF0211.
Posting Date : (I need to display by default based on batch number).
My requirement is, in the above Batch first digit '7' is the year.
And from 2nd to 4th digit. i.e., 111. I need to find out month and day from 111.
I mean from 1 to 365 days, In which day and which month '111' will come ?
Please send me the code or suitable Function Module. Your help will be appreciated.
Thanks,
Ranji.Use FM ADD_TIME_TO_DATE
Do this
days = batch+1(3).
days = days - 1.
Call Function 'ADD_TIME_TO_DATE'
exporting
i_idate = '01.01.2008'
i_time = days
i_iprkz = 'D'
importing
o_idate = date_p_d
You will get the date in date_p_d.
But what about Leap years? IS the first number the year?
IF so pass in i_idate the first of january of that year so you get the correct day depending if it is a leap year or not
Edited by: Ramiro Escamilla on Feb 26, 2008 9:56 PM -
Number of Days from a given Date
How can one calculate the number of days in a month from a given date?
Ex: If I pass 07/12/2008 it should return 31But your example doesn't meet the OP request. The OP wanted the number of days in a month where the month is determined by a specified date (paraprhased).
DimaCit gave two credible solutions that met that requirement. Yours just counts the number of days between two apparently arbitrary dates. -
Calculate previous Sunday from the current day
Hi Gurus,
Can anybody tell what is the name of the function module which caluclates the previous Sunday from the Current system date. or any other idea how to calculate previous sunday from the current system date in Query.
Thanks
LizaHello,
See my previous thread to you for a similar Re: Find out previous Monday based on 0CALDAY
Thanks
Chandran -
"Expected Close" date needs to be 30 days from opened on day
Hi all,
We are trying to auto-populate an opportunity field ("expected close") with a date that would be 30 days in the future from the opportunity field "opened on" date. We have the opened on date already set so that it auto-populates with the date that a new opportunity is created.
This is what we have tried so far in the opportunity field edit area:
[<CloseDate>]=Today()+30
Any ideas as to why this isn't working, and ideas on how to make it work are appreciated!!Yes this works.
Go to the Admin Section, Application customization, pick the field that you want to update (in our case Opportunity),
Click Opportunity Field Set-up, pick the field that you will update (in our case Close Date) and click "edit".
In the Default Value add this: Today()+30 (or however many days you want (in our case "30"days from created date))
click "Save"
Log out and log back in to see if update has happened.
GOOD LUCK!! -
Selecting Missing Days from a given range of Date from a table
Dear Oracle Guru's
Consider the following table
txndetails
Rundate date
Txncnt Number
userid varchar2(100)
Data will be as follows
Rundate txncnt userid
17-Nov-2009 4 admin
18-Nov-2009 7 admin
21-Nov-2009 3 admin
23-Nov-2009 4 admin
We populate this table on the basis of txn generated. This is supposed to run daily based on the transactions. Certain days there wont be any transaction at all. hence there will be no entry on this table .
At any given point of time , we would like to know the days on which there is no entries in this table
In the above sample data, there is no entries on 19th, 20th and 22nd
we have to list out those days
I got confused while trying some methods
Kindly guide me in this regard
with warm regards
SsrHi,
As Centinul and Bhushan said, you need a list of all the possible dates; "CONNECT BY LEVEL <= x" is an efficient way to generate such a list in Oracle SQL.
Once you have the list of all days, you can use MINUS, like Centinul or Bhushan did. You can also use an outer join, as shown below.
WITH extrema AS
SELECT TRUNC (MIN (rundate)) AS start_date
, TRUNC (MAX (rundate)) AS end_date
FROM txndetails
all_days AS
SELECT start_date + LEVEL - 1 AS a_date
, start_date + LEVEL AS next_date
FROM extrema
CONNECT BY LEVEL <= 1 + end_date - start_date
SELECT a.a_date
FROM all_days a
LEFT OUTER JOIN txndetails t ON t.rundate >= a.a_date
AND t.rundate < a.next_date
WHERE t.rundate IS NULL
;Remember that all DATEs include hours, minutes and seconds. In the list of all days that you generate, the hours, minutes and seconds will probably be 00:00:00; be careful if the hours, minutes and seconds in your actual DATEs are not always 00:00:00.
The query above shows missing dates between the first date that is actually in the table and the last date in the table.
In practice, most people are interested in a deffierent range, such as all dates between two given parameters, or all dates within the last year.
If that's the case, you don't need the sub-query extrema; you can use the paremters (or compute the values) in all_days, based on dual.
For example, to get the most recent 365 days:
WITH all_days AS
SELECT TRUNC (SYSDATE) + LEVEL - 365 AS a_date
, TRUNC (SYSDATE) + LEVEL - 364 AS next_date
FROM dual
CONNECT BY LEVEL <= 365
SELECT a.a_date
... -- Same as beforeEdited by: Frank Kulash on Nov 23, 2009 10:54 AM -
Can I find previous screensaver word of the day words?
I really need to find a word that flashed up on my screensaver the other day and I can't remember it. Is there a way to search for previous words? There are usually 5 a day that pop up over again on a loop. Its on the screensaver "word of the day" but there is not just one word there are several each day. Your helps would be sooooo appreciated. 15th February 2012.
consuetude, ravening.....just change the date of your computer (right top: Date & Time Preferences) or -left top under Apple menue :system Preferences - system - Date & Time) to the 15.02.2012.
Then go under: left top Apple menue :system Preferences - Desktop&Screensaver - Test -
and you´ll see or just wait until screensaver switches on....
dont forget to put the actual date back! -
hi,
Is there any FM which will subtract the no of days from a given date.
I hv tried with SUBTRACT_TIME_FROM_DATE , but having some config issue. And it is not available in 3.1H version.
Some one can help me out...
Thanks,
shivaHi,
use the FM RP_CALC_DATE_IN_INTERVAL
and check the sample output.
Import parameters Value
DATE 10/10/2004
DAYS 05
MONTHS 00
SIGNUM +
YEARS 00
Export parameters Value
CALC_DATE 10/15/2004
Regards
vijay -
Find Address from a given LAT/LONG
Hi All,
I need your help in finding an address from a given co-ordinates(Latitude,langitude). Please let me know your ideas.
ThanksI don't know if I am missing something but requirement seems to be simple, you want to know the 30 week alter date...
in a week you have 7 days so 30 weeks will have 30*7 = 210
select to_date('20080114','YYYYMMDD') + 210 from dual
Try this...
If above is not the solution then then pls pur your input and output.... -
Subtracting days from GregorianCalendar
Hi there,
How does one subtract, let's say, 7 days from a given GregorianCalendar instance. Let's say I want to set up two instances on GregorianCalendar. The first one has a known date, like so:
int endYear = 2005;
int endMonth = 7;
int endDay = 6;
GregorianCalendar endDate = new GregorianCalendar();
endDate.set(endYear,endMonth,endDay);
How do I set up a second instance of GregorianCalendar set to 7 days prior to the endDate instance?
GregorianCalendar nearDate = new GregorianCalendar();
What I want to do here is make a comparison with todays date (a third instance of GregorianCalendar that is set to todays date), to see if todays date is within the range between endDate and nearDate.
Can someone please help?
AlanCalendar today = new GregorianCalendar();
Calendar nextWeek;
today.setTimeInMillis(System.currentTimeMillis());
nextWeek = new GregorianCalendar();
nextWeek.setTimeInMillis(today.getTimeInMillis());
nextWeek.add(Calendar.DATE, 7);
if (otherCalendar.getTimeInMillis() >= today.getTimeInMIlis() && otherCalendar.getTimeInMillis() <= nextWeek.getTimeInMillis()) {
// otherCalendar is between now and a week from now
} Of course, the above tests for a 7 day stretch starting at whatever date and time it is now and ending at the same time a week from now. If you really want "any time today (Saturday), tomorrow, etc. through next Friday" then you'll need to adjust the hours, minutes, seconds, and millis to zero. -
In Bex Query day from calday value and sales in prev yr value not come
Dear all
right now i got output like
Sales Sales in Prev Yr
Sales Organization Day From Calday Calendar Day Sales Value Sales Value
1020 Not assigned 05/1/2010 2,013,176.00 INR
1020 Not assigned 05/1/2011 2,945.00 INR
and i want output like base on date 05/01 how to do pl help
Sales Organization Day From Calday Calendar Day Sales Value Sales Value
1020 05/01 05/1/2010 2,945.00 INR 2,013,176.00 INRHi ,
This is possible via customer exit.You can populate day on the bases of your date .
Try this :
WHEN 'tech name of exit var'.
data : v_day type c length 5 ,
v_day_val type c length 5.
IF i_step = 2.
READ TABLE i_t_var_range INTO LS_T_VAR_RANGE WITH KEY vnam = 'date_value u2019.
v_day = LS_T_VAR_RANGE-high+4(4).
concatenate v_day+2(2) '/' v_day(2) into v_day_val .
ls_range-low = v_day_val .
ls_range-opt = 'EQ'.
ls_range-sign = 'I'.
APPEND ls_range TO e_t_range.
Hope this will be helpful .
Regards,
Jaya -
How to customize a datefield component to visible only 40 days from today?
In my project, I came into a situation like, I had a datefield component for which everyday it must show only 40 days from the current day and the remaining days should be unselectable. it can be in any SDK 3/4.
Please somebody help me in logic.
Thanks in advanceread this.
http://blog.flexexamples.com/2007/12/17/setting-selectable-ranges-in-the-flex-datefield-co ntrol/ -
To find the no of working days b/w given date
Hi ABAP Experts,
Here i have one requirement .
table is tfacs
in this table i want to know the no of working days b/w the given date. Here i have attached my code .pls go through it and do me needful.
TABLES : tfacs,vbrk.
DATA: BEGIN OF ty_tfacs OCCURS 0,
ident TYPE tfacs-ident,
jahr TYPE tfacs-jahr,
mon01 TYPE tfacs-mon01,
mon02 TYPE tfacs-mon02,
mon03 TYPE tfacs-mon03,
mon04 TYPE tfacs-mon04,
mon05 TYPE tfacs-mon05,
mon06 TYPE tfacs-mon06,
mon07 TYPE tfacs-mon07,
mon08 TYPE tfacs-mon08,
mon09 TYPE tfacs-mon09,
mon10 TYPE tfacs-mon10,
mon11 TYPE tfacs-mon11,
mon12 TYPE tfacs-mon12,
basis TYPE tfacs-basis,
fenum TYPE tfacs-fenum,
wenum TYPE tfacs-wenum,
load TYPE tfacs-load,
string1(31) TYPE c,
string2(31) TYPE c,
string3(31) TYPE c,
string4(31) TYPE c,
string5(31) TYPE c,
string6(31) TYPE c,
string7(31) TYPE c,
string8(31) TYPE c,
string9(31) TYPE c,
string10(31) TYPE c,
string11(31) TYPE c,
string12(31) TYPE c,
uk(31) TYPE c,
total1 TYPE i,
total2 TYPE i,
total3 TYPE i,
total4 TYPE i,
total5 TYPE i,
total6 TYPE i,
total7 TYPE i,
total8 TYPE i,
total9 TYPE i,
total10 TYPE i,
total11 TYPE i,
total12 TYPE i,
END OF ty_tfacs.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_jahr FOR tfacs-jahr MODIF ID b1.
SELECT-OPTIONS : mon FOR tfacs-mon01 MODIF ID b1.
SELECT-OPTIONS : s_month FOR vbrk-erdat MODIF ID b2.
SELECTION-SCREEN : END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME.
PARAMETERS r1 RADIOBUTTON GROUP c DEFAULT 'X' USER-COMMAND flag .
PARAMETERS r2 RADIOBUTTON GROUP c .
SELECTION-SCREEN END OF BLOCK b.
INITIALIZATION
INITIALIZATION.
AT SELECTION-SCREEN OUTPUT.
IF r1 NE space.
LOOP AT SCREEN.
IF screen-group1 EQ 'B2'.
screen-output = 1.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT SCREEN.
IF screen-group1 EQ 'B1'.
screen-output = 1.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
start - of - selection
start-of-selection.
IF r1 = 'X'.
PERFORM get-data.
PERFORM display-data.
ENDIF.
& form get-data
text
--> p1 text
<-- p2 text
form get-data .
DATA : total1 TYPE i.
SELECT * FROM tfacs INTO TABLE ty_tfacs
WHERE ident EQ 'IN'
AND jahr IN s_jahr.
LOOP AT ty_tfacs WHERE ident = 'IN'.
IF sy-subrc EQ 0.
PERFORM get_string USING ty_tfacs-string1
ty_tfacs-mon01
ty_tfacs-total1.
PERFORM get_string USING ty_tfacs-string2
ty_tfacs-mon02
ty_tfacs-total2.
PERFORM get_string USING ty_tfacs-string3
ty_tfacs-mon03
ty_tfacs-total3.
PERFORM get_string USING ty_tfacs-string4
ty_tfacs-mon04
ty_tfacs-total4.
PERFORM get_string USING ty_tfacs-string5
ty_tfacs-mon05
ty_tfacs-total5.
PERFORM get_string USING ty_tfacs-string6
ty_tfacs-mon06
ty_tfacs-total6.
PERFORM get_string USING ty_tfacs-string7
ty_tfacs-mon07
ty_tfacs-total7.
PERFORM get_string USING ty_tfacs-string8
ty_tfacs-mon08
ty_tfacs-total8.
PERFORM get_string USING ty_tfacs-string9
ty_tfacs-mon09
ty_tfacs-total9.
PERFORM get_string USING ty_tfacs-string10
ty_tfacs-mon10
ty_tfacs-total10.
PERFORM get_string USING ty_tfacs-string11
ty_tfacs-mon11
ty_tfacs-total11.
PERFORM get_string USING ty_tfacs-string12
ty_tfacs-mon12
ty_tfacs-total12.
ENDIF.
ty_tfacs-uk = ty_tfacs-total1 + ty_tfacs-total2
+ ty_tfacs-total3 + ty_tfacs-total4
+ ty_tfacs-total5 + ty_tfacs-total6
+ ty_tfacs-total7 + ty_tfacs-total8
+ ty_tfacs-total9 + ty_tfacs-total10
+ ty_tfacs-total11 + ty_tfacs-total12.
MODIFY ty_tfacs TRANSPORTING total1 total2 total3
total4 total5 total6
total7 total8 total9
total10 total11 total12
uk.
ENDLOOP.
PERFORM write1-data USING 'COU' 'YEAR' 'MONTH01'
'MONTH02' 'MONTH03' 'MONTH04'
'MONTH05' 'MONTH06' 'MONTH07'
'MONTH08' 'MONTH09' 'MONTH10'
'MONTH11' 'MONTH12' 'TOTAL WDAYS' .
LOOP AT ty_tfacs.
PERFORM write1-data USING ty_tfacs-ident ty_tfacs-jahr
ty_tfacs-total1 ty_tfacs-total2
ty_tfacs-total3 ty_tfacs-total4
ty_tfacs-total5 ty_tfacs-total6
ty_tfacs-total7 ty_tfacs-total8
ty_tfacs-total9 ty_tfacs-total10
ty_tfacs-total11 ty_tfacs-total12
ty_tfacs-uk.
ENDLOOP.
ENDFORM. " get-data
TOP-OF-PAGE.
FORMAT COLOR 5 ON.
WRITE :/10 'COUNTRY',
20 'YEARS',
35 'MON01',
45 'MON02',
55 'MON03',
65 'MON04',
75 'MON05',
85 'MON06',
95 'MON07',
105 'MON08',
115 'MON09',
125 'MON10',
135 'MON11',
145 'MON12',
170 'total wdays'.
FORMAT COLOR OFF.
WRITE :/ SY-ULINE.
*& Form display-data
text
--> p1 text
<-- p2 text
FORM display-data .
LOOP AT ty_tfacs.
WRITE :/10 ty_tfacs-ident,
20 ty_tfacs-jahr,
30 ty_tfacs-total1,
40 ty_tfacs-total2,
50 ty_tfacs-total3,
60 ty_tfacs-total4,
70 ty_tfacs-total5,
80 ty_tfacs-total6,
90 ty_tfacs-total7,
100 ty_tfacs-total8,
110 ty_tfacs-total9,
120 ty_tfacs-total10,
130 ty_tfacs-total11,
140 ty_tfacs-total12,
150 ty_tfacs-uk.
ENDLOOP.
ENDFORM. " display-data
*& form get_string
text
-->p_0250 text
-->p_0251 text
-->p_0252 text
form get_string using p_0250 " month
p_0251 " string
p_0252. " total
p_0250 = p_0251. " move month to string
TRANSLATE p_0250 USING '0 ' . " translate
CONDENSE p_0250 NO-GAPS. " condense
p_0252 = STRLEN( p_0250 ). " pass length of string to total
ENDFORM. " get_string
***& Form write1-data
text
-->P_0306 text
-->P_0307 text
-->P_0308 text
-->P_0309 text
-->P_0310 text
-->P_0311 text
-->P_0312 text
-->P_0313 text
-->P_0314 text
-->P_0315 text
-->P_0316 text
-->P_0317 text
-->P_0318 text
-->P_0319 text
-->P_0320 text
*form write1-data using p_0306
p_0307
p_0308
p_0309
p_0310
p_0311
p_0312
p_0313
p_0314
p_0315
p_0316
p_0317
p_0318
p_0319
p_0320.
*WRITE :/ p_0306,
p_0307,
p_0308 left-justified,
p_0309 left-justified,
p_0310 left-justified,
p_0311 left-justified,
p_0312 left-justified,
p_0313 left-justified,
p_0314 left-justified,
p_0315 left-justified,
p_0316 left-justified,
p_0317 left-justified,
p_0318 left-justified,
p_0319 left-justified,
p_0320 left-justified.
*ENDFORM. " write1-data
from this report what i am getting is year and its 12 months but my requirement is i will give date using select options and i should get the total no of working days in b/w this date.Use the following code to find no of working days b/w given date. Use the correct factory_calendar_id in the function module. L_DAYS will display the required result:
PARAMETERS: p_date1 TYPE sydatum,
p_date2 TYPE sydatum.
DATA: date1 LIKE scal-date,
date2 LIKE scal-date,
correction LIKE scal-indicator,
calendar LIKE scal-fcalid,
factorydate1 LIKE scal-facdate,
workday1 LIKE scal-indicator,
factorydate2 LIKE scal-facdate,
workday2 LIKE scal-indicator,
l_days TYPE scal-facdate.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
date = p_date1
correct_option = '+'
factory_calendar_id = 'US'
IMPORTING
date = date1
factorydate = factorydate1
workingday_indicator = workday1
EXCEPTIONS
correct_option_invalid = 1
date_after_range = 2
date_before_range = 3
date_invalid = 4
factory_calendar_not_found = 5.
IF sy-subrc = 0.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
date = p_date2
correct_option = '+'
factory_calendar_id = 'US'
IMPORTING
date = date2
factorydate = factorydate2
workingday_indicator = workday2
EXCEPTIONS
correct_option_invalid = 1
date_after_range = 2
date_before_range = 3
date_invalid = 4
factory_calendar_not_found = 5.
IF sy-subrc = 0.
l_days = factorydate2 - factorydate1.
WRITE: / l_days.
ENDIF.
ENDIF. -
Browser keeps opening with previous tabs from day before. How do I stop this?
Under Tools>Options>General I have the browser set when I open the browser to "open up a blank page" but it keeps opening up previous tabs from the day before. How can I stop this? I read the forum boards but either did not find it or overlooked the answer. I checked all my other settings and cannot find anything that would be causing this. Please advise?
You can check if you have a user.js file in the Firefox profile folder that sets the browser.sessionstore.resume_session_once pref to true.
* http://kb.mozillazine.org/browser.sessionstore.resume_session_once
*http://kb.mozillazine.org/Preferences_not_saved -
i can not find "app of the day" from app store on my ipod,how can i find and download it?
It is possible that the app was removed from the App Store. If so you will not be able to get it back, unless you have it downloaded on your computer.
If you had downloaded it before and it is still in the store, you can go to the App Store app on your iPod and go to the Updates tab. Then you tap on "Purchased" and see if it is available to download from your previous purchases.
Hope this helps!
PSkilton
Maybe you are looking for
-
Firefox cannot load a specific website but other programs can
I have a rare problem with firefox (3.6.18 at the moment) I have to work with a modified mantis bug tracker and the site wont load (the tab says "Loading..." and the bottom status bar says "waiting yourdomain.com...") I can reproduce this and seems t
-
How to Create a blog for a Website
Hello, I am currently working with a client on a web site and they were thinking about adding a blog to their site, and to be honest I have no clue how to do such a thing. Does any one have any ideas, or could anyone stear me in the right direction a
-
Remove DNS entries and reset from the Terminal
I have a DNS service running on my Mac Server and it seems to be screwed up, because I can not remove any entries. Initially, it let's me remove them...but when I click save...they all appear again! What I want to do is to remove all entries manually
-
I need to generate a Form with a layout like an Oracle Reports matrix report. The values for each column and row are known, and the user would enter the data (tyically one value) in each cell. Each cell of course gets its two parent FK's from the val
-
MAC Pro poblems after migration from G4
I have just transferred all my files from my old G4 to my new MAC Pro. Initially everything ran ok, but now when I try to open a program I get a 10810 error code saying 'the program ..... could not be launched'. This includes anything in the Dock, th