0

我还在SAP ABAP的学习阶段,请多多包涵。所以我正在尝试创建一个将从 vbak 表中检索数据的报告,但有一些条件:1)启用和禁用单选按钮。2) 使用“AT SELECTION-SCREEN ON”语句。3) 复选框“组织”(以一种可呈现的方式打印数据) 4) 复选框“下载为文本文件”以将数据下载为文本文件。

我的代码:

REPORT z_testingdemo.
TABLES: vbak.


SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME NO INTERVALS.
PARAMETERS: rb_on RADIOBUTTON GROUP g1.
PARAMETERS: rb_off RADIOBUTTON GROUP g1.
PARAMETERS: p_name TYPE char15.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
PARAMETERS: c_check AS CHECKBOX DEFAULT 'X'.
PARAMETERS: c_check2 AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b1.



AT SELECTION-SCREEN ON RADIOBUTTON GROUP g1.
  IF rb_on IS INITIAL.
    MESSAGE 'Please Press ENABLE to ENABLE the FIELDS' TYPE 'E'.
  ENDIF.

"--------I don't really know why this part didn't work -----------

*  IF rb_off = 'X'.
*    screen-active = 0.
*    modify screen.
*  ELSE.
*    screen-active = 1.
*    modify screen.
*  ENDIF.
"------------------------------------------------------------------


  TYPES: BEGIN OF itab,
           vbeln TYPE vbak-vbeln,
           vkorg TYPE vbak-vkorg,
           vtweg TYPE vbak-vtweg,
           spart TYPE vbak-spart,
         END OF itab.

  DATA: wa_ma TYPE itab,
        it_ma TYPE STANDARD TABLE OF itab.

  SELECT vbeln vkorg vtweg spart
                           FROM vbak
                           INTO TABLE it_ma
                           WHERE vbeln IN s_vbeln.

  IF sy-subrc = 0 AND c_check = '' AND c_check2 = ''.
    LOOP AT it_ma INTO wa_ma.
      WRITE : / wa_ma-vbeln, wa_ma-vkorg , wa_ma-vtweg, wa_ma-spart.
    ENDLOOP.
  ELSEIF sy-subrc = 0 AND c_check = 'X' AND c_check2 = ''.
    LOOP AT it_ma INTO wa_ma.
      WRITE : / wa_ma-vbeln,  17 wa_ma-vkorg ,  37 wa_ma-vtweg,  51 wa_ma-spart.
    ENDLOOP.
  ELSEIF sy-subrc = 0 AND c_check2 = 'X'.

    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename              = 'C:/REPORT4.TXT'
        write_field_separator = ','
      TABLES
        data_tab              = it_ma.

  ELSEIF sy-subrc = 0 AND c_check = '' AND c_check2 = 'X'.
  ENDIF.


TOP-OF-PAGE .
  PERFORM display_heading .
FORM display_heading.
  WRITE : / sy-uline .
  WRITE: / 'REPORT 4'.
  IF c_check = 'X'.
    WRITE:  / .
    WRITE : /'For Mr./Mrs.: ', p_name.
    WRITE : /'SALES DOCUMENT', 17 'SALES ORGANIZATION',  37 'DISTRIBUTION',  51 'CHANN. DIVISION'.
    WRITE : / sy-uline .
  ENDIF.
ENDFORM.

我的意思是,如果没有 AT SELECTION-SCREEN ON 语句,它基本上可以工作。但 AT SELECTION-SCREEN ON 是条件之一。非常感谢。

4

2 回答 2

0

如果要更改字段的设置,则需要在 中进行AT SELECTION-SCREEN OUTPUT,并且需要使用LOOP AT SCREEN语句来遍历字段。

于 2017-01-16T12:15:32.970 回答
0

你开始你的代码没有START-OF_SELECTION.

默认情况下,您的报告以 event 开头START-OF_SELECTION,但在AT SELECTION-SCREEN您定义另一个事件时,您的代码不会从 开始START-OF_SELECTION

所以你有两个解决方案:

  • 将您的代码AT SELECTION-SCREEN移到主代码下方。
  • START-OF_SELECTION在您的主要代码之前添加一个。

正如 vwegert 已经提到的,要更改选择屏幕上的设置,您需要一个LOOP AT SCREEN.

于 2017-01-16T12:21:42.783 回答