ABAP routine for loading previous months data in infopackage
Hi,
I have an infopackage included in a process chain. The issue is that I need to load previous month's data through the infopackage and I have a data field which is of date type. I could not find an appropriate OLAP variable so I chose the ABAP code in the infopackage. My knowledge of ABAP is not very good so I thought I could get some insight from someone. Need this to be a periodic job/regular without any developer interference.
Edited by: BG on Apr 9, 2008 1:03 PM
Hi
Try this code and see if you are able to achive the results
data: month(2).
data: date like sy-datum,
last like sy-datum,
first like sy-datum.
read table l_t_range with key
fieldname = 'BLDAT'.
l_idx = sy-tabix.
date = sy-datum.
month = date+4(2).
if month = 12.
month = 01.
else.
month = month - 1.
endif.
move month to date+4(2).
call function 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
exporting
day_in = date
IMPORTING
LAST_DAY_OF_MONTH = last
EXCEPTIONS
DAY_IN_NOT_VALID = 1
OTHERS = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
first = last.
move 01 to first+6(2).
l_t_range-low = first
l_t_range-high = last
l_t_range-sign = 'I'.
l_t_range-option = 'BT'.
modify l_t_range index l_idx.
p_subrc = 0.
paste the code as it is in your editor activate this and see if you are able to achive the results.
assign points if useful.
regards
Vishal
Edited by: Vishal Vashishta on Apr 9, 2008 2:33 PM
Similar Messages
-
ABAP routin for geeting previous month
Hello.......
I want to writ an ABAP routin at the infopackage level.
I want to get the previous month ( period ).
example : if sy-datum is 2007.01.01
output : 2006.12.01.
reply.
Thanks in advance.Hi,
Write this in the start routine of infosource or update rules...
Try this:
DATA: L_DATE LIKE SY-DATUM.
DATA: L_YEAR TYPE I.
DATA: L_MONTH TYPE I.
L_DATE = (Here enter your input).
MOVE '01' TO L_DATE+6(2).
MOVE L_DATE(4) TO L_YEAR.
MOVE L_DATE+4(2) TO L_MONTH.
L_MONTH = L_MONTH - 1.
IF L_MONTH LT 1.
L_YEAR = L_YEAR - 1.
L_MONTH = 12.
ENDIF.
MOVE L_YEAR TO L_DATE(4).
MOVE L_MONTH TO L_DATE+4(2).
MOVE: L_DATE TO P_DATE.
Hope this helps
PB -
Sample ABAP routine code to load only previous month data in INFOPACKAGE
Hi all,
I want to create one ABAP routine in InfoPackage (Variables change to selection values with background processing) for 0CALMONTH ( Calender year month) so that whenever this infopackage is executed it should fetch only previous month data.
Can anyone please provide any sample code for that.
Thanks in advance.
Uday shankar.Hi
Please check with below code, hope this will resolve your issue
WHEN: 'ZLASTP'.
CLEAR: h_period, h_gjahr.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = sy-datum
I_MONMIT = 00
i_periv = 'AF'
IMPORTING
e_buper = h_period
e_gjahr = h_gjahr
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF h_period = '001'.
h_gjahr = h_gjahr - 1.
h_period = '012'.
ELSE.
h_period = h_period - 1.
ENDIF.
CLEAR l_s_range.
CONCATENATE h_gjahr h_period INTO l_s_range-low.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range. -
ABAP routine for loading data of current month in InfoPackage
Hello experts,
I want to load data of current month. Therefore I implemented the following ABAP-Routine for field 0CALDAY in the InfoPackage's data selection:
data: lv_datum_l like sy-datum,
lv_datum_h like sy-datum.
concatenate sy-datum(6) '01' into lv_datum_l.
call function 'RP_LAST_DAY_OF_MONTHS'
exporting
day_in = sy-datum
importing
last_day_of_month = lv_datum_h.
l_t_range-sign = 'I'.
l_t_range-option = 'BT'.
l_t_range-low = lv_datum_l.
l_t_range-high = lv_datum_h.
But function 'RP_LAST_DAY_OF_MONTHS' cannot be found!
Any other suggestions for getting last day of current month?
regards
hizaHi,
Add this code. When u complete execution of this code, ZDATE will have ur month end date.
data : zdate_c(2) type c,
zyear_c(4) type c,
zmonth_c(2) type c.
data : zdate like sy-datum.
data : zday(2) type n.
zdate = sy-datum
zyear_c = zdate(4).
zmonth_c = zdate+4(2).
zdate_c = '01'.
concatenate zyear_c zmonth_c zdate_c into zdate.
CALL FUNCTION 'FIMA_END_OF_MONTH_DETERMINE'
EXPORTING
I_DATE = zdate
IMPORTING
E_DAYS_OF_MONTH = NO_OF_DAYS.
zday = NO_OF_DAYS.
concatenate zyear_c zmonth_c zday into zdate. -
Trying to fetch previous month data
hi ...
i have to develope a report in which cutomer on selecting month from the prompt , i have to show transactions for that selected month,transactions for previous month and growth %.
for fetching previous month data i am using the below formula in column
FILTER(etxnmistopbr.tot_txns USING (etxnmistopb(TIMESTAMPADD(SQL_TSI_MONTH, -1,etxnmistopbr.month_year)))
but it doesnt fetch any result.
i have tried
FILTER(etxnmistopbr.tot_txns USING (etxnmistopbr.month_year= TIMESTAMPADD(SQL_TSI_MONTH,-1,timestamp '@{current_year}{2012}-@{current_month}{07}-31 00:00:00')))
where current_year and current_month are presentation variable
but it throws error as "
HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46046] Datetime value 2012-8-31 00:00:00 does not match the specified format. (HY000) "
can anyone please help how to retrieve previous month data and current month data
Edited by: 8826 on Sep 27, 2012 4:31 AMI would recommend using Time Series Functions, specifically the Ago function in the RPD. This is precisely what they have been designed for and is a very powerful feature of OBIEE. This removes the need for complex formulae embedded within result columns (which you will have to replicate each time you create a new analysis).
The syntax of the Ago function is as simple as:-
AGO(Measure, Time Dimension Level, Number of Periods Ago) e.g.
AGO(Core."Fact - Project Cost".Cost, Core."Date - Fiscal Calendar"."Fiscal Period", 1)
Please mark if helpful/answered.
Andy. -
How to show a report for 'Previous Month' Data
Hi Gurus,
I have a requirement, where i have to default my report to show previous month data.
Scenario:
My prompts by Default are set to CURRENT (current year,quarter,month). once the user logs in, the report should display data for month 'Nov' instead of 'Dec'.
I tried using TIMESTAMPADD() in the formula , but it didn't work, though i don't see any error. Not sure if i 'm missing something.
Is there a way to achieve this.I 'm using OBIEE 11.1.1.6.
Any help is highly Appreciated ! Please.
Thanks,
RamyaFrom what you wrote I am assuming the user can manually save the report results to the Excel file.
If your report uses ALV Grid it is possible to export the data to a spreadsheet (one of the functions available in the ALV tool bar).
If you have used WRITE statements it is also possible to save the output as a spreadsheet (menu System -> List -> Save), but the latter will not produce as nice a spreadsheet if the data don't form a matrix. In other words, some work may be necessary in the spreadsheet afterwards before it has the format your user wants. -
Help with Setting Previous Month Date Parameter for SSAS via SSRS
Hi All,
Firstly, any assitance is greatly appreciated.
Now, I am working on developing a report for a business area that will be sent on the first of every month. The report will contain data for all records created in the previous month, current year.
I have been able to successfully implement a default year parameter, which will default to current year-
="[REFERRAL LODGEMENT DATE].[CAL YEAR].&["+CSTR(Year(Today))+"]". However, when I attempt to set a previous month paramater it is not setting when the report is generated. The code I have used
is as follows:
="[REFERRAL LODGEMENT DATE].[CAL MONTH NAME].&["+CSTR(Month(Today)-1)+"]"
CheersBefore you spend more time trying to fix the parameter, let me suggest that you can write MDX to come up previous month data.
if you can't go that route, couple of things to consider for your approach:
1) don't subtract 1 from January that won't work. you'll need to handle it using the ssrs expression.
2) when you use the month function it's going to return a month index so effectively you are passing something like [REFERRAL LODGEMENT DATE].[CAL MONTH NAME].&[7] to SSAS, is that the current format?
you can use the MonthName function to get month names but again make sure that the formatting is right.
to see the parameter value, you can display it on the ssrs report and see if it's the right format.
Paras Doshi (Blog: ParasDoshi.com | Twitter:
@Paras_Doshi ) -
Abap Routine for Date selection in Infopackage
Hi
I have to write an abap routine for date selections in the infopackage,
There are two date begda and enda.
Do i code for BEGDA and fill in the begin date using routine and use another routine to fill the ENDA.
JPJPHi JP,
If you have two info objects BEGDA and ENDA in the Info package for selection
then you will have to write seperate routine for each of them.
If you want to give single value for each date field then update only the field l_t_range- low otherwise if you want to give range then you can update the internal table fields l_t_range-low and l_t_range-high .
Regards,
Prakash -
Calc script for calculating current month data after loading
Hi,
I'm trying to write a script to do a calculation to all dimension after load current month data; it ran successfully but current month data is all zero; can someone tell me what i'm doing wrong?
SET CACHE HIGH;
SET UPDATECALC OFF;
SET CALCPARALLEL 4;
FIX (&CurMon, &CurYr)
AGG (Sparse2, Sparse3, Sparse 4, Sparse 5, Sparse 6);
ENDFIX
Dense1 – Dynamic Calc
Period: Dense – Dynamic Calc
Year: Sparse – Dynamic Calc
Sparse2 – Label Only
Sparse3 – Label Only
Sparse 4– Label Only
Sparse5 – Label Only
Sparse6 – Label Only
Thanks!Natilie,
If I understand you correctly, you are loading data, then clearing out the current month->current year, and then aggregating current month->current year? There isn't going to be any data there -- you've cleared it out in your second step.
I think the order you want is:
1) Clear out the current month->current year to be sure it's a good load
2) Load the current month->current year
3) Aggregate the current month->current year
This could be done with a single Maxl that controls two calc scripts and one import database (clear, import, agg) or you could do it manually.
The default calc is (generally) equivalent to CALC ALL using db properties (UPDATECALC, AGGMISSG, etc.). There shouldn't be practical difference between that and the AGG portion of your calc.
I would again confirm that all of your data is at the lowest level, i.e., you can navigate to leaf level on all dimensions and pull a data value before you aggregate. Perhaps you are loading to upper level members and don't realize it. I often use the Excel add-in's Styles to tell me if I'm at the lowest level of a db or not.
Regards,
Cameron Lackpour -
ABAP Routine for 0FISCPER slect options in InfoPackage
Hi,
I am trying to write an ABAP Routine for 0FISCPER as select options (range) dynamically.
Ex:
0FISCPER selection for this year as 001.2008 to 012.2008
0FISCPER selection for next year as 001.2009 to 012.2009.
Now we are changing InfoPackage every year manually, so I need to write a routine for 0FISCPER in InfoPackage to handle dynamically every year
Thanks,
SK.Hi
write an ABAP routine to get that value..But are you getting any planned data(why you want till end of the year...till infopackage runs is o.k i think, if you don't have planned data)...Any way you can check the below code, which can be useful...
You can see the below code at->your infopackage selections>Ty-->choose variable type as 6 and enter any ABAP routine name( to create) and then there is a button on the application tool bar called 'routine info'..this give you the following information...
Definition
You can define complex selections for InfoPackages and control the automatic deletion of requests from InfoCubes in the scheduler, by using routines.
Routines are processing blocks in ABAP programs that consist of a pre-defined data declaration section and an ABAP subroutine (form routine). In the subroutine you can use all of the ABAP programming functions.
You can use the following routines for making selections in InfoPackages:
1. Selection routines for fields, on the Data Selection tab page
2. Selection routines for file names, on the External Data tab page
3. Selection Routines for selecting the from and to dates for time-dependent data, on tab page Update
4. Selection routines for determining old requests to be deleted after successfully loading a new request, on the Data Target tab page
Program frame:
After you have called up the Editor for routine maintenance, you get the following program frame:
1. Selection routines for fields, on tab page Data Selection:
program conversion_routine.
'$*$ begin of global - insert your declaration only below this line -
TABLES: ...
DATA: ...
$$ end of global - insert your declaration only before this line -
FORM COMPUTE_<Fieldname>
tables l_t_range structure rssdlrange
changing p_subrc like sy-subrc.
$$ begin of routine - insert your code only below this line -
data: l_idx like sy-tabix.
read table l_t_range with key
fieldname = <Fieldname>.
l_idx = sy-tabix.
modify l_t_range index l_idx.
p_subrc = 0.
$$ end of routine - insert your code only before this line -
ENDFORM.
2. Selection routines for file names, on tabstrip External Data:
FORM compute_flat_file_filename
changing p_filename like rsldpsel-filename
p_subrc like sy-subrc.
$$ begin of routine - insert your code only below this line-
p_filename =
p_subrc = 0.
$$ end of routine - insert your code only before this line-
ENDFORM.
3. Selection routines for selecting the from and to date for time-dependent data, on tabstrip Update:
form compute_time_dependent_dates
changing p_datefrom type d
p_dateto type d
p_subrc like sy-subrc.
$$ begin of routine - insert your code only below this line-
p_datefrom =
p_dateto =
p_subrc = 0.
$$ end of routine - insert your code only before this line-
ENDFORM.
4. Routines for determining the old requests to be deleted after successfully loading a new request, on tab page Data Targets:
form compute_<InfoCube-Name>
tables l_t_request_to_delete structure rsreqdelstruc
using l_request like rsreqdone-rnr
changing p_subrc like sy-subrc.
*Insert Source Code to decide if requests should be deleted.
*All Requests in table l_t_request_to_delete will be deleted
*from Infocube <InfoCube-Name>.
*Add new requests if you want to delete more (from this cube).
*Remove requests you did not want to be deleted.
$$ begin of routine - insert your code only below this line-
loop at l_t_request_to_delete.
endloop.
clear p_subrc.
$$ end of routine - insert your code only before this line-
ENDFORM.
Note:
Those fields flagged with <...> are dependent on the selection fields and are filled automatically by the system when you call up the Editor.
Procedure
Make the following entries:
1. Between $$ begin of global ... and $$ end of global ... you can define data declarations. These are the declaration sections for the local data in the routine. This data is only visible in the routines.
2. The subroutines begin with FORM and end with ENDFORM.
The subroutines for the particular routines are:
Selection routines for fields on tab page Data Selection: FORM COMPUTE_<Field name>
Selection routines for file names on tab page External Data : FORM compute_flat_file_filename
Selection routines for selecting the from and to dates for time-dependent data on tab page Update: FORM compute_time_dependent_dates
Routines for determining old requests to be deleted after successfully loading a new request on tab page Data Target: FORM COMPUTE_<InfoCube-Name>
The subprograms have the following parameters:
Subprogram FORM COMPUTE_<Field name>:
l_t_range
In the table l_t_range the routines for all selection fields that are filled, or have a routine, are made available.
The routines are executed in the scheduler last of all and therefore, you can change all the selections that you have carried out previously.
p_subrc
Using the variable p_subrc you can report errors to the scheduler. p_subrc <> 0 signals an error and means the data request is terminated.
Subprogram FORM compute_flat_file_filename:
p_filename:
You give the name of the file that is to be loaded in parameter p_filename.
This is useful if your file name contains date dependencies that should be determined by sy-datum and calculated during runtime.
p_subrc
You can inform the scheduler of an error with variable p_subrc. p_subrc <> 0 signals an error and means that the data request is terminated.
Subprogram FORM compute_time_dependent_dates:
p_datefrom and p_dateto
Fill these parameters with the from and to dates for time-dependent master data and texts.
p_subrc
You can inform the scheduler about an error using variable >LS>p_subrc. p_subrc <> 0 signals an error and means the data request is terminated.
Subprogram FORM COMPUTE_<InfoCube-Name>:
l_t_request_to_delete
You give the request number of the request that is to be deleted in parameter l_t_request_to_delete. You can also delete requests from the table. These are then not deleted.
p_subrc
You can inform the scheduler about an error with the variable p_subrc. p_subrc signals an error and means the data request is terminated.
3. Insert your program code for the routines between $$ begin of routine ... and $$ end of routine ... so that the respective subprogram variables are supplied with the corresponding values.
4. Check the syntax of your routine with the Check function.
5. You can then transfer the routine with the Save function.
You end routine maintenance when you exit the Editor.
Hope it helps
Thanks,
Teja -
Is it possible to post the Excise invoice previous month date.
Dear All,
We want to post a excise invoice with previous month date. Is that possible?
We have created a billing document (VF01) last month (October) and not created Excise Invoice (J1IIN).
Now our finance people requirement is to create the excise invoice with last month date.
Kindly let me know whether it is possible.
Regards,
MullairajaYes quite possible provided your FI period is still open. Once you execute J1IIN and clicked the tab "Billing", you can see a field Posting Date where you maintain the billing document date itself if FI period is open.
But from excise point of view, this is wrong due to the fact that excise returns should be submitted on or before 3rd of every month in which case, the excise team would have submitted the returns for October.
thanks
G. Lakshmipathi -
Need to show Previous months data in report
Hi All,
I have a crystal report 2011 which shows monthly Cash data. It has 3 other columns like Previous 3 months cash data, previous 6 months cash data, Previous 12 months cash data in report.
My report also has two parameters- start date and end date. If I give Start date as 1/1/2012 and end date as 12/31/2013 (two years date range) then correct data comes in all columns and for 2013 year, correct data is coming for Previous 12 months column. But if I give only one month date range like start date as 1/1/2013 and end date as 01/31/2013, then it is not showing correct data for these 3 columns - Previous 3 months cash data, previous 6 months cash data, Previous 12 months cash data. Ideally as per requirement, it should calculate previous months data regardless of parameter values and put data in respective columns.
Any help/suggestion? Any trick which can help me to show correct data in all columns no matter what date range or months I am taking in parameters.
Is it mandatory to have previous 12 Months data in report to calculate column-Previous 12 months Cash data?
Thanks,
RemiHi Remi,
You can try like this:
I have given a some suggestions i.e You just take one parameter only because u can imagine 3 columns previous data display correctly i.e From Date
Month parameter is also a alternate option.
For Ex: Column1: From Date - 90 Days/3 Months - we get the three months previous data correctly etc.
Finally, create a stored procedure that returns the required columns and does all the calculations on the database side.
Follow abhilash suggestion as well.
Useful threads: Crystal Report Parameter Issue
Pull Last 6 months of data
Month to date data for Previous month
How to find current month, previous month Net Sales by means of formula?
Thanks,
DJ -
Posting Depreciation for the previous months
HI Experts,
We got new asset AS100SA capitalized on 28.02.2013 (Fiscal Year Period 4 2014 ) and we want to start depreciation this asset
start from Feb 2014 (Fiscal Year Period 4 2014),
We have run the depreciation for all asset in current Month ( Period 5 2014) , when we try run the depreciation for new asset AS100SA
for the previous months in the Current Period , system prompt error msg : "Period 4 is already posted".
Asset Master Data
when I view the posted values Tab in the Asset Explorer (AW01N), system is showing the planned values beginning period 5 (Fiscal Year = March 2014)
AFAB - Depreciation Run
Period 4 (Previous Month for new asset)
Error Message
kindly advise on this issue. thanks in advance.Hi Ginee,
Radio button planned posting run can only be choose once per period and when you choose planned posting run you should not specify your asset number.
As for your case, you can run the depreciation (AFAB) by choosing the repeat button (specify your asset number) since you already done the planned posting run for period 4 and after the depreciation posted you can check the posted value tab in AW01N again, system will show the posted value in period 4.
Ex : asset acquisition : 01.01.2014, in AW01N it start with period 2 but the depreciation start from period 1.
run AFAB with this parameter
AW01N after AFAB
Regards,
Lelyana -
Hi Friends,
Good day,
I want to get the previous month balance.
Here is the my business scenario. I am going to enter the month and year then i can get the values corresponding to this month and year, but in this i want previous month data for one object or one measure.In that query i set the two filter
Enter Month Name:
Enter the Year:
Say for ex, if i enter August means i need all august month data plus i need previous month balance for balance object.if i suppose enter January and year is 2008 means. I need December month data for year 2007 for the balance object and for remaining i need January month Year 2008 data.
Any Suggestions,
Thanks lot,
Regards,
-B-Hi Balaji,
You are a lucky guy, that's why getting these much reply. Congratulations friends for your good replys. I also find a solution with access database and if and mod operation.
temp.Yr ; = @prompt('Enter Year:','A','Time period\Year',Mono,Free,Persistent,,User:0)
AND
temp.Mth ; = @prompt('Enter Month:','N','Time period\Month',Mono,Free,Persistent,,User:0)
OR
temp.Yr ; = @prompt('Enter Year:','A','Time period\Year',Mono,Free,Persistent,,User:0) - (IIF(@prompt('Enter Month:','N','Time period\Month',Mono,Free,Persistent,,User:0)=1,1,0))
AND
temp.Mth ; =( (@prompt('Enter Month:','N','Time period\Month',Mono,Free,Persistent,,User:1)+10)mod 12)+1
The filter contain...
............year equal to @year
........and
............month equal to @month
or
............year equal to @year
........and
............month equal to @month
Regards
Eldose -
Previous month data in WebI Report
Hi All,
I have a universe created on a Bex Query. I don't have any variables created in the Bex Query. I have to create a WebI report with Calendar Year/Month as selection and depending on what user enters, i have to display Cost for the month entered by the user and cost for (month -1 ). For eg. if the user enters Feb 2009, then the report should display Cost for Jan 2009 and Feb 2009. I have created a filter for Calendar Year/Month. How do i bring previous month data in the report ? I don't have to modify the Bex Query. I have to achieve it on the BO side. Can you guys help on this problem.
Thanks,
SaachiHi,
There is a restriction in BO when you use it with SAP.
When the user filters the data for FEB 2009, you will not be able to get data for JAN 2009 as it does
not go again to the Bex query to fetch this data.
The only workaround as of now to this is to bring all the data using Bex query by having a filter
at the BO Query level where you say Cal year/month key = (From prompt) or
Cal year/month key <> #.
This is because it considers Cal year/month as string and so even at the universe level we will not
be able to create a previous month formula.
I hope this helps.
Thanks,
Kartik
Maybe you are looking for
-
I have installed ios7 on my iPad 4. After installation it asked me a pass code which I have never set. After multiple attempts it is disabled. I don't have backup on my iCloud or iTunes. Is there anyone who can help to enable it or to reverse iPad to
-
Hi guys, I did a validation a few weeks ago which was simply: P10_DATEDATE < SYSDATE. I came back and tested it and it still worked as expected. I then tried to recreate it again and the new attempt doesn't work and I don't know why. To begin with it
-
Add new fields on the header screen of COR1
Hi Experts, I am new to this type of work, please help me in doing.... My requirement is, to add one field on the header details of the COR1 from a Z table. Can anyone please tell me how to handle this. I searched the regarding this in SDN but i had
-
Numbers switches sheets when I select cell.
I've have a problem with Numbers '08, ver 1.0.3 that has persisted across the last two OSX upgrades. I have a multi-sheet file, and when I select a sheet using the Sheets sidebar, it changes to the selected sheet without a problem. But when I click
-
"21 hours remaining": Is Migration Assistant meant to be this slow?
I'm trying to migrate from one Lion machine (upgraded from Snow Leopard) to another new Mac Book Pro. 140 G total. It says it will take 21 hours? Is that normal? And when the system looks like it is sleeping, is it?