我在公司中寫了一個ALV的報表,但在測試時發生GETWA_NOT_ASSIGNED的錯誤,在DEBUG中是發生在DISPLAY中,但我看了語法實在不知哪邊出錯,可否請大家幫忙看一下!謝謝,以下為我程式的CODE
*&---------------------------------------------------------------------* *& Report ZPPR0010 *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT ZPPR0010. TABLES : cdhdr. *----------------------------------------------------------------------* * INTERNAL TABLES (i_): ABAP Internal Internal Table definitions *----------------------------------------------------------------------* data : begin of I_TAB occurs 0, udate LIKE cdhdr-udate, changenr LIKE cdhdr-changenr, username LIKE cdhdr-username, wa_item TYPE C, tabname LIKE cdpos-tabname, wa_field TYPE C, chngind LIKE cdpos-chngind, unit_old LIKE cdpos-unit_old, unit_new LIKE cdpos-unit_new, cuky_old LIKE cdpos-cuky_old, cuky_new LIKE cdpos-cuky_new, value_old LIKE cdpos-value_old, value_new LIKE cdpos-value_new, end of I_TAB. DATA : wa_cdhdr TYPE CDHDR, wa_cdpos TYPE CDPOS, itab_cdhdr LIKE STANDARD TABLE OF wa_cdhdr WITH KEY changenr, wa_tab TYPE C, wa_value TYPE C, wa_item(20) TYPE C, wa_routing(8) TYPE C, wa_field(10) TYPE C. *----------------------------------------------------------------------* * ALV *----------------------------------------------------------------------* type-pools: slis. data : fieldcat type slis_t_fieldcat_alv, heading type slis_t_listheader, layout type slis_layout_alv, events type slis_t_event, sort type slis_t_sortinfo_alv. data :i_disp_final_temp like I_TAB occurs 0 with header line. data : v_repid like sy-repid, * WA_ALV_PRINT TYPE SLIS_PRINT_ALV, t_fld type slis_fieldcat_alv. * I_HEADER TYPE SLIS_T_LISTHEADER. data: i_fieldcat_alv type slis_t_fieldcat_alv, i_events type slis_t_event, i_event_exit type slis_t_event_exit, i_list_comments type slis_t_listheader, i_excluding type slis_t_extab, i_header type slis_t_listheader. data: w_variant like disvariant, "?u793A?u5F0F?u6784 wx_variant like disvariant, w_variant_save(1) type c, w_exit(1) type c, w_repid like sy-repid, "abapu7A0Bu5E8FuFF0C?u524Du4E3Bu7A0Bu5E8F w_user_specific(1) type c, w_callback_ucomm type slis_formname, "u5B57u7B26u578B w_print type slis_print_alv, "?u578B? w_layout type slis_layout_alv, "?u578B? w_html_top_of_page type slis_formname, "u5B57u7B26u578B w_fieldcat_alv like line of i_fieldcat_alv, w_excluding like line of i_excluding, w_events like line of i_events, w_event_exit like line of i_event_exit, w_list_comments like line of i_list_comments, w_vbeln like vbfa-vbeln, w_erdat like vbfa-erdat, w_vbeln1 like vbfa-vbeln, w_erdat1 like vbfa-erdat, w_posnn like vbfa-posnn, it_vbfa like vbfa occurs 0 with header line, w_ivno type i. initialization. v_repid = sy-repid. data : g_first_day like sy-datum, g_last_day like sy-datum, g_year like mkpf-mjahr, g_month like mbew-lfmon, g_period like s012-spbup. *----------------------------------------------------------------------* * SELECTION SCREEN DATA : ABAP Internal Select Options&Parameters * SELECT-OPTIONS (so_) definitions * PARAMETERS (pa_) * COMMENT (cm_) *----------------------------------------------------------------------* SELECT-OPTIONS date_ch FOR cdhdr-udate. *----------------------------------------------------------------------* start-of-selection. *----------------------------------------------------------------------* perform GET_data. IF I_TAB[] IS INITIAL. MESSAGE 'u67E5u7121u8CC7u6599' TYPE 'I'. ELSE. LOOP AT I_TAB. MOVE-CORRESPONDING I_TAB TO i_disp_final_temp. APPEND i_disp_final_temp. CLEAR i_disp_final_temp. ENDLOOP. perform display_data. ENDIF. *----------------------------------------------------------------------* end-of-selection. *----------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form GET_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form GET_DATA. SELECT * from CDHDR INTO wa_cdhdr WHERE udate IN date_ch and tcode = 'CA02'. APPEND wa_cdhdr TO itab_cdhdr. ENDSELECT. LOOP AT itab_cdhdr INTO wa_cdhdr. SELECT * from CDPOS INTO wa_cdpos WHERE changenr = wa_cdhdr-changenr. wa_tab = 'Y'. wa_value = 'Y'. CASE wa_cdpos-tabname. WHEN 'PLKZ'. wa_tab = 'N'. ENDCASE. IF wa_cdpos-unit_old = ' ' and wa_cdpos-unit_new = ' ' and wa_cdpos-cuky_old = ' ' and wa_cdpos-cuky_new = ' ' and wa_cdpos-value_old = ' ' and wa_cdpos-value_new = ' '. wa_value = 'N'. ENDIF. IF wa_tab = 'Y' and wa_value = 'Y'. CLEAR wa_item. wa_routing = wa_cdpos-objectid+4(8). SELECT SINGLE matnr from mapl INTO wa_item WHERE plnnr = wa_routing. wa_field = wa_cdpos-fname. Case wa_cdpos-fname. when 'BMSCH'. wa_field = 'u57FAu790Eu6578u91CF'. when 'VGW01'. wa_field = 'u63DBu7DDAu6642u9593'. when 'VGW02'. wa_field = 'u6A5Fu5668'. when 'VGW03'. wa_field = 'u4EBAu5DE5'. Endcase. move wa_cdhdr-udate to i_TAB-udate. move wa_cdhdr-changenr to i_TAB-changenr. move wa_cdhdr-username to i_TAB-username. move wa_item to i_TAB-wa_item. move wa_cdpos-tabname to i_TAB-tabname. move wa_field to i_TAB-wa_field. move wa_cdpos-chngind to i_TAB-chngind. move wa_cdpos-unit_old to i_TAB-unit_old. move wa_cdpos-unit_new to i_TAB-unit_new. move wa_cdpos-cuky_old to i_TAB-cuky_old. move wa_cdpos-cuky_new to i_TAB-cuky_new. move wa_cdpos-value_old to i_TAB-value_old. move wa_cdpos-value_new to i_TAB-value_new. append i_tab. endif. endselect. endloop. endform. " GET_DATA *&---------------------------------------------------------------------* *& Form DISPLAY_DATA *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form display_data . perform fill_layout_structure. perform fill_field_catalog_table using : 'udate' 'I_DISP_FINAL_TEMP' 18 'DATE' ' ' ' '. 'changenr' 'I_DISP_FINAL_TEMP' 18 'CHANGE NO.' ' ' ' '. 'username' 'I_DISP_FINAL_TEMP' 22 'USER' ' ' ' ', 'wa_item' 'I_DISP_FINAL_TEMP' 12 'MATERIAL' ' ' ' ', 'tabname' 'I_DISP_FINAL_TEMP' 22 'TABLE' ' ' ' ', 'wa_field' 'I_DISP_FINAL_TEMP' 8 'FIELD' ' ' ' ', 'chngind' 'I_DISP_FINAL_TEMP' 5 'ACTION' ' ' ' ', 'unit_old' 'I_DISP_FINAL_TEMP' 6 'UNIT OLD' ' ' ' ', 'unit_new' 'I_DISP_FINAL_TEMP' 6 'UNIT NEW' ' ' ' ', 'cuky_old' 'I_DISP_FINAL_TEMP' 6 'CURR OLD' ' ' ' ', 'cuky_new' 'I_DISP_FINAL_TEMP' 6 'CURR NEW' ' ' ' ', 'value_old' 'I_DISP_FINAL_TEMP' 6 'VALUE OLD' ' ' ' ', 'value_new' 'I_DISP_FINAL_TEMP' 6 'VALUE NEW' ' ' ' '. perform events using i_events. perform call_alv_function. endform. " display_data *&---------------------------------------------------------------------* *& Form FILL_LAYOUT_STRUCTURE *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form fill_layout_structure . data: i_events type slis_alv_event. data : line type slis_listheader. data : h_sydate like sy-datum. clear layout. layout-colwidth_optimize = 'X'. * LAYOUT-F2CODE = '&ETA'. * LAYOUT-ZEBRA = 'X'. layout-info_fieldname = 'COLOR'. * LAYOUT-DETAIL_POPUP = 'X'. endform. " FILL_LAYOUT_STRUCTURE *&---------------------------------------------------------------------* *& Form fill_field_catalog_table *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->F text * -->T text * -->O text * -->D text * -->H text * -->TL text *----------------------------------------------------------------------* form fill_field_catalog_table using f t o d h tl . data l_fieldcat type slis_fieldcat_alv. clear l_fieldcat. statics pos like sy-index value 20. pos = pos + 1. clear t_fld. move 1 to t_fld-row_pos. move pos to t_fld-col_pos. move f to l_fieldcat-fieldname. move t to l_fieldcat-tabname. move o to l_fieldcat-outputlen. move d to l_fieldcat-seltext_m. move h to l_fieldcat-hotspot. move tl to l_fieldcat-do_sum. append l_fieldcat to fieldcat. endform. " FILL_FIELD_CATALOG_TABLE *&---------------------------------------------------------------------* *& Form EVENTS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->IT_EVENTS text *----------------------------------------------------------------------* form events using it_events type slis_t_event. data : wa_event type slis_alv_event. clear wa_event. wa_event-name = 'TOP-OF-PAGE'. wa_event-form = 'TOP_OF_PAGE'. append wa_event to i_events. endform. " f4000_event *&---------------------------------------------------------------------* *& Form CALL_ALV_FUNCTION *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* form call_alv_function . call function 'REUSE_ALV_GRID_DISPLAY' exporting i_callback_program = v_repid i_structure_name = 'I_DISP_FINAL_TEMP' * is_layout = layout it_fieldcat = fieldcat * I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE' it_sort = sort i_default = 'X' i_save = 'A' is_variant = w_variant is_layout = w_layout it_events = i_events[] is_print = w_print tables t_outtab = i_disp_final_temp. 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. " CALL_ALV_FUNCTION