*&---------------------------------------------------------------------* *& 包含 ZRFI0058_FRM *&---------------------------------------------------------------------* *&---------------------------------------------------------------------* *& Form FRM_GET_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_get_data . "获取本位币 SELECT bukrs waers butxt FROM t001 INTO CORRESPONDING FIELDS OF TABLE gt_t001 WHERE bukrs = p_bukrs. "获取起初金额 SELECT ryear, rbukrs,racct, SUM( hslvt ) AS hslvt, SUM( hsl01 ) AS hsl01, SUM( hsl02 ) AS hsl02, SUM( hsl03 ) AS hsl03, SUM( hsl04 ) AS hsl04, SUM( hsl05 ) AS hsl05, SUM( hsl06 ) AS hsl06, SUM( hsl07 ) AS hsl07, SUM( hsl08 ) AS hsl08, SUM( hsl09 ) AS hsl09, SUM( hsl10 ) AS hsl10, SUM( hsl11 ) AS hsl11, SUM( hsl12 ) AS hsl12, SUM( hsl13 ) AS hsl13, SUM( hsl14 ) AS hsl14, SUM( hsl15 ) AS hsl15, SUM( hsl16 ) AS hsl16 FROM faglflext INTO CORRESPONDING FIELDS OF TABLE @gt_faglflext WHERE rbukrs = @p_bukrs AND ryear = @p_gjahr AND rldnr = '0L' AND racct IN @s_racct GROUP BY ryear,rbukrs,racct. "计算期初汇总 PERFORM frm_get_hslvt. CLEAR:lv_waers,lv_rate,lv_kurst. LOOP AT lt_fagsum INTO ls_fagsum. "勾选本位币 READ TABLE gt_t001 INTO gs_t001 WITH KEY bukrs = ls_fagsum-rbukrs. IF sy-subrc = 0. lv_waers = gs_t001-waers. lv_kurst = ''. lv_rate = ''. ENDIF. "勾选集团货币 IF p_tcurr IS NOT INITIAL. **********选择 001货币资金 004其他非流动资产取标准汇率 IF p_001 IS NOT INITIAL OR p_004 IS NOT INITIAL. PERFORM frm_get_exch_rate. ELSE. **********其他项目从汇率自建表取数 PERFORM frm_get_zf0i058_rate. ENDIF. ls_fagsum-hslvt = ls_fagsum-hslvt * lv_rate. ENDIF. ENDLOOP. **********计算公式 *********汇总数据到输出表 LOOP AT gt_acc INTO gs_acc . READ TABLE lt_fagsum INTO ls_fagsum WITH KEY racct = gs_acc-saknr rbukrs = gs_acc-bukrs. IF sy-subrc = 0. gs_acc-hslvt = ls_fagsum-hslvt. ENDIF. MODIFY gt_acc FROM gs_acc. CLEAR gs_acc. ENDLOOP. "按报表名称和项目汇总 LOOP AT gt_acc INTO gs_acc. CLEAR:gs_acc-saknr,gs_acc-txt50. COLLECT gs_acc INTO lt_acc. ENDLOOP. "整理输出ALV LOOP AT gt_zfi0058 INTO gs_zfi0058. gs_out-zreport = ls_acc-zreport. gs_out-zname = gs_zfi0058-zname. gs_out-zrow = gs_zfi0058-zrow. gs_out-zformula = gs_zfi0058-zformula. READ TABLE lt_acc INTO ls_acc WITH KEY zreport = gs_zfi0058-zreport zname = gs_zfi0058-zname. IF sy-subrc = 0. gs_out-zamount = ls_acc-hslvt. ENDIF. APPEND gs_out TO gt_out. CLEAR gs_out. ENDLOOP. "弹框更新数据 PERFORM frm_popup_data. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_DISPLAY *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_display . CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' EXPORTING i_callback_program = sy-repid * i_callback_pf_status_set = 'FRM_PF_STATUS' * i_callback_user_command = 'FRM_USER_COMMAND' i_callback_top_of_page = 'FRM_TOP_OF_PAGE' is_layout_lvc = gs_layout it_fieldcat_lvc = gt_fieldcat * I_DEFAULT = 'X' i_save = 'A' TABLES t_outtab = gt_out[]. IF sy-subrc <> 0. * Implement suitable error handling here ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_FIELDCAT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_fieldcat . DEFINE fieldcat. gs_fieldcat-key = &1. gs_fieldcat-fieldname = &2. gs_fieldcat-scrtext_l = &3. * gs_fieldcat-edit = &4. * gs_fieldcat-no_zero = &5. * gs_fieldcat-ref_tabname = &6. * gs_fieldcat-ref_fieldname = &7. APPEND gs_fieldcat TO gt_fieldcat. END-OF-DEFINITION. fieldcat '' 'ZNAME' '项目' . fieldcat '' 'ZAMOUNT' '金额' . ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_LAYOUT *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_layout . gs_layout-cwidth_opt = 'X'. gs_layout-zebra = 'X' . ENDFORM. *&---------------------------------------------------------------------* *& Form frm_init_data *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_init_data . *获取报表行 SELECT * FROM zzt_zfi0058 INTO CORRESPONDING FIELDS OF TABLE gt_zfi0058 WHERE zreport IN s_zreport. *获取报表科目信息 SELECT * FROM zzt_zfi0058_acc INTO CORRESPONDING FIELDS OF TABLE gt_acc WHERE bukrs = p_bukrs AND zreport IN s_zreport. LOOP AT gt_acc INTO gs_acc. s_racct-sign = 'I'. s_racct-option = 'EQ'. s_racct-low = gs_acc-saknr. APPEND s_racct. ENDLOOP. ENDFORM. *&---------------------------------------------------------------------* *& Form frm_get_display *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_get_display . SELECT * FROM zzt_zfi0058_log INTO CORRESPONDING FIELDS OF TABLE gt_out WHERE bukrs = p_bukrs AND gjahr = p_gjahr AND monat = p_monat AND zreport IN s_zreport. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_GET_exch_rate *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_get_exch_rate . DATA lv_datum TYPE sy-datum. CLEAR: lv_datum. lv_datum = p_gjahr && p_monat && 01. CALL FUNCTION 'BKK_GET_MONTH_LASTDAY' EXPORTING i_date = lv_datum IMPORTING e_date = lv_datum. "获取汇率 CALL FUNCTION 'BAPI_EXCHANGERATE_GETDETAIL' EXPORTING rate_type = 'P' from_curr = lv_waers to_currncy = 'CNY' date = lv_datum IMPORTING exch_rate = ls_exch. * return = ls_return. IF ls_exch IS INITIAL. MESSAGE '请维护' && p_bukrs && p_gjahr && p_monat && lv_waers && '对应的汇率 'TYPE 'S' DISPLAY LIKE 'E'. LEAVE LIST-PROCESSING. ENDIF. lv_rate = ls_exch-exch_rate. lv_kurst = '04'. lv_waers = 'CNY'. ENDFORM. *----------------------------------------------------------------------* * FORM FRM_TOP_OF_PAGE *----------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM frm_top_of_page. DATA lt_listheader TYPE slis_t_listheader. "抬头标题 DATA ls_listheader TYPE slis_listheader. DATA lv_waers TYPE t001-waers. DATA lv_ktext TYPE tcurt-ktext. READ TABLE gt_t001 INTO gs_t001 INDEX 1. IF p_fcurr IS NOT INITIAL. "本位币 lv_waers = gs_t001-waers. ELSE. "集团货币默认CNY lv_waers = 'CNY'. ENDIF. SELECT SINGLE ktext INTO lv_ktext FROM tcurt WHERE spras = 1 AND waers = lv_waers. CLEAR ls_listheader. ls_listheader-typ = 'H'. "抬头信息类别 H为标题 S为内容 ls_listheader-info = gs_t001-butxt && p_gjahr && '年' && p_monat && '月' && lv_ktext. APPEND ls_listheader TO lt_listheader. CLEAR ls_listheader. ls_listheader-typ = 'S'. ls_listheader-key = lv_report. * ls_listheader-info = APPEND ls_listheader TO lt_listheader. CLEAR ls_listheader. ls_listheader-typ = 'S'. ls_listheader-key = lv_waers. APPEND ls_listheader TO lt_listheader. "调用显示页头函数 CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = lt_listheader i_logo = 'UNICHARM'. ENDFORM. *&---------------------------------------------------------------------* *& Form frm_get_zf0i058_rate *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_get_zf0i058_rate . SELECT * FROM zzt_zfi0058_rate INTO CORRESPONDING FIELDS OF TABLE gt_rate WHERE gjahr = p_gjahr AND monat = p_monat AND fcurr = lv_waers. IF gt_rate IS INITIAL. MESSAGE '请维护' && p_bukrs && p_gjahr && p_monat && lv_waers && '对应的汇率 'TYPE 'S' DISPLAY LIKE 'E'. LEAVE LIST-PROCESSING. ENDIF. READ TABLE gt_rate INTO gs_rate INDEX 1. IF p_s IS NOT INITIAL. lv_rate = gs_rate-ukurs_s. lv_kurst = '01'. ELSEIF p_hy IS NOT INITIAL. lv_rate = gs_rate-ukurs_hy. lv_kurst = '02'. ELSE. lv_rate = gs_rate-ukurs_y. lv_kurst = '03'. ENDIF. lv_waers = 'CNY'. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_CHECK_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_check_data . IF p_gjahr <= 2021. MESSAGE '仅可查看2022年后的报表数据!' TYPE 'S'DISPLAY LIKE 'E'. STOP. ENDIF. IF p_monat > 12. MESSAGE '禁止输入大于12的期间!' TYPE 'S' DISPLAY LIKE 'E'. STOP. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form frm_get_hslvt *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_get_hslvt . DATA: lv_hslvt TYPE faglflext-hslvt, gv_monat TYPE char2. gv_monat = p_monat. CLEAR:lv_hslvt. LOOP AT gt_faglflext INTO gs_faglflext. CLEAR:lv_hslvt,ls_fagsum. DATA(ls_sum) = gs_faglflext. MOVE-CORRESPONDING:gs_faglflext TO ls_fagsum. CLEAR ls_fagsum-hslvt. DO gv_monat + 1 TIMES VARYING lv_hslvt FROM ls_sum-hslvt NEXT ls_sum-hsl01. ls_fagsum-hslvt = ls_fagsum-hslvt + lv_hslvt. ENDDO. APPEND ls_fagsum TO lt_fagsum. ENDLOOP. "得到根据期间汇总后计算的金额 ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_POPUP_DATA *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_popup_data . lv_msg = p_gjahr && p_monat && p_bukrs && lv_waers &&'数据已存在,是否更新!'. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING text_question = lv_msg icon_button_1 = '是 ' icon_button_2 = '否 ' default_button = '2' display_cancel_button = 'X' start_column = 25 start_row = 6 IMPORTING answer = lv_answer EXCEPTIONS text_not_found = 1 OTHERS = 2. IF lv_answer = 1. LOOP AT gt_out INTO gs_out. gs_update-bukrs = p_bukrs. gs_update-gjahr = p_gjahr. gs_update-monat = p_monat. gs_update-monat = p_monat. gs_update-zreport = gs_out-zreport. gs_update-zrow = gs_out-zrow. gs_update-zname = gs_out-zname. gs_update-zamount = gs_out-zamount. gs_update-zwaers = lv_waers. gs_update-zkurst = lv_kurst.. gs_update-zukurs = lv_rate. APPEND gs_update TO gt_update. CLEAR gs_update. ENDLOOP. SORT gt_update BY zreport zname zrow. IF gt_update[] IS NOT INITIAL. MODIFY zzt_zfi0058_log FROM TABLE gt_update. COMMIT WORK AND WAIT. ENDIF. ELSE. * CLEAR gt_out[]. * PERFORM frm_get_display. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form FRM_GET_SCREEN *&---------------------------------------------------------------------* *& text *&---------------------------------------------------------------------* *& --> p1 text *& <-- p2 text *&---------------------------------------------------------------------* FORM frm_get_screen . LOOP AT SCREEN. IF p_fcurr IS NOT INITIAL. IF screen-group1 = 'M3' . screen-active = '0'. ELSE. screen-active = '1'. ENDIF. ENDIF. IF ( p_001 IS NOT INITIAL OR p_004 IS NOT INITIAL ) AND p_tcurr IS NOT INITIAL. IF screen-group1 = 'M3' . screen-active = '0'. ELSE. screen-active = '1'. ENDIF. ENDIF. MODIFY SCREEN. ENDLOOP. ENDFORM.
标签:p1,&---------------------------------------------------------------------,Fo From: https://www.cnblogs.com/Anyohh233/p/17980197