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

HELP IN ALV

michael_teran
Participant
0 Likes
755

Hi Everybody

I need some help .

I'm working with ALV , my probles is.... I need to have more than one Header so that I could get One header for each detail

example :

Something like that

ALV Report

-


Mat : 000001

Place : Some Place

Country : USA

                    • ******************

Code Description

                    • ******************

8444400 XXXXXXXXXX

3999999 YYYYYYYYY

-


Mat : 00002

Place : Another Place

Country : Whenever

                    • ******************

Code Description

                    • ******************

8999900 TTTTTTTTTTTT

3445699 LLLLLLLLLLLL

3445333 VVVVVVVVV

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
677

Hi,

The following piece of code will display the more than one header in ur ALV output.

Data : wg_head type i value 5,

wf_heading type string,

wf_date type sy-datum.

Call this TOP-OF-PAGE in ur RE_USE_ALVGRID_DISPLAY

FORM top_of_page.

DATA: int_header TYPE slis_t_listheader,

fs_header TYPE slis_listheader.

DEFINE new_header_line.

clear fs_header.

fs_header-typ = &1.

fs_header-key = &2.

fs_header-info = &3.

append fs_header to int_header.

END-OF-DEFINITION.

IF wg_head = 1.

CONCATENATE sy-title text-086 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 2.

CONCATENATE sy-title text-087 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 3.

CONCATENATE sy-title text-088 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 4.

CONCATENATE sy-title text-089 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 5.

CONCATENATE sy-title text-090 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 6.

CONCATENATE sy-title text-091 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 7.

CONCATENATE sy-title text-092 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 8.

CONCATENATE sy-title text-093 INTO wf_heading.

new_header_line 'H' space wf_heading.

ENDIF.

CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum+0(4) INTO wf_date. "todays date

new_header_line 'S' text-004 wf_date.

new_header_line 'S' text-079 sy-uname.

CONCATENATE ra_daterange-low6(2) '.' ra_daterange-low4(2) '.' ra_daterange-low+0(4)

INTO wf_sdate.

CONCATENATE ra_daterange-high6(2) '.' ra_daterange-high4(2) '.' ra_daterange-high+0(4)

INTO wf_edate.

CONCATENATE wf_sdate 'TO' wf_edate INTO wf_headerdate SEPARATED BY space.

new_header_line 'S' text-081 wf_headerdate.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = int_header.

ENDFORM. "top_of_page

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_top_of_page = 'TOP_OF_PAGE'

it_sort = int_sort

i_callback_pf_status_set = 'F_PF_STATUS_SET'

i_callback_user_command = 'F_USER_COMMAND'

it_fieldcat = int_fieldcat

i_save = 'X'

TABLES

t_outtab = int_outputcpy

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

WRITE / 'error'.

ENDIF.

Reward points if useful

Cheers,

Shanthi.

Hi Everybody

I need some help .

I'm working with ALV , my probles is.... I need to have more than one Header so that I could get One header for each detail

example :

Something like that

ALV Report

-


Mat : 000001

Place : Some Place

Country : USA

                    • ******************

Code Description

                    • ******************

8444400 XXXXXXXXXX

3999999 YYYYYYYYY

-


Mat : 00002

Place : Another Place

Country : Whenever

                    • ******************

Code Description

                    • ******************

8999900 TTTTTTTTTTTT

3445699 LLLLLLLLLLLL

3445333 VVVVVVVVV

2 REPLIES 2
Read only

Former Member
0 Likes
677

I'm not quite sure of your exact requirement here but in theory the filter / subtotals buttons on a standard OO GRID should work.

A "Get around" is to call EXCEL using the PIVOT TABLE functionality. This will display it all nicely. You can then save the worksheet or on exit from EXCEL control is given back to the GRID (or your call EXCEL method) where you can exit or continue.

Add a button to the standard ALV toolbar "EXCEL" with function code EXCEL.

The method used here pops up an EXCEL dialog with the Pivot table option included.

here's some code snippets

note that my z_object reference is my own ALV class but it's similar to cl_gui_alv_grid so the principle here should work

ensure the ON_TOOLBAR event handler is present as shown below.

This passes control to your ON_USER_COMMAND method when you click a toolbar with the parameter e_ucomm containing the function code defined in the relevant button of the toolbar you pressed.

 


method constructor .
create object grid_container1
        exporting
*           container_name = 'CCONTAINER1'.
    container_name = cfname.
    create object  grid1
       exporting
          i_parent = grid_container1.
    set handler z_object->on_user_command for grid1.
    set handler z_object->on_toolbar for grid1.
    set handler z_object->handle_data_changed for grid1.
    set handler z_object->handle_data_changed_finished for grid1.
    set handler z_object->on_dubbelklik for grid1.
    set handler z_object->on_hotspot for grid1.
    call method grid1->register_edit_event
        exporting
           i_event_id = cl_gui_alv_grid=>mc_evt_enter.
  endmethod.
 
method on_toolbar .
type-pools icon.
 clear ls_toolbar.
     move  0 to ls_toolbar-butn_type.
     move 'EXCEL' to ls_toolbar-function.
     move  space to ls_toolbar-disabled.
     move  icon_xxl to ls_toolbar-icon.
     move 'Excel' to ls_toolbar-quickinfo.
     move  'EXCEL' to ls_toolbar-text.
     append ls_toolbar to e_object->mt_toolbar.
    perform   toolbar  in program (caller) if found
     using e_object.
 
* ...
endmethod.
 
method on_user_command .
*        FOR EVENT before_user_command OF cl_gui_alv_grid
*        IMPORTING
*          e_ucomm
*          sender
case e_ucomm.
 
 
      when 'EXIT'.
        leave program.
      when 'EXCEL'.
       call method me->download_to_excel.  "Call to EXCEL 
      when 'SAVE'.
      when 'PROC'.
        call method me->process.
      when 'REFR'.
        call method me->refresh.
        when 'SWITCH'.
        call method me->switch.
       when 'TEST'.
        call method me->get_cell.
 
       endcase.
 
* ...
endmethod.
 
method download_to_excel.
field-symbols:
       <fs0> type standard table,
       <fs1> type standard table.
    assign g_outtab1->* to <fs0>.
    assign g_fldcat1->* to <fs1>.
       call function  'LVC_TRANSFER_TO_KKBLO'
      exporting
        it_fieldcat_lvc   = <fs1>
*     is_layout_lvc     = m_cl_variant->ms_layout
         is_tech_complete  = ' '
      importing
        es_layout_kkblo   = ls_layout
        et_fieldcat_kkblo = lt_fieldcat.
 
    loop at lt_fieldcat into lt_fieldcat_wa.
      clear lt_fieldcat_wa-tech_complete.
      if lt_fieldcat_wa-tabname is initial.
        lt_fieldcat_wa-tabname = '1'.
        modify lt_fieldcat from lt_fieldcat_wa.
      endif.
      l_tabname = lt_fieldcat_wa-tabname.
    endloop.
    call function 'ALV_XXL_CALL'
         exporting
              i_tabname           = l_tabname
              is_layout           = ls_layout
              it_fieldcat         = lt_fieldcat
              i_title             = sy-title
         tables
              it_outtab           = <fs0>
         exceptions
              fatal_error         = 1
              no_display_possible = 2
              others              = 3.
    if  sy-subrc  0.
      message id sy-msgid type 'S' number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    endif.
 
* ...
endmethod.
 

Cheers

jimbo

Read only

Former Member
0 Likes
678

Hi,

The following piece of code will display the more than one header in ur ALV output.

Data : wg_head type i value 5,

wf_heading type string,

wf_date type sy-datum.

Call this TOP-OF-PAGE in ur RE_USE_ALVGRID_DISPLAY

FORM top_of_page.

DATA: int_header TYPE slis_t_listheader,

fs_header TYPE slis_listheader.

DEFINE new_header_line.

clear fs_header.

fs_header-typ = &1.

fs_header-key = &2.

fs_header-info = &3.

append fs_header to int_header.

END-OF-DEFINITION.

IF wg_head = 1.

CONCATENATE sy-title text-086 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 2.

CONCATENATE sy-title text-087 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 3.

CONCATENATE sy-title text-088 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 4.

CONCATENATE sy-title text-089 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 5.

CONCATENATE sy-title text-090 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 6.

CONCATENATE sy-title text-091 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 7.

CONCATENATE sy-title text-092 INTO wf_heading.

new_header_line 'H' space wf_heading.

ELSEIF wg_head = 8.

CONCATENATE sy-title text-093 INTO wf_heading.

new_header_line 'H' space wf_heading.

ENDIF.

CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'

sy-datum+0(4) INTO wf_date. "todays date

new_header_line 'S' text-004 wf_date.

new_header_line 'S' text-079 sy-uname.

CONCATENATE ra_daterange-low6(2) '.' ra_daterange-low4(2) '.' ra_daterange-low+0(4)

INTO wf_sdate.

CONCATENATE ra_daterange-high6(2) '.' ra_daterange-high4(2) '.' ra_daterange-high+0(4)

INTO wf_edate.

CONCATENATE wf_sdate 'TO' wf_edate INTO wf_headerdate SEPARATED BY space.

new_header_line 'S' text-081 wf_headerdate.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = int_header.

ENDFORM. "top_of_page

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_callback_top_of_page = 'TOP_OF_PAGE'

it_sort = int_sort

i_callback_pf_status_set = 'F_PF_STATUS_SET'

i_callback_user_command = 'F_USER_COMMAND'

it_fieldcat = int_fieldcat

i_save = 'X'

TABLES

t_outtab = int_outputcpy

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

WRITE / 'error'.

ENDIF.

Reward points if useful

Cheers,

Shanthi.