我从透明表和集群表中选择数据并将结果放入内部表中。由于无法连接集群表,因此我使用了两个select single
来从集群表中检索数据。
问题是,在循环中,每个输出行都被分配了与内部表中第一行相同的信息(D
在每一行)。可能是因为 where 条件的字段从BELNR
列中检索了 3 行具有相同值的行。
首先,这里是代码:
FORM select_data1 CHANGING lt_data LIKE gt_map1.
FIELD-SYMBOLS: <fs_main> TYPE zimposto_consumo.
SELECT a~belnr d~spart a~bldat a~waers c~wrbtr a~hwaer c~dmbtr
INTO CORRESPONDING FIELDS OF TABLE lt_data
FROM ( ( bkpf AS a
INNER JOIN bsis AS c ON c~belnr = a~belnr )
INNER JOIN vbrk AS d ON d~xblnr = c~belnr )
WHERE a~belnr IN belnr.
LOOP AT lt_data ASSIGNING <fs_main>.
SELECT SINGLE kbetr fwste hwste FROM bset
INTO (<fs_main>-kbetr, <fs_main>-fwste, <fs_main>-hwste)
WHERE belnr = <fs_main>-belnr.
SELECT SINGLE koart FROM bseg
INTO (<fs_main>-koart)
WHERE buzei = 1
AND belnr = <fs_main>-belnr.
IF <fs_main>-koart = 'D'.
FORMAT COLOR COL_NORMAL INTENSIFIED OFF.
WRITE:/
sy-vline NO-GAP,
(16) <fs_main>-belnr NO-GAP,
sy-vline NO-GAP,
(16) <fs_main>-spart NO-GAP,
sy-vline NO-GAP,
(10) <fs_main>-bldat NO-GAP,
sy-vline NO-GAP.
perc = <fs_main>-kbetr / 10.
WRITE: (10) perc NO-GAP,
sy-vline NO-GAP,
(5) <fs_main>-waers NO-GAP,
sy-vline NO-GAP,
(16) <fs_main>-wrbtr NO-GAP,
sy-vline NO-GAP,
(16) <fs_main>-fwste NO-GAP,
sy-vline NO-GAP,
(5) <fs_main>-hwaer NO-GAP,
sy-vline NO-GAP,
(16) <fs_main>-dmbtr NO-GAP,
sy-vline NO-GAP,
(16) <fs_main>-hwste NO-GAP,
sy-vline NO-GAP.
WRITE:/ sy-uline(137).
write: <fs_main>-koart.
ELSE.
write: 'Não há dados a mostrar.'.
ENDIF.
ENDLOOP.
ENDFORM. "select_data1
结果是这个:
输出表右侧的“D”不应该D
是 3 行。只有第一个应该是D
,另外两个应该是S
。
怎么了?