ABAP-ALV
22773 단어 .net
REPORT z_scott_alv_3.
*Define tables
TABLES : eine,lfa1,ekpo,eina.
*for alv
TYPE-POOLS: slis.
DATA:
i_fieldcat_alv TYPE slis_t_fieldcat_alv, "Define the fieldcat
i_layout TYPE slis_layout_alv, "alv format
i_fieldcat TYPE slis_fieldcat_alv, "
i_events TYPE slis_t_event, "alv event
w_events LIKE LINE OF i_events,
i_list_comments TYPE slis_t_listheader, "alv listheader
w_list_comments LIKE LINE OF i_list_comments,
w_repid LIKE sy-repid. " current program
*Define the fields of internal table
*1 . selection screen
DATA:
BEGIN OF hd_itab OCCURS 0,
infnr LIKE eine-infnr, "Number of purchasing info record
ekorg LIKE eine-ekorg, "Purchasing organization
matnr LIKE eina-matnr, "Material number
lifnr LIKE eina-lifnr, "Vendor's account number
erdat LIKE eine-erdat, "Date on which the record was created
loekz LIKE eine-loekz, "delete mark
urznr LIKE eina-urznr, "Certificate number
color(4) TYPE c, "Color number
*2. display screen
aplfz LIKE eine-aplfz, "Planned delivery time in days
netpr LIKE eine-netpr, "Net price in purchasing info record
peinh LIKE eine-peinh, "Price unit
dwjj LIKE eine-netpr, "Net price in purchasing info record
bprme LIKE eine-bprme, "Order price unit (purchasing)
maktx LIKE makt-maktx, "Material description
name1 LIKE lfa1-name1, "name of vendor
END OF hd_itab.
*Define selecltion screen
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t1.
SELECT-OPTIONS:s_infnr FOR eine-infnr MEMORY ID inf. "information
PARAMETERS:pr_loekz TYPE c AS CHECKBOX DEFAULT ' '. "display record
SELECT-OPTIONS:s_ekorg FOR eine-ekorg MEMORY ID eko. "purchase
SELECT-OPTIONS:s_matnr FOR eina-matnr MEMORY ID mat. "material number
SELECT-OPTIONS:s_lifnr FOR eina-lifnr MEMORY ID lif. "vendor number
SELECT-OPTIONS:s_erdat FOR eine-erdat MEMORY ID s_erdat. "Creation
SELECT-OPTIONS:s_urznr FOR eina-urznr MEMORY ID s_urznr. "approval
SELECTION-SCREEN END OF BLOCK b1.
*Program initialization
INITIALIZATION.
t1 = 'Purchase selection'.
*Select data
START-OF-SELECTION.
PERFORM getdata. "Read data
PERFORM events_build. "alv event
PERFORM layout_build. "define alv format attribute
PERFORM fields_build. "define information of fieldcat
PERFORM display_data.
END-OF-SELECTION.
DATA:
pagenum TYPE i VALUE 1. "report number
END-OF-PAGE.
pagenum = pagenum + 1.
*double click event of row item
AT LINE-SELECTION.
*&--------------------------------------------------------------------*
*& Form getdata
*&--------------------------------------------------------------------*
* Get data and select relevant fields form database table
*---------------------------------------------------------------------*
FORM getdata.
CLEAR hd_itab.
CLEAR hd_itab[].
*hd_itab table
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'. "Mark red when this purchase record has bee
ENDIF.
hd_itab-dwjj = hd_itab-netpr / hd_itab-peinh.
MODIFY hd_itab.
CLEAR hd_itab.
ENDLOOP.
ENDFORM. "getdata
*
*&--------------------------------------------------------------------*
*& Form layout_build
*&--------------------------------------------------------------------*
* Define ALV layout attribute
*---------------------------------------------------------------------*
FORM layout_build .
i_layout-zebra = 'X'.
* i_layout-detail_popup = 'X'.
i_layout-no_vline = ' '.
i_layout-colwidth_optimize = 'X'.
* i_layout-detail_initial_lines = 'X'.
* i_layout-detail_titlebar = 'detail content'.
* i_layout-box_fieldname = 'LINE'.
* i_layout-f2code = '&ETA'.
* i_layout-f2code = '&IC1'.
i_layout-info_fieldname = 'COLOR'. "Color value
i_layout-no_colhead = ' '.
w_repid = sy-repid.
ENDFORM. " layout_build
*&--------------------------------------------------------------------*
*& Form fields_build
*&--------------------------------------------------------------------*
* Set information of row display attributes
*---------------------------------------------------------------------*
FORM fields_build .
REFRESH i_fieldcat_alv.
CLEAR i_fieldcat.
DATA colnum TYPE i VALUE 1.
i_fieldcat-col_pos = colnum.
* "i_fieldcat-tabname = 'hd_itab'.
* i_fieldcat-ref_tabname = 'zorder_purchase'.
* i_fieldcat-outputlen ='14'.
i_fieldcat-fieldname = 'INFNR'.
i_fieldcat-seltext_s = 'prn'.
i_fieldcat-seltext_m = ' pur rec num '.
i_fieldcat-seltext_l = ' purchase record number '.
i_fieldcat-reptext_ddic = ' purchase record number '.
i_fieldcat-lzero = 'X'.
i_fieldcat-key = 'X'.
i_fieldcat-hotspot = 'X'.
* i_fieldcat-emphasize = 'X'.
* i_fieldcat-tech = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
*i_fieldcat-ref_tabname = 'zorder_purchase'.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'LIFNR'.
i_fieldcat-seltext_s = 'vendor number'.
i_fieldcat-seltext_m = ' vendor number '.
i_fieldcat-seltext_l = ' vendor number '.
i_fieldcat-reptext_ddic = ' vendor number '.
i_fieldcat-lzero = 'X'.
i_fieldcat-key = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
*i_fieldcat-ref_tabname = 'zorder_purchase'.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'NAME1'.
i_fieldcat-seltext_s = ' vendor name'.
i_fieldcat-seltext_m = ' vendor name '.
i_fieldcat-seltext_l = ' vendor name '.
i_fieldcat-reptext_ddic = ' vendor name '.
i_fieldcat-lzero = 'X'.
i_fieldcat-key = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'MATNR'.
* i_fieldcat-ref_tabname = 'zorder_purchase'.
i_fieldcat-seltext_s = 'Material number'.
i_fieldcat-seltext_m = ' Material number '.
i_fieldcat-seltext_l = ' Material number '.
i_fieldcat-reptext_ddic = ' Material number '.
i_fieldcat-lzero = 'X'.
* i_fieldcat-key = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
* "i_fieldcat-tabname = 'hd_itab'.
*i_fieldcat-ref_tabname = 'zorder_purchase'.
i_fieldcat-col_pos = colnum.
i_fieldcat-outputlen ='30'.
i_fieldcat-fieldname = 'MAKTX'.
i_fieldcat-seltext_s = ' Material name'.
i_fieldcat-seltext_m = ' Material name '.
i_fieldcat-seltext_l = ' Material name '.
i_fieldcat-reptext_ddic = ' Material name '.
i_fieldcat-lzero = 'X'.
* i_fieldcat-key = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
i_fieldcat-col_pos = colnum.
* i_fieldcat-outputlen ='30'.
i_fieldcat-fieldname = 'NETPR'.
i_fieldcat-seltext_s = 'net price'.
i_fieldcat-seltext_m = ' net price '.
i_fieldcat-seltext_l = ' net price '.
i_fieldcat-reptext_ddic = ' net price '.
* i_fieldcat-no_sum = 'X'.
* i_fieldcat-icon = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'PEINH'.
i_fieldcat-seltext_s = 'price unit'.
i_fieldcat-seltext_m = ' price unit '.
i_fieldcat-seltext_l = ' price unit '.
i_fieldcat-reptext_ddic = ' price unit '.
* i_fieldcat-no_sum = 'X'.
* i_fieldcat-icon = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'DWJJ'.
i_fieldcat-seltext_s = 'unit net price'.
i_fieldcat-seltext_m = ' unit net price '.
i_fieldcat-seltext_l = ' unit net price '.
i_fieldcat-reptext_ddic = ' unit net price '.
* i_fieldcat-no_sum = 'X'.
* i_fieldcat-icon = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'BPRME'.
i_fieldcat-seltext_s = 'measure'.
i_fieldcat-seltext_m = ' measure '.
i_fieldcat-seltext_l = ' measure '.
i_fieldcat-reptext_ddic = ' measure '.
* i_fieldcat-no_sum = 'X'.
* i_fieldcat-icon = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'EKORG'.
i_fieldcat-seltext_s = 'purchase organization'.
i_fieldcat-seltext_m = ' purchase organization '.
i_fieldcat-seltext_l = ' purchase organization '.
i_fieldcat-reptext_ddic = ' purchase organization '.
i_fieldcat-emphasize = 'X'.
* i_fieldcat-do_sum = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'APLFZ'.
i_fieldcat-seltext_s = 'plan delivery time'.
i_fieldcat-seltext_m = ' plan delivery time '.
i_fieldcat-seltext_l = ' plan delivery time '.
i_fieldcat-reptext_ddic = ' plan delivery time '.
* i_fieldcat-do_sum = 'X'.
i_fieldcat-emphasize = 'C211'.
* i_fieldcat-do_sum = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'ERDAT'.
i_fieldcat-seltext_s = 'record creation date'.
i_fieldcat-seltext_m = ' record creation date '.
i_fieldcat-seltext_l = ' record creation date '.
i_fieldcat-reptext_ddic = ' record creation date '.
* i_fieldcat-do_sum = 'X'.
i_fieldcat-emphasize = 'C211'.
* i_fieldcat-do_sum = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'LOEKZ'.
i_fieldcat-seltext_s = 'delete mark'.
i_fieldcat-seltext_m = ' delete mark '.
i_fieldcat-seltext_l = ' delete mark '.
i_fieldcat-reptext_ddic = ' delete mark '.
* i_fieldcat-do_sum = 'X'.
i_fieldcat-emphasize = 'C211'.
* i_fieldcat-do_sum = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
colnum = colnum + 1.
"i_fieldcat-tabname = 'hd_itab'.
i_fieldcat-col_pos = colnum.
i_fieldcat-fieldname = 'URZNR'.
i_fieldcat-seltext_s = 'approval mark'.
i_fieldcat-seltext_m = ' approval mark '.
i_fieldcat-seltext_l = ' approval mark '.
i_fieldcat-reptext_ddic = ' approval mark '.
* i_fieldcat-do_sum = 'X'.
i_fieldcat-emphasize = 'C211'.
* i_fieldcat-do_sum = 'X'.
APPEND i_fieldcat TO i_fieldcat_alv.
CLEAR i_fieldcat.
ENDFORM. " fields_build
*&--------------------------------------------------------------------*
*& Form display_data
*&--------------------------------------------------------------------*
* display content of report
*---------------------------------------------------------------------*
FORM display_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
is_layout = i_layout
it_fieldcat = i_fieldcat_alv[]
it_events = i_events[]
i_grid_title = ' collection table of purchase record'
* changed by scott comment of i_callback_user_command
i_callback_user_command = 'USER_COMMAND'
* i_callback_pf_status_set = 'WHOLE_TOOLBAR'
* i_save = 'A'
TABLES
t_outtab = hd_itab.
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. " display_data
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING i_ucomm LIKE sy-ucomm
is_selfield TYPE slis_selfield. "#EC CALLED
CASE i_ucomm.
WHEN '&IC1'. " Pick
READ TABLE hd_itab INDEX is_selfield-tabindex.
IF sy-subrc EQ 0.
SET PARAMETER ID 'INF' FIELD hd_itab-infnr.
SET PARAMETER ID 'MAT' FIELD hd_itab-matnr.
SET PARAMETER ID 'LIF' FIELD hd_itab-lifnr.
SET PARAMETER ID 'EKO' FIELD hd_itab-ekorg.
CALL TRANSACTION 'ME13' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM. " USER_COMMAND
*&--------------------------------------------------------------------*
*& Form whole_toolbar
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->EXTAB text
*---------------------------------------------------------------------*
FORM whole_toolbar USING extab TYPE slis_t_extab. "#EC CALLED
SET PF-STATUS 'WHOLE_TOOLBAR' EXCLUDING extab.
ENDFORM. "whole_toolbar
*&--------------------------------------------------------------------*
*& Form alv_top_of_page
*&--------------------------------------------------------------------*
* Set top-of-page
*---------------------------------------------------------------------*
FORM alv_top_of_page.
CLEAR: i_list_comments.
w_list_comments-typ = 'H'.
w_list_comments-key = ''.
w_list_comments-info = 'selection table of purchase record'.
APPEND w_list_comments TO i_list_comments.
CLEAR w_list_comments.
DATA: data_temp(16).
WRITE sy-datum TO: data_temp MM/DD/YYYY.
CONCATENATE 'Date:' data_temp INTO data_temp.
CONCATENATE data_temp 'IT department' INTO data_temp.
w_list_comments-typ = 'S'.
w_list_comments-key = ''.
w_list_comments-info = data_temp.
APPEND w_list_comments TO i_list_comments.
CLEAR w_list_comments.
*Changed by Scott
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_list_comments
i_logo = 'ENJOYSAP_LOGO' "Title logo.
i_end_of_list_grid = ' '. "
* i_logo = 'ENJOYSAP_LOGO'. " Title logo
ENDFORM. "alv_top_of_page
*&--------------------------------------------------------------------*
*& Form alv_end_of_list
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM alv_end_of_list.
CLEAR: i_list_comments.
w_list_comments-typ = 'S'.
w_list_comments-info = 'Created by ITDC'.
APPEND w_list_comments TO i_list_comments.
CLEAR w_list_comments.
* Changed by Scott
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = i_list_comments
i_end_of_list_grid = 'X'. "
* i_logo = 'ENJOYSAP_LOGO'. " Title
CLEAR i_list_comments.
w_list_comments-typ = 'S'.
w_list_comments-info = 'Confirm: ______________ person: ___________'.
APPEND w_list_comments TO i_list_comments.
CLEAR w_list_comments.
w_list_comments-typ = 'S'.
w_list_comments-info = 'Table created by ITDC'.
APPEND w_list_comments TO i_list_comments.
CLEAR w_list_comments.
* CLEAR data_temp.
* CONCATENATE 'Print by :' 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' " Title logo
i_end_of_list_grid = 'X'.
ENDFORM. "alv_end_of_list
*
*&--------------------------------------------------------------------*
*& Form events_build
*&--------------------------------------------------------------------*
* Define ALV event
*---------------------------------------------------------------------*
FORM events_build .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = i_events.
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.
*Changed by Scott w_events-name
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'"slis_ev_end_of_page
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. " events_build
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
AS를 통한 Module 개발1. ModuleLoader 사용 2. IModuleInfo 사용 ASModuleOne 모듈...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.