1.字符串反转 and 寻找字符所在位置
LOOP AT gt_wlmc ASSIGNING FIELD-SYMBOL(<fs_wlmc>). "遍历内表
<fs_wlmc>-matnr = <fs_wlmc>-matnr+(8).
DATA: l_output TYPE char50,
v_off2 TYPE i,
str TYPE i,
str2 TYPE i.
CALL FUNCTION 'STRING_REVERSE' "反转字符窜
EXPORTING
string = <fs_wlmc>-zcailiao
lang = ''
IMPORTING
rstring = l_output
EXCEPTIONS
too_small = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
str = strlen( l_output ).
FIND '_' IN l_output MATCH OFFSET v_off2. "反转后找最后一个字符串出现的位置
str2 = str - v_off2 - 1.
IF sy-subrc = 0 AND str2 <> 0 .
<fs_wlmc>-zcailiao = <fs_wlmc>-zcailiao+(str2).
ELSE.
<fs_wlmc>-zcailiao = '' .
ENDIF.
ENDLOOP.
SORT gt_wlmc BY matnr.
READ TABLE gt_zdz INTO DATA(gs_tou) WITH KEY zdzdh = gs_dzd-zdzdh .
READ TABLE gt_zfp INTO DATA(gs_zfp) WITH KEY zdzdh = gs_dzd-zdzdh .
DATA lv_string TYPE string.
LOOP AT gt_zdz ASSIGNING FIELD-SYMBOL(<fs_row>). "遍历内表
DATA :lv_number TYPE i,
v_off TYPE i.
READ TABLE zsuima INTO DATA(gs_zsuima) WITH KEY mwskz = <fs_row>-zmwskz.
IF sy-subrc = 0 .
FIND '%' IN gs_zsuima-text1 MATCH OFFSET v_off. "第一个%出现的位置
IF sy-subrc = 0.
lv_number = gs_zsuima-text1+(v_off).
ENDIF.
ENDIF.
<fs_row>-znetpr = <fs_row>-znetpr * ( 1 + ( lv_number / 100 ) ).
IF <fs_row>-zmatnr <> ''.
* lv_string = strlen( <fs_row>-zmatnr ) - 3 .
<fs_row>-zmatnr = <fs_row>-zmatnr+(8).
ENDIF.
ENDLOOP.
2.根据数量汇总时把数量转为非数值类型
TYPES:
BEGIN OF tt_zdz,
zdzdh TYPE ztmm019a-zdzdh,
zbckh TYPE ztmm019a-zbckh,
zmatnr TYPE ztmm019a-zmatnr,
znetpr TYPE ztmm019a-zdzdh,
zmenge TYPE ztmm019a-zmenge,
zhsje TYPE ztmm019a-zhsje,
END OF tt_zdz.
DATA:gtt_zdz TYPE STANDARD TABLE OF tt_zdz,
gss_zdz TYPE tt_zdz.
LOOP AT gt_zdz INTO DATA(gs_zdz). "单价数量类型转字符类型汇总
MOVE-CORRESPONDING gs_zdz TO gss_zdz.
COLLECT gss_zdz INTO gtt_zdz.
CLEAR gs_zdz.
CLEAR gss_zdz.
ENDLOOP.
SORT gtt_zdz BY zbckh.
znetpr2 TYPE ztmm019a-znetpr. "定义一个数字类型,把字符串类型转为数值类型
znetpr2 = gss_zdz-znetpr.