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: 

Add Dynamic Variable to ALV Report Title

Former Member
0 Kudos

I have written an ALV report. When the selection screen displays, I want to display the title from the report attribute title followed by a dynamic variable.

For instance, my attribute title is 'E&O Report as of'. I want to display 'E&O Report as of 12/08/2011'.

I am currently using the following code which works:

  CONCATENATE sy-datum+6(2) '/' sy-datum+4(2) '/' sy-datum(4) INTO gv_date.
  CONCATENATE sy-title gv_date INTO sy-title SEPARATED BY space.

I previously tried using SET TITLEBAR, but it didn't work. It displayed the actual attribute title - 'E&O Report as of &1'

SET TITLEBAR gv_title WITH gv_date.

Is there a better way to do this than by using CONCATENATE?

Brenda

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Brenda,

Open your report in change mode and click on 'Display object list' button or cntrl+ shft+ f5 and then roght click on your prgram name and create > GUI titles

Under Title code enter : T01 .

Under Title Enter : E&O Report as of &1

or Under Tilte Enter : E and O Report as of &1

and click on tick mark to save.

Then again right click on prgram name and Activate.

Now it will work.

BR

Dep

Edited by: DeepakNandikanti on Aug 16, 2011 12:23 PM

11 REPLIES 11

former_member203305
Active Contributor
0 Kudos

Hello

maybe you could try to do sth like this on the ALV, not in the title bar.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program      = gd_repid
            i_callback_top_of_page   = 'TOP-OF-PAGE'  "   see FORM

FORM top-of-page.
*ALV Header declarations
  DATA: t_header TYPE slis_t_listheader,
        wa_header TYPE slis_listheader,
        t_line LIKE wa_header-info,
        ld_lines TYPE i,
        ld_linesc(10) TYPE c.

* Title
  wa_header-typ  = 'H'.
  wa_header-info = 'Listado de Contratos ZCON'.
  APPEND wa_header TO t_header.
  CLEAR wa_header.

* Date
  wa_header-typ  = 'S'.
  wa_header-key = 'Fecha Reporte: '.
  CONCATENATE  sy-datum+6(2) '.'
               sy-datum+4(2) '.'
               sy-datum(4) INTO wa_header-info.   "todays date
  APPEND wa_header TO t_header.
  CLEAR: wa_header.

* Total No. of Records Selected
  DESCRIBE TABLE datos LINES ld_lines.
  ld_linesc = ld_lines.
  CONCATENATE 'Total Contratos Encontrados: ' ld_linesc
                    INTO t_line SEPARATED BY space.
  wa_header-typ  = 'A'.
  wa_header-info = t_line.
  APPEND wa_header TO t_header.
  CLEAR: wa_header, t_line.

  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = t_header.

ENDFORM.                    "top-of-page

There you can check and use ur code to make it dynamic.

Regards

Miguel

0 Kudos

Hi Miguel,

I want to change the title on the selection screen where the user enters the parameters. I think your code is for the title on the ALV grid.

Brenda

0 Kudos

Hi Brenda

The title has to be set in the event AT SELECTION-SCREEN OUTPUT, try....it works fine:

PARAMETERS P1.

AT SELECTION-SCREEN OUTPUT.
* Title T01 = 'E&O Report as of &1

  SET TITLEBAR 'T01' WITH SY-DATUM.

Max

0 Kudos

Hi Brenda,

sorry to be a bit offensive.

If you know the SET TITLEBAR command, so why don't you simply press F1 on your keyboard resulting in

[SET TITLEBAR |http://help.sap.com/abapdocu_702/en/abapset_titlebar_dynpro.htm]

Regards

Clemens

0 Kudos

Hi Clemens,

I believe I mentioned that I couldn't get the command to work. I had used F1 and couldn't understand why I couldn't get it to work. That's why I posted here on the forum.

Brenda

0 Kudos

Hi Brenda,

you might have copied the example given with SET titlebar to see why it did not work.

DATA: title TYPE string,
      prog  TYPE string,
      p1    TYPE c LENGTH 10,
      p2    TYPE c LENGTH 10.
...
MODULE status_0100 OUTPUT.
  ...
  title = 'TITLE_0100'.
  prog  = '...'.
  p1 = '...'.
  p2 = '...'.
  SET TITLEBAR title OF PROGRAM prog WITH p1 p2.
  ...
ENDMODULE.

Regards

Clemens

0 Kudos

The example you gave me is for a dialog program. I am writing a report program. Here's a quick and dirty example of the code that does not work for me:

TABLES: marc.

DATA: t01 TYPE string.

SELECT-OPTIONS: s_werks FOR  marc-werks.

AT SELECTION-SCREEN OUTPUT.
* Title = E&O Report as of &1

  SET TITLEBAR 'T01' WITH sy-datum.

This is the output that I get for the title:

E&O Report as of &1

What am I doing wrong?

0 Kudos

Hi

have you create the title T01?

If I run your code the title I see is: E15.08.2011 Report as of 15.08.2011

Max

0 Kudos

created and activated? Goto -> inactive objects

Regards

Clemens

Former Member
0 Kudos

Hi Brenda,

Open your report in change mode and click on 'Display object list' button or cntrl+ shft+ f5 and then roght click on your prgram name and create > GUI titles

Under Title code enter : T01 .

Under Title Enter : E&O Report as of &1

or Under Tilte Enter : E and O Report as of &1

and click on tick mark to save.

Then again right click on prgram name and Activate.

Now it will work.

BR

Dep

Edited by: DeepakNandikanti on Aug 16, 2011 12:23 PM

0 Kudos

Hi Dep,

Thank you very much. That was the piece that I was missing. It works perfectly now.

Brenda