将 SELECT-ENDSELECT 转换为具有更多表的所有条目 [英] Convert SELECT-ENDSELECT in for all entries with more table

查看:22
本文介绍了将 SELECT-ENDSELECT 转换为具有更多表的所有条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想把这个 SELECT-ENDSELECT 转换成 FOR ALL ENTRIES 以获得更好的性能.

I would like to convert this SELECT-ENDSELECT into FOR ALL ENTRIES to have better performance.

LOOP AT it_zgd_check_smc into wa_zgd_check_smc.

    SELECT *
      FROM ever
      INTO wa_ever
      WHERE anlage  EQ wa_euiinstln-anlage
      AND   einzdat <= wa_zgd_check_smc_st-data_inizio
      AND   auszdat >= wa_zgd_check_smc_st-data_inizio.
    ENDSELECT.

"---logic---"

ENDLOOP.

有 2 个表:EUIINSTLNIT_ZGD_CHECK_SMC.如何将其转换为 for all entry?

There are 2 tables : EUIINSTLN and IT_ZGD_CHECK_SMC. How can I do to convert it into for all entries?

谢谢大家.问候.

推荐答案

要摆脱 SELECT - ENDSELECT 你可以简单地使用 INTO TABLE 并在之后循环它.这通常更快,而且您(几乎)每次都可以这样做.

To get rid of the SELECT - ENDSELECT you can simply use INTO TABLE and loop over it afterwards. This is usually faster and you can do it (almost) every time.

    data: lt_ever like table of wa_ever.
    LOOP AT it_zgd_check_smc into wa_zgd_check_smc.
      SELECT *
        FROM ever
        INTO TABLE lt_ever
        WHERE anlage  EQ wa_euiinstln-anlage
        AND   einzdat <= wa_zgd_check_smc_st-data_inizio
        AND   auszdat >= wa_zgd_check_smc_st-data_inizio.
     LOOP AT lt_ever INTO wa_ever.
       "Put here what was in the SELECT - ENDSELECT previously.
     ENDLOOP.
   ENDLOOP.

然后您可以使用 FOR ALL ENTRIES 来摆脱外部循环之一.如果您使用它,您可以简单地用表格替换工作区.但是您应该确保您使用的表不是空的.否则 WHERE 语句将像一个空范围一样(换句话说,它将被忽略),因此它会为您提供数据库中的所有条目.所以它会给你这样的东西:

Then you could use FOR ALL ENTRIES to get rid of one of the outer loops. If you use this, you can simply replace the workarea with the table. But you should make sure, that the table you're using is not empty. Otherwise the WHERE statement will act like an empty range (in other words, it will be ignored), so it gives you all entries from the database. So it would give you something like this:

    data: lt_ever like table of wa_ever.
    
    IF it_zgd_check_smc_st IS NOT INITIAL.
      SELECT *
        FROM ever
        INTO TABLE lt_ever
        FOR ALL ENTRIES IN it_zgd_check_smc_st
        WHERE anlage  EQ wa_euiinstln-anlage
        AND   einzdat <= it_zgd_check_smc_st-data_inizio
        AND   auszdat >= it_zgd_check_smc_st-data_inizio.
     loop at lt_ever into wa_ever.
       "Put here what was in the SELECT - ENDSELECT previously.
     endloop.
   ENDIF.

您不能为所有条目使用第二个表,但您可以为 ANLAGE - 字段 构建一个范围.只要确保您不再使用空范围即可.

You can't use a second table with for all entries, but you could build a range for the ANLAGE - field. Just make sure you don't use an emtpy range again.

DATA: lt_ever LIKE TABLE OF wa_ever.
DATA: lr_anlage TYPE RANGE OF anlage.
DATA: lrs_anlage LIKE LINE OF lr_anlage.

lrs_anlage-sign = 'I'.
lrs_anlage-option = 'EQ'.
LOOP AT euiinstln INTO wa_euiinstln.
  lrs_anlage-low = wa_euiinstln-anlage.
  APPEND lrs_anlage TO lr_anlage.
ENDLOOP.


IF it_zgd_check_smc_st IS NOT INITIAL AND
   lr_anlage IS NOT INITIAL.
  SELECT *
    FROM ever
    INTO TABLE lt_ever
    FOR ALL ENTRIES IN it_zgd_check_smc_st
    WHERE anlage  IN lr_anlage
    AND   einzdat <= it_zgd_check_smc_st-data_inizio
    AND   auszdat >= it_zgd_check_smc_st-data_inizio.
  LOOP AT lt_ever INTO wa_ever.
    "Put here what was in the SELECT - ENDSELECT previously.
  ENDLOOP.
ENDIF.

我不知道代码应该做什么,所以我不知道其中有多少对你有用.不建立范围和循环euiinstln - 表 应该一样快,因为EVER - 数据库无论如何,应该在anlage - 字段 上有一个索引.

I don't know what the code is supposed to do, so I don't know how much of this is actually usefull for you. Not builing the range and looping over the euiinstln - table should be just as fast, since the EVER - Database should have an Index on the anlage - field anyways.

这篇关于将 SELECT-ENDSELECT 转换为具有更多表的所有条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆