Código exemplo abaixo, pegando dados de remessa
sELECT likp~vbeln,
likp~ernam,
lips~matnr,
lips~lfimg
INTO TABLE @DATA(lt_likp)
WHERE likp~lfart = 'ZVME'.
"Criar estrutura que quer fazer a somatória
TYPES: BEGIN OF ty_rem,
matnr TYPE lips-matnr,
lfimg TYPE lips-lfimg,
END OF ty_rem.
TYPES: BEGIN OF ty_rem,
matnr TYPE lips-matnr,
lfimg TYPE lips-lfimg,
END OF ty_rem.
TYPES ty_t_rem TYPE TABLE OF ty_rem WITH DEFAULT KEY.
DATA w_lips TYPE ty_rem.
BREAK-POINT.
DATA(lt_lips) = VALUE ty_t_rem( FOR GROUPS w_lips_x OF <ls_collect> IN lt_likp
GROUP BY ( matnr = <ls_collect>-matnr )
LET coll_line = REDUCE #( INIT ls_sum TYPE ty_rem
FOR ls_sum_likp IN GROUP w_lips_x
NEXT ls_sum-lfimg = ls_sum-lfimg + ls_sum_likp-lfimg
ls_sum-matnr = ls_sum_likp-matnr
) IN ( coll_line ) ).
BREAK-POINT.
GROUP BY ( matnr = <ls_collect>-matnr )
LET coll_line = REDUCE #( INIT ls_sum TYPE ty_rem
FOR ls_sum_likp IN GROUP w_lips_x
NEXT ls_sum-lfimg = ls_sum-lfimg + ls_sum_likp-lfimg
ls_sum-matnr = ls_sum_likp-matnr
) IN ( coll_line ) ).
BREAK-POINT.
Nenhum comentário:
Postar um comentário