Skip navigation


https://belajarabap.wordpress.com/2013/08/04/alv-list-with-multiple-header/ 

Untuk membuat multiple header seperti gambar di atas, umumnya menggunakan alv list dengan me-non-active-kan header dan menulis header baru dengan write command pada top of page dari alv.

*set layout no coloumn head
d_layout-no_colhead         = 'X'. 
*create event top of page of alv
  t_event-form = 'TOP_PAGE'.
  t_event-name = 'TOP_OF_PAGE'.
  append t_event.
*write the multiple header in form of top of page event using write command
form top_page.
  uline (295) .
  format color 1 .
  write: / sy-vline, (18) 'Store' centered,
           sy-vline, (18) 'Book' centered,
           sy-vline, (18) 'Author' centered,
           sy-vline, (8) 'Amount' centered,
           sy-vline, (34) 'Price' centered,
           sy-vline.
  write: / sy-vline, (18) ' ' centered,
         sy-vline, (18)  ' ' centered,
         sy-vline, (18) ' ' centered,
         sy-vline, (8) ' ' centered,
         sy-vline, (13) 'per Unit' centered,
         sy-vline, (18) 'Total' centered,
         sy-vline.

  format COLOR off.
endform.                    "top_of_page


Here’s a full code for you.

REPORT yalvmultipleheader
NO STANDARD PAGE HEADING.

type-pools: slis.

data :t_fieldcat  type slis_t_fieldcat_alv,
      w_fieldcat  type slis_fieldcat_alv,
      layout      type slis_layout_alv,
      t_sort      type slis_t_sortinfo_alv,
      t_event     type slis_t_event with header line,
      d_repid     like sy-repid,
      d_layout    type slis_layout_alv,
      key         type slis_keyinfo_alv.

types : begin of ty_data,
        store(15),
        book(30),
        author(30),
        amount(7) type p,
        price type dmbtr,
        total type dmbtr, "(10) TYPE p DECIMALS 2,
        curr type waers,
        end of ty_data.

data : t_data type ty_data occurs 0 with header line.


START-OF-SELECTION.
PERFORM f_process_data.
PERFORM f_write_data.

*&---------------------------------------------------------------------*
*&      Form  F_PROCESS_DATA
*&---------------------------------------------------------------------*
form f_process_data .
*fill data t_data
  t_data-store = 'Gramedia'.
  t_data-book = 'Negeri 5 Menara'.
  t_data-author = 'A. Fuadi'.
  t_data-amount = 1000.
  t_data-price = 50000.
  t_data-total = t_data-amount * t_data-price.
  t_data-curr = 'IDR'.
  append t_data.
  t_data-store = 'Eureka'.
  t_data-amount = 1000.
  t_data-price = 50000.
  t_data-total = t_data-amount * t_data-price.
  append t_data.
endform.                    " F_PROCESS_DATA
*&---------------------------------------------------------------------*
*&      Form  F_WRITE_DATA
*&---------------------------------------------------------------------*
form f_write_data .
  perform field_catalog.
  perform build_layout.
  perform build_event.

  d_repid = sy-repid.

    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
      i_callback_program = d_repid
      is_layout          = d_layout
      i_bypassing_buffer = 'X'
      it_fieldcat        = t_fieldcat
      i_default          = 'X'
      i_save             = 'A'
      it_events          = t_event[]
      it_sort            = t_sort
    tables
      t_outtab           = t_data[]
    exceptions
      program_error      = 1
      others             = 2.
endform.                    " F_WRITE_DATA
*&---------------------------------------------------------------------*
*&      Form  FIELD_CATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
form field_catalog .
  perform f_fieldcats using :
 'STORE'  'STORE'       '20' ''  ''     ''  ''  '',
 'BOOK'   'BOOK'        '20' ''  ''     ''  ''  '',
 'AUTHOR' 'AUTHOR'      '20' ''  ''     ''  ''  '',
 'AMOUNT' 'AMOUNT'      '10' ''  ''     ''  ''  '',
 'PRICE'  'PRICE'       '15' ''  ''     ''  ''  '',
 'TOTAL'  'TOTAL'       '20' '' ''     ''  ''  ''.
endform.                    " FIELD_CATALOG
*&---------------------------------------------------------------------*
*&      Form  F_FIELDCATS
*&---------------------------------------------------------------------*
form f_fieldcats using fu_fname
                       fu_text
                       fu_len
                       fu_sum
                       fu_curr
                       fu_spot
                       fu_out
                       fu_sign.

  data : lt_fieldcat type slis_fieldcat_alv.
  lt_fieldcat-fieldname      = fu_fname.  "field name
  lt_fieldcat-seltext_l      = lt_fieldcat-seltext_m =  "text
  lt_fieldcat-seltext_s      = fu_text.
  lt_fieldcat-reptext_ddic   = fu_text.
  lt_fieldcat-outputlen      = fu_len.  "text length
  lt_fieldcat-do_sum         = fu_sum.  "summing
  lt_fieldcat-cfieldname     = fu_curr. "currency
  lt_fieldcat-hotspot        = fu_spot.
  lt_fieldcat-no_out         = fu_out.
  lt_fieldcat-no_sign        = fu_sign.

  append lt_fieldcat to t_fieldcat.
  clear: lt_fieldcat.

endform.                    " F_FIELDCATS
*&---------------------------------------------------------------------*
*&      Form  BUILD_LAYOUT
*&---------------------------------------------------------------------*
form build_layout .
  d_layout-colwidth_optimize = ''.
  d_layout-zebra = 'X'.
  d_layout-no_colhead         = 'X'. "space.

endform.                    " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*&      Form  BUILD_EVENT
*&---------------------------------------------------------------------*
form build_event .
  t_event-form = 'TOP_PAGE'.
  t_event-name = 'TOP_OF_PAGE'.
  append t_event.
endform.                    " BUILD_EVENT

*&---------------------------------------------------------------------*
*&      Form  top_of_page
*&---------------------------------------------------------------------*
form top_page.
  uline (295) .
  format color 1 .
  write: / sy-vline, (18) 'Store' centered,
           sy-vline, (18) 'Book' centered,
           sy-vline, (18) 'Author' centered,
           sy-vline, (8) 'Amount' centered,
           sy-vline, (34) 'Price' centered,
           sy-vline.

  write: / sy-vline, (18) ' ' centered,
         sy-vline, (18)  ' ' centered,
         sy-vline, (18) ' ' centered,
         sy-vline, (8) ' ' centered,
         sy-vline, (13) 'per Unit' centered,
         sy-vline, (18) 'Total' centered,
         sy-vline.
  format COLOR off.
endform.                    "top_of_page

 

Advertisements

Leave Your Text

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: