我是 SAP/ABAP 编程的新手。我真的很难从我的内部表格中显示一个简单的表格控件。能否请你帮忙?目前,如果我通过输入课程 ID - 10001 来搜索课程,它会显示一个空白表格控件。它应该显示我已经填充的内容。我完全遵循以下来源:http ://sapabap-4.blogspot.sg/2013/06/simple-table-control.html 。
唯一的区别是我把所有的东西都放在了一个报告程序中,而不是我的讲师要求我做的模块程序中。另请注意,绝对没有错误,表格控件只是不显示。
*-------Declaration of tables for screen fields------------------------*
TABLES: zcms_courses.
*------Declaration of required structures------------------------------*
TYPES: BEGIN OF ty_zcms_courses,
course_id TYPE zcms_courses-course_id,
course_content TYPE zcms_courses-course_content,
music_genre TYPE zcms_courses-music_genre,
options TYPE zcms_courses-options,
course_name TYPE zcms_courses-course_name,
END OF ty_zcms_courses.
*-----Declaration of user command variables----------------------------*
DATA: OK_CODE TYPE sy-ucomm,
OK_CODE1 TYPE sy-ucomm.
*-----Declaration of work area & table---------------------------------*
DATA: wa_zcms_courses TYPE ty_zcms_courses,
itab_zcms_courses_hd TYPE TABLE OF ty_zcms_courses.
*---------Declaration of Table Control---------------------------------*
CONTROLS: zcms_courses_tc TYPE TABLEVIEW USING SCREEN 9002.
MODULE status_9001 OUTPUT.
SET PF-STATUS 'PF_PO_INP'.
SET TITLEBAR 'PO_TITLE'.
ENDMODULE. " status_9001 OUTPUT
MODULE user_command_9001 INPUT.
"Call screen 9001.
CASE OK_CODE.
WHEN 'DISP'. "Display button
CALL SCREEN 9002.
"PERFORM get_po.
WHEN 'CLR'. "Clear button
CLEAR zcms_courses-course_id.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
MODULE status_9003 OUTPUT.
SET PF-STATUS 'PF_PO_INN'.
SET TITLEBAR 'PO_TITLE1'.
ENDMODULE.
module user_command_9003 input.
CASE OK_CODE1.
WHEN 'ADD'.
CALL SCREEN 9003. endcase.
endmodule.
FORM get_po .
IF zcms_courses-course_id IS NOT INITIAL.
REFRESH: itab_zcms_courses_hd .
SELECT SINGLE course_id course_content music_genre options course_name
FROM zcms_courses INTO wa_zcms_courses
WHERE course_id = zcms_courses-course_id.
IF sy-subrc = 0.
SELECT course_id course_content music_genre options course_name
FROM zcms_courses INTO TABLE itab_zcms_courses_hd
WHERE course_id = wa_zcms_courses-course_id.
IF sy-subrc = 0.
SORT itab_zcms_courses_hd.
"Refreshing the table control to have updated data
REFRESH CONTROL 'ZCMS_COURSES_TC' FROM SCREEN 9002.
CALL SCREEN 9002.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.
MODULE STATUS_9002 OUTPUT.
SET PF-STATUS 'PF_PO_INP'.
SET TITLEBAR 'PO_TITLE'.
ENDMODULE.
MODULE table_control OUTPUT.
DESCRIBE TABLE itab_zcms_courses_hd LINES sy-dbcnt.
zcms_courses_tc-current_line = sy-loopc.
zcms_courses_tc-lines = sy-dbcnt.
zcms_courses-course_id = wa_zcms_courses-course_id.
zcms_courses-course_content = wa_zcms_courses-course_content.
zcms_courses-music_genre = wa_zcms_courses-music_genre.
zcms_courses-options = wa_zcms_courses-options.
zcms_courses-course_name = wa_zcms_courses-course_name.
CLEAR wa_zcms_courses.
ENDMODULE.
MODULE user_command_9002 INPUT.
CASE ok_code.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
CLEAR ok_code.
LEAVE LIST-PROCESSING.
LEAVE TO SCREEN 9001.
ENDCASE.
ENDMODULE.
MODULE modify_table_control INPUT.
READ TABLE itab_zcms_courses_hd INTO wa_zcms_courses INDEX
zcms_courses_tc-current_line.
IF sy-subrc = 0.
MODIFY itab_zcms_courses_hd FROM wa_zcms_courses INDEX
zcms_courses_tc-current_line.
ENDIF.
ENDMODULE.
__________________________________________________________________________________
FLOW LOGIC of screen 9002:
PROCESS BEFORE OUTPUT.
MODULE status_9002.
LOOP AT itab_zcms_courses_hd INTO wa_zcms_courses WITH CONTROL
zcms_courses_tc.
MODULE table_control.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT itab_zcms_courses_hd.
MODULE modify_table_control.
ENDLOOP.
MODULE user_command_9002.
__________________________________________________________________________________
FLOW LOGIC of screen 9001
PROCESS BEFORE OUTPUT.
MODULE STATUS_9001.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_9001.