SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Группировка полей в ALV LIST по аналогии с ALV GRID



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sat Feb 16, 2008 9:45 pm    Post subject: Группировка полей в ALV LIST по аналогии с ALV GRID Reply with quote

Code:
REPORT Z_ALV_LIST_SUBTOTAL_DEMO.

TYPE-POOLS slis.
DATA:
  gt_bseg TYPE TABLE OF bseg with header line,
  gt_fieldcatalog TYPE slis_t_fieldcat_alv,
  gs_fieldcatalog TYPE LINE OF slis_t_fieldcat_alv,
  gt_sort TYPE slis_t_sortinfo_alv,
  gs_sort TYPE LINE OF slis_t_sortinfo_alv,
  gt_events           type slis_t_event.

DATA: g_bukrs LIKE bseg-bukrs,
      g_belnr LIKE bseg-belnr,
      g_gjahr LIKE bseg-gjahr.

SELECT * FROM bseg INTO TABLE gt_bseg
  UP TO 100 ROWS.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
  EXPORTING
    i_structure_name       = 'BSEG'
  CHANGING
    ct_fieldcat            = gt_fieldcatalog
  EXCEPTIONS
    inconsistent_interface = 1
    program_error          = 2
    OTHERS                 = 3.

gs_sort-spos = 1.
gs_sort-fieldname = 'BUKRS'.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO gt_sort.

gs_sort-spos = 2.
gs_sort-fieldname = 'GJAHR'.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO gt_sort.

gs_sort-spos = 3.
gs_sort-fieldname = 'BELNR'.
gs_sort-up = 'X'.
gs_sort-subtot = 'X'.
APPEND gs_sort TO gt_sort.

gs_fieldcatalog-do_sum = 'X'.

MODIFY gt_fieldcatalog FROM gs_fieldcatalog TRANSPORTING do_sum
  WHERE fieldname = 'DMBTR'.

data: l_event  type lvc_fname,
      ls_event type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET'
    exporting
      i_list_type     = 0
    importing
      et_events       = gt_events
    exceptions
      list_type_wrong = 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.
  else.
     read table gt_events INTO ls_event
                 with key name = 'BEFORE_LINE_OUTPUT'.
     if sy-subrc eq 0.
        concatenate 'ALV_EVENT_'
                    ls_event-name
                    into ls_event-form.
        MODIFY gt_events FROM ls_event INDEX sy-tabix.
      else.
        ls_event-name = 'BEFORE_LINE_OUTPUT'.
        concatenate 'ALV_EVENT_'
                    'BEFORE_LINE_OUTPUT'
                    into ls_event-form.
        append ls_event to gt_events.
      endif.
  endif.

data: l_callback_program type sy-cprog.

l_callback_program = sy-cprog.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
  EXPORTING
    i_callback_program  = l_callback_program
    it_fieldcat   = gt_fieldcatalog
    it_sort       = gt_sort
    it_events     = gt_events
  TABLES
    t_outtab      = gt_bseg
  EXCEPTIONS
    program_error = 1
    OTHERS        = 2.

*---------------------------------------------------------------------*
*  FORM ALV_EVENT_BEFORE_LINE_OUTPUT
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
form ALV_EVENT_BEFORE_LINE_OUTPUT
                    using rs_lineinfo type slis_lineinfo. "#EC *

  DATA: ls_bseg LIKE LINE OF gt_bseg.

  IF rs_lineinfo-tabindex NE 0.
    IF g_bukrs NE gt_bseg-bukrs.
      g_bukrs = gt_bseg-bukrs.
    ELSE.
      CLEAR gt_bseg-bukrs.
    ENDIF.

    IF g_belnr NE gt_bseg-belnr.
      g_belnr = gt_bseg-belnr.
    ELSE.
      CLEAR gt_bseg-belnr.
    ENDIF.

    IF g_gjahr NE gt_bseg-gjahr.
      g_gjahr = gt_bseg-gjahr.
    ELSE.
      CLEAR gt_bseg-gjahr.
    ENDIF.

  ELSE.
    CLEAR: g_bukrs,
           g_belnr,
           g_gjahr.
  ENDIF.
endform.                               " ALV_EVENT_BEFORE_LINE_OUTPUT
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.