Posted: Sat Jan 26, 2008 4:52 pm Post subject: ALV report displays change document tables CDHDR and CDPOS
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'.
*---------------------------------------------------------------------*
* 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.
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.
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 ********************
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.