我的程序输出一个包含一些发票和详细信息的列表,我希望它们按实体出现。
该列表显示在列表的每一行中重复的实体编号和名称,但我希望它按分组显示。
例如,有 4 张发票:每个实体两张,如何显示实体和所有相应的发票,然后是另一个实体,等等?
我的代码是这个:
FORM select_data3 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
AND buzei = 1 )
INNER JOIN vbrk AS d ON d~xblnr = c~belnr )
WHERE a~gjahr in gjahr.
LOOP AT lt_data ASSIGNING <fs_main>.
clear <fs_main>-kbetr.
clear <fs_main>-fwste.
clear <fs_main>-hwste.
SELECT SINGLE kbetr fwste hwste FROM bset
INTO (<fs_main>-kbetr, <fs_main>-fwste, <fs_main>-hwste)
WHERE belnr = <fs_main>-belnr.
clear <fs_main>-koart.
SELECT SINGLE koart kunnr FROM bseg
INTO (<fs_main>-koart, wa_bseg-kunnr)
WHERE belnr = <fs_main>-belnr.
IF <fs_main>-koart = 'D'.
SELECT SINGLE name1 FROM kna1
INTO (wa_bseg-name1)
WHERE kunnr = wa_bseg-kunnr.
IF sy-subrc = 0.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE:/ sy-uline(137), / sy-vline NO-GAP,
2 'Entidade: ', wa_bseg-kunnr, wa_bseg-name1,
137 sy-vline NO-GAP, / sy-uline(137).
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.
...
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.