gpt4 book ai didi

abap - 删除一行的最简单方法

转载 作者:行者123 更新时间:2023-12-04 04:51:12 26 4
gpt4 key购买 nike

下面的代码有没有最简单/最快的方法:

DATA:   lv_knuma_ag  LIKE STANDARD TABLE OF zta_fg_hdr WITH HEADER LINE.
RANGES: lr_knuma_ag FOR zta_fg_hdr-knuma_ag.

"Select `knuma_ag` and save it to internal table `lv_knuma_ag`
LOOP AT li_promo.
SELECT dest~knuma_ag
FROM zta_fg_dest AS dest
INNER JOIN zta_s_d_xkunnr AS xkunnr ON xkunnr~zcd_dest EQ dest~zcd_dest
APPENDING CORRESPONDING FIELDS OF TABLE lv_knuma_ag
WHERE dest~knuma_ag EQ li_promo-knuma_ag
AND xkunnr~xkunnr EQ gi_vl-vkbur.
ENDLOOP.

"Insert `lv_knuma_ag` onto ranges table `lr_knuma_ag`
LOOP AT lv_knuma_ag.
lr_knuma_ag-sign = 'I'.
lr_knuma_ag-option = 'EQ'.
lr_knuma_ag-low = lv_knuma_ag-knuma_ag.
lr_knuma_ag-high = space.
APPEND lr_knuma_ag.
ENDLOOP.

"Delete row in `li_promo` where `knuma_ag` is in ranges table `lr_knuma_ag`
IF NOT lr_knuma_ag IS INITIAL.
DELETE li_promo WHERE knuma_ag IN lr_knuma_ag.
ENDIF.

正如您在代码中看到的,它包含两次循环以仅填充范围表。我只想做一个,可以吗?谢谢。

最佳答案

是的,应该可以实现这一点,而不会用可能有数千个查询来淹没您的 DBMS:

DATA: lt_knuma_ag_hash TYPE HASHED TABLE OF insert_type_of_knuma_ag_here WITH UNIQUE KEY TABLE_table_line.

IF li_promo[] IS NOT INITIAL.
SELECT DISTINCT knuma_ag
FROM zta_fg_dest
INTO TABLE lt_knuma_ag_hash
FOR ALL ENTRIES IN li_promo
WHERE knuma_ag = li_promo-knuma_ag.
ENDIF.

LOOP AT li_promo ASSIGNING <li_promo>.
READ TABLE lt_knuma_ag_hash TRANSPORTING NO FIELDS WITH TABLE KEY table_line = <li_promo>-knuma_ag.
IF sy-subrc = 0.
DELETE li_promo.
ENDIF.
ENDLOOP.

关于abap - 删除一行的最简单方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17419278/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com