我一直在做报告,现在它在质量服务器中。问题是,它在开发时运行良好,但现在它重复了一些发票编号,而不是全部,并且一张发票重复两次,另一张重复四次。不知道是代码问题还是别的什么。这是代码:
IF kunnr[] IS INITIAL
AND belnr[] IS INITIAL
AND spart IS NOT INITIAL
AND gjahr[] IS NOT INITIAL
AND bukrs[] IS NOT INITIAL
AND allgstid IS INITIAL
AND augdt[] IS NOT INITIAL
AND budat[] IS INITIAL
AND kbetr IS INITIAL
AND vkorg IS INITIAL.
SELECT c~kunnr 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 bsad AS c ON c~belnr = a~belnr )
INNER JOIN vbrk AS d ON d~xblnr = c~belnr )
WHERE a~gjahr IN gjahr
AND a~bukrs IN bukrs
AND d~spart = spart
AND c~augdt IN augdt.
IF sy-subrc <> 0.
MESSAGE i425.
ENDIF.
ENDIF.
LOOP AT lt_data ASSIGNING <fs_main>.
CLEAR <fs_main>-kbetr.
CLEAR <fs_main>-fwste.
CLEAR <fs_main>-hwste.
IF kbetr IS INITIAL.
SELECT SINGLE kbetr fwste hwste
FROM bset
INTO (<fs_main>-kbetr, <fs_main>-fwste, <fs_main>-hwste)
WHERE belnr = <fs_main>-belnr
AND bukrs IN bukrs
AND gjahr IN gjahr
AND mwskz BETWEEN 'L0' AND 'L2'.
ELSE.
SELECT SINGLE kbetr fwste hwste
FROM bset
INTO (<fs_main>-kbetr, <fs_main>-fwste, <fs_main>-hwste)
WHERE belnr = <fs_main>-belnr
AND bukrs IN bukrs
AND gjahr IN gjahr
AND mwskz BETWEEN 'L0' AND 'L2'
AND kbetr = kbetr.
ENDIF.
AT NEW kunnr.
SELECT SINGLE name1 FROM kna1
INTO (wa_bseg-name1)
WHERE kunnr = <fs_main>-kunnr.
IF sy-subrc = 0.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ sy-uline(137), / sy-vline NO-GAP,
2 'Entidade: ', <fs_main>-kunnr, wa_bseg-name1,
137 sy-vline NO-GAP, / sy-uline(137).
ENDIF.
ENDAT.
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 CENTERED 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).