Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
************************************************************************ * 31/07/2009 Wille A. Alcântara * ************************************************************************ report zfiaa0001 message-id 00 line-size 723 no standard page heading. ************************************************************************ * Include para Ole Excel * ************************************************************************ include ole2incl. ************************************************************************ * Tabelas * ************************************************************************ tables: anla, anep, anlp. ************************************************************************ * Work Areas * ************************************************************************ data: begin of wa_anla, anln1 type anla-anln1, anln2 type anla-anln2, anlkl type anla-anlkl, end of wa_anla, begin of wa_anlc, anln1 type anlc-anln1, anln2 type anlc-anln2, gjahr type anlc-gjahr, kansw type anlc-kansw, knafa type anlc-knafa, end of wa_anlc, begin of wa_anea, anln1 type anea-anln1, anln2 type anea-anln2, gjahr type anea-gjahr, lnran type anea-lnran, nafav type anea-nafav, nafal type anea-nafal, end of wa_anea, begin of wa_anep, anln1 type anep-anln1, anln2 type anep-anln2, gjahr type anep-gjahr, lnran type anep-lnran, bwasl type anep-bwasl, anbtr type anep-anbtr, end of wa_anep, begin of wa_anek, anln1 type anek-anln1, anln2 type anek-anln2, lnran type anek-lnran, budat type anek-budat, end of wa_anek, begin of wa_anlp, anln1 type anlp-anln1, anln2 type anlp-anln2, gjahr type anlp-gjahr, afaber type anlp-afaber, nafap type anlp-nafap, nafag type anlp-nafag, nafaz type anlp-nafaz, end of wa_anlp, begin of wa_anlz, anln1 type anlz-anln1, anln2 type anlz-anln2, werks type anlz-werks, end of wa_anlz, begin of wa_ankt, anlkl type ankt-anlkl, txk20 type ankt-txk20, end of wa_ankt, begin of wa_t095b, ktogr type t095b-ktogr, afabe type t095b-afabe, ktnafb type t095b-ktnafb, end of wa_t095b, begin of wa_skat, saknr type skat-saknr, txt20 type skat-txt20, txt50 type skat-txt50, end of wa_skat. data: begin of wa_saida, classe type t095b-ktnafb, descr(20) type c, tot_ant1 type anlc-kansw, tot_ant2 type anlc-kansw, tot_ant3 type anlc-kansw, tot_ant4 type anlc-kansw, tot_ant5 type anlc-kansw, space_1 type c, at0102_1 type anlc-kansw, at0102_2 type anlc-kansw, at0102_3 type anlc-kansw, at0102_4 type anlc-kansw, at0102_5 type anlc-kansw, space_2 type c, at03_1 type anlc-kansw, at03_2 type anlc-kansw, at03_3 type anlc-kansw, at03_4 type anlc-kansw, at03_5 type anlc-kansw, space_3 type c, at04_1 type anlc-kansw, at04_2 type anlc-kansw, at04_3 type anlc-kansw, at04_4 type anlc-kansw, at04_5 type anlc-kansw, space_4 type c, at05_1 type anlc-kansw, at05_2 type anlc-kansw, at05_3 type anlc-kansw, at05_4 type anlc-kansw, at05_5 type anlc-kansw, space_5 type c, resu_1 type anlc-kansw, resu_2 type anlc-kansw, resu_3 type anlc-kansw, resu_4 type anlc-kansw, resu_5 type anlc-kansw, space_6 type c, total_1 type anlc-kansw, total_2 type anlc-kansw, total_3 type anlc-kansw, total_4 type anlc-kansw, total_5 type anlc-kansw, total_6 type anlc-kansw, total_7 type anlc-kansw, tipo type c, end of wa_saida, wa_totais like wa_saida, wa_campos type char72. ************************************************************************ * Tabelas Internas * ************************************************************************ data: t_anla like table of wa_anla, t_anlc like table of wa_anlc, t_anea like table of wa_anea, t_anep like table of wa_anep, t_anek like table of wa_anek, t_anlp like table of wa_anlp, t_anlz like table of wa_anlz, t_ankt like table of wa_ankt, t_t095b like table of wa_t095b, t_skat like table of wa_skat, t_saida like table of wa_saida, t_totais like table of wa_saida, t_select type table of char72. ************************************************************************ * Field-Symbols * ************************************************************************ field-symbols: <fs_campo> type any. ************************************************************************ * Variaveis * ************************************************************************ data: vg_ktopl type skat-ktopl value 'MONS', vg_real(02) type c value 'R$', vg_dolr(03) type c value 'USD', vg_at01 type werks value 'AT01', vg_at02 type werks value 'AT02', vg_at03 type werks value 'AT03', vg_at04 type werks value 'AT04', vg_at05 type werks value 'AT05', vg_020 type anep-bwasl value '020', vg_101 type anep-bwasl value '101', vg_114 type anep-bwasl value '114', vg_200 type anep-bwasl value '200', vg_300 type anep-bwasl value '300', vg_310 type anep-bwasl value '310', vg_331 type anep-bwasl value '331', vg_336 type anep-bwasl value '336', vg_338 type anep-bwasl value '338', vg_339 type anep-bwasl value '339', vg_dtin type d, vg_dtfi type d, vg_dtin_ant type d, vg_dtfi_ant type d, vg_c type c value 'C', vg_d type c value 'D', vg_z type c value 'Z', vg_x type c value 'X', vg_12104000 type anla-anlkl value '12104000', vg_12104001 type anla-anlkl value '12104001', vg_empresa type t001-butxt, vg_descr type t001-butxt, vg_atual(17) type c, vg_anterior(17) type c, vg_titulo(91) type c, vg_campo(30) type c. * Declarações Para OLE EXCEL data: vg_excel type ole2_object, vg_workbooks type ole2_object, vg_cells type ole2_object, vg_cell1 type ole2_object, vg_cell2 type ole2_object, vg_sheet type ole2_object, vg_col type i, vg_lin type i. ************************************************************************ * Selection-Screen * ************************************************************************ selection-screen begin of block blck with frame title text-000. parameter: p_bukrs like anla-bukrs obligatory, p_year like anlp-gjahr obligatory. select-options: s_peri for anlp-afbnr obligatory. parameter: p_afab like anep-afabe obligatory. selection-screen end of block blck. selection-screen begin of screen 0100 title text-039. parameter: p_ver as checkbox, p_file type rlgrap-filename obligatory. selection-screen end of screen 0100. ************************************************************************ * At Selection Screen * ************************************************************************ at selection-screen on value-request for p_file. perform f_salva_arquivo using p_file. ************************************************************************ * At User Command * ************************************************************************ at user-command. case sy-ucomm. when 'LEAV'. perform f_limpa_dados. leave to screen 0. when 'CANC'. perform f_limpa_dados. leave program. when 'BT_EXCEL'. perform: f_call_screen, f_gera_excel. endcase. ************************************************************************ * Start-Of-Selection * ************************************************************************ start-of-selection. set pf-status 'ZFIAA0001'. perform: f_trata_periodo, f_seleciona_dados, f_monta_saida, f_writer. end-of-selection. *&---------------------------------------------------------------------* *& Form f_trata_periodo *&---------------------------------------------------------------------* form f_trata_periodo. data: vl_periodo(02) type n, vl_ano(04) type n. if ( s_peri-low > 12 or s_peri-low < 01 ) or ( s_peri-high > 12 or s_peri-high < 01 ). message i398 with text-040 space space space. stop. endif. if s_peri-high is initial. s_peri-high = s_peri-low. concatenate p_year s_peri-low '01' into vg_dtin. perform f_convert_periodo using vg_dtin vg_dtfi. else. concatenate p_year s_peri-high '01' into vg_dtin. perform f_convert_periodo using vg_dtin vg_dtfi. concatenate p_year s_peri-low '01' into vg_dtin. endif. * Trata Período Anterior vl_periodo = s_peri-low - 1. vl_ano = p_year. if s_peri-low = '01'. vl_periodo = 12. vl_ano = p_year - 1. endif. concatenate vl_ano vl_periodo '01' into vg_dtin_ant. perform f_convert_periodo using vg_dtin_ant vg_dtfi_ant. endform. " f_trata_periodo *&---------------------------------------------------------------------* *& Form f_convert_periodo *&---------------------------------------------------------------------* form f_convert_periodo using p_dtin type d p_dtfi type d. call function 'LAST_DAY_OF_MONTHS' exporting day_in = p_dtin importing last_day_of_month = p_dtfi. if sy-subrc eq 0. endif. endform. " f_convert_periodo *&---------------------------------------------------------------------* *& Form f_seleciona_dados *&---------------------------------------------------------------------* form f_seleciona_dados. refresh t_select. perform f_monta_select using 'WA_ANEK'. select (t_select) from anek into table t_anek where bukrs eq p_bukrs and ( budat >= vg_dtin_ant and budat <= vg_dtfi ). if sy-subrc ne 0. message i398 with text-031 space space space. stop. endif. refresh t_select. perform f_monta_select using 'WA_ANLA'. select (t_select) from anla into table t_anla for all entries in t_anek where bukrs eq p_bukrs and anln1 eq t_anek-anln1 and anln2 eq t_anek-anln2. if sy-subrc ne 0. message i398 with text-029 space space space. stop. endif. refresh t_select. perform f_monta_select using 'WA_ANLC'. select (t_select) from anlc into table t_anlc for all entries in t_anek where bukrs eq p_bukrs and anln1 eq t_anek-anln1 and anln2 eq t_anek-anln2 and gjahr eq p_year. if sy-subrc ne 0. message i398 with text-030 space space space. stop. endif. refresh t_select. perform f_monta_select using 'WA_ANEA'. select (t_select) from anea into table t_anea for all entries in t_anek where bukrs eq p_bukrs and anln1 eq t_anek-anln1 and anln2 eq t_anek-anln2 and gjahr eq p_year and afabe eq p_afab. refresh t_select. perform f_monta_select using 'WA_ANEP'. select (t_select) from anep into table t_anep for all entries in t_anek where bukrs eq p_bukrs and anln1 eq t_anek-anln1 and anln2 eq t_anek-anln2 and gjahr eq p_year and afabe eq p_afab. refresh t_select. perform f_monta_select using 'WA_ANLP'. select (t_select) from anlp into table t_anlp for all entries in t_anek where bukrs eq p_bukrs and anln1 eq t_anek-anln1 and anln2 eq t_anek-anln2 and gjahr eq p_year and afaber eq p_afab. refresh t_select. perform f_monta_select using 'WA_ANLZ'. select (t_select) from anlz into table t_anlz for all entries in t_anek where bukrs eq p_bukrs and anln1 eq t_anek-anln1 and anln2 eq t_anek-anln2. refresh t_select. perform f_monta_select using 'WA_ANKT'. select (t_select) from ankt into table t_ankt for all entries in t_anla where spras = sy-langu and anlkl = t_anla-anlkl. refresh t_select. perform f_monta_select using 'WA_T095B'. select (t_select) from t095b into table t_t095b for all entries in t_anla where ktopl eq vg_ktopl and ktogr eq t_anla-anlkl and afabe eq p_afab. if sy-subrc eq 0. refresh t_select. perform f_monta_select using 'WA_SKAT'. select (t_select) from skat into table t_skat for all entries in t_t095b where saknr eq t_t095b-ktnafb and ktopl eq vg_ktopl and spras eq sy-langu. endif. endform. " f_seleciona_dados *&---------------------------------------------------------------------* *& Form f_monta_saida *&---------------------------------------------------------------------* form f_monta_saida. sort: t_anla by anln1 anln2, t_anlc by anln1 anln2, t_anep by anln1 anln2 lnran, t_anek by budat anln1 anln2 lnran, t_anea by anln1 anln2 lnran, t_anlp by anln1 anln2, t_anlz by anln1 anln2, t_t095b by ktogr ktnafb, t_skat by saknr. loop at t_anek into wa_anek. clear: wa_anla, wa_anlz, wa_t095b, wa_anea, wa_anlc, wa_anep. read table t_anla into wa_anla with key anln1 = wa_anek-anln1 anln2 = wa_anek-anln2 binary search. read table t_anlz into wa_anlz with key anln1 = wa_anla-anln1 anln2 = wa_anla-anln2 binary search. check sy-subrc eq 0. read table t_t095b into wa_t095b with key ktogr = wa_anla-anlkl binary search. read table t_skat into wa_skat with key saknr = wa_t095b-ktnafb binary search. read table t_ankt into wa_ankt with key anlkl = wa_anla-anlkl binary search. read table t_anea into wa_anea with key anln1 = wa_anla-anln1 anln2 = wa_anla-anln2 lnran = wa_anek-lnran binary search. read table t_anlc into wa_anlc with key anln1 = wa_anla-anln1 anln2 = wa_anla-anln2 binary search. read table t_anep into wa_anep with key anln1 = wa_anla-anln1 anln2 = wa_anla-anln2 lnran = wa_anek-lnran binary search. check sy-subrc eq 0. wa_saida-classe = wa_anla-anlkl. wa_saida-descr = wa_ankt-txk20. if wa_anla-anlkl eq vg_12104000 or wa_anla-anlkl eq vg_12104001. wa_saida-tipo = vg_z. else. wa_saida-tipo = vg_c. endif. if wa_anek-budat+4(02) eq vg_dtin_ant+4(02). * Tratamento para Bloco Inicial * Tratamento para Período Anterior ao indicado na Tela de Seleção perform f_trata_bloco_inicial. else. * Tratamento para Bloco Intermediário perform f_trata_intermediario. endif. clear: wa_saida. endloop. * Tratamento para Linhas de Totais sort: t_saida by tipo classe. loop at t_saida into wa_saida. move wa_saida to wa_totais. clear: wa_totais-classe, wa_totais-descr. collect wa_totais into t_totais. clear: wa_totais-tipo. collect wa_totais into t_totais. endloop. endform. " f_monta_saida *&---------------------------------------------------------------------* *& Form F_MONTA_SELECT *&---------------------------------------------------------------------* form f_monta_select using p_struc . data: t_com like rstrucinfo occurs 0 with header line. data: vl_repid type sy-repid. vl_repid = sy-repid. call function 'GET_COMPONENT_LIST' exporting program = vl_repid fieldname = p_struc tables components = t_com[]. loop at t_com. append t_com-compname to t_select. endloop. endform. " F_MONTA_SELECT *&---------------------------------------------------------------------* *& Form f_monta_intermediario *&---------------------------------------------------------------------* form f_monta_intermediario using p_campo2 p_campo3 p_campo4 p_campo5 p_total. if wa_anep-bwasl eq vg_020 or wa_anep-bwasl eq vg_101 or wa_anep-bwasl eq vg_114 or wa_anep-bwasl eq vg_331 or wa_anep-bwasl eq vg_336 or wa_anep-bwasl eq vg_338 or wa_anep-bwasl eq vg_339. wa_saida-resu_2 = p_campo2 = wa_anep-anbtr. elseif wa_anep-bwasl eq vg_300 or wa_anep-bwasl eq vg_310. wa_saida-resu_3 = p_campo3 = wa_anep-anbtr. elseif wa_anep-bwasl eq vg_200. wa_saida-resu_4 = p_campo4 = wa_anep-anbtr. endif. perform f_somatoria using wa_anlc-kansw wa_anep-anbtr changing p_campo5. perform f_calcula_resumo using wa_saida-resu_2 wa_saida-resu_3 wa_saida-resu_4 wa_saida-resu_5. wa_saida-total_7 = wa_saida-resu_1 = p_total = p_campo5. endform. " f_monta_intermediario *&---------------------------------------------------------------------* *& Form f_somatoria *&---------------------------------------------------------------------* form f_somatoria using p_kansw p_anbtr changing p_retorno. p_retorno = p_kansw + p_anbtr. endform. " f_somatoria *&---------------------------------------------------------------------* *& Form f_total_bloco *&---------------------------------------------------------------------* form f_total_bloco using p_valor changing p_total. p_total = p_valor. endform. " f_total_bloco *&---------------------------------------------------------------------* *& Form f_trata_bloco_inicial *&---------------------------------------------------------------------* form f_trata_bloco_inicial. case wa_anlz-werks. when vg_at01 or vg_at02. perform: f_somatoria using wa_anlc-kansw wa_anep-anbtr changing wa_saida-tot_ant1, f_total_bloco using wa_saida-tot_ant1 changing wa_saida-tot_ant5. wa_saida-at0102_1 = wa_saida-tot_ant1. collect wa_saida into t_saida. check wa_anla-anlkl ne vg_12104000 and wa_anla-anlkl ne vg_12104001. clear: wa_saida-tot_ant1, wa_saida-tot_ant5. * Depreciação Acumulada Período Anterior perform f_trata_deprec_acum using wa_saida-tot_ant1 wa_saida-tot_ant5. wa_saida-at0102_1 = wa_saida-tot_ant1. collect wa_saida into t_saida. when vg_at03. perform: f_somatoria using wa_anlc-kansw wa_anep-anbtr changing wa_saida-tot_ant2, f_total_bloco using wa_saida-tot_ant2 changing wa_saida-tot_ant5. wa_saida-at03_1 = wa_saida-tot_ant2. collect wa_saida into t_saida. check wa_anla-anlkl ne vg_12104000 and wa_anla-anlkl ne vg_12104001. clear: wa_saida-tot_ant2, wa_saida-tot_ant5, wa_saida-at03_1. * Depreciação Acumulada Período Anterior perform f_trata_deprec_acum using wa_saida-tot_ant2 wa_saida-tot_ant5. wa_saida-at03_1 = wa_saida-tot_ant2. collect wa_saida into t_saida. when vg_at04. perform: f_somatoria using wa_anlc-kansw wa_anep-anbtr changing wa_saida-tot_ant3, f_total_bloco using wa_saida-tot_ant3 changing wa_saida-tot_ant5. wa_saida-at04_1 = wa_saida-tot_ant3. collect wa_saida into t_saida. check wa_anla-anlkl ne vg_12104000 and wa_anla-anlkl ne vg_12104001. clear: wa_saida-tot_ant3, wa_saida-tot_ant5. * Depreciação Acumulada Período Anterior perform f_trata_deprec_acum using wa_saida-tot_ant3 wa_saida-tot_ant5. wa_saida-at04_1 = wa_saida-tot_ant3. collect wa_saida into t_saida. when vg_at05. perform: f_somatoria using wa_anlc-kansw wa_anep-anbtr changing wa_saida-tot_ant4, f_total_bloco using wa_saida-tot_ant4 changing wa_saida-tot_ant5. wa_saida-at05_1 = wa_saida-tot_ant4. collect wa_saida into t_saida. check wa_anla-anlkl ne vg_12104000 and wa_anla-anlkl ne vg_12104001. clear: wa_saida-tot_ant4, wa_saida-tot_ant5. * Depreciação Acumulada Período Anterior perform f_trata_deprec_acum using wa_saida-tot_ant4 wa_saida-tot_ant5. wa_saida-at05_1 = wa_saida-tot_ant4. collect wa_saida into t_saida. endcase. endform. " f_trata_bloco_inicial *&---------------------------------------------------------------------* *& Form f_trata_intermediario *&---------------------------------------------------------------------* form f_trata_intermediario. case wa_anlz-werks. when vg_at01 or vg_at02. perform f_monta_intermediario using wa_saida-at0102_2 wa_saida-at0102_3 wa_saida-at0102_4 wa_saida-at0102_5 wa_saida-total_3. collect wa_saida into t_saida. * Trata Totais - Último Bloco clear: wa_saida-at0102_2, wa_saida-at0102_3, wa_saida-at0102_4, wa_saida-at0102_5, wa_saida-resu_1, wa_saida-resu_2, wa_saida-resu_3, wa_saida-resu_4, wa_saida-resu_5, wa_saida-total_3. if vg_at01 eq wa_anlz-werks. perform f_somatoria using wa_anlc-kansw wa_anep-anbtr changing wa_saida-total_1. wa_saida-total_7 = wa_saida-total_1. else. perform f_somatoria using wa_anlc-kansw wa_anep-anbtr changing wa_saida-total_2. wa_saida-total_7 = wa_saida-total_2. endif. collect wa_saida into t_saida. check wa_anla-anlkl ne vg_12104000 and wa_anla-anlkl ne vg_12104001. clear: wa_saida-total_1, wa_saida-total_2. * Depreciação Acumulada Período Atual perform f_trata_depre_acum_atual using wa_saida-at0102_2 wa_saida-at0102_4 wa_saida-at0102_5. if vg_at01 eq wa_anlz-werks. perform f_monta_sum_dep using wa_anlp-nafag wa_anlp-nafaz wa_anea-nafav wa_anea-nafal wa_anlc-knafa changing wa_saida-total_1. wa_saida-total_7 = wa_saida-total_1. else. perform f_monta_sum_dep using wa_anlp-nafag wa_anlp-nafaz wa_anea-nafav wa_anea-nafal wa_anlc-knafa changing wa_saida-total_2. wa_saida-total_7 = wa_saida-total_2. endif. collect wa_saida into t_saida. when vg_at03. perform f_monta_intermediario using wa_saida-at03_2 wa_saida-at03_3 wa_saida-at03_4 wa_saida-at03_5 wa_saida-total_4. collect wa_saida into t_saida. * Trata Totais - Último Bloco clear: wa_saida-at03_1, wa_saida-at03_2, wa_saida-at03_3, wa_saida-at03_4, wa_saida-at03_5, wa_saida-resu_1, wa_saida-resu_2, wa_saida-resu_3, wa_saida-resu_4, wa_saida-resu_5, wa_saida-total_4. check wa_anla-anlkl ne vg_12104000 and wa_anla-anlkl ne vg_12104001. * Depreciação Acumulada Período Atual perform f_trata_depre_acum_atual using wa_saida-at03_2 wa_saida-at03_4 wa_saida-at03_5. perform f_monta_sum_dep using wa_anlp-nafag wa_anlp-nafaz wa_anea-nafav wa_anea-nafal wa_anlc-knafa changing wa_saida-total_4. wa_saida-total_7 = wa_saida-total_4. collect wa_saida into t_saida. when vg_at04. perform f_monta_intermediario using wa_saida-at04_2 wa_saida-at04_3 wa_saida-at04_4 wa_saida-at04_5 wa_saida-total_5. collect wa_saida into t_saida. * Trata Totais - Último Bloco clear: wa_saida-at04_1, wa_saida-at04_2, wa_saida-at04_3, wa_saida-at04_4, wa_saida-at04_5, wa_saida-resu_1, wa_saida-resu_2, wa_saida-resu_3, wa_saida-resu_4, wa_saida-resu_5, wa_saida-total_5. check wa_anla-anlkl ne vg_12104000 and wa_anla-anlkl ne vg_12104001. * Depreciação Acumulada Período Atual perform f_trata_depre_acum_atual using wa_saida-at04_2 wa_saida-at04_4 wa_saida-at04_5. perform f_monta_sum_dep using wa_anlp-nafag wa_anlp-nafaz wa_anea-nafav wa_anea-nafal wa_anlc-knafa changing wa_saida-total_5. wa_saida-total_7 = wa_saida-total_5. collect wa_saida into t_saida. when vg_at05. perform f_monta_intermediario using wa_saida-at05_2 wa_saida-at05_3 wa_saida-at05_4 wa_saida-at05_5 wa_saida-total_6. collect wa_saida into t_saida. * Trata Totais - Último Bloco clear: wa_saida-at05_2, wa_saida-at05_3, wa_saida-at05_4, wa_saida-at05_5, wa_saida-resu_1, wa_saida-resu_2, wa_saida-resu_3, wa_saida-resu_4, wa_saida-resu_5, wa_saida-total_6. check wa_anla-anlkl ne vg_12104000 and wa_anla-anlkl ne vg_12104001. * Depreciação Acumulada Período Atual perform f_trata_depre_acum_atual using wa_saida-at05_2 wa_saida-at05_4 wa_saida-at05_5. perform f_monta_sum_dep using wa_anlp-nafag wa_anlp-nafaz wa_anea-nafav wa_anea-nafal wa_anlc-knafa changing wa_saida-total_6. wa_saida-total_7 = wa_saida-total_6. collect wa_saida into t_saida. endcase. endform. " f_trata_intermediario *&---------------------------------------------------------------------* *& Form f_writer *&---------------------------------------------------------------------* form f_writer. data: vl_classe(35) type c, vl_x type c, vl_y type c. sort: t_saida by tipo classe. * Monta Cabeçalho select single butxt into vg_empresa from t001 where bukrs eq p_bukrs and spras eq sy-langu. * Imprime Linha Inicial perform f_linha. concatenate p_bukrs vg_empresa into vg_descr separated by space. concatenate text-002 vg_real into vg_titulo separated by space. if p_afab eq 10. concatenate text-002 vg_dolr into vg_titulo separated by space. endif. perform: f_primeiro_cabec, f_segundo_cabec using vg_descr vg_empresa, f_terceiro_cabec, f_pri_lin_total. loop at t_saida into wa_saida. concatenate wa_saida-classe '-' wa_saida-descr into vl_classe separated by space. format color 2 intensified off. if wa_saida-tipo eq vg_c or wa_saida-tipo eq vg_z. if wa_saida-tipo eq vg_z and vl_y is initial. format color 5 intensified off. read table t_totais into wa_totais with key tipo = vg_z. write: /(001) sy-vline, 002(35) text-037 centered. perform f_imprime_rel using wa_totais. format color 2 intensified off. write: /(001) sy-vline, 002(35) vl_classe left-justified. move vg_z to vl_y. else. write: /(001) sy-vline, 002(35) vl_classe left-justified. endif. else. if wa_saida-tipo eq vg_d and vl_x is initial. format color 5 intensified off. read table t_totais into wa_totais with key tipo = vg_d. write: /(001) sy-vline, 002(35) text-036 left-justified. perform f_imprime_rel using wa_totais. format color 2 intensified off. write: /(001) sy-vline, 002(35) vl_classe left-justified. move vg_z to vl_x. else. write: /(001) sy-vline, 002(35) vl_classe left-justified. endif. endif. perform f_imprime_rel using wa_saida. endloop. * Linha Final perform f_linha. endform. " f_writer *&---------------------------------------------------------------------* *& Form f_monta_sum_dep *&---------------------------------------------------------------------* form f_monta_sum_dep using p_wa_anlp_nafag p_wa_anlp_nafaz p_wa_anea_nafav p_wa_anea_nafal p_wa_anlc_knafa changing p_retorno. p_retorno = ( p_wa_anlp_nafag + p_wa_anlp_nafaz + p_wa_anea_nafav + p_wa_anea_nafal + p_wa_anlc_knafa ). endform. " f_monta_sum_dep *&---------------------------------------------------------------------* *& Form f_trata_deprec_acum *&---------------------------------------------------------------------* form f_trata_deprec_acum using p_total like anlc-kansw p_tot_f like anlc-kansw. wa_saida-classe = wa_t095b-ktnafb. wa_saida-descr = wa_skat-txt20. wa_saida-tipo = vg_d. perform f_monta_sum_dep using wa_anlp-nafag wa_anlp-nafaz wa_anea-nafav wa_anea-nafal wa_anlc-knafa changing p_total. perform f_total_bloco using p_total changing p_tot_f. endform. " f_trata_deprec_acum *&---------------------------------------------------------------------* *& Form f_trata_depre_acum_atual *&---------------------------------------------------------------------* form f_trata_depre_acum_atual using p_campo_2 p_campo_4 p_campo_5. wa_saida-classe = wa_t095b-ktnafb. wa_saida-descr = wa_skat-txt20. wa_saida-resu_2 = p_campo_2 = wa_anlp-nafaz. if wa_anep-bwasl eq vg_020 or wa_anep-bwasl eq vg_101 or wa_anep-bwasl eq vg_114. wa_saida-resu_4 = p_campo_4 = wa_anea-nafav. endif. perform f_monta_sum_dep using wa_anlp-nafag wa_anlp-nafaz wa_anea-nafav wa_anea-nafal wa_anlc-knafa changing p_campo_5. wa_saida-resu_1 = p_campo_5. perform f_calcula_resumo using wa_saida-resu_2 wa_saida-resu_3 wa_saida-resu_4 wa_saida-resu_5. wa_saida-tipo = vg_d. endform. " f_trata_depre_acum_atual *&---------------------------------------------------------------------* *& Form F_PRIMEIRO_CABEC *&---------------------------------------------------------------------* form f_primeiro_cabec. data: vl_periodo(02) type n. vl_periodo = ( s_peri-low - 1 ). perform f_monta_mes using vl_periodo changing vg_anterior. perform f_monta_mes using s_peri-high changing vg_atual. format color 7 intensified on. write: /(001) sy-vline, 037(01) sy-vline, 055(01) sy-vline, 056(17) vg_anterior centered, 074(01) sy-vline, 127(01) sy-vline, 129(01) sy-vline, 130(91) vg_titulo centered, 220(01) sy-vline, 222(01) sy-vline, 223(91) vg_titulo centered, 313(01) sy-vline, 315(01) sy-vline, 316(91) vg_titulo centered, 406(01) sy-vline, 408(01) sy-vline, 409(91) vg_titulo centered, 499(01) sy-vline, 501(01) sy-vline, 502(91) vg_titulo centered, 592(01) sy-vline, 594(01) sy-vline, 595(127) vg_atual centered, 721(01) sy-vline. endform. " F_PRIMEIRO_CABEC *&---------------------------------------------------------------------* *& Form F_MONTA_MES *&---------------------------------------------------------------------* form f_monta_mes using p_periodo changing p_mes. case p_periodo. when 01. perform f_concatena using text-003 changing p_mes. when 02. perform f_concatena using text-004 changing p_mes. when 03. perform f_concatena using text-005 changing p_mes. when 04. perform f_concatena using text-006 changing p_mes. when 05. perform f_concatena using text-007 changing p_mes. when 06. perform f_concatena using text-008 changing p_mes. when 07. perform f_concatena using text-009 changing p_mes. when 08. perform f_concatena using text-010 changing p_mes. when 09. perform f_concatena using text-011 changing p_mes. when 10. perform f_concatena using text-012 changing p_mes. when 11. perform f_concatena using text-013 changing p_mes. when 12. perform f_concatena using text-014 changing p_mes. endcase. endform. " F_MONTA_MES *&---------------------------------------------------------------------* *& Form f_segundo_cabec *&---------------------------------------------------------------------* form f_segundo_cabec using p_empresa p_desc. format color 3 intensified off. write: /(001) sy-vline, 002(35) p_empresa centered, 038(17) text-015 centered, 056(17) text-016 centered, 074(17) text-017 centered, 092(17) text-018 centered, 110(17) p_desc centered, 127(01) sy-vline, 129(01) sy-vline, 130(91) text-015 centered, 220(01) sy-vline, 222(01) sy-vline, 223(91) text-016 centered, 313(01) sy-vline, 315(01) sy-vline, 316(91) text-017 centered, 406(01) sy-vline, 408(01) sy-vline, 409(91) text-018 centered, 499(01) sy-vline, 501(01) sy-vline, 502(91) text-026 centered, 592(01) sy-vline, 594(01) sy-vline, 631(17) text-015 centered, 649(17) text-016 centered, 667(17) text-017 centered, 685(17) text-018 centered, 703(17) p_desc centered, 721(01) sy-vline. endform. " f_segundo_cabec *&---------------------------------------------------------------------* *& Form f_terceiro_cabec *&---------------------------------------------------------------------* form f_terceiro_cabec. format color 7 intensified on. write: /(001) sy-vline, 038(17) text-025 centered, 056(17) vg_at03 centered, 074(17) vg_at04 centered, 092(17) vg_at05 centered, 110(17) text-024 centered, 127(01) sy-vline, 129(01) sy-vline, 130(17) text-019 centered, 148(17) text-020 centered, 166(17) text-021 centered, 184(17) text-022 centered, 202(17) text-023 centered, 220(01) sy-vline, 222(01) sy-vline, 223(17) text-019 centered, 241(17) text-020 centered, 259(17) text-021 centered, 277(17) text-022 centered, 295(17) text-023 centered, 313(01) sy-vline, 315(01) sy-vline, 316(17) text-019 centered, 334(17) text-020 centered, 352(17) text-021 centered, 370(17) text-022 centered, 388(17) text-023 centered, 406(01) sy-vline, 408(01) sy-vline, 409(17) text-019 centered, 424(17) text-020 centered, 445(17) text-021 centered, 463(17) text-022 centered, 481(17) text-023 centered, 499(01) sy-vline, 501(01) sy-vline, 502(17) text-019 centered, 520(17) text-020 centered, 538(17) text-021 centered, 556(17) text-022 centered, 574(17) text-023 centered, 592(01) sy-vline, 594(01) sy-vline, 595(17) vg_at01 centered, 613(17) vg_at02 centered, 631(17) text-025 centered, 649(17) vg_at03 centered, 667(17) vg_at04 centered, 685(17) vg_at05 centered, 703(17) text-024 centered, 721(01) sy-vline. endform. " f_terceiro_cabec *&---------------------------------------------------------------------* *& Form f_pri_lin_total *&---------------------------------------------------------------------* form f_pri_lin_total. sort: t_totais by tipo descending. format color 1 intensified on. read table t_totais into wa_totais with key tipo = space. write: /(001) sy-vline, 002(35) text-027 centered. "Inicial 20 perform f_imprime_rel using wa_totais. format color 2 intensified on. read table t_totais into wa_totais with key tipo = vg_c. write: /(001) sy-vline, 002(35) text-028 centered. perform f_imprime_rel using wa_totais. endform. " f_pri_lin_total *&---------------------------------------------------------------------* *& Form f_imprime_rel *&---------------------------------------------------------------------* form f_imprime_rel using p_saida like wa_saida. data: vl_brl(3) type c value 'BRL', vl_usd(3) type c value 'USD', vl_cur(3) type c. vl_cur = vl_brl. if p_afab eq 10. vl_cur = vl_usd. endif. write: 038(17) p_saida-tot_ant1 currency vl_cur right-justified, 056(17) p_saida-tot_ant2 currency vl_cur right-justified, 074(17) p_saida-tot_ant3 currency vl_cur right-justified, 092(17) p_saida-tot_ant4 currency vl_cur right-justified, 110(17) p_saida-tot_ant5 currency vl_cur right-justified, 127(01) sy-vline, 129(01) sy-vline, 130(17) p_saida-at0102_1 currency vl_cur right-justified, 148(17) p_saida-at0102_2 currency vl_cur right-justified, 166(17) p_saida-at0102_3 currency vl_cur right-justified, 184(17) p_saida-at0102_4 currency vl_cur right-justified, 202(17) p_saida-at0102_5 currency vl_cur right-justified, 220(01) sy-vline, 222(01) sy-vline, 223(17) p_saida-at03_1 currency vl_cur right-justified, 241(17) p_saida-at03_2 currency vl_cur right-justified, 259(17) p_saida-at03_3 currency vl_cur right-justified, 277(17) p_saida-at03_4 currency vl_cur right-justified, 295(17) p_saida-at03_5 currency vl_cur right-justified, 313(01) sy-vline, 315(01) sy-vline, 316(17) p_saida-at04_1 currency vl_cur right-justified, 334(17) p_saida-at04_2 currency vl_cur right-justified, 352(17) p_saida-at04_3 currency vl_cur right-justified, 370(17) p_saida-at04_4 currency vl_cur right-justified, 388(17) p_saida-at04_5 currency vl_cur right-justified, 406(01) sy-vline, 408(01) sy-vline, 409(17) p_saida-at05_1 currency vl_cur right-justified, 427(17) p_saida-at05_2 currency vl_cur right-justified, 445(17) p_saida-at05_3 currency vl_cur right-justified, 463(17) p_saida-at05_4 currency vl_cur right-justified, 481(17) p_saida-at05_5 currency vl_cur right-justified, 499(01) sy-vline, 501(01) sy-vline, 502(17) p_saida-resu_1 currency vl_cur right-justified, 520(17) p_saida-resu_2 currency vl_cur right-justified, 538(17) p_saida-resu_3 currency vl_cur right-justified, 556(17) p_saida-resu_4 currency vl_cur right-justified, 574(17) p_saida-resu_5 currency vl_cur right-justified, 592(01) sy-vline, 594(01) sy-vline, 595(17) p_saida-total_1 currency vl_cur right-justified, 613(17) p_saida-total_2 currency vl_cur right-justified, 631(17) p_saida-total_3 currency vl_cur right-justified, 649(17) p_saida-total_4 currency vl_cur right-justified, 667(17) p_saida-total_5 currency vl_cur right-justified, 685(17) p_saida-total_6 currency vl_cur right-justified, 703(17) p_saida-total_7 currency vl_cur right-justified, 721(01) sy-vline. endform. " f_imprime_rel *&---------------------------------------------------------------------* *& Form f_gera_excel *&---------------------------------------------------------------------* form f_gera_excel. perform: f_cria_planilha, f_monta_cabecalhos, f_monta_linhas, f_salvar_planilha. endform. " f_gera_excel *&---------------------------------------------------------------------* *& Form f_calcula_resumo *&---------------------------------------------------------------------* form f_calcula_resumo using p_resu_2 p_resu_3 p_resu_4 p_resu_5. p_resu_5 = p_resu_2 + p_resu_3 + p_resu_4. endform. " f_calcula_resumo *&---------------------------------------------------------------------* *& Form f_linha *&---------------------------------------------------------------------* form f_linha. write: /001(127) sy-uline, 129(092) sy-uline, 222(092) sy-uline, 315(092) sy-uline, 408(092) sy-uline, 501(092) sy-uline, 594(128) sy-uline. endform. " f_linha *&---------------------------------------------------------------------* *& Form f_concatena *&---------------------------------------------------------------------* form f_concatena using p_texto changing p_mes. case p_afab. when 01. concatenate p_texto '-' vg_real into p_mes separated by space. when 10. concatenate p_texto '-' vg_dolr into p_mes separated by space. endcase. endform. " f_concatena *&---------------------------------------------------------------------* *& Form f_cria_planilha *&---------------------------------------------------------------------* form f_cria_planilha. data: vl_visible type i. vl_visible = 1. if p_ver is initial. vl_visible = 0. endif. * Cria aplicação Excel create object vg_excel 'EXCEL.APPLICATION'. set property of vg_excel 'DisplayAlerts' = 0. call method of vg_excel 'WORKBOOKS' = vg_workbooks. set property of vg_excel 'VISIBLE' = vl_visible. * Criação do WorkBook set property of vg_excel 'SheetsInNewWorkbook' = 1. call method of vg_workbooks 'ADD'. call method of vg_excel 'WORKSHEETS' = vg_sheet. call method of vg_sheet 'ADD'. free object vg_sheet. * Nomeia e Ativa Aba da Planilha call method of vg_excel 'WORKSHEETS' = vg_sheet exporting #1 = 1. set property of vg_sheet 'NAME' = text-038. "Limite 31 Caracteres call method of vg_sheet 'ACTIVATE'. endform. " f_cria_planilha *&---------------------------------------------------------------------* *& Form f_monta_cabecalhos *&---------------------------------------------------------------------* form f_monta_cabecalhos. * Monta Primeiro Cabeçalho perform f_mescla_celulas using 1 1 3 2 vg_descr. perform f_add_field using 1 4 vg_anterior. perform: f_mescla_celulas using 1 9 1 13 vg_titulo, f_mescla_celulas using 1 15 1 19 vg_titulo, f_mescla_celulas using 1 21 1 25 vg_titulo, f_mescla_celulas using 1 27 1 31 vg_titulo, f_mescla_celulas using 1 33 1 37 vg_titulo, f_mescla_celulas using 1 39 1 45 vg_atual. * Monta Segundo Cabeçalho perform: f_add_field using 2 3 text-015, f_add_field using 2 4 text-016, f_add_field using 2 5 text-017, f_add_field using 2 6 text-018, f_add_field using 2 7 vg_empresa. perform: f_mescla_celulas using 2 9 2 13 text-015, f_mescla_celulas using 2 15 2 19 text-016, f_mescla_celulas using 2 21 2 25 text-017, f_mescla_celulas using 2 27 2 31 text-018, f_mescla_celulas using 2 33 2 37 text-026. perform: f_add_field using 2 41 text-015, f_add_field using 2 42 text-016, f_add_field using 2 43 text-017, f_add_field using 2 44 text-018, f_add_field using 2 45 vg_empresa. * Monta Terceiro Cabeçalho perform: f_add_field using 3 3 text-025, f_add_field using 3 4 vg_at03, f_add_field using 3 5 vg_at04, f_add_field using 3 6 vg_at05, f_add_field using 3 7 text-024. perform: f_add_field using 3 9 text-019, f_add_field using 3 10 text-020, f_add_field using 3 11 text-021, f_add_field using 3 12 text-022, f_add_field using 3 13 text-023. perform: f_add_field using 3 15 text-019, f_add_field using 3 16 text-020, f_add_field using 3 17 text-021, f_add_field using 3 18 text-022, f_add_field using 3 19 text-023. perform: f_add_field using 3 21 text-019, f_add_field using 3 22 text-020, f_add_field using 3 23 text-021, f_add_field using 3 24 text-022, f_add_field using 3 25 text-023. perform: f_add_field using 3 27 text-019, f_add_field using 3 28 text-020, f_add_field using 3 29 text-021, f_add_field using 3 30 text-022, f_add_field using 3 31 text-023. perform: f_add_field using 3 33 text-019, f_add_field using 3 34 text-020, f_add_field using 3 35 text-021, f_add_field using 3 36 text-022, f_add_field using 3 37 text-023. perform: f_add_field using 3 39 vg_at01, f_add_field using 3 40 vg_at02, f_add_field using 3 41 text-025, f_add_field using 3 42 vg_at03, f_add_field using 3 43 vg_at04, f_add_field using 3 44 vg_at05, f_add_field using 3 45 text-024. endform. " f_monta_cabecalhos *&---------------------------------------------------------------------* *& Form f_mescla_celulas *&---------------------------------------------------------------------* form f_mescla_celulas using p_l1 type i p_c1 type i p_l2 type i p_c2 type i p_desc. call method of vg_sheet 'Cells' = vg_cells exporting #1 = p_l2 #2 = p_c1. set property of vg_cells 'Value' = p_desc. call method of vg_excel 'Cells' = vg_cell1 exporting #1 = p_l1 #2 = p_c1. call method of vg_excel 'Cells' = vg_cell2 exporting #1 = p_l2 #2 = p_c2. call method of vg_excel 'Range' = vg_cells exporting #1 = vg_cell1 #2 = vg_cell2. call method of vg_cells 'Select' . call method of vg_cells 'Merge' . call method of vg_excel 'Cells' = vg_cell1 exporting #1 = p_l2 #2 = p_c1. set property of vg_cell1 'HorizontalAlignment' = -4108 . set property of vg_cell1 'VerticalAlignment' = -4108 . endform. " f_mescla_celulas *&---------------------------------------------------------------------* *& Form f_add_field *&---------------------------------------------------------------------* form f_add_field using p_linha type i p_coluna type i p_valor. call method of vg_excel 'Cells' = vg_cell1 exporting #1 = p_linha #2 = p_coluna. set property of vg_cell1 'Value' = p_valor. endform. " f_add_field *&---------------------------------------------------------------------* *& Form f_monta_linhas *&---------------------------------------------------------------------* form f_monta_linhas. data: vl_dep type c, vl_and type c. refresh t_select. perform f_monta_select using 'WA_SAIDA'. * Monta Primeira Linha de Totais perform f_mescla_celulas using 4 1 4 2 text-027. read table t_totais into wa_totais with key tipo = space. perform f_print_line using 4 wa_totais vg_x. * Monta Segunda Linha de Totais perform f_mescla_celulas using 5 1 5 2 text-028. read table t_totais into wa_totais with key tipo = vg_c. perform f_print_line using 5 wa_totais vg_x. * Monta Linhas vg_lin = 6. loop at t_saida into wa_saida. * Imprime Cabeçalho para Depreciação Acumulada if wa_saida-tipo eq vg_d and vl_dep is initial. read table t_totais into wa_totais with key tipo = vg_d. perform f_mescla_celulas using vg_lin 1 vg_lin 2 text-036. perform f_print_line using vg_lin wa_totais vg_x. add 1 to vg_lin. add 1 to vl_dep. elseif wa_saida-tipo eq vg_z and vl_and is initial. * Imprime Cabeçalho para Imobilizado em Andamento read table t_totais into wa_totais with key tipo = vg_z. perform f_mescla_celulas using vg_lin 1 vg_lin 2 text-037. perform f_print_line using vg_lin wa_totais vg_x. add 1 to vg_lin. add 1 to vl_and. endif. * Imprime Linhas perform f_print_line using vg_lin wa_saida space. add 1 to vg_lin. endloop. endform. " f_monta_linhas *&---------------------------------------------------------------------* *& Form f_print_line *&---------------------------------------------------------------------* form f_print_line using p_lin type i p_totais like wa_saida p_desc. data: vl_descr(05) type c value 'DESCR', vl_txtcl(06) type c value 'CLASSE', vl_txtsp(03) type c value 'SPA', vl_txtts(09) type c value 'P_TOTAIS-', vl_tipo(04) type c value 'TIPO'. * Ao submeter o programa na SLIN a programa indica uma inconsistência * nesse ponto, por que a estrutua P_TOTAIS não é utilizada estáticamente * mais ela é utilizada de forma dinâmica, por isso a inconsistência foi * ignorada. loop at t_select into wa_campos. vg_col = sy-tabix. concatenate vl_txtts wa_campos into vg_campo. assign (vg_campo) to <fs_campo>. if not p_desc is initial and ( wa_campos eq vl_descr or wa_campos eq vl_txtcl ). continue. endif. check wa_campos(3) ne vl_txtsp and wa_campos ne vl_tipo. perform: f_add_field using p_lin vg_col <fs_campo>. endloop. endform. " f_print_line *&---------------------------------------------------------------------* *& Form f_call_screen *&---------------------------------------------------------------------* form f_call_screen. call selection-screen 0100 starting at 030 010. if sy-subrc ne 0. stop. endif. endform. " f_call_screen *&---------------------------------------------------------------------* *& Form f_salvar_planilha *&---------------------------------------------------------------------* form f_salvar_planilha. call method of vg_sheet 'SaveAs' exporting #1 = p_file #2 = 1. "#EC NEEDED ) call method of vg_sheet 'SAVE'. call method of vg_sheet 'QUIT'. set property of vg_excel 'Visible' = 0. endform. " f_salvar_planilha *&---------------------------------------------------------------------* *& Form f_salva_arquivo *&---------------------------------------------------------------------* form f_salva_arquivo using p_file. data: vl_filename type string, vl_full type string, vl_path type string, vl_filter type string, vl_cam type string, vl_xls(04) type c value '.XLS', vl_ini(03) type c value 'C:\'. vl_filter = vl_xls. vl_cam = vl_ini. call method cl_gui_frontend_services=>file_save_dialog exporting default_file_name = vl_filename file_filter = vl_filter initial_directory = vl_cam changing filename = vl_filename path = vl_path fullpath = vl_full. concatenate vl_full vl_filter into p_file. endform. " f_salva_arquivo *&---------------------------------------------------------------------* *& Form f_limpa_dados *&---------------------------------------------------------------------* form f_limpa_dados. clear: wa_anla, wa_anlc, wa_anea, wa_anep, wa_anek, wa_anlp, wa_anlz, wa_ankt, wa_t095b, wa_skat, wa_saida, wa_totais. refresh: t_anla, t_anlc, t_anea, t_anep, t_anek, t_anlp, t_anlz, t_ankt, t_t095b, t_skat, t_saida, t_totais, t_select. free: t_anla, t_anlc, t_anea, t_anep, t_anek, t_anlp, t_anlz, t_ankt, t_t095b, t_skat, t_saida, t_totais, t_select. free object: vg_excel, vg_workbooks, vg_cells, vg_cell1, vg_cell2, vg_sheet. endform. " f_limpa_dados