TABLES: mara, marc.
"marc is N
"mara is 1
SELECTION-SCREEN PUSHBUTTON 15(10) text-001 USER-COMMAND press.
DATA: lt_mara TYPE TABLE OF mara WITH HEADER LINE,
ls_mara TYPE mara.
DATA: lt_marc TYPE TABLE OF marc WITH HEADER LINE,
ls_marc TYPE marc,
Sum type P length 8 DECIMALS 2.
PARAMETERS: p_mtart TYPE mara-mtart.
SELECT-OPTIONS: so_werks FOR marc-werks.
SELECT * FROM mara INTO TABLE lt_mara
WHERE mtart = p_mtart.
IF sy-subrc = 0.
SELECT * FROM marc INTO TABLE lt_marc
FOR ALL ENTRIES IN lt_mara
WHERE matnr = lt_mara-matnr
AND werks IN so_werks.
LOOP AT lt_marc INTO ls_marc.
READ TABLE lt_mara INTO ls_mara
WITH KEY matnr = ls_marc-matnr.
sum = ls_mara-brgew + ls_mara-ntgew .
WRITE:/ ls_mara-mtart, ls_marc-matnr , ls_marc-werks , ls_mara-brgew, ls_mara-ntgew,sum.
ENDLOOP.
ELSE.
MESSAGE TEXT-e02 TYPE 'E' .
ENDIF.
如何实现这一点:我希望点击按钮来显示表格。请尽可能简单并尽可能简单地理解代码。如果您无法使用按钮使用radiobutton或其他。 提前谢谢!
答案 0 :(得分:1)
显示这样的内部表的最常用方法是使用ALV,可以在此处找到如何构建ALV的简单示例: https://archive.sap.com/discussions/thread/873601
如果您希望执行WRITE:在一种情况下进行屏幕显示,并在另一种情况下显示ALV网格,则应使用选择选项和参数。
您的代码需要添加EVENTS,请查看它们是什么以及如何使用它们: http://www.erpworkbench.com/abap/abap-events.htm
答案 1 :(得分:1)
如果您想保持简单,可以使用“sy-ucomm”存储上次触发的操作。使用按钮,它看起来像这样:
AT SELECTION-SCREEN.
CASE sy-ucomm.
WHEN 'PRESS'.
*code for displaying your table via ALV or WRITE goes here*
ENDCASE.