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 report displays change document tables CDHDR and CDPOS



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Programming Techniques | Приемы программирования -> Arch & Logs
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Sat Jan 26, 2008 4:52 pm    Post subject: ALV report displays change document tables CDHDR and CDPOS Reply with quote

Code:
REPORT z_alv_cdhdr_cdpos.
*---------------------------------------------------------------------*
* This ALV report displays change document tables CDHDR and CDPOS     *
*---------------------------------------------------------------------*
* Author : Michel PIOUD - Updated 21 Dec 2007                         *
* HomePage : http://www.geocities.com/mpioud                          *
*---------------------------------------------------------------------*
CONSTANTS :
  c_x VALUE 'X',
  c_eb9     TYPE syucomm VALUE '&EB9',
  c_refresh TYPE syucomm VALUE '&REFRESH'.

*---------------------------------------------------------------------*
TYPE-POOLS slis.                 " Global ALV types

TYPES :
  BEGIN OF ty_s_cdhdr.
INCLUDE TYPE cdhdr.
TYPES : checkbox TYPE xfeld,
  END OF ty_s_cdhdr,

  BEGIN OF ty_s_cdpos.
INCLUDE TYPE cdpos.
TYPES : checkbox TYPE xfeld,
  END OF ty_s_cdpos.

*---------------------------------------------------------------------*
DATA :
  gs_cdhdr TYPE cdhdr,                 " Change document header

* Layout for ALV
  gs_layout TYPE slis_layout_alv,
* Change document header
  t_cdhdr TYPE TABLE OF ty_s_cdhdr.

*---------------------------------------------------------------------*
SELECT-OPTIONS :
  s_objcls FOR gs_cdhdr-objectclas OBLIGATORY,
  s_objtid FOR gs_cdhdr-objectid,
  s_chngnr FOR gs_cdhdr-changenr,
  s_usrnam FOR gs_cdhdr-username DEFAULT sy-uname,
  s_udate  FOR gs_cdhdr-udate    DEFAULT sy-datum,
  s_time   FOR gs_cdhdr-utime,
  s_tcode  FOR gs_cdhdr-tcode,
  s_plncnr FOR gs_cdhdr-planchngnr,
  s_chngno FOR gs_cdhdr-act_chngno,
  s_wsplnd FOR gs_cdhdr-was_plannd,
  s_chngid FOR gs_cdhdr-change_ind.

SELECTION-SCREEN SKIP.
PARAMETERS p_max TYPE numc3 OBLIGATORY DEFAULT '200'.

*---------------------------------------------------------------------*
START-OF-SELECTION.

  PERFORM f_read_data.

*---------------------------------------------------------------------*
END-OF-SELECTION.

  PERFORM f_display_cdhdr.

*---------------------------------------------------------------------*
*      Form  f_read_data
*---------------------------------------------------------------------*
FORM f_read_data.

* Read Change document header
  SELECT * INTO TABLE t_cdhdr
             UP TO p_max ROWS
           FROM cdhdr
          WHERE objectclas IN s_objcls
            AND objectid   IN s_objtid
            AND changenr   IN s_chngnr
            AND username   IN s_usrnam
            AND udate      IN s_udate
            AND utime      IN s_time
            AND tcode      IN s_tcode
            AND planchngnr IN s_plncnr
            AND act_chngno IN s_chngno
            AND was_plannd IN s_wsplnd
            AND change_ind IN s_chngid.

ENDFORM.                    " F_READ_DATA
*---------------------------------------------------------------------*
*      Form  f_display_cdhdr
*---------------------------------------------------------------------*
FORM f_display_cdhdr.

  DATA :
    ls_event_exit TYPE slis_event_exit,
    lt_event_exit TYPE slis_t_event_exit.

  gs_layout-zebra = c_x.
  gs_layout-colwidth_optimize = c_x.
  gs_layout-group_change_edit = c_x.
  gs_layout-allow_switch_to_list = c_x.
  gs_layout-box_fieldname = 'CHECKBOX'.

* Activate 'More' button
  CLEAR ls_event_exit.
  ls_event_exit-after = c_x.
  ls_event_exit-ucomm = c_eb9.         " More
  APPEND ls_event_exit TO lt_event_exit.

* Activate refresh button
  CLEAR ls_event_exit.
  ls_event_exit-after = c_x.
  ls_event_exit-ucomm = c_refresh.     " Refresh
  APPEND ls_event_exit TO lt_event_exit.

* Display ALV
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program       = sy-cprog
      i_callback_user_command  = 'USER_COMMAND'
      i_callback_pf_status_set = 'PF_STATUS_SET'
      i_structure_name         = 'CDHDR'
      is_layout                = gs_layout
      it_event_exit            = lt_event_exit
      i_save                   = 'A'
    TABLES
      t_outtab                 = t_cdhdr.

ENDFORM.                    " F_DISPLAY_CDHDR
*---------------------------------------------------------------------*
*       FORM USER_COMMAND                                             *
*---------------------------------------------------------------------*
FORM user_command USING u_ucomm     TYPE syucomm
                        us_selfield TYPE slis_selfield.     "#EC CALLED

* Macro definition
  DEFINE m_sort.
    add 1 to ls_sort-spos.
    ls_sort-fieldname = &1.
    ls_sort-up = c_x.
    append ls_sort to lt_sort.
  END-OF-DEFINITION.

  DATA :
    ls_cdhdr TYPE ty_s_cdhdr,
    ls_sort  TYPE slis_sortinfo_alv,
    lt_sort  TYPE slis_t_sortinfo_alv,
*   Change document items
    lt_cdpos TYPE TABLE OF ty_s_cdpos.

  CASE u_ucomm.
    WHEN '&IC1' OR c_eb9.
      PERFORM check_marked USING us_selfield.

*     Read Change document items
      LOOP AT t_cdhdr INTO ls_cdhdr WHERE checkbox = c_x.
        SELECT * APPENDING TABLE lt_cdpos
                 FROM cdpos
                WHERE objectclas = ls_cdhdr-objectclas
                  AND objectid   = ls_cdhdr-objectid
                  AND changenr   = ls_cdhdr-changenr.
      ENDLOOP.

      m_sort 'CHANGENR'.

*     Display ALV
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = sy-cprog
          i_structure_name   = 'CDPOS'
          is_layout          = gs_layout
          it_sort            = lt_sort
          i_save             = 'A'
        TABLES
          t_outtab           = lt_cdpos.

    WHEN c_refresh.
      PERFORM f_read_data.
      us_selfield-refresh = c_x.
  ENDCASE.

ENDFORM.                               " USER_COMMAND
*---------------------------------------------------------------------*
*       Form  CHECK_MARKED
*---------------------------------------------------------------------*
*       What has been marked in t_cdhdr
*---------------------------------------------------------------------*
FORM check_marked USING us_selfield TYPE slis_selfield.

  FIELD-SYMBOLS :
    <cdhdr> TYPE ty_s_cdhdr.

  READ TABLE t_cdhdr TRANSPORTING NO FIELDS WITH KEY checkbox = c_x.
  IF NOT sy-subrc IS INITIAL AND
     NOT us_selfield-tabindex IS INITIAL.
    READ TABLE t_cdhdr INDEX us_selfield-tabindex ASSIGNING <cdhdr>.
    <cdhdr>-checkbox = c_x.
  ENDIF.

ENDFORM.                               " CHECK_MARKED
*---------------------------------------------------------------------*
*       FORM PF_STATUS_SET                                            *
*---------------------------------------------------------------------*
FORM pf_status_set USING ut_extab TYPE slis_t_extab.        "#EC CALLED

* Display 'Refresh' button and 'More' button
  DELETE ut_extab WHERE fcode = c_refresh OR fcode = c_eb9.

  SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'
      EXCLUDING ut_extab.

ENDFORM.                               " PF_STATUS_SET
***************** END OF PROGRAM Z_ALV_CDHDR_CDPOS ********************
 
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 -> Programming Techniques | Приемы программирования -> Arch & Logs 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.