一个极好的ALV例子
在網(wǎng)上找了個不錯的ALV例子,學(xué)習(xí)并整理了一下貼出具體的程式。
REPORT??ZZWEI_ALV_EXAMPLE.
TABLES:LFA1,"供應(yīng)商主數(shù)據(jù)?(一般地區(qū))
??????? EKPO,"采購憑證項目
?????? ?EINE,"采購信息記錄?-?采購組織數(shù)據(jù)
?????? ?EINA."采購信息記錄?-?一般數(shù)據(jù)
INCLUDE?<LIST>.
TYPE-POOLS:SLIS.
DATA:i_fieldcat_alv?TYPE?SLIS_T_FIELDCAT_ALV,"定義列標(biāo)題(屬性信息)
???? ?i_layout?TYPE?SLIS_LAYOUT_ALV,
???? ?i_fieldcat?TYPE?SLIS_FIELDCAT_ALV,"定義對象
????? i_events?TYPE?SLIS_T_EVENT,"alv事件
???? ?w_events?LIKE?LINE?OF?i_events,
???? ?i_list_comments?TYPE?SLIS_T_LISTHEADER,"alv表單標(biāo)題區(qū)域設(shè)置
????? w_list_comments?LIKE?LINE?OF?i_list_comments,
???? ?w_repid?LIKE?SY-REPID."當(dāng)前程序
*定義內(nèi)表字段
DATA:BEGIN?OF?hd_itab?OCCURS?0,
?????? infnr?LIKE?EINE-INFNR,"采購信息記錄
????? ?ekorg?LIKE?EINE-EKORG,"采購組織
????? ?matnr?LIKE?EINA-MATNR,"物料編號
???? ??lifnr?LIKE?EINA-LIFNR,"供應(yīng)商
???? ??erdat?LIKE?EINE-ERDAT,"創(chuàng)建日期
????? ?loekz?LIKE?EINE-LOEKZ,"刪除標(biāo)記
????? ?urznr?LIKE?EINA-URZNR,"批準(zhǔn)號
???? ??color(4)?TYPE?C,?"定義顏色
?????? aplfz?LIKE?EINE-APLFZ,"計劃交貨時間
????? ?netpr?LIKE?EINE-NETPR,"凈價
????? ?peinh?LIKE?EINE-PEINH,"單位價格
????? ?dwjj?LIKE?EINE-NETPR,"單位凈價
?????? bprme?LIKE?EINE-BPRME,"訂單價格單位
????? ?maktx?LIKE?MAKT-MAKTX,"物料名稱
????? ?name1?LIKE?LFA1-NAME1,"供應(yīng)商名稱
????? ?iicon?LIKE?ICON-NAME,?"ICON?圖標(biāo)
????? END?OF?hd_itab.
*選擇屏幕
SELECTION-SCREEN?BEGIN?OF?BLOCK?block1?WITH?FRAME?TITLE?t1.
? ?SELECT-OPTIONS:s_infnr?FOR?EINE-INFNR?MEMORY?ID?INF."信息記錄號碼
?? PARAMETERS:PR_LOEKZ?TYPE?C?AS?CHECKBOX?DEFAULT?''."顯示有刪除標(biāo)志的信息記錄
?? SELECT-OPTIONS:s_ekorg?FOR?EINE-EKORG?MEMORY?ID?EKO."采購組織
? ?SELECT-OPTIONS:s_matnr?FOR?EINA-MATNR?MEMORY?ID?MAT."物料編號
? ?SELECT-OPTIONS:s_lifnr?FOR?EINA-LIFNR?MEMORY?ID?LIF."供應(yīng)商編號
?? SELECT-OPTIONS:s_erdat?FOR?EINA-ERDAT?MEMORY?ID?erd."創(chuàng)建日期
? ?SELECT-OPTIONS:s_urznr?FOR?EINA-URZNR?MEMORY?ID?urz."批準(zhǔn)號
SELECTION-SCREEN?END?OF?BLOCK?block1.
*初始化事件
INITIALIZATION.
????? ?t1?=?'采購查詢'.
*屏幕開始事件
START-OF-SELECTION.
?? ?PERFORM?getdata.
??? PERFORM?events_build.
??? PERFORM?layout_build.
?? ?PERFORM?fieldcat_build.
?? ?PERFORM?alv_display_data.
*&--------------------------------------------------------------------*
*&??????Form??getdata
*&--------------------------------------------------------------------*
FORM?getdata.
? ?CLEAR?hd_itab.
? ?CLEAR?hd_itab[].
? ?IF?PR_LOEKZ?=?''.
??? ?SELECT?*?FROM?EINE?INNER?JOIN?EINA?ON?EINE~INFNR?=?EINA~INFNR?INTO?CORRESPONDING?FIELDS?OF?hd_itab
????WHERE?EINE~INFNR?IN?s_infnr?AND?EINE~EKORG?IN?s_ekorg?AND?EINA~MATNR?IN?s_matnr?AND?EINA~LIFNR?IN?s_lifnr?AND?EINA~LOEKZ?<>?'X'?AND?EINE~ERDAT?IN?s_erdat?AND?EINA~URZNR?IN?s_urznr
???? ORDER?BY?EINE~INFNR?DESCENDING.
????? ?SELECT?SINGLE?MAKTX?FROM?MAKT?INTO?CORRESPONDING?FIELDS?OF?hd_itab?WHERE?matnr?=?hd_itab-matnr.
????? ?SELECT?SINGLE?NAME1?FROM?LFA1?INTO?CORRESPONDING?FIELDS?OF?hd_itab?WHERE?lifnr?=?hd_itab-lifnr.
????? ?APPEND?hd_itab.
?????? CLEAR?hd_itab.
??? ?ENDSELECT.
? ?ELSE.
??? ?SELECT?*?FROM?EINE?INNER?JOIN?EINA?ON?EINE~INFNR?=?EINA~INFNR?INTO?CORRESPONDING?FIELDS?OF?hd_itab
????WHERE?EINE~INFNR?IN?s_infnr?AND?EINE~EKORG?IN?s_ekorg?AND?EINA~MATNR?IN?s_matnr?AND?EINA~LIFNR?IN?s_lifnr?AND?EINE~ERDAT?IN?s_erdat?AND?EINA~URZNR?IN?s_urznr
??? ?ORDER?BY?EINE~INFNR?DESCENDING.
?????? SELECT?SINGLE?MAKTX?FROM?MAKT?INTO?CORRESPONDING?FIELDS?OF?hd_itab?WHERE?matnr?=?hd_itab-matnr.
????? ?SELECT?SINGLE?NAME1?FROM?LFA1?INTO?CORRESPONDING?FIELDS?OF?hd_itab?WHERE?lifnr?=?hd_itab-lifnr.
?????? APPEND?hd_itab.
?????? CLEAR?hd_itab.
???? ENDSELECT.
? ENDIF.
? LOOP?AT?hd_itab.
?? ?IF?hd_itab-loekz?=?'X'.
???? ?hd_itab-color?=?'C610'.
???? ?hd_itab-iicon?=?ICON_INCOMPLETE.?"ICON圖標(biāo)信息
?? ?ELSE.
???? ?hd_itab-iicon?=?ICON_CHECKED.?"ICON圖標(biāo)信息
?? ?ENDIF.
??? hd_itab-dwjj?=?hd_itab-netpr?/?hd_itab-peinh.??"凈價/價格單位
?? ?MODIFY?hd_itab."更新
??? CLEAR?hd_itab."CLEAR?HEADER?LINE
? ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------------*
*&????FORM?LAYOUT?BUILD
*&---------------------------------------------------------------------------*
FORM?layout_build.
? ?i_layout-ZEBRA?=?'X'.?"ALV表格按斑馬線條紋顯示
?? "i_layout-NO_VLINE?=?'X'.?"ALV表格顯示時無堅向線
?? i_layout-COLWIDTH_OPTIMIZE?=?'X'.?"將ALV字段寬度設(shè)置為最優(yōu)化
*?? i_layout-detail_initial_lines?=?'X'.
*?? i_layout-detail_titlebar?=?'詳細(xì)內(nèi)容'.
*?? i_layout-box_fieldname??=?'LINE'.
?? i_layout-INFO_FIELDNAME?=?'COLOR'.?"設(shè)置顏色FIELD
?? i_layout-NO_COLHEAD?=?''.
? ?w_repid?=?SY-REPID.
ENDFORM.
*&---------------------------------------------------------------------------*
*&????FORM?FIELDCAT?BUILD
*&---------------------------------------------------------------------------*
FORM?fieldcat_build.
?? REFRESH?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
?? DATA?column?TYPE?I?VALUE?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'INFNR'.
?? i_fieldcat-SELTEXT_S?=?'采購信息記錄'.
?? i_fieldcat-SELTEXT_M?=?'采購信息記錄'.
? ?i_fieldcat-SELTEXT_L?=?'采購信息記錄'.
?? "i_fieldcat-reptext_ddic?=?'采購信息記錄號'.
?? i_fieldcat-LZERO?=?'X'.?"字義字段前導(dǎo)以"0"的形式顯示
?? i_fieldcat-KEY?=?'X'.
?? i_fieldcat-HOTSPOT?=?'X'."設(shè)置字段是否有熱點(熱點字段顯示有下劃線)
?? i_fieldcat-EMPHASIZE?=?'C300'."設(shè)置字段顏色
?? APPEND?i_fieldcat?TO?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'LIFNR'.
? ?i_fieldcat-SELTEXT_S?=?'供應(yīng)商號碼'.
?? i_fieldcat-SELTEXT_M?=?'供應(yīng)商號碼'.
? ?i_fieldcat-SELTEXT_L?=?'供應(yīng)商號碼'.
?? "i_fieldcat-reptext_ddic?=?'供應(yīng)商號碼'.
?? i_fieldcat-LZERO?=?'X'.
?? i_fieldcat-KEY?=?'X'.
?? i_fieldcat-HOTSPOT?=?'X'.
?? APPEND?i_fieldcat?TO?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'NAME1'.
?? i_fieldcat-SELTEXT_S?=?'供應(yīng)商名稱'.
?? i_fieldcat-SELTEXT_M?=?'供應(yīng)商名稱'.
?? i_fieldcat-SELTEXT_L?=?'供應(yīng)商名稱'.
?? "i_fieldcat-reptext_ddic?=?'供應(yīng)商名稱'.
? ?i_fieldcat-LZERO?=?'X'.
?? i_fieldcat-KEY?=?'X'.
? ?APPEND?i_fieldcat?TO?i_fieldcat_alv.
? ?CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'MATNR'.
?? i_fieldcat-SELTEXT_S?=?'物料編號'.
?? i_fieldcat-SELTEXT_M?=?'物料編號'.
?? i_fieldcat-SELTEXT_L?=?'物料編號'.
?? "i_fieldcat-reptext_ddic?=?'物料編號'.
?? i_fieldcat-LZERO?=?'X'.
? ?i_fieldcat-KEY?=?'X'.
?? APPEND?i_fieldcat?TO?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'MAKTX'.
?? i_fieldcat-SELTEXT_S?=?'物料名稱'.
?? i_fieldcat-SELTEXT_M?=?'物料名稱'.
?? i_fieldcat-SELTEXT_L?=?'物料名稱'.
?? "i_fieldcat-reptext_ddic?=?'物料名稱'.
?? i_fieldcat-LZERO?=?'X'.
?? i_fieldcat-KEY?=?'X'.
?? APPEND?i_fieldcat?TO?i_fieldcat_alv.
? ?CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'NETPR'.
?? i_fieldcat-SELTEXT_S?=?'凈價'.
?? i_fieldcat-SELTEXT_M?=?'凈價'.
?? i_fieldcat-SELTEXT_L?=?'凈價'.
?? "i_fieldcat-reptext_ddic?=?'凈價'.
?? i_fieldcat-LZERO?=?'X'.
?? i_fieldcat-KEY?=?'X'.
? ?APPEND?i_fieldcat?TO?i_fieldcat_alv.
? ?CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'PEINH'.
?? i_fieldcat-SELTEXT_S?=?'價格單位'.
?? i_fieldcat-SELTEXT_M?=?'價格單位'.
?? i_fieldcat-SELTEXT_L?=?'價格單位'.
?? "i_fieldcat-reptext_ddic?=?'價格單位'.
?? i_fieldcat-LZERO?=?'X'.
?? i_fieldcat-KEY?=?'X'.
?? APPEND?i_fieldcat?TO?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
? ?i_fieldcat-FIELDNAME?=?'DWJJ'.
?? i_fieldcat-SELTEXT_S?=?'單位凈價'.
?? i_fieldcat-SELTEXT_M?=?'單位凈價'.
? ?i_fieldcat-SELTEXT_L?=?'單位凈價'.
?? "i_fieldcat-reptext_ddic?=?'單位凈價'.
? ?i_fieldcat-LZERO?=?'X'.
? ?i_fieldcat-KEY?=?'X'.
?? APPEND?i_fieldcat?TO?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'BPRME'.
?? i_fieldcat-SELTEXT_S?=?'計量單位'.
?? i_fieldcat-SELTEXT_M?=?'計量單位'.
?? i_fieldcat-SELTEXT_L?=?'計量單位'.
?? "i_fieldcat-reptext_ddic?=?'計量單位'.
? ?i_fieldcat-LZERO?=?'X'.
?? i_fieldcat-KEY?=?'X'.
?? APPEND?i_fieldcat?TO?i_fieldcat_alv.
? ?CLEAR?i_fieldcat.
?? column?=?column?+?1.
? ?i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'EKORG'.
?? i_fieldcat-SELTEXT_S?=?'采購組織'.
?? i_fieldcat-SELTEXT_M?=?'采購組織'.
? ?i_fieldcat-SELTEXT_L?=?'采購組織'.
? ?"i_fieldcat-reptext_ddic?=?'采購組織'.
?? i_fieldcat-LZERO?=?'X'.
?? i_fieldcat-KEY?=?'X'.
? ?APPEND?i_fieldcat?TO?i_fieldcat_alv.
? ?CLEAR?i_fieldcat.
?? column?=?column?+?1.
? ?i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'APLFZ'.
?? i_fieldcat-SELTEXT_S?=?'計劃交貨時間'.
?? i_fieldcat-SELTEXT_M?=?'計劃交貨時間'.
?? i_fieldcat-SELTEXT_L?=?'計劃交貨時間'.
? ?"i_fieldcat-reptext_ddic?=?'計劃交貨時間'.
? ?i_fieldcat-LZERO?=?'X'.
?? i_fieldcat-KEY?=?'X'.
?? i_fieldcat-Emphasize?=?'C211'.
?? APPEND?i_fieldcat?TO?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'ERDAT'.
?? i_fieldcat-SELTEXT_S?=?'創(chuàng)建日期'.
?? i_fieldcat-SELTEXT_M?=?'創(chuàng)建日期'.
?? i_fieldcat-SELTEXT_L?=?'創(chuàng)建日期'.
?? "i_fieldcat-reptext_ddic?=?'創(chuàng)建日期'.
? ?i_fieldcat-LZERO?=?'X'.
?? i_fieldcat-KEY?=?'X'.
?? APPEND?i_fieldcat?TO?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
?? column?=?column?+?1.
? ?i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'LOEKZ'.
?? i_fieldcat-SELTEXT_S?=?'刪除標(biāo)志'.
?? i_fieldcat-SELTEXT_M?=?'刪除標(biāo)志'.
?? i_fieldcat-SELTEXT_L?=?'刪除標(biāo)志'.
?? "i_fieldcat-reptext_ddic?=?'刪除標(biāo)志'.
? ?i_fieldcat-LZERO?=?'X'.
? ?i_fieldcat-KEY?=?'X'.
? ?APPEND?i_fieldcat?TO?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'URZNR'.
?? i_fieldcat-SELTEXT_S?=?'批準(zhǔn)標(biāo)記'.
?? i_fieldcat-SELTEXT_M?=?'批準(zhǔn)標(biāo)記'.
?? i_fieldcat-SELTEXT_L?=?'批準(zhǔn)標(biāo)記'.
?? "i_fieldcat-reptext_ddic?=?'批準(zhǔn)標(biāo)記'.
? ?i_fieldcat-LZERO?=?'X'.
?? i_fieldcat-KEY?=?'X'.
?? i_fieldcat-Emphasize?=?'C211'.
? ?APPEND?i_fieldcat?TO?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
?? column?=?column?+?1.
?? i_fieldcat-COL_POS?=?column.
?? i_fieldcat-FIELDNAME?=?'IICON'.
*?? i_fieldcat-SELTEXT_S?=?'圖標(biāo)'.
*?? i_fieldcat-SELTEXT_M?=?'ICON'.
?? i_fieldcat-SELTEXT_L?=?'ICON'.
? ?i_fieldcat-HOTSPOT?=?'X'.
?? i_fieldcat-ICON?=?'X'.
?? "i_fieldcat-reptext_ddic?=?'批準(zhǔn)標(biāo)記'.
?? "i_fieldcat-LZERO?=?'X'.
?? "i_fieldcat-KEY?=?'X'.
?? "i_fieldcat-Emphasize?=?'C211'.
? ?APPEND?i_fieldcat?TO?i_fieldcat_alv.
?? CLEAR?i_fieldcat.
ENDFORM.
*&---------------------------------------------------------------------------*
*&????FORM?ALV?DISPLAY?DATA
*&---------------------------------------------------------------------------*
FORM?alv_display_data.
?? CALL?FUNCTION?'REUSE_ALV_GRID_DISPLAY'
?? ?EXPORTING
??? ???I_CALLBACK_PROGRAM????????????????=?w_repid
???? ??I_GRID_TITLE??????????????????????=?'采購信息記錄匯總查詢'
????? ?IS_LAYOUT?????????????????????????=?i_layout
????? ?IT_FIELDCAT???????????????????????=?i_fieldcat_alv[]
????? ?IT_EVENTS?????????????????????????=?i_events[]
????? ?"I_SAVE??=?'A'
????? ?I_CALLBACK_USER_COMMAND???????????=?'USER_COMMAND'?"USER_COMMAND?EVENT
??? ?TABLES
???? ??T_OUTTAB??????????????????????????=?hd_itab[]
? ??EXCEPTIONS
????? PROGRAM_ERROR?????????????????????=?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.
?? ENDIF.
ENDFORM.
FORM?user_command?USING?i_ucomm?TYPE?SY-UCOMM?i_selfield?TYPE?SLIS_SELFIELD.
?? CASE?i_ucomm.
??? ?WHEN?'&IC1'.??"對于熱點鏈接,所對應(yīng)的動作碼為"&IC1"
????? ?IF?i_selfield-FIELDNAME?EQ?'INFNR'.?"判斷用戶當(dāng)前單擊的是哪列
?????? ??PERFORM?call_tran?USING?i_selfield.?"調(diào)用自定義事務(wù)
????? ?ENDIF.
? ?ENDCASE.
ENDFORM.
FORM?call_tran?USING?i_selfield?TYPE?SLIS_SELFIELD.
?? "SET?SCREEN?0.??"返回主屏幕
?? READ?TABLE?hd_itab?INDEX?i_selfield-tabindex.??"i_selfield-tabindex?當(dāng)擊行索引,從內(nèi)表中提取數(shù)據(jù)
? ?IF?SY-SUBRC?=?0.
??? ??SET?PARAMETER?ID?'MAT'?FIELD?hd_itab-MATNR.?"MAT指參數(shù)ID
??? ??SET?PARAMETER?ID?'LIF'?FIELD?hd_itab-LIFNR.
???? ?SET?PARAMETER?ID?'EKO'?FIELD?hd_itab-EKORG.
???? ?SET?PARAMETER?ID?'INF'?FIELD?hd_itab-INFNR.
????? CALL?TRANSACTION?'ME13'."AND?SKIP?FIRST?SCREEN?"調(diào)用其它事務(wù)?ME13是我們要調(diào)用的事務(wù)
?? ENDIF.
ENDFORM.
FORM?ALV_TOP_OF_PAGE.?"ALV表頭信息
?? CLEAR:i_list_comments.
?? w_list_comments-typ?=?'H'.
?? w_list_comments-key?=?''.
?? w_list_comments-info?=?'采購信息記錄查詢報表'.
?? APPEND?w_list_comments?TO?i_list_comments.
?? CLEAR?w_list_comments.
? ?DATA:date_temp(30)?TYPE?C.
? ?WRITE:?SY-DATUM?TO?date_temp?MM/DD/YYYY.
?? CONCATENATE?'日期:'?date_temp?INTO?date_temp.
?? CONCATENATE?date_temp??'.???IT部'?INTO?date_temp.
?? w_list_comments-typ?=?'S'.
?? w_list_comments-key?=?''.
?? w_list_comments-info?=?date_temp.
? ?APPEND?w_list_comments?TO?i_list_comments.
?? CLEAR?w_list_comments.
?? CALL?FUNCTION?'REUSE_ALV_COMMENTARY_WRITE'??"輸出注釋
??? ?EXPORTING
???? ??IT_LIST_COMMENTARY???????=?i_list_comments
????? ?I_LOGO???????????????????=?'ENJOYSAP_LOGO'
????? ?I_END_OF_LIST_GRID???????=?'X'
*????? I_ALV_FORM???????????????=
??????????? ?.
ENDFORM.
FORM?ALV_END_OF_LIST.
? ?CLEAR:?i_list_comments.
*?? w_list_comments-typ?=?'S'.
*?? w_list_comments-info?=?'Create?By?IT?DEPARTMENT'.
*?? APPEND?w_list_comments?TO?i_list_comments.
*?? CLEAR?w_list_comments.
*
*?? CALL?FUNCTION?'REUSE_ALV_COMMENTARY_WRITE'
*???? EXPORTING
*?????? IT_LIST_COMMENTARY???????=?i_list_comments
**?????? I_LOGO???????????????????=?'ENJOYSAP_LOGO'
*?????? I_END_OF_LIST_GRID???????=?'X'
**????? I_ALV_FORM???????????????=
*????????????.
?? CLEAR:i_list_comments.
?? w_list_comments-typ?=?'S'.
?? w_list_comments-info?=?'確認(rèn):________采購申請人:___________________'.
? ?APPEND?w_list_comments?TO?i_list_comments.
?? CLEAR?w_list_comments.
?? w_list_comments-typ?=?'S'.
? ?w_list_comments-info?=?'Create?By?Information?Department'.
? ?APPEND?w_list_comments?TO?i_list_comments.
?? CLEAR?w_list_comments.
?
?? DATA:data_temp(30)?TYPE?C.
?? CONCATENATE?'打印者:'?SY-UNAME?INTO?data_temp.
?? w_list_comments-typ?=?'S'.
? ?w_list_comments-info?=?data_temp.
?? APPEND?w_list_comments?TO?i_list_comments.
? ?CLEAR?w_list_comments.
? ?CALL?FUNCTION?'REUSE_ALV_COMMENTARY_WRITE'
??? ?EXPORTING
???? ??IT_LIST_COMMENTARY???????=?i_list_comments
????? ?I_LOGO???????????????????=?'ENJOYSAP_LOGO'
?????? I_END_OF_LIST_GRID???????=?'X'
*????? I_ALV_FORM???????????????=
????????????.
ENDFORM.
FORM?events_build.
?? CALL?FUNCTION?'REUSE_ALV_EVENTS_GET'?"輸出一個內(nèi)表類型是SLIS_T_EVENT,行項為SLIS_ALV_EVENT,包含兩個字段,一個是事件名稱,另一個是處理事件的FORM名稱?
??? EXPORTING
???? ?I_LIST_TYPE???????????=?0
??? IMPORTING
????? ET_EVENTS?????????????=?i_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.
? ?ENDIF.
?? READ?TABLE?i_events?WITH?KEY?NAME?=?'TOP_OF_PAGE'?INTO?w_events.
? ?IF?SY-SUBRC?=?0.
???? MOVE?'ALV_TOP_OF_PAGE'?TO?w_events-form.
???? MODIFY?i_events?FROM?w_events?INDEX?SY-TABIX.
? ?ENDIF.
?? READ?TABLE?i_events?INTO?w_events?WITH?KEY?NAME?=?'USER_COMMAND'.
?? IF?SY-SUBRC?EQ?0.
??? ?w_events-name?=?'USER_COMMAND'.
??? ?MODIFY?i_events?FROM?w_events?INDEX?SY-TABIX.
?? ENDIF.
??READ?TABLE?i_events?WITH?KEY?NAME?=?'END_OF_LIST'?INTO?w_events.
? ?IF?SY-SUBRC?=?0.
??? ?MOVE?'ALV_END_OF_LIST'?TO?w_events-form.
??? ?MODIFY?i_events?FROM?w_events?INDEX?SY-TABIX.
?? ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*&?Report??ZZWEI_ALV_EXAMPLE
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT??ZZWEI_ALV_EXAMPLE.
TABLES:LFA1,"供應(yīng)商主數(shù)據(jù)?(一般地區(qū))
???????EKPO,"采購憑證項目
???????EINE,"采購信息記錄?-?采購組織數(shù)據(jù)
???????EINA."采購信息記錄?-?一般數(shù)據(jù)
INCLUDE?<LIST>.
TYPE-POOLS:SLIS.
DATA:i_fieldcat_alv?TYPE?SLIS_T_FIELDCAT_ALV,"定義列標(biāo)題(屬性信息)
?????i_layout?TYPE?SLIS_LAYOUT_ALV,
?????i_fieldcat?TYPE?SLIS_FIELDCAT_ALV,"定義對象
?????i_events?TYPE?SLIS_T_EVENT,"alv事件
?????w_events?LIKE?LINE?OF?i_events,
?????i_list_comments?TYPE?SLIS_T_LISTHEADER,"alv表單標(biāo)題區(qū)域設(shè)置
?????w_list_comments?LIKE?LINE?OF?i_list_comments,
?????w_repid?LIKE?SY-REPID."當(dāng)前程序
*定義內(nèi)表字段
DATA:BEGIN?OF?hd_itab?OCCURS?0,
??????infnr?LIKE?EINE-INFNR,"采購信息記錄
??????ekorg?LIKE?EINE-EKORG,"采購組織
??????matnr?LIKE?EINA-MATNR,"物料編號
??????lifnr?LIKE?EINA-LIFNR,"供應(yīng)商
??????erdat?LIKE?EINE-ERDAT,"創(chuàng)建日期
??????loekz?LIKE?EINE-LOEKZ,"刪除標(biāo)記
??????urznr?LIKE?EINA-URZNR,"批準(zhǔn)號
??????color(4)?TYPE?C,?"定義顏色
??????aplfz?LIKE?EINE-APLFZ,"計劃交貨時間
??????netpr?LIKE?EINE-NETPR,"凈價
??????peinh?LIKE?EINE-PEINH,"單位價格
??????dwjj?LIKE?EINE-NETPR,"單位凈價
??????bprme?LIKE?EINE-BPRME,"訂單價格單位
??????maktx?LIKE?MAKT-MAKTX,"物料名稱
??????name1?LIKE?LFA1-NAME1,"供應(yīng)商名稱
??????iicon?LIKE?ICON-NAME,?"ICON?圖標(biāo)
?????END?OF?hd_itab.
*選擇屏幕
SELECTION-SCREEN?BEGIN?OF?BLOCK?block1?WITH?FRAME?TITLE?t1.
??SELECT-OPTIONS:s_infnr?FOR?EINE-INFNR?MEMORY?ID?INF."信息記錄號碼
??PARAMETERS:PR_LOEKZ?TYPE?C?AS?CHECKBOX?DEFAULT?''."顯示有刪除標(biāo)志的信息記錄
??SELECT-OPTIONS:s_ekorg?FOR?EINE-EKORG?MEMORY?ID?EKO."采購組織
??SELECT-OPTIONS:s_matnr?FOR?EINA-MATNR?MEMORY?ID?MAT."物料編號
??SELECT-OPTIONS:s_lifnr?FOR?EINA-LIFNR?MEMORY?ID?LIF."供應(yīng)商編號
??SELECT-OPTIONS:s_erdat?FOR?EINA-ERDAT?MEMORY?ID?erd."創(chuàng)建日期
??SELECT-OPTIONS:s_urznr?FOR?EINA-URZNR?MEMORY?ID?urz."批準(zhǔn)號
SELECTION-SCREEN?END?OF?BLOCK?block1.
*初始化事件
INITIALIZATION.
??????t1?=?'采購查詢'.
*屏幕開始事件
START-OF-SELECTION.
???PERFORM?getdata.
???PERFORM?events_build.
???PERFORM?layout_build.
???PERFORM?fieldcat_build.
???PERFORM?alv_display_data.
*&--------------------------------------------------------------------*
*&??????Form??getdata
*&--------------------------------------------------------------------*
FORM?getdata.
??CLEAR?hd_itab.
??CLEAR?hd_itab[].
??IF?PR_LOEKZ?=?''.
????SELECT?*?FROM?EINE?INNER?JOIN?EINA?ON?EINE~INFNR?=?EINA~INFNR?INTO?CORRESPONDING?FIELDS?OF?hd_itab
????WHERE?EINE~INFNR?IN?s_infnr?AND?EINE~EKORG?IN?s_ekorg?AND?EINA~MATNR?IN?s_matnr?AND?EINA~LIFNR?IN?s_lifnr?AND?EINA~LOEKZ?<>?'X'?AND?EINE~ERDAT?IN?s_erdat?AND?EINA~URZNR?IN?s_urznr
????ORDER?BY?EINE~INFNR?DESCENDING.
??????SELECT?SINGLE?MAKTX?FROM?MAKT?INTO?CORRESPONDING?FIELDS?OF?hd_itab?WHERE?matnr?=?hd_itab-matnr.
??????SELECT?SINGLE?NAME1?FROM?LFA1?INTO?CORRESPONDING?FIELDS?OF?hd_itab?WHERE?lifnr?=?hd_itab-lifnr.
??????APPEND?hd_itab.
??????CLEAR?hd_itab.
????ENDSELECT.
??ELSE.
????SELECT?*?FROM?EINE?INNER?JOIN?EINA?ON?EINE~INFNR?=?EINA~INFNR?INTO?CORRESPONDING?FIELDS?OF?hd_itab
????WHERE?EINE~INFNR?IN?s_infnr?AND?EINE~EKORG?IN?s_ekorg?AND?EINA~MATNR?IN?s_matnr?AND?EINA~LIFNR?IN?s_lifnr?AND?EINE~ERDAT?IN?s_erdat?AND?EINA~URZNR?IN?s_urznr
????ORDER?BY?EINE~INFNR?DESCENDING.
??????SELECT?SINGLE?MAKTX?FROM?MAKT?INTO?CORRESPONDING?FIELDS?OF?hd_itab?WHERE?matnr?=?hd_itab-matnr.
??????SELECT?SINGLE?NAME1?FROM?LFA1?INTO?CORRESPONDING?FIELDS?OF?hd_itab?WHERE?lifnr?=?hd_itab-lifnr.
??????APPEND?hd_itab.
??????CLEAR?hd_itab.
????ENDSELECT.
?ENDIF.
?LOOP?AT?hd_itab.
???IF?hd_itab-loekz?=?'X'.
?????hd_itab-color?=?'C610'.
?????hd_itab-iicon?=?ICON_INCOMPLETE.?"ICON圖標(biāo)信息
???ELSE.
?????hd_itab-iicon?=?ICON_CHECKED.?"ICON圖標(biāo)信息
???ENDIF.
???hd_itab-dwjj?=?hd_itab-netpr?/?hd_itab-peinh.??"凈價/價格單位
???MODIFY?hd_itab."更新
???CLEAR?hd_itab."CLEAR?HEADER?LINE
?ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------------*
*&????FORM?LAYOUT?BUILD
*&---------------------------------------------------------------------------*
FORM?layout_build.
??i_layout-ZEBRA?=?'X'.?"ALV表格按斑馬線條紋顯示
??"i_layout-NO_VLINE?=?'X'.?"ALV表格顯示時無堅向線
??i_layout-COLWIDTH_OPTIMIZE?=?'X'.?"將ALV字段寬度設(shè)置為最優(yōu)化
*??i_layout-detail_initial_lines?=?'X'.
*??i_layout-detail_titlebar?=?'詳細(xì)內(nèi)容'.
*??i_layout-box_fieldname??=?'LINE'.
??i_layout-INFO_FIELDNAME?=?'COLOR'.?"設(shè)置顏色FIELD
??i_layout-NO_COLHEAD?=?''.
??w_repid?=?SY-REPID.
ENDFORM.
*&---------------------------------------------------------------------------*
*&????FORM?FIELDCAT?BUILD
*&---------------------------------------------------------------------------*
FORM?fieldcat_build.
??REFRESH?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??DATA?column?TYPE?I?VALUE?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'INFNR'.
??i_fieldcat-SELTEXT_S?=?'采購信息記錄'.
??i_fieldcat-SELTEXT_M?=?'采購信息記錄'.
??i_fieldcat-SELTEXT_L?=?'采購信息記錄'.
??"i_fieldcat-reptext_ddic?=?'采購信息記錄號'.
??i_fieldcat-LZERO?=?'X'.?"字義字段前導(dǎo)以"0"的形式顯示
??i_fieldcat-KEY?=?'X'.
??i_fieldcat-HOTSPOT?=?'X'."設(shè)置字段是否有熱點(熱點字段顯示有下劃線)
??i_fieldcat-EMPHASIZE?=?'C300'."設(shè)置字段顏色
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'LIFNR'.
??i_fieldcat-SELTEXT_S?=?'供應(yīng)商號碼'.
??i_fieldcat-SELTEXT_M?=?'供應(yīng)商號碼'.
??i_fieldcat-SELTEXT_L?=?'供應(yīng)商號碼'.
??"i_fieldcat-reptext_ddic?=?'供應(yīng)商號碼'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??i_fieldcat-HOTSPOT?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'NAME1'.
??i_fieldcat-SELTEXT_S?=?'供應(yīng)商名稱'.
??i_fieldcat-SELTEXT_M?=?'供應(yīng)商名稱'.
??i_fieldcat-SELTEXT_L?=?'供應(yīng)商名稱'.
??"i_fieldcat-reptext_ddic?=?'供應(yīng)商名稱'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'MATNR'.
??i_fieldcat-SELTEXT_S?=?'物料編號'.
??i_fieldcat-SELTEXT_M?=?'物料編號'.
??i_fieldcat-SELTEXT_L?=?'物料編號'.
??"i_fieldcat-reptext_ddic?=?'物料編號'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'MAKTX'.
??i_fieldcat-SELTEXT_S?=?'物料名稱'.
??i_fieldcat-SELTEXT_M?=?'物料名稱'.
??i_fieldcat-SELTEXT_L?=?'物料名稱'.
??"i_fieldcat-reptext_ddic?=?'物料名稱'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'NETPR'.
??i_fieldcat-SELTEXT_S?=?'凈價'.
??i_fieldcat-SELTEXT_M?=?'凈價'.
??i_fieldcat-SELTEXT_L?=?'凈價'.
??"i_fieldcat-reptext_ddic?=?'凈價'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'PEINH'.
??i_fieldcat-SELTEXT_S?=?'價格單位'.
??i_fieldcat-SELTEXT_M?=?'價格單位'.
??i_fieldcat-SELTEXT_L?=?'價格單位'.
??"i_fieldcat-reptext_ddic?=?'價格單位'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'DWJJ'.
??i_fieldcat-SELTEXT_S?=?'單位凈價'.
??i_fieldcat-SELTEXT_M?=?'單位凈價'.
??i_fieldcat-SELTEXT_L?=?'單位凈價'.
??"i_fieldcat-reptext_ddic?=?'單位凈價'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'BPRME'.
??i_fieldcat-SELTEXT_S?=?'計量單位'.
??i_fieldcat-SELTEXT_M?=?'計量單位'.
??i_fieldcat-SELTEXT_L?=?'計量單位'.
??"i_fieldcat-reptext_ddic?=?'計量單位'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'EKORG'.
??i_fieldcat-SELTEXT_S?=?'采購組織'.
??i_fieldcat-SELTEXT_M?=?'采購組織'.
??i_fieldcat-SELTEXT_L?=?'采購組織'.
??"i_fieldcat-reptext_ddic?=?'采購組織'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'APLFZ'.
??i_fieldcat-SELTEXT_S?=?'計劃交貨時間'.
??i_fieldcat-SELTEXT_M?=?'計劃交貨時間'.
??i_fieldcat-SELTEXT_L?=?'計劃交貨時間'.
??"i_fieldcat-reptext_ddic?=?'計劃交貨時間'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??i_fieldcat-Emphasize?=?'C211'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'ERDAT'.
??i_fieldcat-SELTEXT_S?=?'創(chuàng)建日期'.
??i_fieldcat-SELTEXT_M?=?'創(chuàng)建日期'.
??i_fieldcat-SELTEXT_L?=?'創(chuàng)建日期'.
??"i_fieldcat-reptext_ddic?=?'創(chuàng)建日期'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'LOEKZ'.
??i_fieldcat-SELTEXT_S?=?'刪除標(biāo)志'.
??i_fieldcat-SELTEXT_M?=?'刪除標(biāo)志'.
??i_fieldcat-SELTEXT_L?=?'刪除標(biāo)志'.
??"i_fieldcat-reptext_ddic?=?'刪除標(biāo)志'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'URZNR'.
??i_fieldcat-SELTEXT_S?=?'批準(zhǔn)標(biāo)記'.
??i_fieldcat-SELTEXT_M?=?'批準(zhǔn)標(biāo)記'.
??i_fieldcat-SELTEXT_L?=?'批準(zhǔn)標(biāo)記'.
??"i_fieldcat-reptext_ddic?=?'批準(zhǔn)標(biāo)記'.
??i_fieldcat-LZERO?=?'X'.
??i_fieldcat-KEY?=?'X'.
??i_fieldcat-Emphasize?=?'C211'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
??column?=?column?+?1.
??i_fieldcat-COL_POS?=?column.
??i_fieldcat-FIELDNAME?=?'IICON'.
*??i_fieldcat-SELTEXT_S?=?'圖標(biāo)'.
*??i_fieldcat-SELTEXT_M?=?'ICON'.
??i_fieldcat-SELTEXT_L?=?'ICON'.
??i_fieldcat-HOTSPOT?=?'X'.
??i_fieldcat-ICON?=?'X'.
??"i_fieldcat-reptext_ddic?=?'批準(zhǔn)標(biāo)記'.
??"i_fieldcat-LZERO?=?'X'.
??"i_fieldcat-KEY?=?'X'.
??"i_fieldcat-Emphasize?=?'C211'.
??APPEND?i_fieldcat?TO?i_fieldcat_alv.
??CLEAR?i_fieldcat.
ENDFORM.
*&---------------------------------------------------------------------------*
*&????FORM?ALV?DISPLAY?DATA
*&---------------------------------------------------------------------------*
FORM?alv_display_data.
??CALL?FUNCTION?'REUSE_ALV_GRID_DISPLAY'
???EXPORTING
??????I_CALLBACK_PROGRAM????????????????=?w_repid
??????I_GRID_TITLE??????????????????????=?'采購信息記錄匯總查詢'
??????IS_LAYOUT?????????????????????????=?i_layout
??????IT_FIELDCAT???????????????????????=?i_fieldcat_alv[]
??????IT_EVENTS?????????????????????????=?i_events[]
??????"I_SAVE??=?'A'
??????I_CALLBACK_USER_COMMAND???????????=?'USER_COMMAND'?"USER_COMMAND?EVENT
????TABLES
??????T_OUTTAB??????????????????????????=?hd_itab[]
???EXCEPTIONS
?????PROGRAM_ERROR?????????????????????=?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.
??ENDIF.
ENDFORM.
FORM?user_command?USING?i_ucomm?TYPE?SY-UCOMM?i_selfield?TYPE?SLIS_SELFIELD.
??CASE?i_ucomm.
????WHEN?'&IC1'.??"對于熱點鏈接,所對應(yīng)的動作碼為"&IC1"
??????IF?i_selfield-FIELDNAME?EQ?'INFNR'.?"判斷用戶當(dāng)前單擊的是哪列
????????PERFORM?call_tran?USING?i_selfield.?"調(diào)用自定義事務(wù)
??????ENDIF.
??ENDCASE.
ENDFORM.
FORM?call_tran?USING?i_selfield?TYPE?SLIS_SELFIELD.
??"SET?SCREEN?0.??"返回主屏幕
??READ?TABLE?hd_itab?INDEX?i_selfield-tabindex.??"i_selfield-tabindex?當(dāng)擊行索引,從內(nèi)表中提取數(shù)據(jù)
??IF?SY-SUBRC?=?0.
?????SET?PARAMETER?ID?'MAT'?FIELD?hd_itab-MATNR.?"MAT指參數(shù)ID
?????SET?PARAMETER?ID?'LIF'?FIELD?hd_itab-LIFNR.
?????SET?PARAMETER?ID?'EKO'?FIELD?hd_itab-EKORG.
?????SET?PARAMETER?ID?'INF'?FIELD?hd_itab-INFNR.
?????CALL?TRANSACTION?'ME13'."AND?SKIP?FIRST?SCREEN?"調(diào)用其它事務(wù)?ME13是我們要調(diào)用的事務(wù)
??ENDIF.
ENDFORM.
FORM?ALV_TOP_OF_PAGE.?"ALV表頭信息
??CLEAR:i_list_comments.
??w_list_comments-typ?=?'H'.
??w_list_comments-key?=?''.
??w_list_comments-info?=?'采購信息記錄查詢報表'.
??APPEND?w_list_comments?TO?i_list_comments.
??CLEAR?w_list_comments.
??DATA:date_temp(30)?TYPE?C.
??WRITE:?SY-DATUM?TO?date_temp?MM/DD/YYYY.
??CONCATENATE?'日期:'?date_temp?INTO?date_temp.
??CONCATENATE?date_temp??'.???IT部'?INTO?date_temp.
??w_list_comments-typ?=?'S'.
??w_list_comments-key?=?''.
??w_list_comments-info?=?date_temp.
??APPEND?w_list_comments?TO?i_list_comments.
??CLEAR?w_list_comments.
??CALL?FUNCTION?'REUSE_ALV_COMMENTARY_WRITE'??"輸出注釋
????EXPORTING
??????IT_LIST_COMMENTARY???????=?i_list_comments
??????I_LOGO???????????????????=?'ENJOYSAP_LOGO'
??????I_END_OF_LIST_GRID???????=?'X'
*?????I_ALV_FORM???????????????=
????????????.
ENDFORM.
FORM?ALV_END_OF_LIST.
??CLEAR:?i_list_comments.
*??w_list_comments-typ?=?'S'.
*??w_list_comments-info?=?'Create?By?IT?DEPARTMENT'.
*??APPEND?w_list_comments?TO?i_list_comments.
*??CLEAR?w_list_comments.
*
*??CALL?FUNCTION?'REUSE_ALV_COMMENTARY_WRITE'
*????EXPORTING
*??????IT_LIST_COMMENTARY???????=?i_list_comments
**??????I_LOGO???????????????????=?'ENJOYSAP_LOGO'
*??????I_END_OF_LIST_GRID???????=?'X'
**?????I_ALV_FORM???????????????=
*????????????.
??CLEAR:i_list_comments.
??w_list_comments-typ?=?'S'.
??w_list_comments-info?=?'確認(rèn):________采購申請人:___________________'.
??APPEND?w_list_comments?TO?i_list_comments.
??CLEAR?w_list_comments.
??w_list_comments-typ?=?'S'.
??w_list_comments-info?=?'Create?By?Information?Department'.
??APPEND?w_list_comments?TO?i_list_comments.
??CLEAR?w_list_comments.
?
??DATA:data_temp(30)?TYPE?C.
??CONCATENATE?'打印者:'?SY-UNAME?INTO?data_temp.
??w_list_comments-typ?=?'S'.
??w_list_comments-info?=?data_temp.
??APPEND?w_list_comments?TO?i_list_comments.
??CLEAR?w_list_comments.
??CALL?FUNCTION?'REUSE_ALV_COMMENTARY_WRITE'
????EXPORTING
??????IT_LIST_COMMENTARY???????=?i_list_comments
??????I_LOGO???????????????????=?'ENJOYSAP_LOGO'
??????I_END_OF_LIST_GRID???????=?'X'
*?????I_ALV_FORM???????????????=
????????????.
ENDFORM.
FORM?events_build.
??CALL?FUNCTION?'REUSE_ALV_EVENTS_GET'?"輸出一個內(nèi)表類型是SLIS_T_EVENT,行項為SLIS_ALV_EVENT,包含兩個字段,一個是事件名稱,另一個是處理事件的FORM名稱?
???EXPORTING
?????I_LIST_TYPE???????????=?0
???IMPORTING
?????ET_EVENTS?????????????=?i_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.
??ENDIF.
??READ?TABLE?i_events?WITH?KEY?NAME?=?'TOP_OF_PAGE'?INTO?w_events.
??IF?SY-SUBRC?=?0.
????MOVE?'ALV_TOP_OF_PAGE'?TO?w_events-form.
????MODIFY?i_events?FROM?w_events?INDEX?SY-TABIX.
??ENDIF.
??READ?TABLE?i_events?INTO?w_events?WITH?KEY?NAME?=?'USER_COMMAND'.
??IF?SY-SUBRC?EQ?0.
????w_events-name?=?'USER_COMMAND'.
????MODIFY?i_events?FROM?w_events?INDEX?SY-TABIX.
??ENDIF.
??READ?TABLE?i_events?WITH?KEY?NAME?=?'END_OF_LIST'?INTO?w_events.
??IF?SY-SUBRC?=?0.
????MOVE?'ALV_END_OF_LIST'?TO?w_events-form.
????MODIFY?i_events?FROM?w_events?INDEX?SY-TABIX.
??ENDIF.
ENDFORM.
總結(jié)
以上是生活随笔為你收集整理的一个极好的ALV例子的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 避免CONVT_NO_NUMBER的Ru
- 下一篇: ABAP数据库操作之操作语句Insert