Application Development and Automation 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: 
Read only

Current year on the selection screen by default

Former Member
0 Likes
4,572

Hello All,

I have one small doubt. In my selection screen i am to fill one field which represent year. By default, i have to set the current year on the selection screen. I am using parameters for that field but am not sure how to set the current year as default. I dont want to hard code it.

2. In the same report, i have an alv which has heading like this " This is the alv report for the <Current month> of <Current year>

I am able to get the texts like-this is the alv report on the heading but not sure how to get the current month and current year to be displayed.

Can some one help me?

Thanks!!!!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,439

HI,



1. PARAMETERS p_year TYPE char4.

INITIALIZATION.
P_year = sy-datum(4).

2. In PBO When you double click on the word TITLE a popup is displayed..give the & in the Title input box.

  CONCATENATE 'This is the alv report for the'  l_month  'of'  l_year INTO g_header SEPARATED BY space.
  SET TITLEBAR 'TITLE' OF PROGRAM sy-repid WITH g_header.

HI,



1. PARAMETERS p_year TYPE char4.

INITIALIZATION.
P_year = sy-datum(4).

2. In PBO When you double click on the word TITLE a popup is displayed..give the & in the Title input box.

  CONCATENATE 'This is the alv report for the'  l_month  'of'  l_year INTO g_header SEPARATED BY space.
  SET TITLEBAR 'TITLE' OF PROGRAM sy-repid WITH g_header.

6 REPLIES 6
Read only

Former Member
0 Likes
2,440

HI,



1. PARAMETERS p_year TYPE char4.

INITIALIZATION.
P_year = sy-datum(4).

2. In PBO When you double click on the word TITLE a popup is displayed..give the & in the Title input box.

  CONCATENATE 'This is the alv report for the'  l_month  'of'  l_year INTO g_header SEPARATED BY space.
  SET TITLEBAR 'TITLE' OF PROGRAM sy-repid WITH g_header.

Read only

Former Member
0 Likes
2,439

Hi,

Parameters : p_year(4).

INITIALIZATION.

p_year = sy-datum+0(4).

by doing above, u ill acheive the current year on selection screen.

to get the current yer and montht in the heading use concatenate.

eg:

data : lv_mnth(2),

lv_year(4),

lv_string TYPE string.

lv_mnth = sy-datum+4(2).

lv_year = sy-datum+0(4).

concatenate : 'This is an ALV report for month' lv_mnth 'for year' lv_year INTO lv_string separated by space.

write : lv_string.

pass the above string to FM REUSE_ALV_COMMENTRY_WRITE and call this FM in FORM top_of_list.

(or)

goto SE37 and type above FM and click on WHERE USED LIST, u ill come to understand how to use that FM...

Regards,

Pavan

Read only

Former Member
0 Likes
2,439

you can use the year from sy-datum directly into the place where you want to display.

sy-datum+0(4).

Regards,

Lalit Mohan Gupta.

Read only

Former Member
0 Likes
2,439

Hi,

Use:

PARAMETERS p_year TYPE char4 DEFAULT sy-datum+0(4).

Regards,

Nitin.

Read only

Former Member
0 Likes
2,439

You guys are amazing. Thanks

Read only

dev_parbutteea
Active Contributor
0 Likes
2,439

Hi,

Its simple , in your codes, do as follows. Also, create a title bar 'TEST1' for your program with title 'This is the alv report for the & of &.'. It will solve your problem.

PARAMETERS: p_year TYPE gjahr DEFAULT sy-datum,

p_month TYPE monat DEFAULT sy-datum+4(2).

INITIALIZATION.

set TITLEBAR 'TEST1' WITH p_year p_month.

Regards.