AT SELECTION-SCREEN ON <field>阻止程序检索数据

时间:2017-01-16 11:45:11

标签: sap abap

我还处于SAP ABAP的学习阶段,所以请耐心等待。所以我试图创建一个将从vbak表中检索数据的报告,但是有一些条件: 1)启用和禁用单选按钮。 2)使用&#34; AT SELECTION-SCREEN ON&#34;声明。 3)复选框&#39;组织&#39; (以可显示的方式打印数据) 4)复选框&#39;下载为文本文件&#39;将数据下载为文本文件。

我的代码:

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是其中一个条件。非常感谢。

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

您在没有'./configure' '--with-zlib' '--enable-soap' '--enable-exif' '--with-config-file-path=/usr/local/php' '--with-config-file-scan-dir=/usr/local/php/php.d' '--enable-phar' '--enable-bcmath' '--enable-calendar' '--with-curl' '--with-iconv' '--with-mysql' '--with-mysqli' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-mcrypt' '--with-gettext' '--with-xmlrpc' '--with-pdo-mysql=mysqlnd' '--enable-posix' '--enable-ftp' '--with-openssl' '--enable-mbstring' '**--enable-mailparse**' '--with-kerberos' '--with-xsl' '--with-bz2' '--enable-sockets' '--enable-zip' '--with-gd' '--with-pcre-regex' '--libdir=/usr/lib' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-imap' '--with-imap-ssl' 的情况下启动代码。

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

所以你有两个解决方案:

  • 将代码START-OF_SELECTION移至主代码下方。
  • 在主要代码前添加AT SELECTION-SCREEN

正如vwegert已经提到的,要更改选择屏幕上的设置,您需要START-OF_SELECTION