&---------------------------------------------------------------------
*& Report ZCORP005
&---------------------------------------------------------------------
*&
&---------------------------------------------------------------------
REPORT zcorp005 MESSAGE-ID 00.
TABLES:vbrp,vbrk,mldocccs_extract,vbap,ckmlhd,cosp.
SELECTION-SCREEN:BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : s_bukrs FOR vbrp-bukrs_ana OBLIGATORY NO-EXTENSION NO INTERVALS." 公司代码、WERKS
SELECT-OPTIONS : s_werks FOR vbrp-werks." 工厂、WERKS
SELECT-OPTIONS : s_aubel FOR vbrp-aubel ." 销售凭证
SELECT-OPTIONS : s_aupos FOR vbrp-aupos ." 销售凭证行项目
SELECT-OPTIONS : s_zprono FOR vbap-zprono." 项目号
SELECT-OPTIONS : s_jahr FOR cosp-gjahr." 会计年度
SELECT-OPTIONS : s_perbl FOR cosp-perbl." 记帐期间
SELECT-OPTIONS : s_matnr FOR ckmlhd-matnr ." 物料 ckmlhd-matnr
SELECT-OPTIONS : s_kunag FOR vbrp-kunag_ana." 售达方 s_JAHRPER
SELECT-OPTIONS : s_jah FOR mldocccs_extract-jahrper NO-DISPLAY."
SELECTION-SCREEN:END OF BLOCK b1.
DATA: BEGIN OF ls_data,
sel TYPE c,
bukrs TYPE vbrp-bukrs_ana, " CHAR 4 公司代码
butxt TYPE t001-butxt, " CHAR 4 公司代码描述
fkdat_ana TYPE vbrp-fkdat_ana, " DATS 8 开票日期
aubel TYPE vbrp-aubel, " CHAR 10 销售凭证
aupos TYPE vbrp-aupos, " CHAR 6 销售凭证行项目
zprono TYPE vbap-zprono , "CHAR 10 项目号 是否赠机(行项目类别)?
kunag_ana TYPE vbrp-kunag_ana, " CHAR 10 售达方
kunrg_ana TYPE vbrp-kunrg_ana, " CHAR 10 付款方
kunwe_ana TYPE vbrp-kunwe_ana, " CHAR 10 送达方
kunre_ana TYPE vbrp-kunre_ana , "CHAR 10 受票方
mwsbp TYPE vbrp-mwsbp, "税额
vbeln TYPE vbrp-vbeln,
posnr TYPE vbrp-posnr,
vgbel TYPE vbrp-vgbel,
vgpos TYPE vbrp-vgpos,
werks TYPE vbap-werks,
name1 TYPE kna1-name1, " CURR 35 售达方描述
zkunag TYPE kna1-zkunag , "CHAR 10 所属母公司
zkunag_name1 TYPE kna1-name1, " CURR 35 所属的母公司描述
matkl TYPE t023t-matkl, " CHAR 9 产品类别
wgbez TYPE t023t-wgbez, " CHAR 20 产品类别描述
MATKL TYPE T023T-MATKL ,"CHAR 9 产品型号
WGBEZ TYPE T023T-WGBEZ," CHAR 20 产品型号描述
bklas TYPE mbew-bklas, " CHAR 4 产品系列
bkbez TYPE t025t-bkbez, " CKAR 25 产品系列描述
MATKL TYPE T023T-MATKL ,"CKAR 9 产品型号
WGBEZ TYPE T023T-WGBEZ," CHAR 20 产品型号描述
matnr TYPE vbrp-matnr, " CHAR 40 物料号
maktx TYPE makt-maktx, " CHAR 40 物料描述
netwr TYPE vbrp-netwr, " CURR 15.2 原账面确认收入
netwr1 TYPE vbrp-netwr, "(VBRP-NETWR)+(VBRP-MWSBP) " CURR 15.2 合同金额(含税)
tot1 TYPE mldocccs_extract-tot , " CURR 23.2 原材料
tot2 TYPE mldocccs_extract-tot, " CURR 23.2 半成品
tot3 TYPE mldocccs_extract-tot, " CURR 23.2 产成品
tot4 TYPE mldocccs_extract-tot, " CURR 23.2 其他辅料
tot5 TYPE mldocccs_extract-tot, " CURR 23.2 委外发出材料
tot6 TYPE mldocccs_extract-tot , "CURR 23.2 委外加工费
tot7 TYPE mldocccs_extract-tot , "CURR 23.2 委外-结转
tot8 TYPE mldocccs_extract-tot, " CURR 23.2 人工工时(费用)
tot9 TYPE mldocccs_extract-tot, " CURR 23.2 机器工时(费用)
tot10 TYPE mldocccs_extract-tot, " CURR 23.2 制造费用工时(费用)
aufnr TYPE coas-aufnr, "内部订单
wtg001 TYPE cosp-wtg001 , "CURR 15.2 原材料
wtg002 TYPE cosp-wtg002 , "CURR 15.2 人工工时(费用)
wtg003 TYPE cosp-wtg003 , "CURR 15.2 机器工时(费用)
wtg004 TYPE cosp-wtg004 , "CURR 15.2 研发费用工时(费用)
wavwr TYPE vbrp-wavwr , "CURR 23.2 主营业务成本(销售订单成本)
dmbtr TYPE bseg-dmbtr , "CURR 23.2 主营业务成本(销售订单后发出商品转主营业务成本)
dmbtr1 TYPE bseg-dmbtr , " CURR 23.2 主营业务成本(发出商品内部订单结转到主营业务成本)
dmbtr2 TYPE bseg-dmbtr , "CURR 23.2 运输费用
dmbtr3 TYPE bseg-dmbtr , "CURR 23.2 主营业务成本合计
dmbtr4 TYPE bseg-dmbtr , "CURR 23.2 毛利
dmbtr4_str TYPE string , "CURR 23.2 毛利
gross(6) TYPE p DECIMALS 4 , "毛利率
gross_str TYPE string,
bstdk TYPE vbak-bstdk, " DATS 8 合同日期
wadat_ist TYPE likp-wadat_ist , "DATS 8 实际发货日期
zwaprd TYPE vbap-zwaprd , "NUMC 4 质保期(月)
zday TYPE num , " 验收周期(天)
zsource1 TYPE vbak-zsource1, " CHAR 2 订单取得方式
zsource2 TYPE vbak-zsource2 , "CHAR 15 代理商名称
zattr1 TYPE vbak-zattr1 , "CHAR 2 应用领域
land1 TYPE t001-land1 , "CHAR 3 地区
dmbtr6 TYPE bseg-dmbtr, " CHAR 23.2 已回款金额
dmbtr6_str TYPE string,
dmbtr7 TYPE bseg-dmbtr, " TYPE (VBRP-NETWR)+(VBRP-MWSBP)-已回款金额," CHAR 23.2 未回款金额
dmbtr7_str TYPE string,
zterm TYPE vbrk-zterm, " CHAR 4 付款条件
END OF ls_data.
DATA lt_data LIKE TABLE OF ls_data WITH HEADER LINE .
DATA lt_vbrp LIKE TABLE OF ls_data WITH HEADER LINE .
DATA lt_cosp_b_row LIKE TABLE OF ls_data WITH HEADER LINE .
DATA : BEGIN OF lt_cosp_b_sum OCCURS 0,
kdauf TYPE coas-kdauf,
kdpos TYPE coas-kdpos,
wtg001 TYPE cosp-wtg001,
wtg002 TYPE cosp-wtg002,
wtg003 TYPE cosp-wtg003,
wtg004 TYPE cosp-wtg004,
wtg005 TYPE cosp-wtg005,
wtg006 TYPE cosp-wtg006,
wtg007 TYPE cosp-wtg007,
wtg008 TYPE cosp-wtg008,
wtg009 TYPE cosp-wtg009,
wtg010 TYPE cosp-wtg010,
wtg011 TYPE cosp-wtg011,
wtg012 TYPE cosp-wtg012,
wtg013 TYPE cosp-wtg013,
wtg014 TYPE cosp-wtg014,
wtg015 TYPE cosp-wtg015,
wtg016 TYPE cosp-wtg016,
wtgxx TYPE cosp-wtg001,
zcpzt TYPE ztco004-zcpzt, "产品状态 生产阶段 发出商品阶段
zfylx TYPE ztco004-zfylx, "费用类型 原材料 人工工时等
END OF lt_cosp_b_sum.
*DATA lt_cosp LIKE TABLE OF lt_cosp_b_sum WITH HEADER LINE.
DATA lt_cosp2 LIKE TABLE OF lt_cosp_b_sum WITH HEADER LINE.
DATA lt_cosp2_sum LIKE TABLE OF lt_cosp_b_sum WITH HEADER LINE.
DATA:BEGIN OF lt_bseg_mov OCCURS 0,
vbel2 TYPE bseg-vbel2,
posn2 TYPE bseg-posn2,
shkzg TYPE bseg-shkzg, " 借贷标识
dmbtr TYPE bseg-dmbtr,
END OF lt_bseg_mov.
DATA lt_bseg LIKE TABLE OF lt_bseg_mov WITH HEADER LINE.
*DATA lt_bseg_aufnr LIKE TABLE OF lt_bseg_mov WITH HEADER LINE.
*DATA lt_bseg_unaufnr LIKE TABLE OF lt_bseg_mov WITH HEADER LINE.
DATA lt_bseg_mov1 LIKE TABLE OF lt_bseg_mov .
DATA lt_bseg_mov2 LIKE TABLE OF lt_bseg_mov .
DATA : BEGIN OF lt_wtgfield OCCURS 0,
wtg00(6) TYPE c,
perbl TYPE cosp-perbl,
END OF lt_wtgfield.
FIELD-SYMBOLS .
DATA: BEGIN OF lt_acdoca1 OCCURS 0,
kdauf TYPE acdoca-kdauf,
kdpos TYPE acdoca-kdpos,
wsl TYPE acdoca-wsl,
racct TYPE acdoca-racct,
END OF lt_acdoca1.
DATA lt_acdoca2 LIKE TABLE OF lt_acdoca1 WITH HEADER LINE.
DATA lt_acdoca2_mov LIKE TABLE OF lt_acdoca1 WITH HEADER LINE.
DATA lt_acdoca1_mov LIKE TABLE OF lt_acdoca1 WITH HEADER LINE.
DATA gross_mid(6) TYPE p DECIMALS 2.
****ALV参数定义:
“ALV
DATA: gt_fcat TYPE lvc_t_fcat, " 主屏幕
gs_layo TYPE lvc_s_layo,
gv_title TYPE lvc_title,
gs_variant TYPE disvariant,
gt_event TYPE slis_t_event.
DATA stylelin TYPE lvc_s_styl.
DATA gt_fcat1 TYPE slis_t_fieldcat_alv .” 子屏幕
DATA ls_fcat1 LIKE LINE OF gt_fcat1.
DATA: gs_stable TYPE lvc_s_stbl. "ALV刷新
RANGES: r_fkdat FOR vbrp-fkdat_ana.
START-OF-SELECTION .
AUTHORITY-CHECK OBJECT ‘F_BKPF_BUK’ ID ‘BUKRS’ FIELD s_bukrs-low
ID ‘ACTVT’ DUMMY.
IF sy-subrc <> 0.
MESSAGE e889 WITH ‘没有公司代码权限’.
ENDIF.
PERFORM perbl_wtg. " 构建 WTG*与期间的关系
PERFORM get_data. " 取主数逻辑 组装数据 主营业务数据
PERFORM get_data_wtg00." 组装数据,获取发出商品阶段数据并组装
PERFORM get_data_tot. " 组装数据,获取生产阶段数据并组装
PERFORM frm_deal_data.“最后处理
PERFORM frm_alv.” 报表展示以及功能实现
&---------------------------------------------------------------------
*& Form get_data
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM get_data .
"VBRP-BUKRS_ANA、VBRP-AUPOS AUBEL、VBRP-AUPOS、VBAP-ZPRONO查询以下数据:
SELECT
a~bukrs_ana AS bukrs,
a~fkdat_ana,
a~aubel,
a~aupos,
c~zprono,
a~kunag_ana,
a~kunrg_ana,
a~kunwe_ana,
a~kunre_ana,
a~matnr,
a~netwr,
a~mwsbp,
a~wavwr,
a~vbeln,
a~posnr,
a~vgbel,
a~vgpos,
b~bstdk,
b~zsource1,
b~zsource2,
IF s_jahr[] IS NOT INITIAL.
DELETE lt_vbrp WHERE fkdat_ana(4) NOT IN s_jahr.
ENDIF.
IF s_perbl[] IS NOT INITIAL.
DELETE lt_vbrp WHERE fkdat_ana+4(2) NOT IN s_perbl.
ENDIF.
IF lt_vbrp[] IS NOT INITIAL .
**6 根据VBRP-VGBEL = LIKP-VBELN,取LIKP-WADAT_IST 实际货物移动日期;
SELECT
vbeln,
wadat_ist
FROM likp
FOR ALL ENTRIES IN @lt_vbrp WHERE vbeln = @lt_vbrp-vgbel
INTO TABLE @DATA(lt_likp).
**7、根据VBRP-MATNR = MBEW-MATNR,取MBEW-BKLAS; 评估类
SELECT
matnr,
mbew~bklas,
bkbez
FROM mbew
INNER JOIN t025t ON mbew~bklas = t025t~bklas AND spras = @sy-langu
FOR ALL ENTRIES IN @lt_vbrp WHERE matnr = @lt_vbrp-matnr
INTO TABLE @DATA(lt_mbew).
**9、根据VBRP-MATNR = MARA-MATNR,取MARA-MATKL;物料组
"VBRP-MATNR = MAKT-MATNR,where MAKT-SPRAS = ‘ZH’,取KAKT-MAKTX;
SELECT
mara~matnr,
makt~maktx,
mara~matkl,
t023t~wgbez60 AS wgbez
FROM mara
LEFT JOIN t023t ON mara~matkl = t023t~matkl AND spras = @sy-langu
LEFT JOIN makt ON mara~matnr = makt~matnr AND makt~spras = @sy-langu
FOR ALL ENTRIES IN @lt_vbrp WHERE mara~matnr = @lt_vbrp-matnr
INTO TABLE @DATA(lt_mara)…
**12、根据VBRP-KUNAG_ANA = KNA1-KUNNR OR VBRP-KUNRG_ANA = KNA1-KUNNR
**OR VBRP-KUNWE_ANA = KNA1-KUNNR OR VBRP-KUNRE_ANA = KNA1-KUNNR,各自取描述:KNA1-NAME1;
SELECT
kunnr,
name1,
katr1,
zkunag
FROM
kna1
FOR ALL ENTRIES IN @lt_vbrp WHERE kunnr = @lt_vbrp-kunag_ana
INTO TABLE @DATA(lt_kna1).
"主营业务成本(销售订单后发出商品转主营业务成本) 分配字段为空
SELECT
a~rldnr,
a~rbukrs,
a~gjahr,
a~belnr,
a~docln,
a~kdauf AS vbel2,
a~kdpos AS posn2,
a~hsl AS dmbtr
FROM acdoca AS a
FOR ALL ENTRIES IN @lt_vbrp
WHERE a~blart = 'SA' AND a~kdauf = @lt_vbrp-aubel AND a~kdpos = @lt_vbrp-aupos
AND a~gkont LIKE '1406%' AND a~racct IN ('6401010300','6401010100','6401010200')
AND NOT EXISTS ( SELECT mandt FROM coas AS b WHERE b~aufnr = a~zuonr )
INTO TABLE @DATA(lt_bseg_unaufnr).
REFRESH:lt_bseg_mov.
LOOP AT lt_bseg_unaufnr INTO DATA(ls_bseg_unaufnr).
CLEAR:lt_bseg_mov.
MOVE-CORRESPONDING ls_bseg_unaufnr TO lt_bseg_mov.
COLLECT lt_bseg_mov.
ENDLOOP.
"主营业务成本(发出商品内部订单结转到主营业务成本) 内部订单填写分配字段
SELECT
a~rldnr,
a~rbukrs,
a~gjahr,
a~belnr,
a~docln,
a~kdauf AS vbel2,
a~kdpos AS posn2,
a~hsl AS dmbtr
FROM acdoca AS a
JOIN coas AS b ON a~zuonr = b~aufnr AND a~zzxmbm = b~aufex
FOR ALL ENTRIES IN @lt_vbrp
WHERE a~blart = 'SA' AND a~kdauf = @lt_vbrp-aubel AND a~kdpos = @lt_vbrp-aupos
AND a~gkont LIKE '1406%' AND a~racct IN ('6401010300','6401010100','6401010200')
INTO TABLE @DATA(lt_bseg_aufnr).
REFRESH:lt_bseg_mov1.
LOOP AT lt_bseg_aufnr INTO DATA(ls_bseg_aufnr).
CLEAR:lt_bseg_mov.
MOVE-CORRESPONDING ls_bseg_aufnr TO lt_bseg_mov.
COLLECT lt_bseg_mov INTO lt_bseg_mov1.
ENDLOOP.
"运输费用
" 取1410*的对方科目的金额汇总
SELECT
a~rldnr,
a~rbukrs,
a~gjahr,
a~belnr,
a~docln,
a~kdauf AS vbel2,
a~kdpos AS posn2,
a~hsl AS dmbtr
FROM acdoca AS a
FOR ALL ENTRIES IN @lt_vbrp
WHERE a~blart = 'SA' AND a~kdauf = @lt_vbrp-aubel AND a~kdpos = @lt_vbrp-aupos
AND a~gkont LIKE '1410%' AND a~racct IN ('6401010300','6401010100','6401010200')
INTO TABLE @DATA(lt_bseg).
REFRESH: lt_bseg_mov2.
LOOP AT lt_bseg INTO DATA(ls_bseg).
CLEAR:lt_bseg_mov.
MOVE-CORRESPONDING ls_bseg TO lt_bseg_mov.
COLLECT lt_bseg_mov INTO lt_bseg_mov2.
ENDLOOP.
SELECT
kdauf,
kdpos,
wsl ,
racct
FROM
acdoca
FOR ALL ENTRIES IN @lt_vbrp WHERE kdauf = @lt_vbrp-aubel AND kdpos = @lt_vbrp-aupos
AND racct IN ('1423010000 ','1423020000 ','1122010100','1122010200','2204010000','2204020000') AND blart = 'DZ'
INTO CORRESPONDING FIELDS OF TABLE @lt_acdoca1 .
LOOP AT lt_acdoca1.
COLLECT lt_acdoca1 INTO lt_acdoca1_mov.
ENDLOOP.
** "客户预收款
** SELECT
** KDAUF,
** KDPOS,
** WSL ,
** RACCT
** from
** ACDOCA
** FOR ALL ENTRIES IN @lt_vbrp where KDAUF = @lt_vbrp-aubel and KDPOS = @lt_vbrp-aupos
** and RACCT in ('2203010000 ','2203020000 ')
** into CORRESPONDING FIELDS OF TABLE @lt_acdoca1 .
**
** LOOP AT lt_acdoca1.
** COLLECT lt_acdoca1 INTO lt_acdoca1_mov.
** ENDLOOP.
**
** " 客户收款
** SELECT
** KDAUF,
** KDPOS,
** WSL,
** RACCT
** from
** ACDOCA
** FOR ALL ENTRIES IN @lt_vbrp where KDAUF = @lt_vbrp-aubel and KDPOS = @lt_vbrp-aupos
** and RACCT in ('2203010000 ','2203020000 ')
** into CORRESPONDING FIELDS OF TABLE @lt_acdoca2.
**
** LOOP AT lt_acdoca2.
** COLLECT lt_acdoca2 INTO lt_acdoca2_mov.
** ENDLOOP.
ENDIF.
LOOP AT lt_vbrp . " 组装基本数据
READ TABLE lt_likp ASSIGNING FIELD-SYMBOL() WITH KEY vbeln = lt_vbrp-vgbel.
IF sy-subrc = 0.
lt_vbrp-wadat_ist = -wadat_ist.
ENDIF.
READ TABLE lt_mbew ASSIGNING FIELD-SYMBOL() WITH KEY matnr = lt_vbrp-matnr.
IF sy-subrc = 0.
lt_vbrp-bklas = -bklas.
lt_vbrp-bkbez = -bkbez.
ENDIF.
READ TABLE lt_mara ASSIGNING FIELD-SYMBOL() WITH KEY matnr = lt_vbrp-matnr.
IF sy-subrc = 0.
lt_vbrp-maktx = -maktx.
lt_vbrp-matkl = -matkl.
lt_vbrp-wgbez = -wgbez.
ENDIF.
READ TABLE lt_kna1 ASSIGNING FIELD-SYMBOL() WITH KEY kunnr = lt_vbrp-kunag_ana.
IF sy-subrc = 0.
lt_vbrp-name1 = -name1.
lt_vbrp-zkunag_name1 = -name1.
lt_vbrp-zkunag = -zkunag.
lt_vbrp-zattr1 = -katr1.
ENDIF.
lt_vbrp-netwr1 = lt_vbrp-netwr + lt_vbrp-mwsbp. " 合同金额(含税)= (VBRP-NETWR)+(VBRP-MWSBP);
"主营业务成本(销售订单后发出商品转主营业务成本)(无内部订单)
READ TABLE lt_bseg_mov ASSIGNING FIELD-SYMBOL() WITH KEY vbel2 = lt_vbrp-aubel posn2 = lt_vbrp-aupos.
IF sy-subrc = 0.
lt_vbrp-dmbtr = -dmbtr.
ENDIF.
"主营业务成本(发出商品内部订单结转到主营业务成本)(有内部订单)
READ TABLE lt_bseg_mov1 ASSIGNING WITH KEY vbel2 = lt_vbrp-aubel posn2 = lt_vbrp-aupos.
IF sy-subrc = 0.
lt_vbrp-dmbtr1 = -dmbtr.
ENDIF.
"运输费用=从合同履约成本科目(1410*)转到主营业务成本时 "取1410* 对方科目的S(和)-H(和) 的值
READ TABLE lt_bseg_mov2 ASSIGNING WITH KEY vbel2 = lt_vbrp-aubel posn2 = lt_vbrp-aupos.
IF sy-subrc = 0.
lt_vbrp-dmbtr2 = -dmbtr.
ENDIF.
此处还未计算完成,需要计算完成后再计算主营业务成本
lt_vbrp-dmbtr3 = lt_vbrp-wavwr + lt_vbrp-dmbtr + lt_vbrp-dmbtr1 + lt_vbrp-dmbtr2."主营业务成本合计
lt_vbrp-dmbtr4 = lt_vbrp-netwr - lt_vbrp-dmbtr3 . "毛利
PERFORM put_sign_front USING lt_vbrp-dmbtr4 lt_vbrp-dmbtr4_str.
IF lt_vbrp-netwr <> 0.
lt_vbrp-gross = lt_vbrp-dmbtr4 / lt_vbrp-netwr." 毛利率
gross_mid = lt_vbrp-gross * 100.
lt_vbrp-gross_str = gross_mid && '%'.
" lt_vbrp-gross = gross_str.
ENDIF.
READ TABLE lt_acdoca1_mov WITH KEY KDAUF = lt_vbrp-aubel KDPOS = lt_vbrp-aupos.
IF sy-subrc = 0.
IF lt_acdoca1_mov-wsl > 0 . "客户预收款:借方+贷方之后取贷方负数余额,如果借方+贷方余额在借方,则收款金额为零
lt_acdoca1_mov-wsl = 0.
ENDIF.
READ TABLE lt_acdoca2_mov WITH KEY KDAUF = lt_vbrp-aubel KDPOS = lt_vbrp-aupos.
IF sy-subrc = 0.
IF lt_acdoca2_mov-wsl > 0 . "客户收款:借方+贷方之后取贷方负数余额,如果借方+贷方余额在借方,则收款金额为零
lt_acdoca2_mov-wsl = 0.
ENDIF.
lt_vbrp-dmbtr6 = lt_acdoca1_mov-wsl + lt_vbrp-netwr1 - lt_acdoca2_mov-wsl ."已回收金额 = 客户预收款+ 合同金额-客户收款
ENDIF.
READ TABLE lt_acdoca1_mov WITH KEY kdauf = lt_vbrp-aubel kdpos = lt_vbrp-aupos.
IF sy-subrc = 0.
lt_vbrp-dmbtr6 = lt_acdoca1_mov-wsl."已回收金额
PERFORM put_sign_front USING lt_vbrp-dmbtr6 lt_vbrp-dmbtr6_str.
ENDIF.
lt_vbrp-dmbtr7 = lt_vbrp-netwr1 - lt_vbrp-dmbtr6.
PERFORM put_sign_front USING lt_vbrp-dmbtr7 lt_vbrp-dmbtr7_str.
READ TABLE lt_acdoca2_mov WITH KEY KDAUF = lt_vbrp-aubel KDPOS = lt_vbrp-aupos.
IF sy-subrc = 0.
IF lt_acdoca2_mov-wsl > 0 . "客户收款:借方+贷方之后取贷方负数余额,如果借方+贷方余额在借方,则收款金额为零
lt_acdoca2_mov-wsl = 0.
ENDIF.
lt_vbrp-dmbtr6 = lt_acdoca1_mov-wsl + lt_vbrp-netwr1 - lt_acdoca2_mov-wsl ."已回收金额 = 客户预收款+ 合同金额-客户收款
ENDIF.
ENDIF.
"dmbtr6 "已回收金额
CATCH SYSTEM-EXCEPTIONS arithmetic_errors = 4
OTHERS = 8.
IF lt_vbrp-NETWR <> 0.
lt_vbrp-gross = lt_vbrp-dmbtr4 / lt_vbrp-NETWR." 毛利率
ENDIF.
ENDCATCH.
IF sy-subrc <> 0. " 捕捉溢出
RETURN.
ENDIF.
MODIFY lt_vbrp.
ENDLOOP.
ENDFORM.
&---------------------------------------------------------------------
*& Form frm_alv
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_alv .
PERFORM frm_set_alv_parameter.
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY_LVC’
EXPORTING
i_callback_program = sy-repid
is_layout_lvc = gs_layo
it_fieldcat_lvc = gt_fcat
TABLES
t_outtab = lt_vbrp[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDFORM.
&---------------------------------------------------------------------
*& Form perbl_wtg
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
& <-- p2 text
&---------------------------------------------------------------------
FORM perbl_wtg .
*** 构建 WTG与期间的关系
DATA wtg00(6) TYPE c.
DATA wtgx TYPE perbl VALUE 001.
DO 16 TIMES.
wtg00 = 'WTG' && wtgx ."lt_wtgfield-perbl.
lt_wtgfield-wtg00 = wtg00 .
lt_wtgfield-perbl = lt_wtgfield-perbl + 1.
IF sy-index > 12 .
lt_wtgfield-perbl = 012.
ENDIF.
wtgx = wtgx + 1.
APPEND lt_wtgfield.
ENDDO.
ENDFORM.
&---------------------------------------------------------------------
*& Form get_data_wtg00
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM get_data_wtg00 .
*** 根据销售订单与行项目取数
IF lt_vbrp[] IS NOT INITIAL.
SELECT
a~kdauf,
a~kdpos,
a~aufnr,
b~lednr,
b~objnr,
b~gjahr,
b~wrttp,
b~versn,
b~kstar,
b~hrkft,
b~vrgng,
b~vbund,
b~pargb,
b~beknz,
b~twaer,
" a~aufex,
" a~objnr,
" b~kstar,
b~wtg001,
b~wtg002,
b~wtg003,
b~wtg004,
b~wtg005,
b~wtg006,
b~wtg007,
b~wtg008,
b~wtg009,
b~wtg010,
b~wtg011,
b~wtg012,
b~wtg013,
b~wtg014,
b~wtg015,
b~wtg016,
c~zcpzt,"产品状态 生产阶段 发出商品阶段
c~zfylx"费用类型 原材料 人工工时等
FROM coas AS a
INNER JOIN cosp AS b
ON a~objnr = b~objnr AND b~wrttp = ‘04’
AND b~versn = ‘000’
AND b~beknz = ‘A’
AND ( b~beknz = 'H' OR b~beknz = 'S')
INNER JOIN ztco004 AS c
ON c~saknr = b~kstar AND zcpzt = 'B'"IN ('','B' )" --------------- 缺少生成阶段待提供
INTO TABLE @DATA(lt_cosp)
FOR ALL ENTRIES IN @lt_vbrp
WHERE a~kdauf = @lt_vbrp-aubel
AND a~kdpos = @lt_vbrp-aupos
AND b~gjahr IN @s_jahr
AND b~perbl IN @s_perbl.
**** 根据项目号
SELECT
a~kdauf,
a~kdpos,
a~aufex, " 项目号
a~objnr,
" b~kstar, "科目
b~wtg001,
b~wtg002,
b~wtg003,
b~wtg004,
b~wtg005,
b~wtg006,
b~wtg007,
b~wtg008,
b~wtg009,
b~wtg010,
b~wtg011,
b~wtg012,
b~wtg013,
b~wtg014,
b~wtg015,
b~wtg016,
c~zcpzt,"产品状态 生产阶段 发出商品阶段
c~zfylx"费用类型 原材料 人工工时等
FROM coas AS a
INNER JOIN cosp AS b
ON a~objnr = b~objnr AND b~wrttp = '04'
AND b~versn = '000' AND ( b~beknz = 'H' OR b~beknz = 'S')
INNER JOIN ztco004 AS c
ON c~saknr = b~kstar AND zcpzt = 'B' "IN ('A','B' )" --------------- 缺少生成阶段待提供 暂定A
INTO CORRESPONDING FIELDS OF TABLE @lt_cosp2
WHERE b~gjahr IN @s_jahr.
ENDIF.
DELETE lt_wtgfield WHERE perbl NOT IN s_perbl.
SORT lt_wtgfield BY perbl.
DATA(table_num) = lines( lt_wtgfield ).
DATA name_field1 TYPE c LENGTH 6.
DATA num TYPE cosp-perbl.
DATA(lt_cosp_b) = lt_cosp[].
DATA lv_wtg LIKE cosp-wtg001.
delete lt_cosp_b WHERE zcpzt = ‘B’. "lt_cosp_b 发出商品阶段
delete lt_cosp WHERE zcpzt = ‘A’. "lt_cosp 生产商品阶段
" 根据销售订单 行项目 产品状态 费用类型 纵向发出商品阶段汇总各个wtg
LOOP AT lt_cosp_b ASSIGNING FIELD-SYMBOL(
CLEAR:lt_cosp_b_sum.
MOVE-CORRESPONDING
COLLECT lt_cosp_b_sum.
ENDLOOP.
READ TABLE lt_wtgfield INDEX 1.
LOOP AT lt_cosp_b_sum.
" 汇总横向比如 期间 010-012 则汇总wgt010*wgt011 *wgt012 wgt013 wgt014 wgt015 wgt016
num = lt_wtgfield-perbl.
DO table_num TIMES.
name_field1 = 'WTG' && num.
ASSIGN COMPONENT name_field1 OF STRUCTURE lt_cosp_b_sum TO .
lt_cosp_b_sum-wtgxx = lt_cosp_b_sum-wtgxx + .
num = num + 1.
ENDDO.
MODIFY lt_cosp_b_sum.
ENDLOOP.
LOOP AT lt_cosp2 ASSIGNING FIELD-SYMBOL(
COLLECT
ENDLOOP.
LOOP AT lt_cosp2_sum.
" 汇总横向比如 期间 010-012 则汇总wgt010*wgt011 *wgt012 wgt013 wgt014 wgt015 wgt016
num = lt_wtgfield-perbl.
DO table_num TIMES.
name_field1 = 'WTG' && num.
ASSIGN COMPONENT name_field1 OF STRUCTURE lt_cosp2_sum TO .
lt_cosp2_sum-wtgxx = lt_cosp2_sum-wtgxx + .
num = num + 1.
ENDDO.
ENDLOOP.
SORT lt_cosp2_sum BY aufex.
SORT lt_cosp_b_sum BY kdauf kdpos.
LOOP AT lt_vbrp . " 组装数据
"zcpzt = ‘B’ 为发出商品阶段
READ TABLE lt_cosp INTO DATA(ls_cosp) WITH KEY kdauf = lt_vbrp-aubel kdpos = lt_vbrp-aupos.
IF sy-subrc = 0.
lt_vbrp-aufnr = ls_cosp-aufnr.
ENDIF.
READ TABLE lt_cosp_b_sum WITH KEY kdauf = lt_vbrp-aubel kdpos = lt_vbrp-aupos zcpzt = ‘B’ zfylx = 01 BINARY SEARCH . " 原材料 根据销售订单
IF sy-subrc = 0.
lt_vbrp-wtg001 = lt_cosp_b_sum-wtgxx.
ENDIF.
IF lt_cosp_b_sum-wtgxx <> lt_cosp2_sum-wtgxx . " 如果两者不一致,则以项目为准
lt_vbrp-wtg001 = lt_cosp2_sum-wtgxx .
ENDIF.
READ TABLE lt_cosp_b_sum WITH KEY kdauf = lt_vbrp-aubel kdpos = lt_vbrp-aupos zcpzt = 'B' zfylx = 02 BINARY SEARCH . " 人工工时(费用) 根据销售订单
IF sy-subrc = 0.
lt_vbrp-wtg002 = lt_cosp_b_sum-wtgxx.
ENDIF.
IF lt_cosp_b_sum-wtgxx <> lt_cosp2_sum-wtgxx . " 如果两者不一致,则以项目为准
lt_vbrp-wtg002 = lt_cosp2_sum-wtgxx .
ENDIF.
READ TABLE lt_cosp_b_sum WITH KEY kdauf = lt_vbrp-aubel kdpos = lt_vbrp-aupos zcpzt = 'B' zfylx = 03 BINARY SEARCH . " 机器工时(费用)) 根据销售订单
IF sy-subrc = 0.
lt_vbrp-wtg003 = lt_cosp_b_sum-wtgxx.
ENDIF.
IF lt_cosp_b_sum-wtgxx <> lt_cosp2_sum-wtgxx . " 如果两者不一致,则以项目为准
lt_vbrp-wtg003 = lt_cosp2_sum-wtgxx .
ENDIF.
READ TABLE lt_cosp_b_sum WITH KEY kdauf = lt_vbrp-aubel kdpos = lt_vbrp-aupos zcpzt = 'B' zfylx = 04 BINARY SEARCH . " 制造费用工时(费用) 根据销售订单
IF sy-subrc = 0.
lt_vbrp-wtg004 = lt_cosp_b_sum-wtgxx.
ENDIF.
IF lt_cosp_b_sum-wtgxx <> lt_cosp2_sum-wtgxx . " 如果两者不一致,则以项目为准
lt_vbrp-wtg004 = lt_cosp2_sum-wtgxx .
ENDIF.
lt_vbrp-wtg001 = lt_cosp_b_sum-wtgxx.
** READ TABLE lt_cosp2_sum WITH KEY aufex = lt_vbrp-zprono zcpzt = ‘A’ zfylx = 01 BINARY SEARCH . " 原材料 根据项目号
** IF sy-subrc = 0.
** IF lt_cosp_b_sum-wtgxx <> lt_cosp2_sum-wtgxx . " 如果两者不一致,则以项目为准
** lt_vbrp-wtg001 = lt_cosp2_sum-wtgxx .
** ENDIF.
** ENDIF.
*
lt_vbrp-wtg002 = lt_cosp_b_sum-wtgxx.
** READ TABLE lt_cosp2_sum WITH KEY aufex = lt_vbrp-zprono zcpzt = ‘A’ zfylx = 02 BINARY SEARCH . " 人工工时(费用)根据项目号
** IF sy-subrc = 0.
** IF lt_cosp_b_sum-wtgxx <> lt_cosp2_sum-wtgxx . " 如果两者不一致,则以项目为准
** lt_vbrp-wtg002 = lt_cosp2_sum-wtgxx .
** ENDIF.
** ENDIF.
*
lt_vbrp-wtg003 = lt_cosp_b_sum-wtgxx.
** READ TABLE lt_cosp2_sum WITH KEY aufex = lt_vbrp-zprono zcpzt = ‘A’ zfylx = 03 BINARY SEARCH . " 机器工时(费用)根据项目号
** IF sy-subrc = 0.
** IF lt_cosp_b_sum-wtgxx <> lt_cosp2_sum-wtgxx . " 如果两者不一致,则以项目为准
** lt_vbrp-wtg003 = lt_cosp2_sum-wtgxx .
** ENDIF.
** ENDIF.
*
lt_vbrp-wtg004 = lt_cosp_b_sum-wtgxx.
** READ TABLE lt_cosp2_sum WITH KEY aufex = lt_vbrp-zprono zcpzt = ‘A’ zfylx = 04 BINARY SEARCH . " 制造费用工时(费用)根据项目号
** IF sy-subrc = 0.
** IF lt_cosp_b_sum-wtgxx <> lt_cosp2_sum-wtgxx . " 如果两者不一致,则以项目为准
** lt_vbrp-wtg004 = lt_cosp2_sum-wtgxx .
** ENDIF.
** ENDIF.
MODIFY lt_vbrp.
ENDLOOP.
ENDFORM.
&---------------------------------------------------------------------
*& Form get_data_tot
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM get_data_tot .
DATA fname(6) TYPE c.
*关系:T001k.BWKEY = T001W.BWKEY
*
T001k.BUKRS = T001.BUKRS
**以下获取生产阶段数据
SELECT COUNT()
FROM t001 AS a
INNER JOIN t001k AS b ON a~bukrs = b~bukrs
INNER JOIN t001w AS c ON b~bwkey = c~bwkey
WHERE a~bukrs IN @s_bukrs AND c~werks IN @s_werks
.
IF sy-subrc = 0.
SELECT
COUNT(*)
FROM tck07
WHERE werks = ‘++++’ OR werks IN @s_werks .
ENDIF.
IF sy-subrc = 0.
SELECT
c~vbeln,
c~posnr,
m~jahrper,
SUM( m~tot ) AS tot,
t2~elemt
FROM ckmlhd AS c
INNER JOIN mldocccs_extract AS m ON m~kalnr = c~kalnr
INNER JOIN tckh3 AS t2 ON t2~elehk = ‘Z1’ AND m~element = t2~elemt
"FOR ALL ENTRIES IN @lt_vbrp WHERE vbeln = @lt_vbrp-aubel and posnr = @lt_vbrp-aupos
WHERE c~bwkey IN @s_werks AND m~elesmhk = ‘Z1’
AND c~matnr IN @s_matnr AND c~vbeln IN @s_aubel AND c~posnr IN @s_aupos
GROUP BY vbeln ,posnr ,m~jahrper, elemt
INTO TABLE @DATA(lt_totl) .
IF s_jahr IS NOT INITIAL.
DELETE lt_totl WHERE jahrper(4) NOT IN s_jahr.
ENDIF.
IF s_perbl IS NOT INITIAL.
DELETE lt_totl WHERE jahrper+4(3) NOT IN s_perbl.
ENDIF.
DATA: ls_totl LIKE LINE OF lt_totl,
lt_tot LIKE TABLE OF ls_totl.
LOOP AT lt_totl INTO ls_totl.
CLEAR: ls_totl-jahrper.
COLLECT ls_totl INTO lt_tot.
ENDLOOP.
SORT lt_tot BY vbeln posnr elemt.
ENDIF.
SELECT
a~elemt,
b~txele
FROM tckh3 AS a
INNER JOIN tckh1 AS b ON a~elehk = b~elehk AND a~elemt = b~elemt AND spras = @sy-langu
WHERE a~elehk = ‘Z1’
INTO TABLE @DATA(lt_tckh3).
SORT lt_tckh3 BY elemt.
**** 以下获取主营业务成本
**
**SELECT
** VBEL2,
** POSN2,
** DMBTR,
** "SUM( DMBTR ) as DMBTR,
** HKONT
** from bseg
** FOR ALL ENTRIES IN @lt_vbrp WHERE VBEL2 = @lt_vbrp-aubel and POSN2 = @lt_vbrp-aupos
** and HKONT LIKE ‘1406%’
** INTO TABLE @DATA(lt_bseg) .
LOOP AT lt_vbrp . "组装数据
LOOP AT lt_tckh3 ASSIGNING FIELD-SYMBOL(
fname = ‘TOT’ && sy-tabix.
READ TABLE lt_tot ASSIGNING FIELD-SYMBOL(
IF sy-subrc = 0.
ASSIGN COMPONENT fname OF STRUCTURE lt_vbrp TO FIELD-SYMBOL().
IF sy-subrc = 0.
= -tot.
ENDIF.
ENDIF.
ENDLOOP.
MODIFY lt_vbrp.
ENDLOOP.
ENDFORM.
&---------------------------------------------------------------------
*& Form frm_set_alv_parameter
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_set_alv_parameter .
DATA: ls_fcat TYPE lvc_s_fcat. "字段目录结构
DEFINE app_fcat.
CLEAR: ls_fcat.
ls_fcat-fieldname = &1. "字段名
ls_fcat-coltext = &2. "标题
ls_fcat-scrtext_s = &2. "短标签
ls_fcat-scrtext_m = &2. "中标签
ls_fcat-scrtext_l = &2. "长标签
ls_fcat-seltext = &2. "选择文本
ls_fcat-ref_table = &3. "参考表
ls_fcat-ref_field = &4. "参考字段
ls_fcat-cfieldname = &5. "金额单位字段
ls_fcat-qfieldname = &6. "数量单位字段
ls_fcat-outputlen = &7. "输出长度
IF ls_fcat-fieldname = ‘SEL’.
ls_fcat-checkbox = ‘X’.
ls_fcat-edit = ‘X’.
ENDIF.
APPEND ls_fcat TO gt_fcat.
END-OF-DEFINITION.
app_fcat ‘BUKRS’ ‘公司代码’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘BUTXT’ ‘公司代码描述’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘FKDAT_ANA’ ‘开票日期’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘AUBEL’ ‘销售凭证’ ‘VBAK’ ‘VBELN’ ‘’ ‘’ ‘10’.
app_fcat ‘AUPOS’ ‘销售凭证行项目’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘ZPRONO’ ‘项目号’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘KUNAG_ANA’ ‘售达方’ ‘KNA1’ ‘KUNNR’ ‘’ ‘’ ‘10’.
app_fcat ‘KUNRG_ANA’ ‘付款方’ ‘KNA1’ ‘KUNNR’ ‘’ ‘’ ‘10’.
app_fcat ‘KUNWE_ANA’ ‘送达方’ ‘KNA1’ ‘KUNNR’ ‘’ ‘’ ‘10’.
app_fcat ‘KUNRE_ANA’ ‘受票方’ ‘KNA1’ ‘KUNNR’ ‘’ ‘’ ‘10’.
app_fcat ‘MWSBP’ ‘税额’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘VBELN’ ‘开票凭证’ ‘VBRK’ ‘VBELN’ ‘’ ‘’ ‘10’.
app_fcat ‘POSNR’ ‘开票凭证项目’ ‘’ ‘’ ‘’ ‘’ ‘10’.
APP_FCAT 'VGBEL'
APP_FCAT 'VGPOS'
APP_FCAT 'WERKS'
app_fcat ‘NAME1’ ‘售达方描述’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘ZKUNAG’ ‘所属母公司’ ‘KNA1’ ‘KUNNR’ ‘’ ‘’ ‘10’.
app_fcat ‘ZKUNAG_NAME1’ ‘所属的母公司描述’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘MATKL’ ‘产品类别’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘WGBEZ’ ‘产品类别描述’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘BKLAS’ ‘产品系列’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘BKBEZ’ ‘产品系列描述’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘MATNR’ ‘物料号’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘MAKTX’ ‘物料描述’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘NETWR’ ‘原账面确认收入’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘NETWR1’ ‘合同金额(含税)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘TOT1’ ‘原材料’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘TOT2’ ‘半成品’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘TOT3’ ‘产成品’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘TOT4’ ‘其他辅料’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘TOT5’ ‘委外发出材料’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘TOT6’ ‘委外加工费’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘TOT7’ ‘委外-结转’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘TOT8’ ‘生产阶段-人工工时(费用)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘TOT9’ ‘生产阶段-机器工时(费用)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘TOT10’ ‘生产阶段-制造费用工时(费用)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘AUFNR’ ‘内部订单号’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘WTG001’ ‘发出商品-原材料’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘WTG002’ ‘发出商品-人工工时(费用)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘WTG003’ ‘发出商品-机器工时(费用)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘WTG004’ ‘发出商品-研发费用工时(费用)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘WAVWR’ ‘主营业务成本(销售订单成本)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘DMBTR’ ‘主营业务成本(销售订单后发出商品转主营业务成本)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘DMBTR1’ ‘主营业务成本(发出商品内部订单结转到主营业务成本)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘DMBTR2’ ‘运输费用’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘DMBTR3’ ‘主营业务成本合计’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘DMBTR4_STR’ ‘毛利’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘GROSS_STR’ ‘毛利率’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘BSTDK’ ‘合同日期’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘WADAT_IST’ ‘实际发货日期’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘ZWAPRD’ ‘质保期(月)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘ZDAY’ ‘验收周期(天)’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘ZSOURCE1’ ‘订单取得方式’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘ZSOURCE2’ ‘代理商名称’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘ZATTR1’ ‘应用领域’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘LAND1’ ‘地区’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘DMBTR6_STR’ ‘已回款金额’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘DMBTR7_STR’ ‘未回款金额’ ‘’ ‘’ ‘’ ‘’ ‘10’.
app_fcat ‘ZTERM’ ‘付款条件’ ‘’ ‘’ ‘’ ‘’ ‘10’.
gs_layo-cwidth_opt = ‘X’. "Colwidth optimize
gs_layo-zebra = ‘X’. "斑马线
ENDFORM.
&---------------------------------------------------------------------
*& Form put_sign_front
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM put_sign_front USING in_dmbtr TYPE dmbtr out_dmbtr TYPE string.
TABLES : bseg.
DATA : e_dmbtr TYPE string.
e_dmbtr = in_dmbtr.
CALL FUNCTION ‘CLOI_PUT_SIGN_IN_FRONT’
CHANGING
value = e_dmbtr.
out_dmbtr = e_dmbtr.
ENDFORM.
&---------------------------------------------------------------------
*& Form frm_deal_data
&---------------------------------------------------------------------
*& text
&---------------------------------------------------------------------
*& --> p1 text
*& <-- p2 text
&---------------------------------------------------------------------
FORM frm_deal_data .
LOOP AT lt_vbrp.
lt_vbrp-dmbtr3 = "lt_vbrp-wtg001 + lt_vbrp-wtg002 + lt_vbrp-wtg003 + lt_vbrp-wtg004 +
lt_vbrp-wavwr + lt_vbrp-dmbtr + lt_vbrp-dmbtr1 + lt_vbrp-dmbtr2."主营业务成本合计
lt_vbrp-dmbtr4 = lt_vbrp-netwr - lt_vbrp-dmbtr3 . "毛利
PERFORM put_sign_front USING lt_vbrp-dmbtr4 lt_vbrp-dmbtr4_str.
IF lt_vbrp-netwr <> 0.
lt_vbrp-gross = lt_vbrp-dmbtr4 / lt_vbrp-netwr." 毛利率
gross_mid = lt_vbrp-gross * 100.
lt_vbrp-gross_str = gross_mid && '%'.
" lt_vbrp-gross = gross_str.
ENDIF.
lt_vbrp-zday = lt_vbrp-fkdat_ana - lt_vbrp-wadat_ist."验收周期(天)=开票日期-实际发货日期
MODIFY lt_vbrp.
ENDLOOP.
ENDFORM.