之前写的汇总案例
DATA:lv_num_char TYPE char2,
lv_num TYPE numc3,
lv_hsl TYPE faglflext-hslvt,
lv_hsl_temp TYPE faglflext-hslvt,
lv_field TYPE string.
FIELD-SYMBOLS:<fs_faglflext> TYPE faglflext,
<fs_any> TYPE any.
LOOP AT lt_faglflext_yywsr ASSIGNING <fs_faglflext>.
CLEAR:lv_hsl_temp,lv_field,lv_num,lv_num_char.
LOOP AT lr_perio.
IF lr_perio-option = 'EQ'.
lv_num_char = lr_perio-low+1(2).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_num_char
IMPORTING
output = lv_num_char.
CONCATENATE '<FS_FAGLFLEXT>-HSL' lv_num_char INTO lv_field.
UNASSIGN <fs_any>.
ASSIGN (lv_field) TO <fs_any>.
IF <fs_any> IS ASSIGNED.
lv_hsl = <fs_any>.
ENDIF.
ELSEIF lr_perio-option = 'BT'.
lv_num_char = lr_perio-low+1(2).
lv_num = lr_perio-low.
DO.
IF lv_num > lr_perio-high..
EXIT.
ENDIF.
CLEAR:lv_hsl_temp.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_num_char
IMPORTING
output = lv_num_char.
CONCATENATE '<FS_FAGLFLEXT>-HSL' lv_num_char INTO lv_field.
UNASSIGN <fs_any>.
ASSIGN (lv_field) TO <fs_any>.
IF <fs_any> IS ASSIGNED.
lv_hsl_temp = <fs_any>.
lv_hsl = lv_hsl + lv_hsl_temp.
ENDIF.
lv_num = lv_num + 1.
lv_num_char = lv_num_char + 1.
ENDDO.
ENDIF.
ENDLOOP.
lt_yywsr-bukrs = <fs_faglflext>-rbukrs.
lt_yywsr-hsl = 0 - lv_hsl."营业外收入金额行取反 20191120
COLLECT lt_yywsr.
CLEAR:lv_num_char,lv_hsl.
ENDLOOP.