*&---------------------------------------------------------------------*
*& Report Z_BARRY_CDHDR_CDPOS_FM *
*& *
*&---------------------------------------------------------------------*
*& 对程序Z_BARRY_CDHDR_CDPOS的改进 *
*& 标准程序:RSSCD100
*&---------------------------------------------------------------------*
REPORT z_barry_cdhdr_cdpos_fm .
TYPE-POOLS slis.
DATA : cdhdr TYPE cdhdr.
SELECT-OPTIONS :
s_objcls FOR cdhdr-objectclas OBLIGATORY NO INTERVALS ,
s_objtid FOR cdhdr-objectid,
s_chngnr FOR cdhdr-changenr,
s_usrnam FOR cdhdr-username ,"DEFAULT sy-uname,
s_udate FOR cdhdr-udate DEFAULT sy-datum OBLIGATORY,
s_time FOR cdhdr-utime,
s_tcode FOR cdhdr-tcode,
s_plncnr FOR cdhdr-planchngnr,
s_chngno FOR cdhdr-act_chngno,
s_wsplnd FOR cdhdr-was_plannd,
s_chngid FOR cdhdr-change_ind.
SELECTION-SCREEN SKIP.
PARAMETERS p_max TYPE TBMAXSEL OBLIGATORY DEFAULT '200'.
TYPES: BEGIN OF ty_s_cdhdr.
INCLUDE STRUCTURE cdhdr.
TYPES: checkbox,
END OF ty_s_cdhdr.
TYPES: BEGIN OF ty_s_cdred.
INCLUDE STRUCTURE cdred.
TYPES: checkbox,
END OF ty_s_cdred.
DATA : gs_layout TYPE slis_layout_alv,
t_cdhdr TYPE TABLE OF ty_s_cdhdr.
DATA: BEGIN OF itab_obj OCCURS 10,
objcls TYPE text20,
objdes TYPE text40,
END OF itab_obj.
DEFINE m_sort.
add 1 to ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = '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,
lt_cdred TYPE TABLE OF ty_s_cdred.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_objcls-low .
PERFORM objclsf4.
INITIALIZATION.
PERFORM fillitab USING: 'INFOSATZ' '采购信息记录',
'ORDERBUCH' '货源清单',
'EINKBELEG' '采购订单',
'MAT_FULL' 'Material' ,
'MATERIAL' '物料主数据' ,
'KRED' '供货商主数据',
'ADRESSE' '地址',
'COND_A' '条件',
'DEBI' '客户主档',
'INCOMINGINVOICE' '发票验证',
'KLASSE' '类别数据',
'KSTAR' '成本要素主数据',
'LIEFERUNG' '外向交货' .
START-OF-SELECTION.
m_sort 'UDATE'.
m_sort 'UTIME'.
* m_sort 'CHANGENR'.
* m_sort 'OBJECTID'.
* m_sort 'CHANGENR'.
* m_sort 'USERNAME'.
* m_sort 'UDATE'.
* m_sort 'UTIME'.
* m_sort 'TCODE'.
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.
gs_layout-zebra = 'X'.
gs_layout-colwidth_optimize = 'X'.
gs_layout-box_fieldname = 'CHECKBOX'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'CDHDR'
is_layout = gs_layout
it_sort = lt_sort
TABLES
t_outtab = t_cdhdr.
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING u_ucomm TYPE syucomm
us_selfield TYPE slis_selfield.
CASE u_ucomm.
WHEN '&IC1'.
PERFORM check_marked USING us_selfield.
LOOP AT t_cdhdr INTO ls_cdhdr WHERE checkbox = 'X'.
CALL FUNCTION 'CHANGEDOCUMENT_READ'
EXPORTING
changenumber = ls_cdhdr-changenr
objectclass = ls_cdhdr-objectclas
objectid = ls_cdhdr-objectid
TABLES
editpos = lt_cdred
EXCEPTIONS
no_position_found = 1
wrong_access_to_archive = 2
time_zone_conversion_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_structure_name = 'CDRED'
is_layout = gs_layout
it_sort = lt_sort
TABLES
t_outtab = lt_cdred.
ENDCASE.
ENDFORM. " USER_COMMAND
*---------------------------------------------------------------------*
* Form CHECK_MARKED
*---------------------------------------------------------------------*
FORM check_marked USING us_selfield TYPE slis_selfield.
FIELD-SYMBOLS : TYPE ty_s_cdhdr.
READ TABLE t_cdhdr TRANSPORTING NO FIELDS WITH KEY checkbox = 'X'.
IF NOT sy-subrc IS INITIAL AND NOT us_selfield-tabindex IS INITIAL.
READ TABLE t_cdhdr INDEX us_selfield-tabindex ASSIGNING .
-checkbox = 'X'.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form objclsf4
*&---------------------------------------------------------------------*
FORM objclsf4.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'OBJCLS'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_OBJCLS-LOW'
value_org = 'S'
TABLES
value_tab = itab_obj
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
ENDFORM.
*---------------------------------------------------------------------*
* FORM fillitab *
*---------------------------------------------------------------------*
FORM fillitab USING objcls objdes.
itab_obj-objcls = objcls.
itab_obj-objdes = objdes.
APPEND itab_obj.
ENDFORM.
阅读(5734) | 评论(1) | 转发(0) |