简体   繁体   English

程序中错误 DBIF_RSQL_INVALID_RSQL CX_SY_OPEN_SQL_DB

[英]Error DBIF_RSQL_INVALID_RSQL CX_SY_OPEN_SQL_DB in program

I get the following error: DBIF_RSQL_INVALID_RSQL CX_SY_OPEN_SQL_DB (Open SQL command is too big. Condition WHERE of the Open SQL command contains too many conditions).我收到以下错误:DBIF_RSQL_INVALID_RSQL CX_SY_OPEN_SQL_DB(Open SQL 命令太大。Open SQL 命令的条件 WHERE 包含太多条件)。 The error points to the following line:错误指向以下行:

select * from Z3T_MAILS into table t_full_mail UP TO 250 ROWS where ID in r_mid  and (p_dat_clause).

Other parts of code:其他部分代码:

    DATA: p_dat_clause type STRING,
    t_full_mail type Z3TT_MAILS,
    r_mid       type range of Z3E_MAIL_ID.

 <...>

  if not NOT_READED is initial.
    p_clause = 'ISREAD = '''''.
  endif.

  if DATETO is initial.
    p_dateto = DATEFROM.
  else.
    p_dateto = DATETO.
  endif.
  if not DATEFROM is initial or not DATETO is initial.
    concatenate 'SEND_DATE >= ''' DATEFROM  ''' and SEND_DATE <= ''' p_dateto '''' into p_dat_clause.
  endif.

    <...>

      if MAILS is supplied  or  BODY is supplied  or  p_dat_clause ne ''.
        if not r_mid[] is initial.
          select * from Z3T_MAILS into table t_full_mail UP TO 250 ROWS where ID in r_mid  and (p_dat_clause).
        endif.
      endif.

I am new to ABAP and would appreciate any help!我是 ABAP 的新手,希望得到任何帮助!

That error happens when you use a range/select-option that has too many entries for the database to handle.当您使用具有太多条目供数据库处理的范围/选择选项时,会发生该错误。 The solution to this is always dependent on the use, but in any case you have to limit the number of entries in the range.对此的解决方案始终取决于使用情况,但在任何情况下,您都必须限制范围内的条目数。

In your case you only want up to 250 rows from the database anyway.在您的情况下,您只需要数据库中最多 250 行。 So, if R_MID is filled with all rows containing a single ID you can check the number of lines in it (LINES( R_MID ) ) and limit it to 250 if there are more than that.因此,如果 R_MID 填充了包含单个 ID 的所有行,您可以检查其中的行数 (LINES( R_MID) ),如果行数多于 250,则将其限制为 250。 In most systems this would get rid of the error.在大多数系统中,这将消除错误。

I'm just guessing here but your range r_mid probably has hundreds of lines that look like this:我只是在这里猜测,但您的范围r_mid可能有数百行,如下所示:

r_mid-sign   = 'I'.
r_mid-option = 'EQ'.
r_mid-low    = '123123123'.
r_mid-high   = ''.

So instead you could store those IDs in an internal table.因此,您可以将这些 ID 存储在内部表中。 You even might be able to use the internal table you're looping over to fill r_mid in the first place.您甚至可以首先使用您循环的内部表来填充r_mid

Your date variables on the other hand are actually well suited to be declared as a single range:另一方面,您的日期变量实际上非常适合声明为单个范围:

 r_date-sign   = 'I'.
 r_date-option = 'BT'. 
 r_date-low    = datefrom.
 r_date-high   = dateto.

Also note the documentation about ranges.另请注意有关范围的文档

Finally you can write your query as follows:最后,您可以按如下方式编写查询:

SELECT *
   FROM z3t_mails
   INTO TABLE t_full_mail
   FOR ALL ENTRIES IN lt_mid
   WHERE id EQ lt_mid-id
   AND send_date IN r_date.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM