cancel
Showing results for 
Search instead for 
Did you mean: 

ALV grid Header !!

Former Member
0 Kudos
111

Hi good fellows,

I have searched the forum for my problem but all the codes I tried have not helped.

My problem:

I have an itab (Cus_itab) filled with customer data (kna1-kunnr, kna1-name1, kna1-stras etc) and I also have an output itab (Ausgabe_itab) filled. (field-1, 2, 3 ...)

I am able to get my list out using REUSE_ALV_DISPLAY. This is no problem. I want my output like this:

-


Customer Data: kna1-kunnr

kna1-name1

kna1-stras

-


-


Output list: field-1, field-2 etc etc

-


How could I do this.

Please simple but helpfull solution. Great points will be awarded.

Thanks in advance

Ara

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

Thanks Anver,

though I have already solved the problem, I have given good points.

regards

Ara

Former Member
0 Kudos

Hello to everyone,

I have tried your suggestions but I am sitll not getting the header as I want it. Please see my code. Can any one tell me how and where I have to put internal table "lt_header". In Lt_header are the customer data which I want to have as ALV_Display header.

Please help !!!

Thanks in advance.

Ara.

FORM alv.

  • TYPE-POOLS: slis.

DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,

ls_fieldcat TYPE slis_fieldcat_alv,

ls_layout TYPE slis_layout_alv,

lt_events TYPE slis_t_event,

lt_sort TYPE slis_t_sortinfo_alv,

ls_variant LIKE disvariant,

ls_print TYPE slis_print_alv.

DATA: lv_repid TYPE sy-repid.

lv_repid = sy-repid.

*List header----


*

TYPES: BEGIN OF customer_data,

kunnr TYPE kunnr,

name1 TYPE name1,

stras TYPE stras,

pstlz TYPE pstlz,

ort01 TYPE ort01,

land1 TYPE land1,

END OF customer_data.

DATA: lt_cust_data TYPE STANDARD TABLE OF customer_data,

ls_cust_data TYPE customer_data.

DATA:

lt_header TYPE slis_t_listheader,

ls_header TYPE slis_listheader,

lv_day(2) TYPE c,

lv_month(2) TYPE c,

lv_year(4) TYPE c.

CLEAR: lt_header, ls_header.

SELECT kunnr

name1

stras

pstlz

ort01

land1

INTO CORRESPONDING FIELDS OF ls_cust_data

FROM kna1

WHERE kunnr = gp_kunnr.

ENDSELECT.

APPEND ls_cust_data TO lt_cust_data.

IF sy-subrc NE 0.

MESSAGE e021(zmr01_sd1) .

EXIT.

ENDIF.

lv_day = sy-datum+6(2).

lv_month = sy-datum+4(2).

lv_year = sy-datum+0(4).

*Überschrift

CLEAR ls_header.

ls_header-typ = 'H'.

ls_header-info = 'Customer Data:'.

APPEND ls_header TO lt_header.

*Datum

ls_header-typ = 'H'.

CONCATENATE 'Date:' ' ' lv_day '.' lv_month '.' lv_year INTO ls_header-info .

APPEND ls_header TO lt_header.

*Customer No

ls_header-typ = 'H'.

CONCATENATE 'Customer No. :' ls_cust_data-kunnr INTO ls_header-info SEPARATED BY space.

APPEND ls_header TO lt_header.

*Customer Name

ls_header-typ = 'H'.

CONCATENATE 'Customer Name. :' ls_cust_data-name1 INTO ls_header-info SEPARATED BY space.

APPEND ls_header TO lt_header.

*Street

ls_header-typ = 'H'.

CONCATENATE 'Street. :' ls_cust_data-stras INTO ls_header-info SEPARATED BY space.

APPEND ls_header TO lt_header.

*ZIP-Code + City

ls_header-typ = 'H'.

CONCATENATE 'Zip Code + City. :' ls_cust_data-pstlz ls_cust_data-ort01 INTO ls_header-info SEPARATED BY space.

APPEND ls_header TO lt_header.

*Country

ls_header-typ = 'H'.

CONCATENATE 'Country. :' ls_cust_data-land1 INTO ls_header-info SEPARATED BY space.

APPEND ls_header TO lt_header.

.

  • CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

  • EXPORTING

  • it_list_commentary = lt_header.

*Ausgabe List----


*

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'ZAUSGABE_DR530' "Struktur ZAUSGABE_DR530 in Data Dic.

CHANGING

ct_fieldcat = lt_fieldcat

EXCEPTIONS

OTHERS = 3.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_grid_title = 'Overview of customers open engine repairs'

is_layout = ls_layout

it_fieldcat = lt_fieldcat

i_callback_program = lv_repid

i_callback_top_of_page = 'TOP_OF_PAGE'

  • it_events = lt_header

i_callback_user_command = 'ITAB_USER_COMMAND'

TABLES

t_outtab = gt_ausgabe

EXCEPTIONS

OTHERS = 2.

ENDFORM. "ALV

anversha_s
Active Contributor
0 Kudos

hi,

where is the sub routine 'TOP-OF-PAGE' .

chk this and do it like this only.

 call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            i_callback_program      = gd_repid
            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
            is_layout               = gd_layout
            it_fieldcat             = fieldcatalog[]
            i_save                  = 'X'
       tables
            t_outtab                = it_ekko
       exceptions
            program_error           = 1
            others                  = 2.

*-------------------------------------------------------------------*
* Form  TOP-OF-PAGE                                                 *
*-------------------------------------------------------------------*
* ALV Report Header                                                 *
*-------------------------------------------------------------------*
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 = 'EKKO Table Report'.
  append wa_header to t_header.
  clear wa_header.

* Date
  wa_header-typ  = 'S'.
  wa_header-key = 'Date: '.
  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 it_ekko lines ld_lines.
  ld_linesc = ld_lines.
  concatenate 'Total No. of Records Selected: ' 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.
*            i_logo             = 'Z_LOGO'.
endform.

rgds

Anver

Former Member
0 Kudos

Hi,,

try this code,,

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = gd_repid

i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

i_save = 'X'

tables

t_outtab = it_ekko

exceptions

program_error = 1

others = 2.

----


  • Form TOP-OF-PAGE *

----


  • ALV Report Header *

----


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 = 'EKKO Table Report'.

append wa_header to t_header.

clear wa_header.

  • Date

wa_header-typ = 'S'.

wa_header-key = 'Date: '.

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 it_ekko lines ld_lines.

ld_linesc = ld_lines.

concatenate 'Total No. of Records Selected: ' 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.

  • i_logo = 'Z_LOGO'.

endform.

hope this helps..

Reward if helpful..

Regards,

Ajith

Former Member
0 Kudos
check this also

*&---------------------------------------------------------------------*
*& Report  Y_TOP_PAGE                                                  *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  y_top_page                              .

TABLES : mara.
TYPE-POOLS: slis.

DATA : w_repid LIKE sy-repid.
  w_repid = sy-repid.

DATA : BEGIN OF it_mara OCCURS 0,
       matnr LIKE mara-matnr,
       END OF it_mara.

*layout
DATA: wa_layout           TYPE SLIS_LAYOUT_ALV.
*field catalog
DATA: it_fieldcat_wrt_off TYPE slis_t_fieldcat_alv,
      wa_fieldcat_wrt_off TYPE slis_fieldcat_alv.

START-OF-SELECTION.

  SELECT matnr FROM mara INTO CORRESPONDING FIELDS OF TABLE it_mara.

END-OF-SELECTION.


  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
   EXPORTING
     i_program_name               = w_repid
   I_INTERNAL_TABNAME           = 'IT_MARA'
*     i_structure_name             = 'IT_MARA'
*   I_CLIENT_NEVER_DISPLAY       = 'X'
   I_INCLNAME                   = w_repid
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
    CHANGING
      ct_fieldcat                  = it_fieldcat_wrt_off[]
   EXCEPTIONS
     inconsistent_interface       = 1
     program_error                = 2
     OTHERS                       = 3
            .
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program     = w_repid
      i_callback_top_of_page = 'TOP-OF-PAGE'
      is_layout              = wa_layout
      it_fieldcat            = it_fieldcat_wrt_off
    TABLES
      t_outtab               = it_mara
    EXCEPTIONS
      program_error          = 1
      OTHERS                 = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



*-------------------------------------------------------------------*
* Form  TOP-OF-PAGE                                                 *
*-------------------------------------------------------------------*
* ALV Report Header                                                 *
*-------------------------------------------------------------------*
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 = 'CHANDU REPORT'.
  APPEND wa_header TO t_header.
  CLEAR wa_header.

* Date
  wa_header-typ  = 'S'.
  wa_header-key = 'Date: '.
  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 it_ekko lines ld_lines.
*  ld_linesc = ld_lines.
*  concatenate 'Total No. of Records Selected: ' 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.
*            i_logo             = 'Z_LOGO'.
ENDFORM.                    "top-of-page
Manohar2u
Active Contributor
0 Kudos

Refer to this example program

<b> BALVHD01 Demo program ALV: Hierarchical-sequential list flight model</b>

Hope this helps you.

Cheers

Manohar

Former Member
0 Kudos

Hi

U have to insert the field KUNNR in the output table, define criteria for sorting for field KUNNR (using the sorting table):

LT_SORT-FIELDNAME = 'KUNNR'.

LT_SORT-UP = 'X'.

LT_SORT-SUM = 'X'.

LT_SORT-GROUP = '*'. <-- It means the system breaks the page for a new customer.

After define the event TOP_OF_PAGE where you'll write the customer data:

FORM TOP_OF_PAGE.

READ TABLE CUS_ITAB WITH KEY KUNNR = Ausgabe_itab-KUNNR.

CHECK SY-SUBRC = 0.

WRITE:.......

ENDFORM.

Max

Former Member
0 Kudos

Hi,

Go through the links given..

very helpful..

http://www.erpgenie.com/abap/controls/alvgrid.htm#Refresh%20grid%20display

<b>http://www.sapdevelopment.co.uk/reporting/alvhome.htm</b>

reward if helpful

Regards,

Ajith

Former Member
0 Kudos

I guess u r looking for this kind of output

---------------------------------------------------
Customer Data: kna1-kunnr 
               kna1-name1
               kna1-stras
---------------------------------------------------------

but this not possible ,instead u can go like this with dots


---------------------------------------------------------
Customer Data: kna1-kunnr 
 ..............kna1-name1
 ..............kna1-stras
---------------------------------------------------------

Message was edited by:

chandrasekhar jagarlamudi