on 03-01-2007 2:14 PM
Can someone give me a code for exit variable which gives the number of days in a month automatically with out the user's entering anything, as input. For example if i run the query today (march 1) it should return 31.
Thank You
hi,
As say Chamarthy, there is no reason why a FM does not work in your system.
When you call a FM, be careful about importing and exporting variable types. They must be the same as those declared in your FM.
Try this code:
data: L_GJAHR type T009B-BDATJ,
L_PERIV type T009B-PERIV,
L_POPER type T009B-POPER,
L_DATE type SY-DATUM.
data: MY_LAST_DAY type string.
L_GJAHR = [MY_GJAHR].
L_PERIV = [MY_PERIV].
L_POPER = [MY_POPER].
L_DATE = [MY_DATE].
CALL FUNCTION 'LAST_DAY_IN_PERIOD_GET'
EXPORTING
I_GJAHR = l_GJAHR
I_MONMIT = 00
I_PERIV = L_PERIV
I_POPER = L_POPER
IMPORTING
E_DATE = L_DATE
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4
.
MY_LAST_DAY = L_DATE+4(2).
Jacques
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i had the same problem a couple weeks ago and i wrote an ABAP code for this, I_STEP.
here's my code. It's very similiar and if you know a liitle bit of ABAP you should be able to understand it
DATA: L_S_RANGE TYPE RSR_S_RANGESID.
DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.
DATA: lv_text(20) type c,
lv_year(4) type c,
lv_month(3) type c,
lv_rawdate(7) type c.
DATA: WA_I_T_VAR_RANGE like line of I_T_VAR_RANGE.
if i_step eq 1.
case i_vnam.
when 'ZVAR6'.<---- Custom exit Variable
L_S_RANGE-LOW = lv_text.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
endcase.
elseif i_step eq 2.
case i_vnam.
when 'ZVAR6'.
loop at I_T_VAR_RANGE into wa_I_T_VAR_RANGE.
if wa_I_T_VAR_RANGE-vnam eq 'ZP_FYSR01'.
lv_rawdate = wa_I_T_VAR_RANGE-low.
lv_month = lv_rawdate+4(3).
lv_year = lv_rawdate+0(4).
endif.
endloop.
if lv_month eq '001'.
concatenate 'October' lv_year into lv_text.
elseif lv_month eq '002'.
concatenate 'November' lv_year into lv_text.
elseif lv_month eq '003'.
concatenate 'December' lv_year into lv_text.
elseif lv_month eq '004'.
concatenate 'January' lv_year into lv_text.
elseif lv_month eq '005'.
concatenate 'February' lv_year into lv_text.
elseif lv_month eq '006'.
concatenate 'March' lv_year into lv_text.
elseif lv_month eq '007'.
concatenate 'April' lv_year into lv_text.
elseif lv_month eq '008'.
concatenate 'May' lv_year into lv_text.
elseif lv_month eq '009'.
concatenate 'June' lv_year into lv_text.
elseif lv_month eq '010'.
concatenate 'July' lv_year into lv_text.
elseif lv_month eq '011'.
concatenate 'August' lv_year into lv_text.
elseif lv_month eq '012'.
concatenate 'September' lv_year into lv_text.
else.
lv_text = 'UNKN.MO'.
endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi:
The Code for Function Module is not very useful to you if Functions Modules are not Executing in your system.
Because, this FM - LAST_DAY_IN_PERIOD_GET itself calls other FMs (e.g., GET_ACCOUNT_OF_PERIODS).
So, how can you create your own FM or ABAP Code if the SAP deliverd one doesn't work?
Your best bet is to find out why the FM is not working rather than re-invent the wheel with your own ABAP Code.
Good luck,
Chamarthy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try Function Module LAST_DAY_IN_PERIOD_GET. With Fiscal Year, Fiscal year variant and Period, you obtain the last ay of the month.
An other tips. You take the first day of the next month and you substract 1. Then you obtain the last day of the current month.
Jacques
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jacques,
Appreciate your response, but i am unable to make any functional modules work on my system. I dont know why. Could you give me a complete code to get this or alternately can u give me the code to execute "Function Module LAST_DAY_IN_PERIOD_GET". I am an ABAP illitrate so finding it difficult to compile stuff. Thank You.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.