Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Selection screen - month and year

Former Member
0 Kudos

Hi friends,

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

17 REPLIES 17

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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.

Regards,

Rich Heilman

0 Kudos

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.

Regards,

Rich Heilman

0 Kudos

Hi Rich,

But in this field can we get the current month and year when we execute the program.

For me F4 is not that important.

How can we compare this field to a field like 08/24/2006.

PLease help.

Former Member
0 Kudos

Hi raju,

initialization.

p_lfmon = 08.

p_lfgja = 2006.

comparing with another date:

if p_lfgja = date1+4(4).

.

.

endif.

regards ,

keerthi.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Sure if you need to go that way, you can do just like this.




report zrich_0001.

data: datum type sy-datum value '20060608'.

parameters: p_spbup type spbup default '200606'.



if datum+0(6) = p_spbup.

write:/ datum, 'is in period', p_spbup.

endif.

Regards,

Rich Heilman

0 Kudos

I will try this. Finally Rich, can we get the current period and year into this field when I execute my program. Like sy-datum can we do something at the initialization event to put current period and year in this field. Just think about this. Waiting

0 Kudos

When you say period, do you mean fiscal period based on a FI calendar or just the current month?

Regards,

Rich Heilman

0 Kudos

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.

Regards,

Rich Helman

0 Kudos

No I dont mean the current(08) period. I mean when I execute my program now it should show 08/2006 and when I execute next month it should show 09/2006. It should go like that........... Sorry for not being clear... thanks

0 Kudos

Yes..

initialization.

p_spbup = sy-datum+0(6).

~Suresh

0 Kudos

Thanks Rich,

I got what I was looking for....

0 Kudos

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.

Regards,

Rich Heilman

0 Kudos

Rich, whats the difference between the Current calender month and current fiscal period.

rahulkavuri
Active Contributor
0 Kudos

hey if u want to get the current year into the field then u can declare another field say v_year.

data: cur_year(8).

cur_year = sy-datum.

v_year = cur_year+0(4).

parameters : p_lfmon like mbewh-lfmon value v_year.

Former Member
0 Kudos

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.

0 Kudos

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.

Regards,

Rich Heilman

Former Member
0 Kudos

Can you please close this post, if answered?