Last day of previous month for data load
Hi,
I have to load data from the previous month into the psa and then into an infocube. I was wondering as to how to get the last of the previous month to write a code in ABAP. I will be writing the code at the infopackage level in the data selection. I could load data from the 1st of the previous month to the 1st of the current month. This will be an additional load of 30,000 records for the 1st of every month, since I will be loading 30,000 records everyday, I was wondering if I could limit the load from the 1st of every previous month to the last day of that month. This will be a repetitive loading.
DATA: CURR_MM(2) TYPE N,
CURR_YYYY(4) TYPE N,
CURR_DD(2) TYPE N,
PREV_MM(2) TYPE N,
PREV_YYYY(4) TYPE N,
PREV_DD(2) TYPE N,
YYYY_MM(6),
YYYY_MM1(6),
DATE LIKE SY-DATUM.
DATE = SY-DATUM.
CURR_YYYY = DATE+0(4).
CURR_MM = DATE+4(2).
CURR_DD = DATE+6(2).
PREV_DD = 1.
IF CURR_MM = '01'.
PREV_MM = '12'.
PREV_YYYY = CURR_YYYY - 1.
ELSE.
PREV_MM = CURR_MM - 1.
PREV_YYYY = CURR_YYYY.
ENDIF.
concatenate PREV_YYYY PREV_MM PREV_DD into YYYY_MM.
concatenate CURR_YYYY PREV_MM PREV_DD into YYYY_MM1.
read table l_t_range with key
fieldname = 'BLDAT'.
l_idx = sy-tabix.
l_t_range-low = YYYY_MM.
l_t_range-high = YYYY_MM1.
l_t_range-sign = 'I'.
l_t_range-option = 'BT'.
modify l_t_range index l_idx.
p_subrc = 0.
Mind you this code will load data from 1st of the previous month to the 1st of current month. I just don't want to load that extra "1st day" of current month data as I have 30,000 records everyday.
Say for example, I want to load data from 1st Mar to 31st Mar or 1st Feb to 28thFeb. How should I modify the above code.
Is there a formula to get the last date of the previous month. That's all I need. This would solve the problem.
try this routine. it will return a range from 1st day to end of the month.
DATA: l_s_range TYPE rsr_s_rangesid,
E_T_RANGE TYPE RSR_T_RANGESID.
DATA: year(4) TYPE n,
month(2) TYPE n,
day(2) TYPE n,
ld_keydate TYPE sydatum,
ld_lastday TYPE sydatum.
REFRESH e_t_range.
CLEAR l_s_range.
year = sy-datum(4).
month = sy-datum+4(2).
*Months with 31 days in year
IF month = '01' OR
month = '03' OR
month = '05' OR
month = '07' OR
month = '08' OR
month = '10' OR
month ='12'.
day = '31'.
ENDIF.
*check for leap year: provoking sy-sybrc <> 0
IF month = '02'.
day = '29'.
MOVE: '02' TO ld_keydate+4(2),
year TO ld_keydate(4),
day TO ld_keydate+6(2).
CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
EXPORTING
date = ld_keydate
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
day = '28'.
ENDIF.
ENDIF.
*months with 31 days in year
IF month = '04' OR
month = '06' OR
month = '09' OR
month = '11'.
day = '30'.
ENDIF.
MOVE: year TO ld_lastday(4),
month TO ld_lastday+4(2),
day TO ld_lastday+6(2).
l_s_range-low = sy-datum.
l_s_range-high = ld_lastday.
l_s_range-sign = 'I'.
l_s_range-opt = 'BT'.
APPEND l_s_range TO e_t_range.
Similar Messages
-
Show data of last day of previous month against any day of current month
Hi,
I have fact table which contains data at date level (we have data for oct-2009 to april-2010). Our requirement is to show data of last day of previous month against any day of current month in obiee 11g. I am facing problem in Feb 2010 its picking data of 28-Jan-2010 instead of 31-jan-2010 and for April its picking data of 30-mar-2010 instead of 31-mar -2010.
Any suggestion ???You're asking to filter your data set to only include rows between:
1) last day of the previous month
2) any day of the current month
This can be achieved with prompting in OBIEE Answers.
last day of previous month = TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)) . The problem is you need to make query work within Oracle's Answer syntax.
In the prompt, select the operator type for your date dimension as 'between' and default to 'SQL Results'.
For the 'last day of previous month' , use the query:
SELECT
case when 1=0 then Time."Fiscal Date" else TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))
end
FROM ENTER_YOUR_PRESENTATION_FACT_FOLDER_HERE
For the current date, use the query:
SELECT
case when 1=0 then Time."Fiscal Date" else CURRENT_DATE
end
FROM ENTER_YOUR_PRESENTATION_FACT_FOLDER_HERE
Another option is to create a last_date_pervious_month variable in the RPD and have that as the default value in your prompt. -
Defining last day of previous month in ABAP
All,
I am a BW guy and hardly know ABAP. I have a requirement where I have to calculate last day of previous month and use it in the routines of the transformations.
I have decided to define the Last day of previous month in Start routine and then use the global variable in Transformations to calculate further.
The logic that i have used is outlined below.
Define G_DATE in global declaration for further use in Transformations.
In the Routine section,
Assign G_DATE to SY-DATUM
G_DATE + 6(2) = '01' (Replace last to field of date with '01' to establish first day of the current month)
G_DATE = G_DATAE - 1 (To get to last day of previous month)
My dilemma is to implement this in ABAP in Start routine of transformations. Please include the exact ABAP code that would be needed in Declarations and Routine section.
Thanks in advance.Hi..,
Go with the function module: LAST_DAY_OF_MONTHS
So, Just determine the last month from the sy-datum and then use above function module and pick the last date of the month.
Thanks,
Naveen Inuganti. -
Printing Last Day of previous month
I need to print Last day of previous month, and the date value is relative to the system date.
In my previous post i have got the answer to print last day of current month. To print last date in previous month do i need to use RelativeDate? and I am not sure whether I can use RelativeDate for months.
RaghuRight now I have written below formula, and it works fine in all cases like if the current month equals to 01, 03, 05,07,08,10 and 12 and months other than mentioned in above including 02.
for First day of previous month
=If (FormatDate(CurrentDate();"MM"))InList("07";"08";"10";"12";"05";"01";"03") Then
(If(FormatDate(CurrentDate();"dd"))="01" Then
FormatDate(LastDayOfMonth(RelativeDate(CurrentDate();-1));"MM")"/01/"FormatNumber(Year(LastDayOfMonth(RelativeDate(CurrentDate();-1)));"####")Else
FormatDate(LastDayOfMonth(RelativeDate(CurrentDate();-31));"MM")"/01/"FormatNumber(Year(LastDayOfMonth(RelativeDate(CurrentDate();-31)));"####"))Else
FormatDate(LastDayOfMonth(RelativeDate(CurrentDate();-30));"MM")"/01/"FormatNumber(Year(LastDayOfMonth(RelativeDate(CurrentDate();-30)));"####")
For Last day of previous month
=If (FormatDate(CurrentDate();"MM"))InList("07";"08";"10";"12";"05";"03";"01") Then
(If(FormatDate(CurrentDate();"dd"))="01" Then LastDayOfMonth(RelativeDate(CurrentDate();-1))Else
LastDayOfMonth(RelativeDate(CurrentDate();-31)))Else LastDayOfMonth(RelativeDate(CurrentDate();-30))
Please let me know any other suggestions.
-Raghu -
Last day of previous month, first day of current month
Hi,
Whats the best way to calculate the last date of the previous month, and the first day of the current month.
Thank you for your help.
Sumit.Here are FMs
SG_PS_GET_LAST_DAY_OF_MONTH FM calculating the last day of a month
FVOZ
RE_LAST_DAY_OF_MONTH
HRHCP00_TIME_HANDLING
HR_HCP_GET_LAST_DAY_OF_MONTH
HRVE_REPORTING
HRVE_LAST_DAY_OF_MONTH
RPDD HR-D: Payroll Germany
RP_LAST_DAY_OF_MONTHS HR-D: Determine last day of month
SLS0 PAW - Miscelaneous (MISC)
SLS_MISC_GET_LAST_DAY_OF_MONTH FM calculating the last day of a month
VVSRCH
LAST_DAY_OF_MONTHS
BWSO_DATE_GET_FIRST_WEEKDAY
CKSO
CK_F_GET_FIRST_DAY_OF_DATE
HRBEN00SPENDA
HR_BEN_SPENDA_FIRST_LAST_DAY
HRPB
HRPP_CCODE_GET_FIRSTDAY_PERIOD
HRVE_PAYROLL
HRVE_GET_FIRST_LAST_MONDAY
JBT6
ISB_GET_FIRST_DAY
KED2
RKE_GET_FIRST_DAY_IN_PERIOD
MCP2
MC_PERIOTAB_BT_FIRST_LASTDAY
MC_PERIO_GET_FIRST_AND_LASTDAY
Thanks
SK -
How to find first and last day of previous month?.
Based on current month, I want to find start and end day of
previous month.
For example,
For august, Start date is July 1st and End date July 31st.
How can i get first of previous month as start date and last
day of the previous month as end date?.
Same way,
i want to find start date of current month and end date of
next month.
Example:
For august,
i want to get start date, august 1st and end date : september
30.
How can i do this from current date or now().
I am looking for best and easy way to find start and end
dates..
Thanks<cfset today = now()>
<cfset firstOfThisMonth = createDate(year(today),
month(today), 1)>
<cfset lastOfNextMonth = dateAdd("d", -1, dateAdd("m", 2,
firstOfThisMonth))>
<cfoutput>
today = #today#<br>
firstOfThisMonth = #firstOfThisMonth#<br>
lastOfNextMonth = #lastOfNextMonth#<br>
</cfoutput>
Edit - To find the start and end day of previous month, get
the first of THIS month. Use Subtract 1 month ("m") to get the
start date. Subtract 1 day ("d") to get the end date. -
Hi Experts,
I need to create a report which includes records of current month and last 7 days of previous month.
I will get records of current month by this formula :- month({PROBSUMMARYM1.OPEN_TIME})=month(currentdate)
Please tell me how to add the records of last 7 days of previous Month for the same report.
Thanks in Advance.Hi Ajay,
If you have more than a year data in your database then your formula will return wrong results. ie. If your data consist of 2012,2013,2014 data then below formula will return all 8th month data irrespective of year. So, you need to check year also here
month({PROBSUMMARYM1.OPEN_TIME})=month(currentdate) and
Year({PROBSUMMARYM1.OPEN_TIME})=Year(currentdate)
Now add Abhilash second statement in OR so, your formula should look like :
(month({PROBSUMMARYM1.OPEN_TIME})=month(currentdate) and
Year({PROBSUMMARYM1.OPEN_TIME})=Year(currentdate))
OR
Date({PROBSUMMARYM1.OPEN_TIME}) IN [DateAdd('d',-7,Maximum(LastFullMonth)), Maximum(LastFullMonth)
-Sastry -
Previous month first data and previous month last date
can any body have query to get previous month first date and previous month last date.
Ex: First day of the previous week:
TIMESTAMPADD(SQL_TSI_DAY,-6, (TIMESTAMPADD(SQL_TSI_DAY, DAYOFWEEK(CURRENT_DATE) *-1,CURRENT_DATE)))
Last day of the previous week:
TIMESTAMPADD(SQL_TSI_DAY, DAYOFWEEK(CURRENT_DATE) *-1,CURRENT_DATE)
can anybody have it for first day of the previous month,last day of the previous month?
Edited by: user12255470 on Apr 7, 2010 3:30 AMHi,
1st day of previous month :
TIMESTAMPADD(SQL_TSI_DAY, ( DAYOFMONTH(TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE)) * -1) + 1, TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE))
last day of previous month :
TIMESTAMPADD(SQL_TSI_DAY,DAYOFMONTH(TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE)) * -1 , TIMESTAMPADD(SQL_TSI_MONTH, 1, TIMESTAMPADD(SQL_TSI_MONTH,-1,CURRENT_DATE)))
Please mark Q answered and award points for correct answers !
Thanks
Alastair -
BIP eBusiness Suite Dates - How to include the last day of the month?
How can I get my report to include the last day of the month 'without' forcing my users to enter the non-intuitive first of the next month as a parm?
I have a report that will generally be run for a month but can be run for any pair of dates representing the first and last date to be included in the report.
When we pass the dates from Oracle Apps to the report it is truncating the date to midnight. This results in the last date entered 'NOT' being included in the report as the second date is marked as "midnight". When I attempt to simply add "=1" to the end date it fails due to formatting issues in apps (only). I have gotten this to work on our Enterprise edition server that we use for testing (only) but it fails in our apps environment.
In APPs we input the date in the format "01-AUG-2007", and this is how it shows in the parm line before the report is submitted as well as in the "View Details" after the report is executed: http://home.swbell.net/grog1//work/req_details_5607586.jpg
However it is odd in that we in the "View Log" entry it shows the date formatted as "2007/08/01 00:00:00": http://home.swbell.net/grog1/work/view_log_5607586.jpg
Even odder is that under diagnostics, "View XML" the date is formatted third way as: "2007/08/01 00:00:00.0" (note it now includes tenths of a second): http://home.swbell.net/grog1/work/view_xml_5607586.jpg
This of course makes it difficult to perform conversions and calculations on the date in the SQL.
Is APPs doing some sort of 'timestamp' conversion?
How can I get my report to include the last day of the month 'without' forcing my users to enter the non-intuitive first of the next month as a parm?
Any feedback is appreciated,
ScottNo. The problem/error occurs long before the data is formatted into xml for presentation to the format template.
The error occurs in the SQL in the 'data' template when I attempt to add a day to the date. It either does not like the implicit conversion with the "+1" and then the use of the "between" with another date or if I attempt to manually convert it has problems with the format mask.
Scott -
How do I set a recurring event for the last day of the month on iphone 4s calendar?
I want to set a recurring event for the last day of every month - regardless of the date/number of days in the month. I'd prefer not to have to use an app to do this.
Hi,
You can do this using the custom repeat in iCal. You'll need two events to cover the second and fourth Mondays.
Create the event on the second Monday of the month. In Repeat select Custom... > Frequency: Monthly > On the: second Monday.
Do the same for the Fourth Monday.
Best wishes
John M -
How do I set a reminder for the last day of every month
Have I missed something? But how do you set a reminder for the last day of every month to recurr indefinatley in iOS6? Sorry if this is really simple but I just can't seem to work it out. Any help gratefully received.
Hey Mattye88 not sure if you have seen but actully you can do this, but for some reason you have to use Siri. If you bring up Siri and say "set a reminder ever 4 weeks from next wednesday to check the gas meter" it will set one and it will work just fine, I have reminders to water a Bonsai every three days and it works fine it just shows as custom repeat on the user interface. Alas it seems you can not use Siri to set one for the end of the month though which is why I am in this threed. Still hope it helps you to know how to sort this problem atleast.
-
Previous month end data for report
Hi expert,
I have to calculate previous month end data for my report.
let say if user select 15 oct then he should be able to see 30 sept data.
I have calander prompt.
Thanks,Hi,
Use presentation variable in date prompt.
Apply sql filter(covert to sql) on report as date_column= TIMESTAMPADD(SQL_TSI_DAY,-DAYOFMONTH(date 'presntation_variable'),date 'presentation_variable')
Refer : How to get LAST_DAY in obiee
Regards,
Srikanth -
Object date - how to get the last day of the month?
hi all,
I have a date object in which I would like to get the last day of the month. any idea?
eg AUG=31
Feb = 28 (depends if a leap year)
thanksUse java.util.Calendar
Add 1 month to the day.
Set the day of month to be 1.
Subtract 1 day.
Now you are on the last day of the month you wanted. -
Display a metric differently only on last day of the month.
Have a Daily transaction fact where unit cost of product is stored at a day/part num /business unit level.
When we drag and drop date column and unit cost in the report like below we will have
Date cost
Sep29 $10
sep30 $12
Oct1 $12
Oct2 $14
..........ans so on
The source sustem program runs on last day of the month around 8pm for setting up cost to reflect on 1st of every month
But the nighly OBI load ( Runs at 2am every day) when incrementally updating Sep30 data picks up $12 from the erp and populates in OBI.
But actually speaking, on Sep30 the cost was $10.
There is no way of running the ERP program to run afer OBI load. Hence we need an expression in the RPD (not answers) saying
when last day of the month (any month) the standard cost must be a previous day value.All other days the same value should be returned.
Is this possible without impacting report performance ?
So, when we drag and drop date and cost value the above report should change as
Date Cost
sep29 $10
sep30 $10
Oct1 $12
Oct2 $14
Oct30 $12.5
Oct31 $12.5
Nov1 $13.5You can achieve the above requirement for current month alone with below steps:
The solution requires to have a union report
First part of the report will have Date and Cost fields with a report level date filter, Date NOT IN (TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))))
Second part of the report will have Date and Cost fields with a report level date filter Date IN (TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))))In the second part of the report,
Change the column formula for Date to display only Current_Date
Change the column formula for Cost field with FILTER(Cost USING Date = Current_Date-1)
Pls mark if correct/helpful. -
SQL select Statement -first day and last day of the month - 1 year from now
Hi,
I need to write a SQL to get the dates in between first day and last day of the month one year from now.
SELECT last_day(add_months(sysdate,12)) as lastday from dual
What could be the Query to get the first day of the month one year from now..
ie ..Sysdate - 3-DEC-2009
Result - 1-DEC-2010
thank youHi,
You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
SELECT TRUNC ( ADD_MONTHS ( SYSDATE
, 12
, 'MONTH'
) AS first_of_month
FROM dual
;The DATE returned will be in the same month, year, quearter, ... as the first argument.
\We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
For example, to find all appointment_dates in the current month next year:
SELECT *
FROM appointments
WHERE appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
AND appointment_date < TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future.
Maybe you are looking for
-
How to rename existing members in an Essbase Outline
Hi there, I would like to do as follows: 1. List all members at Level-0 of a specified dimension (or parent member) that have names matching a wildcard string. e.g. names begining with 'JWC'. 2. Delete the Level-0 members that satisfy the above condi
-
ORA-00001 - unique constraint violation when upgrading 10g EUL
Hi, I am trying to upgrade my Discoverer 4i to Discoverer 10g. When I log into 10g, it prompts me to upgrade the EUL. After making the right back up of my 4i EUL, I continue with the upgrade. During the upgrade, I am hit with this error: Database err
-
The serial number is on the back of the box my DVD came in.
-
ImageIcon's not displaying in JRE1.3
I have an application which is distributed as an applet and distributes its classes and images files in a series of Jar files. When using JRE1.2 in Internet Explorer the ImageIcon's in the system are all found and display correctly. However, using JR
-
My blackberry q10 and its problem with the boradcast
hii there, could you please help me with a problem that i cant solve? , this is why im posting here so i can get the best answer. i have almost 2000 bb contacts in my list, and whenever i try to send a BC using "select all " feature, it says the mess