&---------------------------------------------------------------------
*& Report ZCORP008
&---------------------------------------------------------------------
*&
&---------------------------------------------------------------------
REPORT zcorp008.
TABLES:afpo,mara,makt,coep,cosb,jest,aufk,keko,ckis.
TYPE-POOLS: slis,truxs.
DATA : i1 TYPE i,
i2 TYPE i,
i3 TYPE i,
i4 TYPE i,
i5 TYPE i,
i6 TYPE i,
month_t TYPE bkpf-monat,
line TYPE bsvx-sttxt.
DATA: gt_field TYPE slis_t_fieldcat_alv WITH HEADER LINE , "ALV字段
gs_layout TYPE slis_layout_alv, "ALV 样式
gt_sort TYPE slis_t_sortinfo_alv. "ALV-sort
DATA: progname LIKE sy-repid, "定义alv名字,参照系统变量
title(70).
DATA:g_msg TYPE char64,
l_menge1 TYPE menge_d,
l_menge2 TYPE menge_d,
l_date1 TYPE syst-datum,
l_date2 TYPE syst-datum.
DATA: gs_events TYPE slis_alv_event,
gt_events TYPE slis_t_event.
DATA:BEGIN OF ltd_werks OCCURS 0,"P_MATNR参数用的
werks TYPE werks_d,
END OF ltd_werks.
DATA:BEGIN OF ltd_aufnr OCCURS 0,"P_MATNR参数用的
werks TYPE werks_d,
aufnr TYPE aufnr,
aedat TYPE aedat,
erdat TYPE erdat,
matnr TYPE matnr,
maktx TYPE makt-maktx,
psmng TYPE afpo-psmng,
wemng TYPE afpo-wemng,
objnr TYPE caufv-objnr,
kokrs LIKE aufk-kokrs,
sttxt TYPE co_sttxt,
spart LIKE mara-spart,
vtext LIKE tspat-vtext,
wkgbtr00 TYPE coep-wkgbtr, " 材料-实际
wkgbtr01 TYPE coep-wkgbtr, " 人工-实际 110101
wkgbtr02 TYPE coep-wkgbtr, " 机器-实际 110102
wkgbtr03 TYPE coep-wkgbtr, " 制造费用-实际 110103
wkgbtr04 TYPE coep-wkgbtr, " 外协加工费-实际
wkgbtr05 TYPE coep-wkgbtr, " 差异-实际
-
wkgbtr06 TYPE coep-wkgbtr, " 其它制费-实际
-
wkgbtr07 TYPE coep-wkgbtr, " 外协加工费-实际 wkgbtr08 TYPE coep-wkgbtr, " 实际成本合计 wkgbtr20 TYPE coep-wkgbtr, " 材料-差异 wkgbtr21 TYPE coep-wkgbtr, " 人工-差异 wkgbtr22 TYPE coep-wkgbtr, " 机器-差异 wkgbtr23 TYPE coep-wkgbtr, " 制造费用-差异 wkgbtr24 TYPE coep-wkgbtr, " 外协加工费-差异 wkgbtr25 TYPE coep-wkgbtr, " 差异-差异
-
wkgbtr26 TYPE coep-wkgbtr, " 其它制费-差异
-
wkgbtr27 TYPE coep-wkgbtr, " 外协加工费-差异 wkgbtr28 TYPE coep-wkgbtr, " 差异合计 wkgbtr30 TYPE coep-wkgbtr, " 材料-标准 wkgbtr31 TYPE coep-wkgbtr, " 人工-标准 wkgbtr32 TYPE coep-wkgbtr, " 机器-标准 wkgbtr33 TYPE coep-wkgbtr, " 制造费用-标准 wkgbtr34 TYPE coep-wkgbtr, " 外协加工费-标准 wkgbtr35 TYPE coep-wkgbtr, " 差异-标准
-
wkgbtr36 TYPE coep-wkgbtr, " 其它制费-标准
-
END OF ltd_aufnr.wkgbtr37 TYPE coep-wkgbtr, " 外协加工费-标准 wkgbtr38 TYPE coep-wkgbtr, " 合计 cyl TYPE p DECIMALS 5, " 差异率
DATA:BEGIN OF ltd_aufnr02 OCCURS 0,"P_MATNR参数用的
werks TYPE werks_d,
aufnr TYPE aufnr,
aedat TYPE aedat,
erdat TYPE erdat,
matnr TYPE matnr,
maktx TYPE makt-maktx,
psmng TYPE afpo-psmng,
wemng TYPE afpo-wemng,
objnr TYPE caufv-objnr,
kokrs LIKE aufk-kokrs,
sttxt TYPE co_sttxt,
spart LIKE mara-spart,
vtext LIKE tspat-vtext,
kstar TYPE coep-kstar, "成本要素
ktext TYPE csku-ktext, "成本要素描述
hrkft TYPE coep-hrkft, "次级成本要素
wkgbtr00 TYPE coep-wkgbtr, " 实际
wkgbtr20 TYPE coep-wkgbtr, " 差异
wkgbtr30 TYPE coep-wkgbtr, " 标准
wkgbtr40 TYPE coep-wkgbtr, " 计划
megbtr TYPE coep-megbtr, "数量 实际
megbtr2 TYPE coep-megbtr, "数量 标准
megbtr3 TYPE coep-megbtr, "数量 计划
matnr2 TYPE matnr,
maktx2 TYPE makt-maktx,
cyl TYPE p DECIMALS 5, " 差异率
END OF ltd_aufnr02.
DATA:gt_aufnr02 LIKE TABLE OF ltd_aufnr02 WITH HEADER LINE.
DATA:l_wkg001 TYPE cosb-wkg001,
l_wkg002 TYPE cosb-wkg001,
l_wkg003 TYPE cosb-wkg001,
l_wkg004 TYPE cosb-wkg001,
l_wkg005 TYPE cosb-wkg001,
l_wkg006 TYPE cosb-wkg001,
l_wkg007 TYPE cosb-wkg001,
l_wkg008 TYPE cosb-wkg001,
l_wkg009 TYPE cosb-wkg001,
l_wkg010 TYPE cosb-wkg001,
l_wkg011 TYPE cosb-wkg001,
l_wkg012 TYPE cosb-wkg001,
l_wkg013 TYPE cosb-wkg001,
l_wkg014 TYPE cosb-wkg001,
l_wkg015 TYPE cosb-wkg001,
l_wkg016 TYPE cosb-wkg001.
DATA:ltd_aufnr2 LIKE ltd_aufnr OCCURS 0 WITH HEADER LINE.
DATA: lt_stpox TYPE TABLE OF stpox .
DATA: lw_stpox TYPE stpox .
DATA: lw_topmat TYPE cstmat .
DATA: g_vprsv TYPE vprsv,
g_verpr TYPE verpr,
g_stprs TYPE stprs,
g_peinh TYPE peinh,
g_wkgbtr13 TYPE p DECIMALS 2,
g_wkgbtr13a TYPE p DECIMALS 2,
g_kalnr TYPE keko-kalnr,
g_losgr TYPE keko-losgr,
g_kadky TYPE keko-kadky.
DATA:BEGIN OF gt_itab1 OCCURS 0,
bukrs TYPE anla-bukrs,
END OF gt_itab1.
DATA:BEGIN OF gt_coep OCCURS 0,
objnr TYPE coep-objnr,
kokrs TYPE coep-kokrs,
gjahr TYPE coep-gjahr,
perio TYPE coep-perio,
kstar TYPE coep-kstar,
hrkft TYPE coep-hrkft,
wrttp TYPE coep-wrttp,
wkgbtr TYPE coep-wkgbtr,
megbtr TYPE coep-megbtr,
megbtr2 TYPE coep-megbtr,
megbtr3 TYPE coep-megbtr,
matnr TYPE coep-matnr,
END OF gt_coep.
DATA:BEGIN OF gt_cosp OCCURS 0,
objnr TYPE coep-objnr,
kokrs TYPE coep-kokrs,
gjahr TYPE coep-gjahr,
perio TYPE coep-perio,
kstar TYPE coep-kstar,
hrkft TYPE coep-hrkft,
wrttp TYPE coep-wrttp,
matnr TYPE cokey-matnr,
wtg001 TYPE cosp-wtg001,
wtg002 TYPE cosp-wtg001,
wtg003 TYPE cosp-wtg001,
wtg004 TYPE cosp-wtg001,
wtg005 TYPE cosp-wtg001,
wtg006 TYPE cosp-wtg001,
wtg007 TYPE cosp-wtg001,
wtg008 TYPE cosp-wtg001,
wtg009 TYPE cosp-wtg001,
wtg010 TYPE cosp-wtg001,
wtg011 TYPE cosp-wtg001,
wtg012 TYPE cosp-wtg001,
wtg013 TYPE cosp-wtg001,
wtg014 TYPE cosp-wtg001,
wtg015 TYPE cosp-wtg001,
wtg016 TYPE cosp-wtg001,
meg001 TYPE cosp-meg001,
meg002 TYPE cosp-meg001,
meg003 TYPE cosp-meg001,
meg004 TYPE cosp-meg001,
meg005 TYPE cosp-meg001,
meg006 TYPE cosp-meg001,
meg007 TYPE cosp-meg001,
meg008 TYPE cosp-meg001,
meg009 TYPE cosp-meg001,
meg010 TYPE cosp-meg001,
meg011 TYPE cosp-meg001,
meg012 TYPE cosp-meg001,
meg013 TYPE cosp-meg001,
meg014 TYPE cosp-meg001,
meg015 TYPE cosp-meg001,
meg016 TYPE cosp-meg001,
END OF gt_cosp.
CONSTANTS: c_kstar01 TYPE ckis-kstar VALUE ‘0000110101’, " 人工
c_kstar02 TYPE ckis-kstar VALUE ‘0000110102’, " 机器
c_kstar03 TYPE ckis-kstar VALUE ‘0000110103’, " 制造费用
c_kstar04 TYPE ckis-kstar VALUE ‘5001040000’, " 生产成本-工序委外
c_kstar05 TYPE ckis-kstar VALUE ‘5001050000’, " 差异
c_kstar06 TYPE ckis-kstar VALUE ‘9430106000’, " 其它制费
c_kstar07 TYPE ckis-kstar VALUE ‘5000040000’. " 外协加工费
DEFINE alv_key.
gt_field-fieldname = ‘&1’.
gt_field-seltext_m = ‘&2’.
gt_field-outputlen = &3.
gt_field-key = ‘X’.
gt_field-no_zero = ‘X’.
APPEND gt_field.
CLEAR gt_field.
END-OF-DEFINITION.
DEFINE alv_edit.
gt_field-fieldname = ‘&1’.
gt_field-seltext_m = ‘&2’.
gt_field-outputlen = &3.
gt_field-input = &4.
gt_field-edit = &5.
gt_field-no_zero = ‘X’.
APPEND gt_field.
CLEAR gt_field.
END-OF-DEFINITION.
DATA: BEGIN OF r_month OCCURS 0,
ryear TYPE faglflext-ryear,
month TYPE bkpf-monat,
qj TYPE coep-perio,
END OF r_month.
DATA: BEGIN OF r_ryear OCCURS 0,
ryear TYPE faglflext-ryear,
END OF r_ryear.
DATA: wkgbtr TYPE coep-wkgbtr.
SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE TEXT-001.
PARAMETERS: p_bukrs TYPE t001-bukrs OBLIGATORY DEFAULT ‘1100’.
SELECT-OPTIONS: s_werks FOR aufk-werks OBLIGATORY DEFAULT ‘1101’,
s_aufnr FOR aufk-aufnr,
s_erdat FOR aufk-erdat,
s_matnr FOR afpo-matnr,
-
s_spart FOR mara-spart, s_gjahr FOR coep-gjahr DEFAULT '2022' OBLIGATORY NO-EXTENSION.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(31) TEXT-002.
PARAMETERS: s_month1 LIKE bkpf-monat OBLIGATORY DEFAULT ‘01’.
SELECTION-SCREEN COMMENT 52(5) TEXT-003.
PARAMETERS: s_month2 LIKE bkpf-monat OBLIGATORY DEFAULT ‘12’.
SELECTION-SCREEN END OF LINE.PARAMETERS: p_chk1 AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK 001.
SELECTION-SCREEN BEGIN OF BLOCK 002 WITH FRAME TITLE TEXT-004.
PARAMETERS:r1 TYPE xfeld RADIOBUTTON GROUP g1,
r2 TYPE xfeld RADIOBUTTON GROUP g1 DEFAULT ‘X’.
SELECTION-SCREEN END OF BLOCK 002.
INITIALIZATION.
AT SELECTION-SCREEN.
IF s_gjahr-low = s_gjahr-high OR s_gjahr-high IS INITIAL.
IF s_month2 < s_month1.
MESSAGE e001(00) WITH ‘同一年到的月数不能小于开始的月!’.
ENDIF.
ENDIF.
START-OF-SELECTION.
AUTHORITY-CHECK OBJECT ‘M_RECH_BUK’
ID ‘BUKRS’ FIELD p_bukrs.
IF sy-subrc <> 0.
CLEAR g_msg.
CONCATENATE ‘You have no authority for this company:’ p_bukrs INTO g_msg.
MESSAGE e888(sabapdocu) WITH g_msg.
ENDIF.
CLEAR: l_date1,l_date2.
l_date1 = s_gjahr-low && s_month1 && ‘01’.
IF s_gjahr-high IS INITIAL.
l_date2 = s_gjahr-low && s_month2 && ‘01’.
ELSE.
l_date2 = s_gjahr-high && s_month2 && ‘01’.
ENDIF.
CALL FUNCTION ‘LAST_DAY_OF_MONTHS’
EXPORTING
day_in = l_date2
IMPORTING
last_day_of_month = l_date2
EXCEPTIONS
day_in_no_date = 1
OTHERS = 2.
CLEAR: ltd_werks,ltd_werks[].
SELECT a~werks
FROM t001w AS a
INTO CORRESPONDING FIELDS OF TABLE ltd_werks
WHERE werks IN s_werks.
LOOP AT ltd_werks.
AUTHORITY-CHECK OBJECT ‘M_BEST_WRK’
ID ‘WERKS’ FIELD ltd_werks-werks.
IF sy-subrc <> 0.
MESSAGE s001(00) WITH ‘所选择的工厂:’ ltd_werks-werks ‘,没权限查询’ DISPLAY LIKE ‘E’.
RETURN.
ENDIF.
ENDLOOP.
PERFORM get_qijian_data.
IF r1 = ‘X’.
PERFORM get_data.
ELSEIF r2 = ‘X’.
PERFORM get_data2.
ENDIF.
END-OF-SELECTION.
IF r1 = ‘X’.
PERFORM display_alv.
ELSEIF r2 = ‘X’.
PERFORM display_alv2.
ENDIF.
FORM get_data.
RANGES: lr_bwart FOR aufm-bwart.
APPEND ‘IEQ101’ TO lr_bwart.
APPEND ‘IEQ102’ TO lr_bwart.
APPEND ‘IEQ122’ TO lr_bwart.
CLEAR ltd_aufnr.
REFRESH ltd_aufnr.
SELECT aufk~aufnr
aufk~erdat
aufk~aedat
aufk~werks
aufk~kokrs
aufk~objnr
afpo~matnr
afpo~psmng
afpo~wemng
-
mara~spart
FROM aufk JOIN afpo
ON aufk~aufnr = afpo~aufnr -
JOIN mara
-
ON afpo~matnr = mara~matnr
INTO CORRESPONDING FIELDS OF TABLE ltd_aufnr
WHERE aufk~bukrs = p_bukrs
AND aufk~werks IN s_werks
AND aufk~aufnr IN s_aufnr
AND aufk~erdat IN s_erdat
AND aufk~loekz = space
AND afpo~matnr IN s_matnr. -
AND mara~spart IN s_spart.
LOOP AT ltd_aufnr.
CLEAR line.
CALL FUNCTION ‘STATUS_TEXT_EDIT’
EXPORTING
objnr = ltd_aufnr-objnr
only_active = ‘X’
spras = sy-langu
IMPORTING
line = line
EXCEPTIONS
object_not_found = 01.
IF sy-subrc NE 0.
CLEAR line.
ELSE.
ltd_aufnr-sttxt = line.
ENDIF.
SELECT SINGLE maktx INTO ltd_aufnr-maktx FROM makt WHERE matnr = ltd_aufnr-matnr AND spras = ‘1’.
IF ltd_aufnr-spart IS NOT INITIAL.
SELECT SINGLE vtext INTO ltd_aufnr-vtext FROM tspat WHERE spras = ‘1’ AND spart = ltd_aufnr-spart.
ENDIF.
CLEAR:l_menge1,l_menge2.
SELECT SUM( menge ) INTO l_menge1 FROM aufm WHERE aufnr = ltd_aufnr-aufnr AND bwart IN lr_bwart AND shkzg = ‘S’ AND mjahr IN s_gjahr AND budat BETWEEN l_date1 AND l_date2.
SELECT SUM( menge ) INTO l_menge2 FROM aufm WHERE aufnr = ltd_aufnr-aufnr AND bwart IN lr_bwart AND shkzg = ‘H’ AND mjahr IN s_gjahr AND budat BETWEEN l_date1 AND l_date2.
ltd_aufnr-wemng = l_menge1 - l_menge2.
MODIFY ltd_aufnr.
CLEAR ltd_aufnr.
ENDLOOP.DATA: lw_sttxt TYPE bsvx-sttxt,
lt_sttxt LIKE TABLE OF lw_sttxt.IF p_chk1 = ‘X’.
LOOP AT ltd_aufnr.
SPLIT ltd_aufnr-sttxt AT ‘’ INTO TABLE lt_sttxt.
READ TABLE lt_sttxt INTO lw_sttxt WITH KEY table_line = ‘CRTD’. " 创建状态
IF sy-subrc NE 0.
READ TABLE lt_sttxt INTO lw_sttxt WITH KEY table_line = ‘REL’. " 下达状态
IF sy-subrc NE 0.
DELETE ltd_aufnr.
ENDIF.
ENDIF.
CLEAR:ltd_aufnr.
ENDLOOP.
ENDIF.IF ltd_aufnr[] IS INITIAL.
MESSAGE ‘没有符合条件的数据!’ TYPE ‘S’ DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.LOOP AT ltd_aufnr.
LOOP AT r_month.
***1)实际
CLEAR wkgbtr.
SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar BETWEEN ‘5001010100’ AND ‘5001031800’
AND gjahr = r_month-ryear AND perio = r_month-qj
AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = ‘04’.
ltd_aufnr-wkgbtr00 = ltd_aufnr-wkgbtr00 + wkgbtr. " 材料-实际CLEAR wkgbtr. SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar IN ( '0000110101','5001999997' ) "c_kstar01 "'110101' & 5001999997, " 人工 &生产成本-期初在制工单-人工费用 AND gjahr = r_month-ryear AND perio = r_month-qj AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '04'. ltd_aufnr-wkgbtr01 = ltd_aufnr-wkgbtr01 + wkgbtr. " 人工-实际 CLEAR wkgbtr. SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar = c_kstar02 "'110102', " 机器 AND gjahr = r_month-ryear AND perio = r_month-qj AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '04'. ltd_aufnr-wkgbtr02 = ltd_aufnr-wkgbtr02 + wkgbtr. " 机器-实际 CLEAR wkgbtr. SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar IN ( '0000110103','5001999998' ) " = c_kstar03 " '110103'&5001999998, " 制造费用&生产成本-期初在制工单-制造费用 AND gjahr = r_month-ryear AND perio = r_month-qj AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '04'. ltd_aufnr-wkgbtr03 = ltd_aufnr-wkgbtr03 + wkgbtr. " 制造费用-实际 CLEAR wkgbtr. SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar = c_kstar04 "'5001040000', " 外协加工费 AND gjahr = r_month-ryear AND perio = r_month-qj AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '04'. ltd_aufnr-wkgbtr04 = ltd_aufnr-wkgbtr04 + wkgbtr. " 外协加工费-实际 CLEAR wkgbtr. SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar = c_kstar05 "'5001050000', " 差异 AND gjahr = r_month-ryear AND perio = r_month-qj AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '04'. ltd_aufnr-wkgbtr05 = ltd_aufnr-wkgbtr05 + wkgbtr. " 差异-实际
***2)标准
CLEAR wkgbtr.
SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar BETWEEN ‘5001010100’ AND ‘5001031800’
AND gjahr = r_month-ryear AND perio = r_month-qj
AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = ‘05’.
ltd_aufnr-wkgbtr30 = ltd_aufnr-wkgbtr30 + wkgbtr. " 材料-标准
CLEAR wkgbtr.
SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar IN ( '0000110101','5001999997' ) "c_kstar01 "'110101' & 5001999997, " 人工 &生产成本-期初在制工单-人工费用
AND gjahr = r_month-ryear AND perio = r_month-qj
AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '05'.
ltd_aufnr-wkgbtr31 = ltd_aufnr-wkgbtr31 + wkgbtr. " 人工-标准
CLEAR wkgbtr.
SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar = c_kstar02 "'110102', " 机器
AND gjahr = r_month-ryear AND perio = r_month-qj
AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '05'.
ltd_aufnr-wkgbtr32 = ltd_aufnr-wkgbtr32 + wkgbtr. " 机器-标准
CLEAR wkgbtr.
SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar IN ( '0000110103','5001999998' ) " = c_kstar03 " '110103'&5001999998, " 制造费用&生产成本-期初在制工单-制造费用
AND gjahr = r_month-ryear AND perio = r_month-qj
AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '05'.
ltd_aufnr-wkgbtr33 = ltd_aufnr-wkgbtr33 + wkgbtr. " 制造费用-标准
CLEAR wkgbtr.
SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar = c_kstar04 "'5001040000', " 外协加工费
AND gjahr = r_month-ryear AND perio = r_month-qj
AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '05'.
ltd_aufnr-wkgbtr34 = ltd_aufnr-wkgbtr34 + wkgbtr. " 外协加工费-标准
CLEAR wkgbtr.
SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar = c_kstar05 "'5001050000', " 差异
AND gjahr = r_month-ryear AND perio = r_month-qj
AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '05'.
ltd_aufnr-wkgbtr35 = ltd_aufnr-wkgbtr35 + wkgbtr. " 差异-标准
-
CLEAR wkgbtr.
-
SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar = c_kstar06 " '9430106000', " 其它制费
-
AND gjahr = r_month-ryear AND perio = r_month-month
-
AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '04'.
-
ltd_aufnr-wkgbtr06 = ltd_aufnr-wkgbtr06 + wkgbtr. " 其它制费-实际
-
CLEAR wkgbtr.
-
SELECT SUM( wkgbtr ) INTO wkgbtr FROM coep WHERE kstar = c_kstar07 "'5000040000'. " 外协加工费
-
AND gjahr = r_month-ryear AND perio = r_month-month
-
AND objnr = ltd_aufnr-objnr AND kokrs = ltd_aufnr-kokrs AND wrttp = '04'.
-
ltd_aufnr-wkgbtr07 = ltd_aufnr-wkgbtr07 + wkgbtr. " 外协加工费-实际
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
SELECT SUM( wkg001 ) SUM( wkg002 ) SUM( wkg003 ) SUM( wkg004 ) SUM( wkg005 ) SUM( wkg006 ) SUM( wkg007 ) SUM( wkg008 )
-
SUM( wkg009 ) SUM( wkg010 ) SUM( wkg011 ) SUM( wkg012 ) SUM( wkg013 ) SUM( wkg014 ) SUM( wkg015 ) SUM( wkg016 )
-
INTO (l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,
-
l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016)
-
FROM cosb
-
WHERE kstar BETWEEN '5001010100' AND '5001031800' AND wrttp = '31'
-
AND gjahr = r_month-ryear
-
AND objnr = ltd_aufnr-objnr.
-
IF r_month-month = '01'.
-
CLEAR: l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '02'.
-
CLEAR: l_wkg001,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '03'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '04'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '05'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '06'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '07'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '08'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '09'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '10'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '11'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg002,l_wkg010,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '12'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011.
-
ENDIF.
-
ltd_aufnr-wkgbtr20 = ltd_aufnr-wkgbtr20 + l_wkg001 + l_wkg002 + l_wkg003 + l_wkg004 + l_wkg005 + l_wkg006 + l_wkg007 + l_wkg008
-
+ l_wkg009 + l_wkg010 + l_wkg011 + l_wkg012 + l_wkg013 + l_wkg014 + l_wkg015 + l_wkg016. " 材料-差异
-
CLEAR:l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
SELECT SUM( wkg001 ) SUM( wkg002 ) SUM( wkg003 ) SUM( wkg004 ) SUM( wkg005 ) SUM( wkg006 ) SUM( wkg007 ) SUM( wkg008 )
-
SUM( wkg009 ) SUM( wkg010 ) SUM( wkg011 ) SUM( wkg012 ) SUM( wkg013 ) SUM( wkg014 ) SUM( wkg015 ) SUM( wkg016 )
-
INTO (l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,
-
l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016)
-
FROM cosb
-
WHERE kstar IN ( '110101','5001999997' ) AND wrttp = '31'
-
AND gjahr = r_month-ryear
-
AND objnr = ltd_aufnr-objnr.
-
IF r_month-month = '01'.
-
CLEAR: l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '02'.
-
CLEAR: l_wkg001,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '03'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '04'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '05'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '06'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '07'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '08'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '09'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '10'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '11'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg002,l_wkg010,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '12'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011.
-
ENDIF.
-
ltd_aufnr-wkgbtr21 = ltd_aufnr-wkgbtr21 + l_wkg001 + l_wkg002 + l_wkg003 + l_wkg004 + l_wkg005 + l_wkg006 + l_wkg007 + l_wkg008
-
+ l_wkg009 + l_wkg010 + l_wkg011 + l_wkg012 + l_wkg013 + l_wkg014 + l_wkg015 + l_wkg016. " 人工-差异
-
CLEAR:l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
SELECT SUM( wkg001 ) SUM( wkg002 ) SUM( wkg003 ) SUM( wkg004 ) SUM( wkg005 ) SUM( wkg006 ) SUM( wkg007 ) SUM( wkg008 )
-
SUM( wkg009 ) SUM( wkg010 ) SUM( wkg011 ) SUM( wkg012 ) SUM( wkg013 ) SUM( wkg014 ) SUM( wkg015 ) SUM( wkg016 )
-
INTO (l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,
-
l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016)
-
FROM cosb
-
WHERE kstar = c_kstar02 AND wrttp = '31'
-
AND gjahr = r_month-ryear
-
AND objnr = ltd_aufnr-objnr.
-
IF r_month-month = '01'.
-
CLEAR: l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '02'.
-
CLEAR: l_wkg001,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '03'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '04'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '05'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '06'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '07'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '08'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '09'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '10'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '11'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg002,l_wkg010,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '12'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011.
-
ENDIF.
-
ltd_aufnr-wkgbtr22 = ltd_aufnr-wkgbtr22 + l_wkg001 + l_wkg002 + l_wkg003 + l_wkg004 + l_wkg005 + l_wkg006 + l_wkg007 + l_wkg008
-
+ l_wkg009 + l_wkg010 + l_wkg011 + l_wkg012 + l_wkg013 + l_wkg014 + l_wkg015 + l_wkg016. " 机器-差异
-
CLEAR:l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
SELECT SUM( wkg001 ) SUM( wkg002 ) SUM( wkg003 ) SUM( wkg004 ) SUM( wkg005 ) SUM( wkg006 ) SUM( wkg007 ) SUM( wkg008 )
-
SUM( wkg009 ) SUM( wkg010 ) SUM( wkg011 ) SUM( wkg012 ) SUM( wkg013 ) SUM( wkg014 ) SUM( wkg015 ) SUM( wkg016 )
-
INTO (l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,
-
l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016)
-
FROM cosb
-
WHERE kstar IN ( '110103','5001999998' ) AND wrttp = '31'
-
AND gjahr = r_month-ryear
-
AND objnr = ltd_aufnr-objnr.
-
IF r_month-month = '01'.
-
CLEAR: l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '02'.
-
CLEAR: l_wkg001,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '03'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '04'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '05'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '06'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '07'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '08'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '09'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '10'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '11'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg002,l_wkg010,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '12'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011.
-
ENDIF.
-
ltd_aufnr-wkgbtr23 = ltd_aufnr-wkgbtr23 + l_wkg001 + l_wkg002 + l_wkg003 + l_wkg004 + l_wkg005 + l_wkg006 + l_wkg007 + l_wkg008
-
+ l_wkg009 + l_wkg010 + l_wkg011 + l_wkg012 + l_wkg013 + l_wkg014 + l_wkg015 + l_wkg016. " 制造费用-差异
-
CLEAR:l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
SELECT SUM( wkg001 ) SUM( wkg002 ) SUM( wkg003 ) SUM( wkg004 ) SUM( wkg005 ) SUM( wkg006 ) SUM( wkg007 ) SUM( wkg008 )
-
SUM( wkg009 ) SUM( wkg010 ) SUM( wkg011 ) SUM( wkg012 ) SUM( wkg013 ) SUM( wkg014 ) SUM( wkg015 ) SUM( wkg016 )
-
INTO (l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,
-
l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016)
-
FROM cosb
-
WHERE kstar = c_kstar04 AND wrttp = '31'
-
AND gjahr = r_month-ryear
-
AND objnr = ltd_aufnr-objnr.
-
IF r_month-month = '01'.
-
CLEAR: l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '02'.
-
CLEAR: l_wkg001,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '03'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '04'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '05'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '06'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '07'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '08'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '09'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '10'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '11'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg002,l_wkg010,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '12'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011.
-
ENDIF.
-
ltd_aufnr-wkgbtr24 = ltd_aufnr-wkgbtr24 + l_wkg001 + l_wkg002 + l_wkg003 + l_wkg004 + l_wkg005 + l_wkg006 + l_wkg007 + l_wkg008
-
+ l_wkg009 + l_wkg010 + l_wkg011 + l_wkg012 + l_wkg013 + l_wkg014 + l_wkg015 + l_wkg016. " 外协加工费-差异
-
CLEAR:l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
SELECT SUM( wkg001 ) SUM( wkg002 ) SUM( wkg003 ) SUM( wkg004 ) SUM( wkg005 ) SUM( wkg006 ) SUM( wkg007 ) SUM( wkg008 )
-
SUM( wkg009 ) SUM( wkg010 ) SUM( wkg011 ) SUM( wkg012 ) SUM( wkg013 ) SUM( wkg014 ) SUM( wkg015 ) SUM( wkg016 )
-
INTO (l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,
-
l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016)
-
FROM cosb
-
WHERE kstar = c_kstar05 AND wrttp = '31'
-
AND gjahr = r_month-ryear
-
AND objnr = ltd_aufnr-objnr.
-
IF r_month-month = '01'.
-
CLEAR: l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '02'.
-
CLEAR: l_wkg001,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '03'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '04'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '05'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '06'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '07'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '08'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '09'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '10'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '11'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg002,l_wkg010,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '12'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011.
-
ENDIF.
-
ltd_aufnr-wkgbtr25 = ltd_aufnr-wkgbtr25 + l_wkg001 + l_wkg002 + l_wkg003 + l_wkg004 + l_wkg005 + l_wkg006 + l_wkg007 + l_wkg008
-
+ l_wkg009 + l_wkg010 + l_wkg011 + l_wkg012 + l_wkg013 + l_wkg014 + l_wkg015 + l_wkg016. " 物料消耗-差异
-
CLEAR:l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
SELECT SUM( wkg001 ) SUM( wkg002 ) SUM( wkg003 ) SUM( wkg004 ) SUM( wkg005 ) SUM( wkg006 ) SUM( wkg007 ) SUM( wkg008 )
-
SUM( wkg009 ) SUM( wkg010 ) SUM( wkg011 ) SUM( wkg012 ) SUM( wkg013 ) SUM( wkg014 ) SUM( wkg015 ) SUM( wkg016 )
-
INTO (l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,
-
l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016)
-
FROM cosb
-
WHERE kstar = c_kstar06 AND wrttp = '31'
-
AND gjahr = r_month-ryear
-
AND objnr = ltd_aufnr-objnr.
-
IF r_month-month = '01'.
-
CLEAR: l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '02'.
-
CLEAR: l_wkg001,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '03'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '04'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '05'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '06'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '07'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '08'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '09'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '10'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '11'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg002,l_wkg010,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '12'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011.
-
ENDIF.
-
ltd_aufnr-wkgbtr26 = ltd_aufnr-wkgbtr26 + l_wkg001 + l_wkg002 + l_wkg003 + l_wkg004 + l_wkg005 + l_wkg006 + l_wkg007 + l_wkg008
-
+ l_wkg009 + l_wkg010 + l_wkg011 + l_wkg012 + l_wkg013 + l_wkg014 + l_wkg015 + l_wkg016. " 其它制费-差异
-
CLEAR:l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
SELECT SUM( wkg001 ) SUM( wkg002 ) SUM( wkg003 ) SUM( wkg004 ) SUM( wkg005 ) SUM( wkg006 ) SUM( wkg007 ) SUM( wkg008 )
-
SUM( wkg009 ) SUM( wkg010 ) SUM( wkg011 ) SUM( wkg012 ) SUM( wkg013 ) SUM( wkg014 ) SUM( wkg015 ) SUM( wkg016 )
-
INTO (l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,
-
l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016)
-
FROM cosb
-
WHERE kstar = c_kstar07 AND wrttp = '31'
-
AND gjahr = r_month-ryear
-
AND objnr = ltd_aufnr-objnr.
-
IF r_month-month = '01'.
-
CLEAR: l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '02'.
-
CLEAR: l_wkg001,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '03'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '04'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '05'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '06'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '07'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg008,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '08'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg009,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '09'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg010,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '10'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg011,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '11'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg002,l_wkg010,l_wkg012,l_wkg013,l_wkg014,l_wkg015,l_wkg016.
-
ELSEIF r_month-month = '12'.
-
CLEAR: l_wkg001,l_wkg002,l_wkg003,l_wkg004,l_wkg005,l_wkg006,l_wkg007,l_wkg008,l_wkg009,l_wkg010,l_wkg011.
-
ENDIF.
-
ltd_aufnr-wkgbtr27 = ltd_aufnr-wkgbtr27 + l_wkg001 + l_wkg002 + l_wkg003 + l_wkg004 + l_wkg005 + l_wkg006 + l_wkg007 + l_wkg008
-
+ l_wkg009 + l_wkg010 + l_wkg011 + l_wkg012 + l_wkg013 + l_wkg014 + l_wkg015 + l_wkg016. " 外协加工费-差异 CLEAR r_month.
ENDLOOP.
ltd_aufnr-wkgbtr08 = ltd_aufnr-wkgbtr00 + ltd_aufnr-wkgbtr01 + ltd_aufnr-wkgbtr02 + ltd_aufnr-wkgbtr03 +
ltd_aufnr-wkgbtr04 + ltd_aufnr-wkgbtr05 ."+ ltd_aufnr-wkgbtr06 + ltd_aufnr-wkgbtr07. -
ltd_aufnr-wkgbtr28 = ltd_aufnr-wkgbtr20 + ltd_aufnr-wkgbtr21 + ltd_aufnr-wkgbtr22 + ltd_aufnr-wkgbtr23 +
-
ltd_aufnr-wkgbtr24 ."+ ltd_aufnr-wkgbtr25 + ltd_aufnr-wkgbtr26 + ltd_aufnr-wkgbtr27.
ltd_aufnr-wkgbtr38 = ltd_aufnr-wkgbtr30 + ltd_aufnr-wkgbtr31 + ltd_aufnr-wkgbtr32 + ltd_aufnr-wkgbtr33 +
ltd_aufnr-wkgbtr34 + ltd_aufnr-wkgbtr35 ."+ ltd_aufnr-wkgbtr26 + ltd_aufnr-wkgbtr27.ltd_aufnr-wkgbtr20 = ltd_aufnr-wkgbtr00 - ltd_aufnr-wkgbtr30.
ltd_aufnr-wkgbtr21 = ltd_aufnr-wkgbtr01 - ltd_aufnr-wkgbtr31.
ltd_aufnr-wkgbtr22 = ltd_aufnr-wkgbtr02 - ltd_aufnr-wkgbtr32.
ltd_aufnr-wkgbtr23 = ltd_aufnr-wkgbtr03 - ltd_aufnr-wkgbtr33.
ltd_aufnr-wkgbtr24 = ltd_aufnr-wkgbtr04 - ltd_aufnr-wkgbtr34.
ltd_aufnr-wkgbtr25 = ltd_aufnr-wkgbtr05 - ltd_aufnr-wkgbtr34. -
ltd_aufnr-wkgbtr30 = ltd_aufnr-wkgbtr00 - ltd_aufnr-wkgbtr20.
-
ltd_aufnr-wkgbtr31 = ltd_aufnr-wkgbtr01 - ltd_aufnr-wkgbtr21.
-
ltd_aufnr-wkgbtr32 = ltd_aufnr-wkgbtr02 - ltd_aufnr-wkgbtr22.
-
ltd_aufnr-wkgbtr33 = ltd_aufnr-wkgbtr03 - ltd_aufnr-wkgbtr23.
-
ltd_aufnr-wkgbtr34 = ltd_aufnr-wkgbtr04 - ltd_aufnr-wkgbtr24.
-
ltd_aufnr-wkgbtr35 = ltd_aufnr-wkgbtr05 - ltd_aufnr-wkgbtr25.
-
ltd_aufnr-wkgbtr36 = ltd_aufnr-wkgbtr06 - ltd_aufnr-wkgbtr26.
-
ltd_aufnr-wkgbtr37 = ltd_aufnr-wkgbtr07 - ltd_aufnr-wkgbtr27.
-
ltd_aufnr-wkgbtr30 = ltd_aufnr-wkgbtr00 + abs( ltd_aufnr-wkgbtr20 ).
-
ltd_aufnr-wkgbtr31 = ltd_aufnr-wkgbtr01 + abs( ltd_aufnr-wkgbtr21 ).
-
ltd_aufnr-wkgbtr32 = ltd_aufnr-wkgbtr02 + abs( ltd_aufnr-wkgbtr22 ).
-
ltd_aufnr-wkgbtr33 = ltd_aufnr-wkgbtr03 + abs( ltd_aufnr-wkgbtr23 ).
-
ltd_aufnr-wkgbtr34 = ltd_aufnr-wkgbtr04 + abs( ltd_aufnr-wkgbtr24 ).
-
ltd_aufnr-wkgbtr35 = ltd_aufnr-wkgbtr05 + abs( ltd_aufnr-wkgbtr25 ).
-
ltd_aufnr-wkgbtr36 = ltd_aufnr-wkgbtr06 + abs( ltd_aufnr-wkgbtr26 ).
-
ltd_aufnr-wkgbtr37 = ltd_aufnr-wkgbtr07 + abs( ltd_aufnr-wkgbtr27 ).
-
ltd_aufnr-wkgbtr38 = ltd_aufnr-wkgbtr30 + ltd_aufnr-wkgbtr31 + ltd_aufnr-wkgbtr32 + ltd_aufnr-wkgbtr33 +
-
ltd_aufnr-wkgbtr34 ."+ ltd_aufnr-wkgbtr35 + ltd_aufnr-wkgbtr36 + ltd_aufnr-wkgbtr37.
ltd_aufnr-wkgbtr28 = ltd_aufnr-wkgbtr20 + ltd_aufnr-wkgbtr21 + ltd_aufnr-wkgbtr22 + ltd_aufnr-wkgbtr23 +
ltd_aufnr-wkgbtr24 + ltd_aufnr-wkgbtr25 ."+ ltd_aufnr-wkgbtr36 + ltd_aufnr-wkgbtr37.IF ltd_aufnr-wkgbtr38 <> 0.
-
ltd_aufnr-cyl = abs( ltd_aufnr-wkgbtr28 ) / abs( ltd_aufnr-wkgbtr38 ). "20210514-yucy-marked ltd_aufnr-cyl = ltd_aufnr-wkgbtr28 / ltd_aufnr-wkgbtr38 . "20210514-yucy-added
ENDIF.
MODIFY ltd_aufnr.
CLEAR:ltd_aufnr.
ENDLOOP.
SORT ltd_aufnr BY aufnr. -
LOOP AT ltd_aufnr.
-
IF ltd_aufnr-wkgbtr20 IS INITIAL AND ltd_aufnr-wkgbtr21 IS INITIAL AND ltd_aufnr-wkgbtr22 IS INITIAL AND
-
ltd_aufnr-wkgbtr23 IS INITIAL AND ltd_aufnr-wkgbtr24 IS INITIAL AND ltd_aufnr-wkgbtr28 IS INITIAL."ltd_aufnr-wkgbtr25 IS INITIAL AND
-
" ltd_aufnr-wkgbtr26 IS INITIAL AND ltd_aufnr-wkgbtr27 IS INITIAL AND ltd_aufnr-wkgbtr28 IS INITIAL.
-
CLEAR:g_kadky.
-
SELECT MAX( kadat ) INTO g_kadky FROM keko
-
WHERE matnr = ltd_aufnr-matnr
-
AND werks = ltd_aufnr-werks
-
AND kadat <> ''
-
AND feh_sta = 'FR'.
-
CLEAR:g_losgr, g_kalnr.
-
SELECT SINGLE kalnr losgr kadky INTO (g_kalnr,g_losgr,g_kadky)
-
FROM keko
-
WHERE matnr = ltd_aufnr-matnr
-
AND werks = ltd_aufnr-werks
-
AND kadat = g_kadky
-
AND feh_sta = 'FR'.
-
SELECT SUM( wertn ) INTO ltd_aufnr-wkgbtr30
-
FROM ckis
-
WHERE kalnr = g_kalnr
-
AND kadky = g_kadky AND werks = ltd_aufnr-werks
-
AND ( ( kstar BETWEEN '5001010100' AND '5000030000' ) OR ( kstar BETWEEN '1408010100' AND '1408030000' ) ).
-
IF g_losgr IS NOT INITIAL.
-
ltd_aufnr-wkgbtr30 = ltd_aufnr-wkgbtr30 / g_losgr * ltd_aufnr-wemng.
-
ENDIF.
-
SELECT SUM( wertn ) INTO ltd_aufnr-wkgbtr31
-
FROM ckis
-
WHERE kalnr = g_kalnr AND typps = 'E'
-
AND kadky = g_kadky AND werks = ltd_aufnr-werks
-
AND kstar IN ( '110101','5001999997' ) ."= c_kstar01.
-
IF g_losgr IS NOT INITIAL.
-
ltd_aufnr-wkgbtr31 = ltd_aufnr-wkgbtr31 / g_losgr * ltd_aufnr-wemng.
-
ENDIF.
-
SELECT SUM( wertn ) INTO ltd_aufnr-wkgbtr32
-
FROM ckis
-
WHERE kalnr = g_kalnr AND typps = 'E'
-
AND kadky = g_kadky AND werks = ltd_aufnr-werks
-
AND kstar = c_kstar02.
-
IF g_losgr IS NOT INITIAL.
-
ltd_aufnr-wkgbtr32 = ltd_aufnr-wkgbtr32 / g_losgr * ltd_aufnr-wemng.
-
ENDIF.
-
SELECT SUM( wertn ) INTO ltd_aufnr-wkgbtr33
-
FROM ckis
-
WHERE kalnr = g_kalnr AND typps = 'E'
-
AND kadky = g_kadky AND werks = ltd_aufnr-werks
-
AND kstar IN ( '110103','5001999998' ) ."= c_kstar03.
-
IF g_losgr IS NOT INITIAL.
-
ltd_aufnr-wkgbtr33 = ltd_aufnr-wkgbtr33 / g_losgr * ltd_aufnr-wemng.
-
ENDIF.
-
SELECT SUM( wertn ) INTO ltd_aufnr-wkgbtr34
-
FROM ckis
-
WHERE kalnr = g_kalnr AND typps = 'E'
-
AND kadky = g_kadky AND werks = ltd_aufnr-werks
-
AND kstar = c_kstar04.
-
IF g_losgr IS NOT INITIAL.
-
ltd_aufnr-wkgbtr34 = ltd_aufnr-wkgbtr34 / g_losgr * ltd_aufnr-wemng.
-
ENDIF.
** SELECT SUM( wertn ) INTO ltd_aufnr-wkgbtr35
** FROM ckis
** WHERE kalnr = g_kalnr AND typps = ‘E’
** AND kadky = g_kadky AND werks = ltd_aufnr-werks
** AND kstar = c_kstar05.
** IF g_losgr IS NOT INITIAL.
** ltd_aufnr-wkgbtr35 = ltd_aufnr-wkgbtr35 / g_losgr * ltd_aufnr-wemng.
** ENDIF.
**
** SELECT SUM( wertn ) INTO ltd_aufnr-wkgbtr36
** FROM ckis
** WHERE kalnr = g_kalnr AND typps = ‘E’
** AND kadky = g_kadky AND werks = ltd_aufnr-werks
** AND kstar = c_kstar06.
** IF g_losgr IS NOT INITIAL.
** ltd_aufnr-wkgbtr36 = ltd_aufnr-wkgbtr36 / g_losgr * ltd_aufnr-wemng.
** ENDIF.
**
** SELECT SUM( wertn ) INTO ltd_aufnr-wkgbtr37
** FROM ckis
** WHERE kalnr = g_kalnr AND typps = ‘E’
** AND kadky = g_kadky AND werks = ltd_aufnr-werks
** AND kstar = c_kstar07.
** IF g_losgr IS NOT INITIAL.
** ltd_aufnr-wkgbtr37 = ltd_aufnr-wkgbtr37 / g_losgr * ltd_aufnr-wemng.
** ENDIF.
*
-
ltd_aufnr-wkgbtr38 = ltd_aufnr-wkgbtr30 + ltd_aufnr-wkgbtr31 + ltd_aufnr-wkgbtr32 + ltd_aufnr-wkgbtr33 +
-
ltd_aufnr-wkgbtr34 ."+ ltd_aufnr-wkgbtr35 + ltd_aufnr-wkgbtr36 + ltd_aufnr-wkgbtr37.
-
ltd_aufnr-wkgbtr20 = ltd_aufnr-wkgbtr30 - ltd_aufnr-wkgbtr00.
-
ltd_aufnr-wkgbtr21 = ltd_aufnr-wkgbtr31 - ltd_aufnr-wkgbtr01.
-
ltd_aufnr-wkgbtr22 = ltd_aufnr-wkgbtr32 - ltd_aufnr-wkgbtr02.
-
ltd_aufnr-wkgbtr23 = ltd_aufnr-wkgbtr33 - ltd_aufnr-wkgbtr03.
-
ltd_aufnr-wkgbtr24 = ltd_aufnr-wkgbtr34 - ltd_aufnr-wkgbtr04.
** ltd_aufnr-wkgbtr25 = ltd_aufnr-wkgbtr35 - ltd_aufnr-wkgbtr05.
** ltd_aufnr-wkgbtr26 = ltd_aufnr-wkgbtr36 - ltd_aufnr-wkgbtr06.
** ltd_aufnr-wkgbtr27 = ltd_aufnr-wkgbtr37 - ltd_aufnr-wkgbtr07.
-
ltd_aufnr-wkgbtr28 = ltd_aufnr-wkgbtr38 - ltd_aufnr-wkgbtr08.
-
IF ltd_aufnr-wkgbtr38 <> 0.
** ltd_aufnr-cyl = abs( ltd_aufnr-wkgbtr28 ) / abs( ltd_aufnr-wkgbtr38 ). "20210514-yucy-marked
-
ltd_aufnr-cyl = ltd_aufnr-wkgbtr28 / ltd_aufnr-wkgbtr38 . "20210514-yucy-added
-
ENDIF.
-
MODIFY ltd_aufnr.
- ENDIF.
- CLEAR:ltd_aufnr.
- ENDLOOP.
ENDFORM.
FORM display_alv.
REFRESH gt_field.
progname = sy-repid. "获得程序名称
IF p_chk1 = ‘X’.
title = ‘订单状态(在制)’.
ELSE.
title = syst-title. "标题
ENDIF.
gs_layout-zebra = ‘X’. "设置每行的背景颜色交错 显示。
gs_layout-colwidth_optimize = ‘X’. "ALV输出时候自动优化宽 度
alv_key werks 工厂 4.
alv_key aufnr 订单号 12.
alv_edit sttxt 工单系统状态 64 ‘’ ‘’.
alv_edit matnr 物料编码 20 ‘’ ‘’.
alv_edit maktx 物料名称 40 ‘’ ‘’.
- alv_edit spart 产品组 10 ‘’ ‘’.
- alv_edit vtext 产品组描述 15 ‘’ ‘’.
alv_edit psmng 订单数量 20 ‘’ ‘’.
alv_edit wemng 收货数量 20 ‘’ ‘’.
alv_edit wkgbtr00 材料-实际 20 ‘’ ‘’.
alv_edit wkgbtr01 人工-实际 20 ‘’ ‘’.
alv_edit wkgbtr02 机器-实际 20 ‘’ ‘’.
alv_edit wkgbtr03 制造费用-实际 20 ‘’ ‘’.
alv_edit wkgbtr04 工序委外-实际 20 ‘’ ‘’.
alv_edit wkgbtr05 生产成本差异-实际 20 ‘’ ‘’.
- alv_edit wkgbtr06 其它制费-实际 20 ‘’ ‘’.
- alv_edit wkgbtr07 外协加工费-实际 20 ‘’ ‘’.
alv_edit wkgbtr08 实际成本合计 20 ‘’ ‘’.
alv_edit wkgbtr30 材料-标准 20 ‘’ ‘’.
alv_edit wkgbtr31 人工-标准 20 ‘’ ‘’.
alv_edit wkgbtr32 机器-标准 20 ‘’ ‘’.
alv_edit wkgbtr33 制造费用-标准 20 ‘’ ‘’.
alv_edit wkgbtr34 工序委外-标准 20 ‘’ ‘’.
alv_edit wkgbtr35 生产成本差异-标准 20 ‘’ ‘’.
- alv_edit wkgbtr36 其它制费-标准 20 ‘’ ‘’.
- alv_edit wkgbtr37 外协加工费-标准 20 ‘’ ‘’.
alv_edit wkgbtr38 合计 20 ‘’ ‘’.
alv_edit wkgbtr20 材料-差异 20 ‘’ ‘’.
alv_edit wkgbtr21 人工-差异 20 ‘’ ‘’.
alv_edit wkgbtr22 机器-差异 20 ‘’ ‘’.
alv_edit wkgbtr23 制造费用-差异 20 ‘’ ‘’.
alv_edit wkgbtr24 工序委外-差异 20 ‘’ ‘’.
alv_edit wkgbtr25 生产成本差异-差异 20 ‘’ ‘’.
- alv_edit wkgbtr26 其它制费-差异 20 ‘’ ‘’.
- alv_edit wkgbtr27 外协加工费-差异 20 ‘’ ‘’.
alv_edit wkgbtr28 差异合计 20 ‘’ ‘’.
alv_edit cyl 差异率 20 ‘’ ‘’.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = progname
is_layout = gs_layout
it_fieldcat = gt_field[]
-
TABLESi_grid_title = title i_callback_user_command = 'USERCOMMAND' i_save = 'A'
t_outtab = ltd_aufnr
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
FORM usercommand USING i_ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
DATA: lr_grid TYPE REF TO cl_gui_alv_grid.
DATA: lv_aufnr TYPE aufk-aufnr.
DATA: wa_aufk TYPE aufk.
DATA: lt_subobj TYPE TABLE OF jsto_pre WITH HEADER LINE.
CALL FUNCTION ‘GET_GLOBALS_FROM_SLVC_FULLSCR’
IMPORTING
e_grid = lr_grid.
CALL METHOD lr_grid->check_changed_data.
selfield-refresh = ‘X’.
selfield-row_stable = ‘X’.
selfield-col_stable = ‘X’.
CASE i_ucomm.
WHEN ‘&IC1’.
CASE selfield-sel_tab_field.
WHEN ‘1-AUFNR’.
CLEAR ltd_aufnr2.
REFRESH ltd_aufnr2.
READ TABLE ltd_aufnr INTO ltd_aufnr2 WITH KEY aufnr = selfield-value.
SET PARAMETER ID ‘ANR’ FIELD selfield-value.
lv_aufnr = selfield-value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = lv_aufnr
IMPORTING
output = lv_aufnr.
SELECT SINGLE * INTO wa_aufk FROM aufk WHERE aufnr = lv_aufnr.
IF sy-subrc EQ 0.
CALL FUNCTION 'CK_F_CO_OBJECT_DISPLAY'
EXPORTING
kokrs_imp = wa_aufk-kokrs
objnr_imp = wa_aufk-objnr
TABLES
subobjs_imp = lt_subobj
EXCEPTIONS
data_not_found = 01
job_does_not_exist = 02
not_generated = 03
no_authority = 04.
ENDIF.
ENDCASE.
WHEN OTHERS.
ENDCASE.
ENDFORM.
FORM get_qijian_data.
IF s_gjahr-high IS INITIAL.
s_gjahr-high = s_gjahr-low.
ENDIF.
REFRESH r_month.
CLEAR r_month.
CLEAR r_month.
r_month-ryear = s_gjahr-low.
r_month-month = s_month1.
r_month-qj = r_month-month.
APPEND r_month.
IF s_gjahr-high = s_gjahr-low.
IF s_month2 > s_month1.
CLEAR: i1,i2,i3.
i3 = s_month2.
i2 = s_month1.
i1 = i3 - i2.
CLEAR i4.
DO i1 TIMES.
CLEAR: month_t.
i4 = i4 + 1.
month_t = s_month1 + i4.
CLEAR r_month.
r_month-ryear = s_gjahr-low.
r_month-month = month_t.
r_month-qj = r_month-month.
APPEND r_month.
ENDDO.
ENDIF.
ELSE.
CLEAR r_ryear.
REFRESH r_ryear.
CLEAR:i1,i2,i3,i5.
i5 = s_gjahr-high - s_gjahr-low.
IF i5 = 0.
ELSE.
r_ryear-ryear = s_gjahr-low.
APPEND r_ryear.
CLEAR r_ryear.
DO i5 TIMES.
i1 = i1 + 1.
r_ryear-ryear = s_gjahr-low + i1.
APPEND r_ryear.
CLEAR r_ryear.
ENDDO.
ENDIF.
LOOP AT r_ryear.
IF r_ryear-ryear = s_gjahr-low.
CLEAR: i1,i2,i3.
i3 = 12.
i2 = s_month1.
i1 = i3 - i2.
CLEAR i4.
DO i1 TIMES.
CLEAR: month_t.
i4 = i4 + 1.
month_t = s_month1 + i4.
CLEAR r_month.
r_month-ryear = s_gjahr-low.
r_month-month = month_t.
r_month-qj = r_month-month.
APPEND r_month.
ENDDO.
ELSEIF r_ryear-ryear = s_gjahr-high.
CLEAR: i1,i2,i3.
i2 = s_month2.
i1 = i2.
CLEAR i4.
DO i1 TIMES.
CLEAR: month_t.
i4 = i4 + 1.
month_t = i4.
CLEAR r_month.
r_month-ryear = s_gjahr-high.
r_month-month = month_t.
r_month-qj = r_month-month.
APPEND r_month.
ENDDO.
ELSE.
CLEAR i4.
DO 12 TIMES.
CLEAR: month_t.
i4 = i4 + 1.
month_t = i4.
CLEAR r_month.
r_month-ryear = r_ryear-ryear.
r_month-month = month_t.
r_month-qj = r_month-month.
APPEND r_month.
ENDDO.
ENDIF.
ENDLOOP.
ENDIF.
SORT r_month BY ryear month.
DELETE ADJACENT DUPLICATES FROM r_month COMPARING ALL FIELDS.
ENDFORM.
&---------------------------------------------------------------------
*& Form get_data2
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM get_data2 .
RANGES: lr_bwart FOR aufm-bwart.
APPEND ‘IEQ101’ TO lr_bwart.
APPEND ‘IEQ102’ TO lr_bwart.
APPEND ‘IEQ122’ TO lr_bwart.
CLEAR ltd_aufnr02.
REFRESH:gt_coep,gt_cosp,ltd_aufnr02,gt_aufnr02.
SELECT aufk~aufnr
aufk~erdat
aufk~aedat
aufk~werks
aufk~kokrs
aufk~objnr
afpo~matnr
afpo~psmng
afpo~wemng
-
mara~spart
FROM aufk JOIN afpo
ON aufk~aufnr = afpo~aufnr -
JOIN mara
-
ON afpo~matnr = mara~matnr
INTO CORRESPONDING FIELDS OF TABLE ltd_aufnr02
WHERE aufk~bukrs = p_bukrs
AND aufk~werks IN s_werks
AND aufk~aufnr IN s_aufnr
AND aufk~erdat IN s_erdat
AND aufk~loekz = space
AND afpo~matnr IN s_matnr.LOOP AT ltd_aufnr02.
CLEAR line.
CALL FUNCTION ‘STATUS_TEXT_EDIT’
EXPORTING
objnr = ltd_aufnr02-objnr
only_active = ‘X’
spras = sy-langu
IMPORTING
line = line
EXCEPTIONS
object_not_found = 01.
IF sy-subrc NE 0.
CLEAR line.
ELSE.
ltd_aufnr02-sttxt = line.
ENDIF.
SELECT SINGLE maktx INTO ltd_aufnr02-maktx FROM makt WHERE matnr = ltd_aufnr02-matnr AND spras = ‘1’.
IF ltd_aufnr02-spart IS NOT INITIAL.
SELECT SINGLE vtext INTO ltd_aufnr02-vtext FROM tspat WHERE spras = ‘1’ AND spart = ltd_aufnr02-spart.
ENDIF.
CLEAR:l_menge1,l_menge2.
SELECT SUM( menge ) INTO l_menge1 FROM aufm WHERE aufnr = ltd_aufnr02-aufnr AND bwart IN lr_bwart AND shkzg = ‘S’ AND mjahr IN s_gjahr AND budat BETWEEN l_date1 AND l_date2.
SELECT SUM( menge ) INTO l_menge2 FROM aufm WHERE aufnr = ltd_aufnr02-aufnr AND bwart IN lr_bwart AND shkzg = ‘H’ AND mjahr IN s_gjahr AND budat BETWEEN l_date1 AND l_date2.
ltd_aufnr02-wemng = l_menge1 - l_menge2.
MODIFY ltd_aufnr02.
CLEAR ltd_aufnr02.
ENDLOOP.DATA: lw_sttxt TYPE bsvx-sttxt,
lt_sttxt LIKE TABLE OF lw_sttxt.IF p_chk1 = ‘X’.
LOOP AT ltd_aufnr02.
SPLIT ltd_aufnr02-sttxt AT ‘’ INTO TABLE lt_sttxt.
READ TABLE lt_sttxt INTO lw_sttxt WITH KEY table_line = ‘CRTD’. " 创建状态
IF sy-subrc NE 0.
READ TABLE lt_sttxt INTO lw_sttxt WITH KEY table_line = ‘REL’. " 下达状态
IF sy-subrc NE 0.
DELETE ltd_aufnr02.
ENDIF.
ENDIF.
CLEAR:ltd_aufnr02.
ENDLOOP.
ENDIF.IF ltd_aufnr02[] IS INITIAL.
MESSAGE ‘没有符合条件的数据!’ TYPE ‘S’ DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.DATA:r_month2 LIKE TABLE OF r_month WITH HEADER LINE.
REFRESH r_month2.
r_month2[] = CORRESPONDING #( r_month[] ).
SORT r_month2 BY ryear.
DELETE ADJACENT DUPLICATES FROM r_month2 COMPARING ryear.LOOP AT ltd_aufnr02.
LOOP AT r_month.
SELECT
objnr
kokrs
gjahr
perio
kstar
hrkft
wrttp
wkgbtr
megbtr
matnr
APPENDING CORRESPONDING FIELDS OF TABLE gt_coep
FROM coep
WHERE objnr = ltd_aufnr02-objnr
AND kokrs = ltd_aufnr02-kokrs
AND gjahr = r_month-ryear
AND perio = r_month-qj
AND wrttp IN ( ‘04’,‘05’ ).CLEAR r_month.
ENDLOOP.
LOOP AT r_month2.
SELECT "计划成本(不含人工/机器/制作费用)
a~objnr
a~gjahr
a~kstar
a~hrkft
a~wrttp
a~wtg001
a~wtg002
a~wtg003
a~wtg004
a~wtg005
a~wtg006
a~wtg007
a~wtg008
a~wtg009
a~wtg010
a~wtg011
a~wtg012
a~wtg013
a~wtg014
a~wtg015
a~wtg016
a~meg001
a~meg002
a~meg003
a~meg004
a~meg005
a~meg006
a~meg007
a~meg008
a~meg009
a~meg010
a~meg011
a~meg012
a~meg013
a~meg014
a~meg015
a~meg016
b~matnr
APPENDING CORRESPONDING FIELDS OF TABLE gt_cosp
FROM cosp AS a
JOIN cokey AS b ON a~hrkft EQ b~hrkft
WHERE a~objnr = ltd_aufnr02-objnr
AND a~gjahr = r_month2-ryear
AND a~wrttp = ‘01’
AND b~werks = ltd_aufnr02-werks.
ENDLOOP.CLEAR:ltd_aufnr02.
ENDLOOP.DATA: lt_coep LIKE TABLE OF gt_coep WITH HEADER LINE.
DATA: lt_coep2 LIKE TABLE OF gt_coep WITH HEADER LINE.
DATA: lv_f1,lv_f2.
REFRESH :lt_coep,lt_coep2.LOOP AT gt_coep.
CLEAR :lt_coep.
lt_coep-objnr = gt_coep-objnr.
lt_coep-kstar = gt_coep-kstar.
lt_coep-hrkft = gt_coep-hrkft.
lt_coep-wrttp = gt_coep-wrttp.
lt_coep-matnr = gt_coep-matnr.
lt_coep-wkgbtr = gt_coep-wkgbtr.
IF lt_coep-wrttp = ‘04’.
lt_coep-megbtr = gt_coep-megbtr.
ENDIF.
IF lt_coep-wrttp = ‘05’.
lt_coep-megbtr2 = gt_coep-megbtr.
ENDIF.
IF lt_coep-kstar = ‘0000110101’ OR lt_coep-kstar = ‘0000110102’ OR lt_coep-kstar = ‘0000110103’.
CLEAR lt_coep-hrkft.
ENDIF.
COLLECT lt_coep.
ENDLOOP.
LOOP AT gt_cosp.
CLEAR :lt_coep.
lt_coep-objnr = gt_cosp-objnr.
lt_coep-kstar = gt_cosp-kstar.
lt_coep-hrkft = gt_cosp-hrkft.
lt_coep-wrttp = gt_cosp-wrttp.
lt_coep-matnr = gt_cosp-matnr.
lt_coep-wkgbtr = gt_cosp-wtg001 + gt_cosp-wtg002 + gt_cosp-wtg003 + gt_cosp-wtg004 + gt_cosp-wtg005 + gt_cosp-wtg006 + gt_cosp-wtg007 + gt_cosp-wtg008
+ gt_cosp-wtg009 + gt_cosp-wtg010 + gt_cosp-wtg011 + gt_cosp-wtg012 + gt_cosp-wtg013 + gt_cosp-wtg014 + gt_cosp-wtg015 + gt_cosp-wtg016.
lt_coep-megbtr3 = gt_cosp-meg001 + gt_cosp-meg002 + gt_cosp-meg003 + gt_cosp-meg004 + gt_cosp-meg005 + gt_cosp-meg006 + gt_cosp-meg007 + gt_cosp-meg008
+ gt_cosp-meg009 + gt_cosp-meg010 + gt_cosp-meg011 + gt_cosp-meg012 + gt_cosp-meg013 + gt_cosp-meg014 + gt_cosp-meg015 + gt_cosp-meg016…
COLLECT lt_coep.
ENDLOOP.
SORT lt_coep BY objnr kokrs kstar hrkft matnr wrttp.APPEND LINES OF lt_coep TO lt_coep2.
SORT lt_coep2 BY objnr ASCENDING kokrs ASCENDING kstar ASCENDING hrkft ASCENDING matnr DESCENDING.
DELETE ADJACENT DUPLICATES FROM lt_coep2 COMPARING objnr kokrs kstar hrkft matnr.SELECT
matnr,
maktx
INTO TABLE @DATA(lt_makt)
FROM makt
FOR ALL ENTRIES IN @lt_coep2
WHERE matnr = @lt_coep2-matnr.
SORT lt_makt BY matnr.SELECT
kstar,
ktext
INTO TABLE @DATA(lt_csku)
FROM csku
WHERE ktopl = ‘8000’.
SORT lt_csku BY kstar.LOOP AT ltd_aufnr02.
CLEAR :gt_aufnr02,lv_f1,lv_f2.
MOVE-CORRESPONDING ltd_aufnr02 TO gt_aufnr02.LOOP AT lt_coep2 WHERE objnr = gt_aufnr02-objnr." AND kokrs = gt_aufnr02-kokrs.
lv_f1 = ‘X’.
CLEAR:gt_aufnr02.
MOVE-CORRESPONDING ltd_aufnr02 TO gt_aufnr02.
gt_aufnr02-kstar = lt_coep2-kstar.
gt_aufnr02-matnr2 = lt_coep2-matnr.
gt_aufnr02-hrkft = lt_coep2-hrkft.READ TABLE lt_makt INTO DATA(lw_makt) WITH KEY matnr = gt_aufnr02-matnr2 BINARY SEARCH. IF sy-subrc = 0. gt_aufnr02-maktx2 = lw_makt-maktx. ENDIF. READ TABLE lt_csku INTO DATA(lw_csku) WITH KEY kstar = gt_aufnr02-kstar BINARY SEARCH. IF sy-subrc = 0. gt_aufnr02-ktext = lw_csku-ktext. ENDIF. READ TABLE lt_coep WITH KEY objnr = gt_aufnr02-objnr
-
kokrs = gt_aufnr02-kokrs kstar = gt_aufnr02-kstar matnr = gt_aufnr02-matnr2 wrttp = '04'. "实际 IF sy-subrc = 0. gt_aufnr02-wkgbtr00 = lt_coep-wkgbtr. gt_aufnr02-megbtr = lt_coep-megbtr. ENDIF. READ TABLE lt_coep WITH KEY objnr = gt_aufnr02-objnr
-
kokrs = gt_aufnr02-kokrs kstar = gt_aufnr02-kstar matnr = gt_aufnr02-matnr2 wrttp = '05'. "标准 IF sy-subrc = 0. gt_aufnr02-wkgbtr30 = lt_coep-wkgbtr. gt_aufnr02-megbtr2 = lt_coep-megbtr2. ENDIF. READ TABLE lt_coep WITH KEY objnr = gt_aufnr02-objnr kstar = gt_aufnr02-kstar hrkft = gt_aufnr02-hrkft wrttp = '01'. "计划 IF sy-subrc = 0. gt_aufnr02-wkgbtr40 = lt_coep-wkgbtr. gt_aufnr02-megbtr3 = lt_coep-megbtr3. ENDIF. IF gt_aufnr02-kstar = '0000110101' OR gt_aufnr02-kstar = '0000110102' OR gt_aufnr02-kstar = '0000110103'. "人工/机器/制作费用 coss SELECT SINGLE * INTO @DATA(lw_coss) FROM coss WHERE objnr = @gt_aufnr02-objnr AND wrttp = '01' AND kstar = @gt_aufnr02-kstar. IF sy-subrc = 0. gt_aufnr02-wkgbtr40 = lw_coss-wtg001 + lw_coss-wtg002 + lw_coss-wtg003 + lw_coss-wtg004 + lw_coss-wtg005 + lw_coss-wtg006 + lw_coss-wtg007 + lw_coss-wtg008 + lw_coss-wtg009 + lw_coss-wtg010 + lw_coss-wtg011 + lw_coss-wtg012 + lw_coss-wtg013 + lw_coss-wtg014 + lw_coss-wtg015 + lw_coss-wtg016. gt_aufnr02-megbtr3 = lw_coss-meg001 + lw_coss-meg002 + lw_coss-meg003 + lw_coss-meg004 + lw_coss-meg005 + lw_coss-meg006 + lw_coss-meg007 + lw_coss-meg008 + lw_coss-meg009 + lw_coss-meg010 + lw_coss-meg011 + lw_coss-meg012 + lw_coss-meg013 + lw_coss-meg014 + lw_coss-meg015 + lw_coss-meg016. ENDIF. ENDIF. IF gt_aufnr02-wkgbtr30 = 0 OR gt_aufnr02-wkgbtr30 IS INITIAL. IF gt_aufnr02-wkgbtr40 > 0 OR gt_aufnr02-wkgbtr40 < 0. gt_aufnr02-wkgbtr30 = gt_aufnr02-wkgbtr40. gt_aufnr02-megbtr2 = gt_aufnr02-megbtr3. ENDIF. ENDIF. IF gt_aufnr02-wkgbtr30 = 0 OR gt_aufnr02-wkgbtr30 IS INITIAL . CLEAR:g_kadky. SELECT MAX( kadat ) INTO g_kadky FROM keko WHERE matnr = gt_aufnr02-matnr AND werks = gt_aufnr02-werks AND kadat <> '00000000' AND feh_sta = 'FR'. CLEAR:g_losgr, g_kalnr. SELECT SINGLE kalnr losgr kadky INTO (g_kalnr,g_losgr,g_kadky) FROM keko WHERE matnr = gt_aufnr02-matnr AND werks = gt_aufnr02-werks AND kadat = g_kadky AND feh_sta = 'FR'. SELECT SUM( wertn ) INTO gt_aufnr02-wkgbtr30 FROM ckis WHERE kalnr = g_kalnr AND kadky = g_kadky AND werks = gt_aufnr02-werks AND kstar = gt_aufnr02-kstar AND matnr = gt_aufnr02-matnr2.
-
AND ( ( kstar BETWEEN '5001010100' AND '5000030000' ) OR ( kstar BETWEEN '1408010100' AND '1408030000' ) ). IF g_losgr IS NOT INITIAL. ltd_aufnr-wkgbtr30 = gt_aufnr02-wkgbtr30 / g_losgr * gt_aufnr02-wemng. ENDIF. ENDIF. gt_aufnr02-wkgbtr20 = gt_aufnr02-wkgbtr00 - gt_aufnr02-wkgbtr30. APPEND gt_aufnr02.
ENDLOOP.
IF lv_f1 = ‘’.
APPEND gt_aufnr02.
ENDIF.ENDLOOP.
SORT gt_aufnr02 BY aufnr objnr kstar matnr.
ENDFORM.
&---------------------------------------------------------------------
*& Form display_alv2
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM display_alv2 .
REFRESH gt_field.
progname = sy-repid. "获得程序名称
IF p_chk1 = ‘X’.
title = ‘订单状态(在制)’.
ELSE.
title = syst-title. "标题
ENDIF.
gs_layout-zebra = ‘X’. "设置每行的背景颜色交错 显示。
gs_layout-colwidth_optimize = ‘X’. "ALV输出时候自动优化宽 度
alv_key werks 工厂 4.
alv_key aufnr 订单号 12.
alv_key erdat 创建日期 10.
alv_edit sttxt 工单系统状态 64 ‘’ ‘’.
alv_edit matnr 物料编码 20 ‘’ ‘’.
alv_edit maktx 物料名称 40 ‘’ ‘’.
alv_edit psmng 订单数量 20 ‘’ ‘’.
alv_edit wemng 收货数量 20 ‘’ ‘’.
alv_edit kstar 成本要素 10 ‘’ ‘’.
alv_edit ktext 成本要素描述 30 ‘’ ‘’.
alv_edit wkgbtr00 实际 20 ‘’ ‘’.
alv_edit megbtr 实际数量 20 ‘’ ‘’.
alv_edit wkgbtr30 标准 20 ‘’ ‘’.
alv_edit megbtr2 标准数量 20 ‘’ ‘’.
alv_edit wkgbtr40 计划 20 ‘’ ‘’.
alv_edit megbtr3 计划数量 20 ‘’ ‘’.
alv_edit wkgbtr20 差异 20 ‘’ ‘’.
alv_edit matnr2 组件物料 20 ‘’ ‘’.
alv_edit maktx2 组件物料描述 40 ‘’ ‘’.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = progname
is_layout = gs_layout
it_fieldcat = gt_field[]
-
TABLESi_grid_title = title i_callback_user_command = 'USERCOMMAND' i_save = 'A'
t_outtab = gt_aufnr02
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.