I have a selection screen where I need to have two fields one for Period(month) and the other for Fiscal year. So I used
parameters : p_lfmon like mbewh-lfmon. parameters : p_lfgja like mbewh-lfgja.
My requirement is when I execute the program I want to see the current period(08) and Year(2006) in these two fields. And also I was wondering if we can add the input help F4 for these two fields as they dont have one right now.
Finally if I want to compare the these two fields month and year with a field in normal date format (08/25/2006), what is the easiest way to do that.
Waiting for replies. Especially from Rich. Thanks
Well, when I have this type of requirement, I usually use a combined field TYPE SPBUP. This is period/year combined into one. The internal format is YYYYPP, external is PP/YYYY.
parameters: p_spbup type spbup.
Then only bad part about this is that it does not provide F4 help.
For converting to YYYYMMDD format, you will need to decide what day you want to add to it. In this example, I'm defaulting the first day of the period.
report zrich_0001. data: datum type sy-datum. parameters: p_spbup type spbup default '200606'. write:/ p_spbup. datum = p_spbup. datum+6(2) = '01'. write:/ datum.
If period means, just current calendar month, then you can do this.
report zrich_0001. data: datum type sy-datum value '20060806'. parameters: p_spbup type spbup . initialization. p_spbup = sy-datum+0(6). start-of-selection. if datum+0(6) = p_spbup. write:/ datum, 'is in period', p_spbup. endif.
If you need to default the current fiscal period, then you can do this.
report zrich_0001. data: datum type sy-datum value '20060806'. parameters: p_spbup type spbup . initialization. data: xgjahr type bkpf-gjahr. data: xpoper type t009b-poper. call function 'FI_PERIOD_DETERMINE' exporting i_budat = sy-datum i_bukrs = '0010' importing e_gjahr = xgjahr e_poper = xpoper. concatenate xgjahr xpoper+1(2) into p_spbup. start-of-selection. if datum+0(6) = p_spbup. write:/ datum, 'is in period', p_spbup. endif.
In finance you have what are called fiscal periods. This is something internal to an origanization in which they split a fiscal(read finance) year to be certain number of periods. Your fiscal year can be starting in March and ending in February. So that is when you close your books, show the earnings etc. Within the fiscal year, you will have lower level units which are your fiscal periods. Again, these fiscal periods need not be starting from the first. It can be starting on the 15th of every calendar month. Also you may have up to 16 periods in a fiscal year (a limitation of SAP).
That is why you always have to be careful about what period and year you are dealing with. You should ask your business owner to tell you if it is fiscal period or calendar month that they are looking for.
In most cases, for simplicity sake, finance decides to use calendar year and months as fiscal year and periods as well.
Couldn't have said it better myself, Srinivas. In my system, we have 12 fiscal periods, but they do not run the same as calendar periods, its like 4 or 5 days off, for example period 1 starts on 01/03/2006 and ends the first week in Febuary, and so on. This is why I have given both senarios.
Like Srinivas has suggested, you need to ask the user what they mean by period, fiscal or calendar.