User Exit Variable for Calculating number of days in a month
I need a query to calulate the number of days in a particular month upto the current date. For example if i give 26 Feb it should reutrn 25, if i enter 30march it should return 29 for any specific year. I have gone through some posts and understood that i need to create a formula variable (under calculated KF's) and then go to CMOD, create a project, then enancement Assignment RSAP0001 then EXIT_SAPLRSAP_001 and include a code in INCLUDE ZXRSAU01. But i have any clue of coding. Could someone give me the entire code and how to connect it to the formula variable KF in created. The technical name of the key figure is ZMDAYS. If i have made any mistakes or if there is another eaier alternative please let me know. I thankyou all for the help.
Hi Uday,
I have a few modifications in the code
Data: xdate type d,
ip_year(4) type N,
ip_month(2) type N.
Types : Begin of ty_month_days,
month(2) type N,
days(2) type N,
End of ty_month_days.
Data : it_month_days type ty_month_days occurs 0 with header line.
ip_year = 2006.
ip_month = 01.
do 12 times.
CONCATENATE ip_year ip_month '01' INTO xdate.
xdate = xdate + 33. "this date is in the next month
xdate+6(2) = '01'. "first day of next month
xdate = xdate - 1. "last day of xmonth
it_month_days-month = xdate+4(2). "number of days of xmonth.
it_month_days-days = xdate+6(2).
append it_month_days.
ip_month = ip_month + 1.
enddo.
This code stores Month and No. of days in the internal table it_month_days.
You can access this internal table for your calculations
This should help.
Regards,
Praveen.
Message was edited by: praveen mathew
Similar Messages
-
User Exit Variable for Bex in CMOD (ABAP Code)
Hi Experts
My requirment is to develop a Restricted Keyfigure...
The restriction is based on 0Calmonth (Calendar Year/Month)
The sales from beginning of calendar year up to last "closed" month in a Calendar.
Ex: in June i want to see 01.01.2009 to 31.05.2009 data.
in October i want to see 01.01.2009 to 30.09.2009 data.
When user execute the report
in Jan 2010 i want to see 0 as there is no closed month in that particular year.
in Fed 2010 i want to see 01.01.2010 to 31.01.2010 data.
For that purpose i need to create a User Exit variable in CMOD...
I am struggling to get an idea on how to write a code to meet the requirment
Please help me with code that i can use in cmod
Thanks in advanceHi,
Use the following code :
when' variable name ' .
DATA : year(4) type n,
month2(2) type n,
date_in type sy-datum,
date_op type sy-datum.
IF I_STEP = 1.
CLEAR L_S_RANGE.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
month2 = sy-datum+4(2).
if month2 = '01'.
concatenate sy-datum+0(4) '01' '01' into l_s_range-low.
l_s_range-high = sy-datum.
else.
month2 = month2 - 1.
clear : date_in, date_op.
concatenate sy-datum+0(4) month2 '01' into date_in.
CALL FUNCTION 'SLS_MISC_GET_LAST_DAY_OF_MONTH'
EXPORTING
DAY_IN = date_in
IMPORTING
LAST_DAY_OF_MONTH = date_op
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.
concatenate sy-datum+0(4) '01' '01' into l_s_range-low.
l_s_range-high = date_op.
endif.
APPEND L_S_RANGE TO E_T_RANGE.
ENDIF.
I dint know what output do you want if the current month is jan.
I have put it as 1st jan till current date.
Modify it if you need.
Regards,
Mansi -
User Exit Variable for Infoprovider based on month characterstic in query
Hi,
I am financial reporting with reports created on a mulit-provider over a plan & Actual cube. Along the top of the report is a structure which has amongst other restricitions a column for each month, i.e columns 1 to 12.
Currently we are in month 9, so the report should show data from the Actual infoprovider for months 1 to 9, but data from the plan infoproviders for 10 to 12. My question is how should the variable be coded for the infoprovider which will return a value based on the month characteristic in each columns selection. I understand how I can look at say the current system date, derive the month and return the plan/actual value for the correct infoprovider based on the current month. But I need to create a variable which will look at the month value which is in each column selection in the query itself.
Many thanks,
Richardwe recently had this kind of reporting requirement. only difference being week instead of month.
you need to create 12 variables for actual month columns and 12 for budget.
now you will write a code to address all the variables. in following format :-
when var1. "suppose var1 represents month 1 of actual columns
1. derive month from date.
2. if month <= i_vnam+3(1) "get the number from var and compare
set the variable value as the month number of that year for e.g
concatenate year i_vnam+3(1) into l_s_range-low
else
set the variable value way back in past which will not have any data.
above logic will cause values in following fashion
if this month is 3 and year is 2008
var1 = 200801
var2 = 200802
var3 = 200803
var4 = 199001
var5 = 199001
etc.
In the query all columns will be set with the property = hide if not values are present. so if 199001 is set in the variable then it will be collapsed.
same way logic for variables in budget column can be written which will set all the month variables which are less than
current month to 199001 (just in reverse fashion of above mentioned logic.) -
How to select several values from a user exit variable in a planning folder
Hello,
I have created a user exit variable for limiting the values only to which the user need to access.
For a simulation part, it is then necessary for him to select several values from these values (not only one, and not all)
But It seems in this case the user has only two possibilities :
- keep all the values without any restriction
- restrain the selection to only one value.
It seems possible for the user to access to a multiple choice window, but this possibility doesn't seems to work : in all tests we did, only the first value was taken into account by BPS.
If this method is not good do you know an other manner to permit the user to choice several values amongst a set of pre-selected (because the original set is too important) values ?
Thanks for your help.Hi Mayank,
Thanks for your response, but I don't think it corresponds to my problem.
I my case, I use a user exit variable to filter some data. It seems BPS offers the possibility to the user to select several values amongts the pre-selected values presented by the user exit variable, but it doesn't work. We can use a popup in which we enters the required values, but in final, only the first value is taken into account.
I don't know if it is due to a BPS bug or if it is not a good solution in regard to BPS philosophy. In this case, the concerned caracteristic isn't in the header but in lead columns.
I must present a solution to my client next monday, so I have not enough time to open an OSS message.
An alternate solution should be interesting too.
My need is to present to a user a selection of values amongst all values from an infoobject (the user exit variable seemed to be a good solution) and the user must have the possibility to select some values amongst these as filter.
Regards -
How to Broadcast Control Query based on User Exit Variable
Hi Gurus,
How to Broadcast dashboard based on Control Query based on User Exit
Variable to different users via mail in BW 3.5 version. Any document or
steps to achieve this will be very helpful.
Regards
VishwanathHi Surendra,
Thanks for the reply and your suggestion. It will be great if you can help me to answer the below:
1) What exactly we mean by Control Query - Any example will be very helpful
2) As you mentioned, yes the user exist to be written will be for user-exit variable for dynamic period selection - An Example on how to create this will be helpful
3) Once the above variable is created, what are the steps to include this variable in the Bex Query?
4) Once all the queries to be used in dashboard are implemented with the exit variable, how to create a variant to be used in Broadcasting?
5) How and where to configure the email recipients (to whom this dashboard will be sent via mail)?
6) How to set up the BW broadcaster in BW 3.5 using the control query ?( My question is though we have to send the dashboard to the users, which has multiple queries, how a single control query with variant will help us).
Awaiting your reply.
Thanks and Regards
Vishwanath -
Defining an exit variable for a specific day based on Fiscal Period
If I do not have Calendar Day time dimension available for reporting is it possible to define a customer exit variable for a specific day. The days are the first and last day of the financial year?
Example
User Input for Fiscal Period: 2009004
The exit is to define a value for 01.01.2009 and 31.12.2008 (end of last year)
ThanksHello Niten,
yes it is possible. Procedure:
- add a new column in the report structure
- hide this column
- create a new text variable in this column (for customer exit)
- now you can fill this variable during query execution based on 0FISCPER
You don't want to filter by this variable. Right?
Buy,
André -
Value for user-exit variable is invalid
Hi Gurus,
My Value for a Fiscal Year Prd returns a invalid value for the 12th month of each year( for Example 12/2004, returns the error "Value 200313 for User-exit variable is invalid.
This is the code that is being used.
*Rolling 12 months for entered month
when 'ZCALM12'.
clear: v_mth, v_yr.
REFRESH E_T_RANGE.
CLEAR L_S_RANGE.
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZCALMON'.
exit.
endloop.
v_yr = LOC_VAR_RANGE-LOW+0(4) - 1.
v_mth = LOC_VAR_RANGE-LOW+4(2) + 1.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
concatenate v_yr v_mth into L_S_RANGE-LOW.
L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW.
APPEND L_S_RANGE TO E_T_RANGE.
Thanks in Advance.Hi Ravi,
when 'ZCALM12'.
clear: v_mth, v_yr.
REFRESH E_T_RANGE.
CLEAR L_S_RANGE.
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZCALMON'.
exit.
endloop.
<b>-->> Here, you are not checking any thing.</b> <i>On which logic you are reducing year by one and increasing month by 1..?</i>
v_yr = LOC_VAR_RANGE-LOW+0(4) - 1.
v_mth = LOC_VAR_RANGE-LOW+4(2) + 1.
-->><i>IF month is 200512 you will get output from above code is :</i> please check.
v_yr = 2005 - 1 = 2004
v_mth = 12 +1 = 13.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'BT'.
concatenate v_yr v_mth into L_S_RANGE-LOW.
L_S_RANGE-HIGH = LOC_VAR_RANGE-LOW.
APPEND L_S_RANGE TO E_T_RANGE.
Try to debug the code by keeping break point after When. and execute the report, you will be debugging mode.
Hope it Helps
Srini -
In ME21N,User Exit/BADI for Defaulting Vendor number at item level.
Hi Experts.
In ME21N, for every purchase order, we have condtion tab for each line item.
Many condition typesot taxes are listed based on the config for the materials.
My requirements is, When we go inside by selecting a condition type we find vendor number displayed.
I need a user exit/BADI for defaulting the Vendor number.
Regards
Balaji RHi,
check with below link,
fo this one you will find both user exit and badis
https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/find%252bapplication%252bclass%252bwith%252bexits%252band%252bbadis%252bfor%252ba%252btransaction
Regards,
Madhu -
How to create an user input variable for customer exit variable? - BW3.5
Hi Guru,
I have a requirement for the selection period of my reports. There are 3 possible reporting periods which should be user selectable:
1. Month: Current reporting month
2. Fiscal Year to Date
3. Project Year to Date
Here I need 2 variable to do these, 1 customer exit and 1 user input variable. I have created a variable customer exit to calculate all these requirement. But can any1 tell on how to create the user input variable for my customer exit? I need a user input variable with drop down list like below.
01-Current month
02- Fiscal Year to Date
03-Project Year to Date
I have create a new master data for this variable, but it's not working. What I need now is a standalone master data which do not need to link to any exiting records. Can any1 tell me how to create this?Just go to the definition of the variable for which you have created a customer exit. There you will find a check box for "Ready for Input". Just tick that checkbox and the variable will be available as a selection variable in the reports selection screen.
Regards,
Yogesh -
User Exit/BAdi for Number Range
Hi All,
Can anyone tell me is there any User Exit/BAdi for Number Range?
Rgds,
TrinadhaHi,
Please check RHIV0001 through transaction SMOD.
Hope this helps.
Donnie -
To find out appropriate user exit/ badi for transaction VT01n
Hi,
I have the following requirement.
Cass shipment type (VTTK-ADD03) field needs to be required and should be automatically populated upon creation of the shipment document. The rules for populating the value (SO, ST, PO and RA) are as follows:
If any of the orders on the shipment are customer order types, then the CASS shipment type should be a SO,
If all of the orders are STO orders, then the Cass shipment type should be "ST",
If all of the orders are PO orders, then the Cass shipment type should be "PO" , and
If all of the orders are customer return orders, then the Cass shipment type should be "RA".
I have to find out proper user exit / badi to do this.I have tried with many userexit but it won't work.
Thanking in advance to give your suggestion in order to resolve it.
With regards,
Ajit.Hi this code will enable you to find the user exit for any transaction . Just give the transaction as input
tables : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
tables : tstct.
data : jtab like tadir occurs 0 with header line.
data : field1(30).
data : v_devclass like tadir-devclass.
parameters : p_tcode like tstc-tcode obligatory.
select single * from tstc where tcode eq p_tcode.
if sy-subrc eq 0.
select single * from tadir where pgmid = 'R3TR'
and object = 'PROG'
and obj_name = tstc-pgmna.
move : tadir-devclass to v_devclass.
if sy-subrc ne 0.
select single * from trdir where name = tstc-pgmna.
if trdir-subc eq 'F'.
select single * from tfdir where pname = tstc-pgmna.
select single * from enlfdir where funcname =
tfdir-funcname.
select single * from tadir where pgmid = 'R3TR'
and object = 'FUGR'
and obj_name eq enlfdir-area.
move : tadir-devclass to v_devclass.
endif.
endif.
select * from tadir into table jtab
where pgmid = 'R3TR'
and object = 'SMOD'
and devclass = v_devclass.
select single * from tstct where sprsl eq sy-langu and
tcode eq p_tcode.
format color col_positive intensified off.
write:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
skip.
if not jtab[] is initial.
write:/(95) sy-uline.
format color col_heading intensified on.
write:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
write:/(95) sy-uline.
loop at jtab.
select single * from modsapt
where sprsl = sy-langu and
name = jtab-obj_name.
format color col_normal intensified off.
write:/1 sy-vline,
2 jtab-obj_name hotspot on,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
endloop.
write:/(95) sy-uline.
describe table jtab.
skip.
format color col_total intensified on.
write:/ 'No of Exits:' , sy-tfill.
else.
format color col_negative intensified on.
write:/(95) 'No User Exit exists'.
endif.
else.
format color col_negative intensified on.
write:/(95) 'Transaction Code Does Not Exist'.
endif.
at line-selection.
get cursor field field1.
check field1(4) eq 'JTAB'.
set parameter id 'MON' field sy-lisel+1(10).
call transaction 'SMOD' and skip first screen.
*---End of Program
Just for your information the User exits available for VT01n are
MV56AINI Initialization of transaction control for transportation
V56AFCCH Shipment processing: Check function code allowed
V56AGTAR User Exit for Filtering Shipping Unit Calculation
V56ARCHV Customer-spec. checks for archiving shipments
V56ATKTX Change the number of lines for text input in shipment
V56BMOD Transportation processing: Field modification
V56DISTZ Shipment Processing: Determine Distance
V56FCOPY Shipment processing: Copy delivery data
V56FSTAT Shipment processing: Activities when setting a status
V56L0001 Status of Shipments for a Delivery
V56LDELI Read Delivery Data for Shipment Processing
V56LOCID Shipment Processing: Determine Location Identification
V56MVT04 Extensions for Collective Processing of Shipments
V56SLDET Shipment processing: Leg determination
V56TDLIF Filter Delivery Items for Shipment
V56UCHCH Shipment processing: Check whether changes were made
V56UCHCO Check shipments are complete
V56UDLUP Obsolete as of 4.6C: Delivery Update on Delivery Routines
V56UNUMB Shipment number allocation
V56USTAT User-individual definition of transportation planning status
V56USVDO Update new objects for transport
V56USVDP Preparation for updating new objects for transport?
Award points if helpful..
Thanks -
BI 7 Bex Query - User exit variables after variable screen re-processed
User exit variables are not re-calculated after the variable screen is called up to re-run report with a new selection. Is there some way to force the user exit variables to change? I am aware of note 1064273 but this doesn't seem to help in these circumstances.
Example:
My Bex Query uses OI_FYPER for a static characteristic selection and I have defined a customer exit formula variable which uses the values in OI_FYPER.
All works fine when the query is run first time but if the user calls up the variable screen to change the selection and re-run the query, the customer exit formula variable is not re-calculated (customer exit is called but only with ISTEP = 3).
Software version is NS2004S (BI 7.0) SPS10, BI ABAP SP11, BI JAVA SP10, BI Front End Package 1401 rel 354.hi.. i just came to know about this in another thread..
I_STEP 3 does not have I_VNAM stored. So, to access values at I_STEP3 :
data: l_range TYPE RRS0_S_VAR_RANGE.
if I_STEP = '3'.
read table I_T_VAR_RANGE into L_RANGE with key VNAM = 'OI_FYPER'
if SY-SUBRC = 0.
...code as required...
endif.
endif.
Customer-Exit for analysis Authorizations: i_step = 3, i_vnam is empty -
Problem with User exit variable
We're using an user exit variable (var2) for YTD calculation (For getting the first month of current year). It gets value from another exit variable (var1) which has by default value last month of current year(populated in I_step1 from sy-datum). If the user wants he can change the default value of var1. It works fine when the query is executed the first time. But if the user calls the variable screen again, the variable screen does not show var1 in the popup and the user gets an error message that no value could be determined for var2. How can this issue be resolved or is there any other method to satisfy this requirement.
Your help would be appreciated and rewarded.
Thanks & Regards
HariHi Ravi,
Sorry, there's a correction. <b>var2 is used for getting the first month of the year selected by the user in var1</b>. If the user doesn't enter a value for var1, then var2 should take first month of current year from var1 which has by default last month of current year (populated in i_step1 from sy-datum). The user can select the value of var1 according to his requirement. Then var 2 should get first month of the year selected. That's why I'm using two exit variables.
It works fine during the initial run of the query. But when the user clicks on the variable button in the toolbar and executes the query, var1 is not being displayed and an error message <i>No value could be determined for var2</i> is shown. All other variables used in the query are displayed except var1.
Krzys, Is the option <i>Can be changed in Query Navigation</i> available for Exit variables. I'll check that and get back to you.
Boujema, Thanks for the OSS note.
Thanks
Hari -
User Exit variable to determine Month to date
Hello folks, wondering if someone could please assist with this problem. I have a need for a user exit variable that will determine the MTD based on a user input from another variable. For example, if a user enters 09/15/2009, the exit will know to retrieve information only for the days from 09/012009 - 09/15/2009. Here is the sample of the code that our ABAP programmer came up with but so far it's not working. Can someone please have a look at the codes below and let me know what may be the problem? Thanks.
in CMOD:
*& Include ZXRSRU01
DATA: l_sub_name TYPE char30,
l_f_chk TYPE rs38l_fnam.
CONSTANTS: lc_sub_prefix TYPE char5 VALUE 'F_BW_'.
CASE i_step.
WHEN 3.
CONCATENATE lc_sub_prefix i_s_rkb1d-infocube INTO l_sub_name.
WHEN OTHERS.
CONCATENATE lc_sub_prefix i_vnam INTO l_sub_name.
ENDCASE.
*--- this for XXX project. please create programs for
*--- each individual projects (project).
*--- variables at STEP 2
CASE i_vnam.
WHEN 'BCCMTD'.
IF l_sub_name IS NOT INITIAL.
SORT i_t_var_range BY vnam iobjnm.
PERFORM (l_sub_name) IN PROGRAM zbw_XXX_exit
USING i_t_var_range
CHANGING e_t_range.
CLEAR l_sub_name.
ENDIF.
WHEN OTHERS.
ENDCASE.
**--- infocubes at STEP 3
CASE i_s_rkb1d-infocube.
WHEN 'BSD_M01'.
IF l_sub_name IS NOT INITIAL.
SORT i_t_var_range BY vnam iobjnm.
PERFORM (l_sub_name) IN PROGRAM zbw_XXX_exit
USING i_t_var_range
CHANGING e_t_range.
CLEAR l_sub_name.
ENDIF.
WHEN OTHERS.
ENDCASE.
Edited by: David on Oct 1, 2009 5:08 PMmore info on the program
In zbw_XXX_exit program
FORM f_bw_bccmtd USING i_t_var_range TYPE zbw_rrs0_t_var_range
CHANGING e_t_range TYPE rsdd_t_range.
*--- current date
DATA: l_current_date TYPE sy-datum.
*--- initialize the variables
CLEAR: v_wa_var_range, v_exch_rate,
v_exch_temp, v_wa_return.
*--- get the appropriate value from input variable table
READ TABLE i_t_var_range INTO v_wa_var_range
WITH KEY vnam = c_var_name3
iobjnm = c_obj_name2
BINARY SEARCH.
IF sy-subrc = 0.
l_current_date = v_wa_var_range-low.
l_current_date = l_current_date - 1.
CLEAR v_wa_return.
*--- populate return value
v_wa_return-sign = c_sign.
v_wa_return-opt = c_opt_bt.
CONCATENATE l_current_date+0(6) c_one INTO v_wa_return-low.
v_wa_return-high = l_current_date.
APPEND v_wa_return TO e_t_range.
ENDIF.
ENDFORM. -
I_STEP=2 in Planning sequence and user exit variable
Hello!
I need some issue, help plz.
I have planning sequence with currency translation type fuction.
In this function Exch. rate type calculated from user-exit variable VAR_1 (for example).
This VAR_1 calculate from VAR_2 (ready for input) variable on I_STEP = 2.
In pure report all fine, i fill VAR_2 in variable screen and VAR_1 fill in exit.
But! In planning sequence (run from Excel) in I_STEP = 2 structure i_t_var_range is empty and my VAR_1 cannt be calculated.
I try any command and parameters in Bex - no result.
How can i calculate VAR_1? Or what i must do in order to get i_t_var_range on I_STEP 2 with VAR_1.
Thanks.
Anton.
BW SP 17(DEV) AND 19(QAS)Hello Matthias!
I try all kind of binding, using command VAR_NAME and VAR_VALUE, without command etc.
But it seems like my user-exit variable start in different context and do not see other variable.
My planning sequence start working only when i insert condition for planning function and set VAR_2 here. After that VAR_1 calculate normally ( i_t_var_range on I_STEP 2 contain VAR_2). But i think all should be working without condition...i dont need condition.
Any idea?
Anton.
Maybe you are looking for
-
Once again: rc.lua changes in awesome 3.4
Awesome syntax changed heavily in the new awesome release and my old rc.lua isn´t working at all. Maybe some helpful awesome-users would be so kind as to have a look on my config. require("awful") require("beautiful") require("naughty") require("wick
-
Converting a Color Cad file into a Black and White .pdf
My company recently bought me Adobe Acrobat XI-Professional as an upgrade from Adobe Acrobat 9-Standard. As such, one of the tasks assigned to me was to take color CAD drawings (.DWG extension) created in AutoCAD 12 and then convert them into black-a
-
Online preorder for Witcher 3 recieved without steelbook
I was under the impression that all preorders for the Witcher 3 were supposed to have a steelbook. I canceled my preorder that I had for over a year from Amazon just for this reason. I have recieved the game in the mail and it was the standard PS4 ca
-
Scheduling Background Jobs at OS level
Hi all, How to schedule Background jobs at operating system level. Thanks vijay
-
0.02s 1.3.0.ipa what app is this?
I found this (0.02s 1.3.0.ipa) in my folder of mobile applications. what is it and can I delete it without harming the iOS?