Sie sind auf Seite 1von 64

************************************************************************

*
*
*
Umsatzsteuer-Voranmeldung RFUMSV00 mit dem ALV
*
*
*
*----------------------------------------------------------------------*
* Dieser Report basiert auf der alten Umsatzsteuer-Voranmeldung,
*
* welche nun den Namen RFUMSV00_P trgt.
*
*----------------------------------------------------------------------*
* Korrekturen:
*
* OT-07 Note 204972
Australische Steuermeldung BAS braucht Paramet.*
*----------------------------------------------------------------------*
* OP-01 Note 339121
Legal Requirement Thailand
*
*----------------------------------------------------------------------*
* OP-02 Note 356441
falsche laufende Nummer
*
*----------------------------------------------------------------------*
* OP-03 Note 374145
Legal Requirements Italien
*
*----------------------------------------------------------------------*
* OP-04 Note 375429
gestundete Steuern selektieren
*
*----------------------------------------------------------------------*
* OP-05 Note 351280
Fiskalische Anschrift bercksichtigen
*
*----------------------------------------------------------------------*
* OP-06 Note 379155 nderungen fr DME Engine Anschlu
*
*----------------------------------------------------------------------*
* OP-07 Note 335539
Formulardruck
*
*----------------------------------------------------------------------*
* OP-08 Note 380868
short header, MWSKZ-Text, TRVOR und Druckeinst.*
*----------------------------------------------------------------------*
* OP-09 Note 381346
Selektion von Hauptbuchkonten
*
*----------------------------------------------------------------------*
* OP-10 Note 380004
Vorzeichen von HWGROSS
*
*----------------------------------------------------------------------*
* OP-11 Note 377276
Reihenfolge der Vergabe der laufende Nr.
*
*----------------------------------------------------------------------*
* OP-12 Note 362762
parallele laufende Nummern
*
*----------------------------------------------------------------------*
* OP-13 Note 384192
tax account number in the sum lists
*
*----------------------------------------------------------------------*
* OP-14 Note 385260
handling update TRVOR and BSET
*
*----------------------------------------------------------------------*
* OP-15 Note 385378
nur eine fortlaufende Nr. pro Dokument
*
*----------------------------------------------------------------------*
* OP-16 Note 385679
Echtlauf und Beleg speichern fr Italien
*
*----------------------------------------------------------------------*
* OP-17 Note 386165
Felder im header
*
*----------------------------------------------------------------------*
* OP-18 Note 386627
mehrere Sortierungen der lfd. Nummer
*
*----------------------------------------------------------------------*
* OP-19 Note 394073
Umrechnungskurs anzeigen
*
*----------------------------------------------------------------------*
* OP-20 Note 400886
FI ALE FIDCC1: fehlerhaft in Zentrale
*
*----------------------------------------------------------------------*
* OP-21 Note 408237
Fehler in Batch Input Mappe sofort abspielen
*

*----------------------------------------------------------------------*
* OP-22 Note 407474
abzf. Vorsteuer in der Summenliste
*
*----------------------------------------------------------------------*
* OP-23 Note 417018
berschrift fr Name1
*
*----------------------------------------------------------------------*
* OP-24 Note 401661
Ausgabe des Bolle Doganali Kontentextes
*
*----------------------------------------------------------------------*
* OP-25 Note 417687
Werke im Ausland und Alternative Hauswhrung
*
*----------------------------------------------------------------------*
* OP-26 Note 422816
fehlehnder Steuerprozentsatz
*
*----------------------------------------------------------------------*
* OP-27 Note 422066
FI_TAX_BADI_012 ist nicht filterabhngig
*
*----------------------------------------------------------------------*
* OP-28 Note 418476
falsches Vorzeichen des Bruttobetrages
*
*----------------------------------------------------------------------*
* OP-29 Note 425071 Zuordnungsnummer wird nicht ausgegeben
*
*----------------------------------------------------------------------*
* OP-30 Note 412860
falsches Hauptbuchkonto
*
*----------------------------------------------------------------------*
* Note 429158 Ausgabe Mikrofiche-Information
*
*----------------------------------------------------------------------*
* Note 736203 Fehlende USt-Identnummern in Einzelpostenliste
*
************************************************************************
REPORT rfumsv00
LINE-COUNT (1)
LINE-SIZE 132
NO STANDARD PAGE HEADING
MESSAGE-ID f7.

*----------------------------------------------------------------------*
* BADI
*
*----------------------------------------------------------------------*
* "Vorwrtsdeklaration der "Factory"
CLASS cl_exithandler DEFINITION LOAD.
* "Interfacereferenz
DATA: g_ref_to_exit_010 TYPE REF TO if_ex_fi_tax_badi_010,
g_ref_to_exit_011 TYPE REF TO if_ex_fi_tax_badi_011,
g_ref_to_exit_012 TYPE REF TO if_ex_fi_tax_badi_012,
g_ref_to_exit_013 TYPE REF TO if_ex_fi_tax_badi_013,
g_ref_to_exit_014 TYPE REF TO if_ex_fi_tax_badi_014, "OP-06
g_ref_to_exit_015 TYPE REF TO if_ex_fi_tax_badi_015, "OP-06
g_ref_to_exit_016 TYPE REF TO if_ex_fi_tax_badi_016. "500308

*----------------------------------------------------------------------*
* Type-Pools
*
*----------------------------------------------------------------------*
* ABAP List-Viewer (ALV)
TYPE-POOLS: slis.

*----------------------------------------------------------------------*
* Includes
*
*----------------------------------------------------------------------*
* Icons
INCLUDE <icon>.
* Tabellen und Feldleisten
INCLUDE i_rfums_tables.
* Parameter
INCLUDE i_rfums_parameter.
* Die brigen Variablen
INCLUDE i_rfums_data.
* Tabelle mit Buchungskreisen, aus denen Belege zu 4.0 umgesetzt wurden
INCLUDE fiuums40.

*----------------------------------------------------------------------*
* Macros
*
*----------------------------------------------------------------------*
DEFINE heading_hw_lw.
if par_xstw <> space.
&1 = &2.
endif.
END-OF-DEFINITION.

*----------------------------------------------------------------------*
* Field-Groups
*
*----------------------------------------------------------------------*
FIELD-GROUPS:
header,
daten.
INSERT
ep-bukrs
ep-mwart
* ep-mwskz
ep-mwskz
ep-bldat
ep-ktosl
ep-buper
* ep-waers
ep-waers
ep-budat
ep-belnr
hlp_sort
INTO header.
INSERT ep INTO daten.

"Buchungskreis
"Umsatzsteuerart
"Umsatzsteuerkennzeichen "OP-11
"OP-17
"OP-18
"Vorgangsschlssel
"Buchungsperiode
"Whrungsschlssel "OP-02
"OP-17
"Buchungsdatum
"Belegnummer
"Hilfsfeld fr die Sortierung

*----------------------------------------------------------------------*
* Vorbelegung im Selektionsdynpro
*
*----------------------------------------------------------------------*
INITIALIZATION.
* make RLDNR invisible
PERFORM make_rldnr_invisible.

"871301

* Selection-Screen
par_xsau = 'X'.
par_xsvo = 'X'.
CLEAR: par_lis5.
par_bina = sy-repid.

"No list: Tax Difference

* Constants
CLEAR hlp_vline_space.
hlp_vline_space+0(1) = sy-vline.
g_repid = sy-repid.
* No Authority-Check for BR_BUKRS in the logical Database BRF
auth_buk = 'X'.
* No Authority-Check for ledger in the logical Database BRF "1036175
auth_ldr = 'X'.
"1036175
* Close Selection-Screen Block 1 - 5
par_cb1 = 'X'.
par_cb2 = 'X'.
par_cb3 = 'X'.
par_cb4 = 'X'.
par_cb5 = 'X'.
* Set Text & Icon for Pushbutton c1 - c5, o1 - o5
* CONCATENATE icon_collapse: text-051 INTO pushb_c1,
*
text-057 INTO pushb_c2,
*
text-053 INTO pushb_c3,
*
text-054 INTO pushb_c4,
*
text-052 INTO pushb_c5.
* CONCATENATE icon_expand:
text-051 INTO pushb_o1,
*
text-057 INTO pushb_o2,
*
text-053 INTO pushb_o3,
*
text-054 INTO pushb_o4,
*
text-052 INTO pushb_o5.
*Accessibility:
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name
text
*
INFO
= ' '
IMPORTING
RESULT

= icon_collapse
= text-051

= pushb_c1

EXCEPTIONS
OTHERS
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name
text
*
INFO
= ' '
IMPORTING
RESULT
EXCEPTIONS
OTHERS
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name
text
*
INFO
= ' '
IMPORTING
RESULT
EXCEPTIONS
OTHERS
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name
text
*
INFO
= ' '
IMPORTING
RESULT
EXCEPTIONS
OTHERS
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name
text
*
INFO
= ' '
IMPORTING
RESULT
EXCEPTIONS
OTHERS
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name
text
*
INFO
= ' '
IMPORTING
RESULT
EXCEPTIONS
OTHERS

= 3.

= icon_collapse
= text-057

= pushb_c2
= 3.

= icon_collapse
= text-053

= pushb_c3
= 3.

= icon_collapse
= text-054

= pushb_c4
= 3.

= icon_collapse
= text-052

= pushb_c5
= 3.

= icon_expand
= text-051

= pushb_o1
= 3.

CALL FUNCTION 'ICON_CREATE'


EXPORTING
name
text
*
INFO
= ' '
IMPORTING
RESULT
EXCEPTIONS
OTHERS
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name
text
*
INFO
= ' '
IMPORTING
RESULT
EXCEPTIONS
OTHERS
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name
text
*
INFO
= ' '
IMPORTING
RESULT
EXCEPTIONS
OTHERS
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name
text
*
INFO
= ' '
IMPORTING
RESULT
EXCEPTIONS
OTHERS

= icon_expand
= text-057

= pushb_o2
= 3.

= icon_expand
= text-053

= pushb_o3
= 3.

= icon_expand
= text-054

= pushb_o4
= 3.

= icon_expand
= text-052

= pushb_o5
= 3.

* Check if the user is a tax auditor


PERFORM check_tax_audit
CHANGING gd_tax_auditor.

"925217
"925217
"925217

* Check if personal data can be blocked


PERFORM check_cvp_ilm_1
CHANGING gd_cvp_active.

"2073571
"2073571
"2073571

*----------------------------------------------------------------------*
* Aufbereitung des Selektionsbildes im PBO
*

*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
* check DMEE-tree for additional parameters structure
par_dmea = parpdmea.
push_dme = pushpdme.
PERFORM check_dmee_param_struc.
parpdmea = par_dmea.
pushpdme = push_dme.

"899205
"931482
"931482
"899205
"931482
"931482

* make RLDNR invisible


PERFORM make_rldnr_invisible.

"871301

CLEAR: par_euva, par_corr, par_dyea, par_dper.


par_euva = parpeuva.
par_corr = parpcorr.
par_dyea = parpdyea.
par_dper = parpdper.
* form routines use a copy of sel_vtdt because of rgjvtax2
CLEAR: dso_vtdt[], dso_vtdt.
dso_vtdt[] = sel_vtdt[].
READ TABLE dso_vtdt INDEX 1.
IF gd_tax_auditor = 'X'.
par_cb2 = 'X'.
"turn off batch input block
par_cb5 = 'X'.
"turn off posting block
PERFORM tax_audit_clear.
ENDIF.
check_wia_and_modify_screen flg_xwia.
LOOP AT SCREEN.
PERFORM close_block USING: par_cb1 'MC1'
par_cb1 'WIA'
par_cb1 'MO1'
par_cb2 'MC2'
par_cb2 'MO2'
par_cb3 'MC3'
par_cb3 'MO3'
par_cb4 'MC4'
par_cb4 'MO4'
par_cb5 'MC5'
par_cb5 'MO5'

*
*

*
*

"803670
"803670
"803670
"803670
"803670
"1100622
"1100622
"1100622
"1100622
"925217
"925217
"925217
"925217
"925217

space,
space,
'X' ,
space,
'X' ,
space,
'X' ,
space,
'X' ,
space,
'X' .

IF gd_tax_auditor = 'X'.
turn off buttons for batch input block MO2
and for posting block MO5 completely
PERFORM close_block USING: par_cb2 'MO2' space,
par_cb5 'MO5' space.
ENDIF.
XML-Erzeugung ausbauen
turn off par_xml

"925217
"925217
"925217
"925217
"925217
"N1576305
"N1576305
"925217

IF screen-name = 'PAR_XML'.
screen-active = '0'.
MODIFY screen.
ENDIF.
ENDIF.
ENDLOOP.
CASE g_sscr_ucomm.
WHEN 'UCOMM_O1'.
SET CURSOR FIELD
WHEN 'UCOMM_O2'.
SET CURSOR FIELD
WHEN 'UCOMM_O3'.
SET CURSOR FIELD
WHEN 'UCOMM_O4'.
SET CURSOR FIELD
WHEN 'UCOMM_O5'.
SET CURSOR FIELD
WHEN OTHERS.
SET CURSOR FIELD
ENDCASE.

"925217

"925217
"925217
"925217
"925217
"N1576305

"Open Block 1
'SEL_TMTI-LOW'.
"Open Block 2
'PAR_ZEIT'.
"Open Block 3
'PAR_LINE'.
"Open Block 4
'PAR_VAR7'.
"Open Block 5
'PAR_SNIN'.
g_cursor_field.

*----------------------------------------------------------------------*
* Prfung der Eingaben in den Selektionsdynpro "ON sel_field"
*
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON sel_bupl.
"OP-01
* perform check_selction_variable using 'B_BUPLA'. "OP-01
PERFORM check_selection_variable TABLES sel_bupl.
"OP-01
AT SELECTION-SCREEN ON par_var1.
PERFORM alv_variante_exist USING c_auste_ep
par_var1.
AT SELECTION-SCREEN ON par_var2.
PERFORM alv_variante_exist USING c_auste_sum
par_var2.
AT SELECTION-SCREEN ON par_var3.
PERFORM alv_variante_exist USING c_voste_ep
par_var3.
AT SELECTION-SCREEN ON par_var4.
PERFORM alv_variante_exist USING c_voste_sum
par_var4.
AT SELECTION-SCREEN ON par_var5.
PERFORM alv_variante_exist USING c_sdiff_ep
par_var5.
AT SELECTION-SCREEN ON par_var6.
PERFORM alv_variante_exist USING c_bukrs
par_var6.

AT SELECTION-SCREEN ON par_var7.
PERFORM alv_variante_exist USING c_bukrs_sum
par_var7.
AT SELECTION-SCREEN.
CLEAR: par_euva, par_corr, par_dyea, par_dper.
par_euva = parpeuva.
par_corr = parpcorr.
par_dyea = parpdyea.
par_dper = parpdper.
* form routines use a copy of sel_vtdt because of rgjvtax2
CLEAR: dso_vtdt[], dso_vtdt.
dso_vtdt[] = sel_vtdt[].
READ TABLE dso_vtdt INDEX 1.

"803670
"803670
"803670
"803670
"803670
"1100622
"1100622
"1100622
"1100622

GET CURSOR FIELD g_cursor_field.


IF flg_xwia = space.
CLEAR: par_xstw, sel_lstm.
REFRESH sel_lstm.
ENDIF.
* Wurden Umsatzsteuerkreise abgegrenzt?
DESCRIBE TABLE sel_ukrs LINES cnt_lines.
IF cnt_lines > 0.
flg_umkrs = 1.
"Es wurden Umsatzsteuerkreise abgegrenzt.
CALL FUNCTION 'TAX_UMKRS_TIMEDEP_ACTIVE'
"N1542782
IMPORTING
"N1542782
E_UMKRS_ACTIVE
= gd_umkrs_active
"N1542782
TABLES
"N1542782
T_R_BUKRS
= br_bukrs
"N1542782
T_R_UMKRS
= sel_ukrs
"N1542782
T_R_BUDAT
= br_budat
"N1542782
T_R_BLDAT
= sel_bldt
"N1542782
T_R_VATDATE
= dso_vtdt
"N1542782
.
"N1542782
IF gd_umkrs_active = 'X'.
"N1542782
flg_umkrs = 2.
"N1542782
ENDIF.
"N1542782
ELSE.
flg_umkrs = 0.
"Es wurden Buchungskreise abgegrenzt.
ENDIF.
g_sscr_ucomm = sscrfields-ucomm.
* Auf die User-Commands reagieren
CASE sscrfields-ucomm.
WHEN 'UCOMM_O1'.
CLEAR par_cb1.
WHEN 'UCOMM_C1'.

"Open Block 1
"Close Block 1

par_cb1 = 'X'.
WHEN 'UCOMM_O2'.
CLEAR par_cb2.
WHEN 'UCOMM_C2'.
par_cb2 = 'X'.
WHEN 'UCOMM_O3'.
CLEAR par_cb3.
WHEN 'UCOMM_C3'.
par_cb3 = 'X'.
WHEN 'UCOMM_O4'.
CLEAR par_cb4.
WHEN 'UCOMM_C4'.
par_cb4 = 'X'.
WHEN 'UCOMM_O5'.
CLEAR par_cb5.
WHEN 'UCOMM_C5'.
par_cb5 = 'X'.
WHEN 'CON1'.
PERFORM config_list USING '1'.
WHEN 'CON2'.
PERFORM config_list USING '2'.
WHEN 'CON3'.
PERFORM config_list USING '3'.
WHEN 'CON4'.
PERFORM config_list USING '4'.
WHEN 'CON5'.
PERFORM config_list USING '5'.
WHEN 'CON6'.
PERFORM config_list USING '6'.
WHEN 'CON7'.
PERFORM config_list USING '7'.
WHEN OTHERS.
PERFORM check_selection_screen.
ENDCASE.
*
*
*
*

"Open Block 2
"Close Block 2
"Open Block 3
"Close Block 3
"Open Block 4
"Close Block 4
"Open Block 5
"Close Block 5
"Ausgabeliste konfigurieren
"Ausgabeliste konfigurieren
"Ausgabeliste konfigurieren
"Ausgabeliste konfigurieren
"Ausgabeliste konfigurieren
"Ausgabeliste konfigurieren
"Ausgabeliste konfigurieren
"Input-Validierung

This must be the last action in selection screen


processing. Events like sending of a message
can cause changes of -ucomm by giving the user a
chance to press another button.
CLEAR gd_exec_and_print.
IF sscrfields-ucomm = 'PRIN'.
gd_exec_and_print = 'X'.
ENDIF.

"1307450
"1307450
"1307450
"1307450
"1307450
"1307450
"1307450
"1307450

*----------------------------------------------------------------------*
* F4-Hilfe fr die Anzeigevarianten (ALV)
*
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR par_var1.
PERFORM alv_variante_f4 USING c_auste_ep.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR par_var2.
PERFORM alv_variante_f4 USING c_auste_sum.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR par_var3.


PERFORM alv_variante_f4 USING c_voste_ep.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR par_var4.
PERFORM alv_variante_f4 USING c_voste_sum.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR par_var5.
PERFORM alv_variante_f4 USING c_sdiff_ep.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR par_var6.
PERFORM alv_variante_f4 USING c_bukrs.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR par_var7.
PERFORM alv_variante_f4 USING c_bukrs_sum.

*----------------------------------------------------------------------*
* F4-Hilfe fr den Lauf
*
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON VALUE-REQUEST FOR par_laud.
PERFORM f4_lauf(rfuvde00) USING 'D' par_laud par_laui.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR par_laui.
PERFORM f4_lauf(rfuvde00) USING 'I' par_laud par_laui.

*----------------------------------------------------------------------*
* Vorbereitungen
*
*----------------------------------------------------------------------*
START-OF-SELECTION.
" check if bseg has been declustered or not
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
name = 'BSEG'
IMPORTING
dd02v_wa = ls_dd02v_wa_bseg.
CALL FUNCTION 'DDIF_TABL_GET'
EXPORTING
name = 'BSET'
IMPORTING
dd02v_wa = ls_dd02v_wa_bset.
"use external optimization if bseg has been declustered
IF ls_dd02v_wa_bseg-tabclass eq 'TRANSP' AND ls_dd02v_wa_bset-tabclass eq
'TRANSP'.
"PERFORM process_result.
xhana = 'E'.
ENDIF.
b0sg-xcurr = 'X'.
"455755
CLEAR gd_selection_stopped.

"1066663

CLEAR: par_euva, par_corr, par_dyea, par_dper.


par_euva = parpeuva.
par_corr = parpcorr.
par_dyea = parpdyea.
par_dper = parpdper.
* form routines use a copy of sel_vtdt because of rgjvtax2
CLEAR: dso_vtdt[], dso_vtdt.
dso_vtdt[] = sel_vtdt[].
READ TABLE dso_vtdt INDEX 1.

"803670
"803670
"803670
"803670
"803670
"1100622
"1100622
"1100622
"1100622

*
*
*
*

Internal table tab_001 can only be built correctly after


"893630
processing get bkpf. If it has been used during parameter "893630
checks it needs to be refreshed here.
"893630
It may be created incomplete in form routine check_euva.
"893630
REFRESH tab_001.
"893630
* XML-Erezugung ausbauen, deshlab PAR_XML lschen
"N1576305
CLEAR par_xml.
"N1576305
PERFORM badi_preparation.
CASE par_avpn.
WHEN '1'. var_avp1 = 'X'.
WHEN '2'. var_avp2 = 'X'.
WHEN '3'. var_avp3 = 'X'.
WHEN '4'. var_avp4 = 'X'.
WHEN '5'. var_avp5 = 'X'.
WHEN '6'. var_avp6 = 'X'.
WHEN '7'. var_avp7 = 'X'.
WHEN OTHERS. flg_notp = 'X'.
ENDCASE.
* Last Check
IF flg_xwia = 'X' AND par_xstw = 'X'.
PERFORM wia_tax_decl_country(sapdbbrf) USING sel_lstm-low.
ENDIF.
* Set output language
IF NOT par_lang IS INITIAL.
IF NOT sy-batch IS INITIAL
OR NOT gd_exec_and_print IS INITIAL.
GET LOCALE LANGUAGE gd_locale_language
COUNTRY gd_locale_country
MODIFIER gd_locale_modifier.
TRY.
SET LOCALE LANGUAGE par_lang.
SET LANGUAGE sy-langu.
IF NOT g_bukrs_land IS INITIAL.
SET COUNTRY g_bukrs_land.
ENDIF.
CATCH cx_sy_localization_error.

"1263340
"1263340
"1263340
"1307450
"1263340
"1263340
"1263340
"1263340
"1263340
"1263340
"1263340
"1263340
"1263340
"1263340

CLEAR: gd_locale_language,
gd_locale_country.
MESSAGE s146
WITH par_lang g_bukrs_land.
ENDTRY.
ENDIF.
ENDIF.
COMMIT WORK.
IF NOT ( sel_tmti IS INITIAL ).
ran_tmti[] = sel_tmti[].
ENDIF.
copy sel_cpud to br_cpudt.
copy sel_bldt to br_bldat.
copy sel_vtdt to br_vatdt.
READ TABLE br_bldat INDEX 1.
READ TABLE br_vatdt INDEX 1.
hlp_stmdt = sy-datum.
hlp_stmti = sy-uzeit.
REFRESH tab_bset_key.

"1263340
"1263340
"1263340
"1263340
"1263340
"1263340
"1263340

"N1023317
"N1023317

IF flg_umkrs = 1.
Es wurden Umsatzsteuerkreise abgegrenzt.
REFRESH br_bukrs.
CLEAR br_bukrs.
br_bukrs-sign = 'I'.
br_bukrs-option = 'EQ'.
*
Zugehrige Buchungskreise holen.
SELECT * FROM t007f
WHERE umkrs IN sel_ukrs.
SELECT * FROM t001
WHERE umkrs = t007f-umkrs.
br_bukrs-low = t001-bukrs.
APPEND br_bukrs.
*note 877045: feststellen, fr welche Buchungskreise der Splitter aktiv ist.
APPEND t001-bukrs TO lt_bukrs_hlp.
*

CALL METHOD cl_fagl_split_services=>check_activity


EXPORTING
it_bukrs = lt_bukrs_hlp
RECEIVING
rb_active = ld_active_split
EXCEPTIONS
OTHERS
= 1.
IF ld_active_split = abap_true.
APPEND t001-bukrs TO gt_bukrs_split_act.
ENDIF.
CLEAR ld_active_split.
REFRESH lt_bukrs_hlp.
*end of note 877045
ENDSELECT.

ENDSELECT.
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
"<<<< 31H
EXPORTING
xdatabase = 'B'
"<<<< 31H
TABLES
xbukreis = br_bukrs.
"<<<< 31H
ELSE.
* note 877045: wenn Buchungskreise abgegrenzt wurden muss ermittelt werden, w
elche
* Bukrs den splitter nutzen
IF flg_umkrs = '0'.
"N1542782
SELECT bukrs FROM t001 INTO TABLE lt_selected_bukrs
WHERE bukrs IN br_bukrs.
ELSE.
"N1542782
*
flg_umkrs = 2 -->
"N1542782
lt_selected_bukrs[] = lt_all_bukrs[].
"N1542782
br_bukrs[]
= gt_range_bukrs[].
"N1542782
ENDIF.
"N1542782
LOOP AT lt_selected_bukrs INTO ls_selected_bukrs.
APPEND ls_selected_bukrs TO lt_bukrs_hlp.
CALL METHOD cl_fagl_split_services=>check_activity
EXPORTING
it_bukrs = lt_bukrs_hlp
RECEIVING
rb_active = ld_active_split
EXCEPTIONS
OTHERS
= 1.
IF ld_active_split = abap_true.
APPEND ls_selected_bukrs TO gt_bukrs_split_act.
ENDIF.
CLEAR ld_active_split.
REFRESH lt_bukrs_hlp.

ENDLOOP.
end note 877045
ENDIF.

* Tabelle T007B einlesen


SELECT * FROM t007b INTO TABLE tab_007b.
* Report-Titel aufbauen; FLG_PERSEL setzen
PERFORM create_report_title.
* Batch-Heading vorbereiten
bhdgd-inifl = 0.
bhdgd-lines = sy-linsz.

bhdgd-uname
bhdgd-repid
bhdgd-line1
bhdgd-line2
bhdgd-separ
bhdgd-domai

=
=
=
=
=
=

sy-uname.
sy-repid.
sy-title.
par_line.
par_lsep.
'BUKRS'.

* IF NOT p_bupla IS INITIAL.


" TP-01
"OP-01
*
Add the value <P_BUPLA> into the second line of the header "TP-01
*
bhdgd-line2 = 'Geschftsort ist &1'(008).
"TP-01 "OP-01
*
REPLACE '&1' WITH p_bupla INTO bhdgd-line2.
"TP-01 "OP-01
*
CONCATENATE '(' bhdgd-line2 ')' INTO bhdgd-line2."TP-01 "OP-01
*
CONCATENATE bhdgd-line2 par_line INTO bhdgd-line2 "TP-01 "OP-01
*
SEPARATED BY ' '.
" TP-01
* ENDIF. " not p_bupla is initial
"TP-01 "OP-01
* Mikrofiche-Zeile vorbereiten
bhdgd-miffl = par_mikf.

"429158

IF par_lis5 = 'X'.
Erlaubte Rundungsdifferenzen pro Buchungskreis holen
REFRESH tab_001r.
SELECT * FROM t001
WHERE bukrs IN br_bukrs.
*
Rundungsdifferenzen nur fr die Hauswhrung merken
SELECT SINGLE * FROM t001r
WHERE bukrs = t001-bukrs
AND waers = t001-waers.
IF sy-subrc = 0.
MOVE-CORRESPONDING t001r TO tab_001r.
APPEND tab_001r.
ELSE.
MOVE-CORRESPONDING t001 TO tab_001r.
tab_001r-reinh = 1.
APPEND tab_001r.
ENDIF.
ENDSELECT.
ENDIF.
*

* Tabelle mit Buchungskreisen, aus denen Belege zu 4.0 umgesetzt wurden


IMPORT ums40 FROM DATABASE rfdt(fu) ID 'UMS40'.

* enqueue status records for electronic tax declaration


* (entries for table gt_foteclsta have been created
* at selection screen in form check_euva)
IF par_euva = 'X'.
CALL FUNCTION 'FOT_ENQUEUE_DECLSTA'
EXPORTING
it_fotdeclsta = gt_fotdeclsta
id_enqmod
= 'ENQ'.
ENDIF.

"751603
"751603
"751603
"751603
"751603
"751603
"751603
"751603
"751603

GET bosg.
" Optimization
IF xhana eq 'E'.
IF alcur EQ 'X'.
PERFORM read_teurb TABLES br_bukrs.
ENDIF. "<<<<euro
PERFORM process_result.
ENDIF.
*&---------------------------------------------------------------------*
*&
Form process_bkpf
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM process_bkpf
CHANGING lv_reject TYPE abap_bool.
"2103962
lv_reject = abap_false.
"2103962
*
*
*
*

IF xhana <> 'E'.


CHECK:
sel_mona.
ENDIF.
IF NOT bkpf-monat IN sel_mona.
lv_reject = abap_true.
RETURN.
ENDIF.

* Prfen Umsatzsteuerkreis Zeitabh. durchfhren


If flg_umkrs = '2'.
CALL FUNCTION 'TAX_UMKRS_DETERMINE'
EXPORTING
i_bkpf
= bkpf
IMPORTING
E_UMKRS
= gd_umkrs.
*
Weiterverarb. nur, wenn der UMKRS bestimt werden konnte
*
CHECK: gd_umkrs IS NOT INITIAL.
"N1542782
*
IF gd_umkrs IS NOT INITIAL.
"2103962
IF gd_umkrs IS INITIAL.
"2103962
lv_reject = abap_true.
RETURN.
ENDIF.
ENDIF.
*
REFRESH:
tab_diff,
tab_ep.
CLEAR:
ep,
tab_diff,
tab_ep,

"2103962
"2103962
"2103962
"2103962
"2103962
"2103962
"2103962
"2103962
"N1542782
"N1542782
"N1542782
"N1542782
"N1542782
"N1542782
"N1542782
"N1542782
"2103962
"2125886
"2125886
"2103962
"2103962
"2103962
"N1542782

g_linewise,
hlp_umskz,
hlp_zuonr,
hlp_gl_account.
IF NOT par_bodo IS INITIAL.
flg_bd_only_gl = 'X'.
REFRESH tab_bd_gl_accounts.
CLEAR hlp_bodo_accnt.
ENDIF.
CLEAR gs_any_bseg.
REFRESH gt_ese_bset.
REFRESH gt_wia_adrnr.
REFRESH gt_discounts.
CLEAR: gd_hwbas,
gd_lwbas.

"1584037
"938627
"Bolle Doganle

"1014836
"1120571
"859167
"1686870
"1868787
"1868787
"1868787

PERFORM read_t001 USING bkpf-bukrs.


* IF par_bsud = 'X'.
**
Bukrs, Belegnummer und Geschftsjahr fr BSET-Update
**
mit den aus TAB_EP gelschten Zeilen merken
*
CLEAR tab_bset_key.
*
MOVE-CORRESPONDING bkpf TO tab_bset_key.
* ENDIF.

"2061805
"2061805
"2061805
"2061805
"2061805
"2061805

* Erlaubte Rundungsdifferenz fr Buchungskreis bzgl. Hauswhrung


IF par_lis5 = 'X'.
READ TABLE tab_001r WITH KEY bukrs = bkpf-bukrs
waers = tab_001-waers.
"1104702
IF sy-subrc <> 0.
"1104702
SELECT SINGLE * FROM t001r
"1104702
WHERE bukrs = bkpf-bukrs
"1104702
AND waers = tab_001-waers.
"1104702
IF sy-subrc = 0.
"1104702
MOVE-CORRESPONDING t001r TO tab_001r.
"1104702
APPEND tab_001r.
"1104702
ELSE.
"1104702
MOVE-CORRESPONDING tab_001 TO tab_001r.
"1104702
tab_001r-reinh = 1.
"1104702
APPEND tab_001r.
"1104702
ENDIF.
"1104702
ENDIF.
"1104702
*

Erlaubte Rundungsdifferenz bzgl. Belegwaehrung


IF bkpf-waers <> tab_001-waers.
READ TABLE tab_001r INTO gs_t001r_fc
WITH KEY bukrs = bkpf-bukrs
waers = bkpf-waers.
IF sy-subrc <> 0.
SELECT SINGLE * FROM t001r INTO gs_t001r_fc
WHERE bukrs = bkpf-bukrs
AND waers = bkpf-waers.

"1104702
"1104702
"1104702
"1104702
"1104702
"1104702
"1104702
"1104702
"1104702

IF sy-subrc = 0.
APPEND gs_t001r_fc TO tab_001r.
ELSE.
gs_t001r_fc-bukrs = bkpf-bukrs.
gs_t001r_fc-waers = bkpf-waers.
gs_t001r_fc-reinh = 1.
APPEND gs_t001r_fc TO tab_001r.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM.

"1104702
"1104702
"1104702
"1104702
"1104702
"1104702
"1104702
"1104702
"1104702
"1104702

"process_bkpf

*----------------------------------------------------------------------*
* Belegkopf
*
*----------------------------------------------------------------------*
GET bkpf.
DATA lv_reject TYPE abap_bool.
"2103962
PERFORM process_bkpf
CHANGING lv_reject.
IF lv_reject = abap_true.
REJECT.
ENDIF.

"2103962
"2103962
"2103962
"2103962

*&---------------------------------------------------------------------*
*&
Form process_bseg
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM process_bseg.
* Flag Negativbuchung setzen
"OP-07
ep-negp = bseg-xnegp.
"OP-07
* Steuerkontrolle: Zulssige Rundungsdifferenz ermitteln
IF par_lis5 EQ 'X'.
"Steuerkontrolle
*
Merken der zulssigen Rundungsdifferenz pro Steuerkz. im Beleg,
*
abhngig von der Anzahl der Beleg- und Steuerzeilen mit diesem Kz
*
Kontokorrentzeilen und durch Steuerbetrge erzeugte automatische
*
Zeilen werden nicht bercksichtigt
IF bseg-koart <> 'D' AND bseg-koart <> 'K'
AND ( bseg-mwart = space OR bseg-xauto = space )
OR ( bseg-umsks = 'A' AND bseg-mwskz <> space ).
"1134305
tab_diff-flg_fc = space.
"1104702
tab_diff-mwskz = bseg-mwskz.
tab_diff-rndbl = tab_001r-reinh.
tab_diff-rndst = 0.
COLLECT tab_diff.
IF bkpf-waers <> tab_001-waers.
"1104702
tab_diff-flg_fc = 'X'.
"1104702

tab_diff-rndbl = gs_t001r_fc-reinh.
COLLECT tab_diff.
ENDIF.
ENDIF.
ENDIF.

"1104702
"1104702
"1104702

* Read tax-relevant Account with KOART <> K, D, S


IF ( 'KDS' NA bseg-koart ) AND ( NOT bseg-txgrp IS INITIAL ).
IF hlp_gl_account IS INITIAL.
hlp_gl_account = bseg-hkont.
ENDIF.
ENDIF.
* Account number of the first G/L-Account of each tax code
IF ( bseg-koart CA 'SAM' )
AND ( NOT bseg-mwskz IS INITIAL )
AND ( bseg-mwart IS INITIAL ).
READ TABLE it_glaccount INTO is_glaccount WITH KEY
mwskz = bseg-mwskz
koart = bseg-koart.
IF sy-subrc NE space.
is_glaccount-hkont = bseg-hkont.
is_glaccount-mwskz = bseg-mwskz.
is_glaccount-koart = bseg-koart.
APPEND is_glaccount TO it_glaccount.
ENDIF.
ENDIF.

"992241
"992241
"992241
"992241
"992241
"992241
"992241
"992241
"992241
"992241
"992241
"992241
"992241

* Read tax-relevant G/L-Accounts


* IF ( ep-zuonr IS INITIAL ) AND ( bseg-koart = 'S' )
*
AND ( ( ( NOT bseg-mwskz IS INITIAL ) AND
*
( bseg-mwart IS INITIAL ) ) OR
*
( NOT bseg-txgrp IS INITIAL ) )."435455
*
**
Allocation number of one G/L-Account
*
IF ( ep-zuonr IS INITIAL ).
*
ep-zuonr = bseg-zuonr.
*
ENDIF.
* get discount amounts per tax code
IF NOT so_diac[] IS INITIAL
AND NOT bseg-mwskz IS INITIAL.
IF bseg-koart CA 'SAM'
AND bseg-hkont IN so_diac.
gs_discounts-mwskz = bseg-mwskz.
gs_discounts-ktosl = space.
IF bseg-shkzg = 'S'.
gs_discounts-dmbtr = bseg-dmbtr.
gs_discounts-wrbtr = bseg-wrbtr.
ELSE.
gs_discounts-dmbtr = - bseg-dmbtr.
gs_discounts-wrbtr = - bseg-wrbtr.

"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787

ENDIF.
COLLECT gs_discounts INTO gt_discounts.
ENDIF.
ENDIF.
* get zuonr from tax postings as fallback value
IF NOT bseg-mwart IS INITIAL.
IF hlp_zuonr IS INITIAL
AND NOT bseg-zuonr IS INITIAL.
hlp_zuonr = bseg-zuonr.
ENDIF.
ENDIF.

"1868787
"1868787
"1868787
"1868787
"938627
"938627
"938627
"938627
"938627
"938627
"938627

IF ( bseg-koart = 'S' ) AND ( NOT bseg-mwskz IS INITIAL )


AND ( bseg-mwart IS INITIAL ).
"545812
*
*
*

EU-Ident number from first G/L-Account


"736203
An EU-Ident number in the first personal account will
"736203
override this.
"736203
IF ( ep-stceg IS INITIAL ) AND ( NOT bseg-stceg IS INITIAL )."736203
ep-stceg = bseg-stceg.
"640269
ENDIF.
"736203

Allocation number of one G/L-Account


IF ( ep-zuonr IS INITIAL ) AND ( bseg-koart = 'S' )
AND ( ( ( NOT bseg-mwskz IS INITIAL ) AND
( bseg-mwart IS INITIAL ) ) OR
( NOT bseg-txgrp IS INITIAL ) )."545812
ep-zuonr = bseg-zuonr.
ENDIF.

*
*
*
*
*
*
*
*
*
*

Account number of the first G/L-Account


Account number of the first G/L-Account of each tax code
READ TABLE it_glaccount INTO is_glaccount WITH KEY
"992241
mwskz = bseg-mwskz.
"992241

IF sy-subrc NE space.
is_glaccount-hkont = bseg-hkont.
is_glaccount-mwskz = bseg-mwskz.
APPEND is_glaccount TO it_glaccount.
ENDIF.
IF ( ep-hkont IS INITIAL ).
ep-hkont = bseg-hkont.
IF NOT g_read_bseg IS INITIAL.
PERFORM append_bseg.
ENDIF.
ENDIF.
Bolle Doganali: Save all tax-relevant G/L-Accounts
IF ( NOT par_bodo IS INITIAL ).
APPEND bseg-hkont TO tab_bd_gl_accounts.

"992241
"992241
"992241
"992241
"992241

ENDIF.
ENDIF.
* Bolle Doganali: Save the first non-tax-relevant G/L-account
IF ( NOT par_bodo IS INITIAL ).
"1014836
IF bseg-koart = 'S' and bseg-mwskz IS INITIAL.
"1014836
IF hlp_bodo_accnt IS INITIAL.
"1014836
hlp_bodo_accnt = bseg-hkont.
"1014836
ENDIF.
"1014836
ENDIF.
"1014836
ENDIF.
"1014836
* G/L-item for BADI_011 in case no bette item is available. "1120571
IF NOT g_read_bseg IS INITIAL.
"1120571
IF bseg-koart CA 'SAM'.
"1120571
IF bseg-mwskz IS INITIAL
"1120571
OR NOT bseg-MWART IS INITIAL.
"1120571
MOVE bseg TO gs_any_bseg.
"1120571
ENDIF.
"1120571
ENDIF.
"1120571
ENDIF.
"1120571
***********************************************************************
* Special treatment for personal accounts
*
***********************************************************************
CHECK bseg-koart EQ 'D' OR bseg-koart EQ 'K'
OR ( bseg-koart EQ 'S' AND NOT bseg-lifnr EQ space ).
"Impact on
"Aquisition Accrual Tax
"Note 831532
* First special G/L indicator
IF NOT bseg-umskz IS INITIAL.
IF hlp_umskz IS INITIAL.
hlp_umskz = bseg-umskz.
ENDIF.
ENDIF.
* Bolle Doganali
IF NOT par_bodo IS INITIAL.
CLEAR flg_bd_only_gl.
ENDIF.

"Bolle Doganali
"There are not only G/L-Accounts

* Account number of the first personal account


IF ep-ktnra EQ space.
ep-koart = bseg-koart.
*
EU-Ident number from first personal account
"736203
IF ( NOT bseg-stceg IS INITIAL ).
"736203
ep-stceg = bseg-stceg.
ENDIF.
"736203
IF bseg-koart EQ 'D'.
ep-ktnra = bseg-kunnr.
ELSE.
"bseg-koart = 'K' or 'S'

ep-ktnra = bseg-lifnr.
ENDIF.
ep-bcode = bseg-j_1tpbupl.
IF NOT g_read_bseg IS INITIAL.
PERFORM append_bseg.
ENDIF.
ENDIF.

"BP Branch Code TH

* check again for 'D' or 'K' because there are


* G/L items with LIFNR filled ( MM and note 831532).
IF bseg-koart CA 'DK'.
ep-augdt = bseg-augdt.
IF bseg-augdt EQ space.
CLEAR ep-augdt.
ENDIF.
ENDIF.
ENDFORM.
"process_bseg

"2097858

"1299120
"1299120
"1299120

"1299120

*----------------------------------------------------------------------*
* Belegposition (Adressdaten, Skonto, Fortschreiben Anzahl der
*
*
Sachkontenzeilen pro Steuerkennzeichen)
*
*----------------------------------------------------------------------*
GET bseg.
PERFORM process_bseg.
*&---------------------------------------------------------------------*
*&
Form PROCESS_BSET
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM process_bset CHANGING lv_reject TYPE abap_bool.
* save some bset data for 100%-ESE correction
PERFORM append_ese_bset.

*
*
*
*
*

"859167
"859167

IF NOT sel_ktos IS INITIAL.


CHECK bset-ktosl IN sel_ktos.
ENDIF.

"400505
"400505
"400505

IF NOT skonto IS INITIAL.


CHECK bset-hkont IN skonto.
ENDIF.

"OP-09
"OP-09
"OP-09

IF NOT sel_bupl IS INITIAL.


"OP-01
CHECK bset-bupla IN sel_bupl.
"OP-01
ENDIF.
"OP-01
IF bset-bupla <> p_bupla AND NOT p_bupla IS INITIAL."OP-01
There may be at most one business place in each document."OP-01
The business place of the current document does not match"OP-01
the input <p_bupla> ==> Go to the next document
"OP-01
REJECT 'BKPF'.
"OP-01

ENDIF.
"OP-01
lv_reject = abap_false.
IF NOT hlp_umskz IN sel_umsk.
*
There may be at most one special G/L indicator in each document.
*
The special G/L indicator of the current document does not match
*
the input <sel_umsk> ==> Go to the next document
"for external optimization, simulating logic is introduced for the REJECT
statement related to the LDB in the original report
*
IF xhana = 'E'.
"2103962
lv_reject = abap_true.
EXIT.
*
ELSE.
"2103962
*
REJECT 'BKPF'.
"2103962
*
ENDIF.
"2103962
ENDIF.
CHECK:
sel_mwkz, sel_lstm,
bset-hwbas NE 0 OR
( par_xstw = 'X' AND BSET-LWBAS NE 0 ).

"1632983
"1632983

*
*
*

Begin of Note 1359126


When the tax code is relevant for refund of VAT then it shall
not be processed here
DATA:
ls_tax_rfd_codes TYPE tax_rfd_codes.
CLEAR ls_tax_rfd_codes.
CALL FUNCTION 'GET_TAX_RFD_CODE'
EXPORTING
iv_kalsm
= tab_001-kalsm
iv_mwskz
= bset-mwskz
IMPORTING
es_tax_rfd_codes = ls_tax_rfd_codes
EXCEPTIONS
not_found
= 1
OTHERS
= 2.
CHECK ls_tax_rfd_codes IS INITIAL.
* End of Note 1359126
* berprfen, ob Steuerzeile fr aktuellen Lauf relevant ist
IF ( NOT sel_tmdt IS INITIAL ) AND ( sel_tmti IS INITIAL ).
CHECK sel_tmdt.
ELSEIF ( NOT sel_tmti IS INITIAL ).
CHECK sel_tmdt.
CHECK bset-stmti IN ran_tmti.
ELSEIF par_bsud = 'X' OR par_bupl = 'X'.
CHECK:
bset-stmdt IS INITIAL,
bset-stmti IS INITIAL.
ENDIF.
PERFORM:

read_t007a USING tab_001-kalsm bset-mwskz,


read_t007b USING bset-ktosl.
* Exclude MOSS tax codes unless explicitly selected.
IF ( par_moss IS INITIAL ).
CHECK tab_007a-mossc IS INITIAL.
ENDIF.

"2101269
"2101269
"2101269
"2101269

PERFORM check_read_konp?.
"447075
IF read_konp? = 'y'.
"447075
READ TABLE it_coco_calcproc WITH KEY bukrs = bset-bukrs."481176
PERFORM
"447075
read_konp
USING bset-mwskz bset-kschl bset-ktosl it_coco_calcproc-land1.
"481176 "OP-20
ENDIF.
"447075
CHECK tab_007b-stgrp NE 4.
** if it is a Russian company code, tax line items
** will be handled different
* READ TABLE gt_isocodes INTO s_isocodes
*
WITH KEY bukrs = bset-bukrs.
*
* IF sy-subrc = 0.
*
IF s_isocodes-intca = 'RU' OR
*
s_isocodes-intca = 'UA'.
"566949
*
IF NOT par_binp = space.
** No deferred tax with tax amount <> 0
*
IF ( NOT tab_007a-zmwsk IS INITIAL ).
*
CHECK ( bset-kbetr IS INITIAL ).
*
ENDIF.
*
ENDIF.
*
ELSE.
** No deferred tax with tax amount <> 0
*
IF ( NOT tab_007a-zmwsk IS INITIAL ).
*
CHECK ( bset-kbetr IS INITIAL ).
*
ENDIF.
*
ENDIF.
* ENDIF.
* -----Begin insert Note 1948319 ----* check if deferred tax code is to be processed
IF NOT tab_007a-zmwsk IS INITIAL.
DATA: ld_def_type
TYPE c,
ld_def_show
TYPE xfeld,
ld_def_show_0 TYPE xfeld.
PERFORM check_def_ctry_option
USING
bset-bukrs
space
CHANGING
ld_def_type
ld_def_show
ld_def_show_0.

with deferred taxes


"566949 "1948319
"566949 "1948319
"566949 "1948319
"566949 "1948319
"566949 "1948319
"1948319
"595718 "1948319
"566949 "1948319
"1948319
"566949 "1948319
"566949 "1948319
"566949 "1948319
"566949 "1948319
"566949 "1948319
"1948319
"566949 "1948319
"566949 "1948319
"566949 "1948319
"566949 "1948319
"566949 "1948319
"1948319
"1948319
"1948319

IF ld_def_show_0 = 'X' AND


bset-kbetr IS INITIAL.
ld_def_show = 'X'.
"show 0% deferred tax codes
ENDIF.
CHECK ld_def_show = 'X'.
ENDIF.
* -----End insert Note 1948319 -----

"1948319
"1948319

* Check if linewise tax calculation has been activated.


* for this document. A filled taxps is a safe indicator.
* This information is used when merging non-deductible tax.
IF NOT bset-taxps IS INITIAL.
g_linewise = 'X'.
ENDIF.

"1584037
"1584037
"1584037
"1584037
"1584037
"1584037

*
*

IF par_lis5 EQ 'X'.
"Steuerkontrolle
Merken der zulssigen Rundungsdifferenz pro Steuerkz. im Beleg,
abhngig von der Anzahl der Beleg- und Steuerzeilen mit diesem Kz
tab_diff-flg_fc = space.
"1104702
tab_diff-mwskz = bset-mwskz.
tab_diff-rndbl = 0.
tab_diff-rndst = tab_001r-reinh.
COLLECT tab_diff.
IF bkpf-waers <> tab_001-waers.
"1104702
tab_diff-flg_fc = 'X'.
"1104702
tab_diff-rndst = gs_t001r_fc-reinh.
"1104702
COLLECT tab_diff.
"1104702
ENDIF.
"1104702
ENDIF.

* Einzelpostentabelle fllen ------------------------------------------MOVE-CORRESPONDING bset TO tab_ep.


tab_ep-tkont = bset-hkont.
IF par_xstw = 'X' AND alcur NE 'X'.
"OP-25
tab_ep-hwbas = bset-lwbas.
tab_ep-hwste = bset-lwste.
ENDIF.
IF bset-shkzg EQ 'H'.
tab_ep-hwbas = tab_ep-hwbas * -1.
tab_ep-fwbas = tab_ep-fwbas * -1.
tab_ep-hwste = tab_ep-hwste * -1.
tab_ep-fwste = tab_ep-fwste * -1.
ENDIF.
tab_ep-mwart = tab_007a-mwart.
tab_ep-text1 = tab_007a-text1.
"OP-08
tab_ep-stgrp = tab_007b-stgrp.
tab_ep-stazf = tab_007b-stazf.
IF read_konp? = 'y'.
"447075
tab_ep-kbetr = tab_konp-kbetr.
"OP-26
ENDIF.
"447075
*
"720567
* Bei ESA/ESA wenn ESA negativ und nur Basisbetrag ausgewiesen wird,

* dann muss beim Basisbetrag noch mal mit -1 multipliziert werden


* da beim Buchen der Betrag nicht negativ wird
IF tab_ep-hwste = 0
AND
"720567
tab_ep-kbetr < 0.
"720567
tab_ep-hwbas = - tab_ep-hwbas.
"720567
tab_ep-fwbas = - tab_ep-fwbas.
"720567
ENDIF.
"720567
APPEND tab_ep.
gd_hwbas = gd_hwbas + ABS( bset-hwbas ).
gd_lwbas = gd_lwbas + ABS( bset-lwbas ).
i_lwbas = bset-lwbas.
i_fwbas = bset-fwbas.
ENDFORM.
" GET_BSET

"1868787
"1868787
"455681
"455681

*----------------------------------------------------------------------*
* Umsatzsteuerposition
*
*----------------------------------------------------------------------*
GET bset.
" create a local data object to reuse the subroutine process_bset for synta
x check, no other meaning here.
DATA lv_reject TYPE abap_bool.
PERFORM process_bset CHANGING lv_reject.
IF lv_reject = abap_true.
"2103962
REJECT 'BKPF'.
"2103962
ENDIF.
"2103962

*&---------------------------------------------------------------------*
*&
Form PROCESS_BKPF_LATE
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM process_bkpf_late .
* Belegkopf-Felder zum Extrahieren fllen -----------------------------ep-bukrs
= bkpf-bukrs.
ep-buper(4) = bkpf-gjahr.
ep-buper+4 = bkpf-monat.
ep-bktxt
= bkpf-bktxt.
ep-blart
= bkpf-blart.
ep-bldat
= bkpf-bldat.
ep-xmwst
= bkpf-xmwst.
ep-waers
= bkpf-waers.
ep-budat
= bkpf-budat.
ep-belnr
= bkpf-belnr.
ep-xblnr
= bkpf-xblnr.
ep-xblnr_alt = bkpf-xblnr_alt.
"792331
ep-vatdate = bkpf-vatdate.
"1023317
IF par_xstw NE space.
data
floatvalue type f. "665165

"455681

clear floatvalue.
SELECT SINGLE * FROM t005
WHERE land1 = sel_lstm-low.

"455681

IF bkpf-waers EQ t005-waers
OR i_fwbas = 0.
CLEAR ep-ex_rate.
ELSE.

"1747902
"1747902
"1747902
"1747902

LOOP AT it_tcurf INTO is_tcurf WHERE


kurst = t005-kurst AND
fcurr = bkpf-waers AND
tcurr = t005-waers.
"455681
ENDLOOP.
"455681
IF sy-subrc NE 0.
"455681
SELECT SINGLE * FROM tcurf
WHERE kurst = t005-kurst AND
fcurr = bkpf-waers AND
tcurr = t005-waers.
"455681
IF sy-subrc = 0.
is_tcurf = tcurf.
"455681
PERFORM adapt_tcurf_decimals
"1963595
CHANGING is_tcurf.
"1963595
APPEND is_tcurf TO it_tcurf.
"455681
* ----- Begin Delete 1747902 ----"1747902
*
i_helpamount = ( i_lwbas * tcurf-ffact ) * 100000. "455681
*
floatvalue = i_helpamount / ( i_fwbas * tcurf-tfact ).
**
if floatvalue < 10000.
"1015278
*
if floatvalue < 1000000000
"1015278
*
and floatvalue > 0.
"1617293
*
move floatvalue to ep-ex_rate.
*
else.
*
clear ep-ex_rate.
*
endif.
* ----- End Delete 1747902 ----"1747902
ELSE.
"455681
is_tcurf-kurst = t005-kurst.
"1747902
is_tcurf-fcurr = bkpf-waers.
"1747902
is_tcurf-tcurr = t005-waers.
"1747902
is_tcurf-ffact = 1.
"1747902
is_tcurf-tfact = 1.
"1747902
*
also put not-found entry to buffer
"1747902
PERFORM adapt_tcurf_decimals
"1963595
CHANGING is_tcurf.
"1963595
APPEND is_tcurf TO it_tcurf.
"1747902
* ----- Begin Delete 1747902 ----"1747902
*
i_helpamount = i_lwbas * 100000.
"455681
*
floatvalue = i_helpamount / i_fwbas.
"455681
**
if floatvalue < 10000.
"1015278
*
if floatvalue < 1000000000
"1015278
*
and floatvalue > 0.
"1617293
*
move floatvalue to ep-ex_rate.

*
else.
*
clear ep-ex_rate.
*
endif.
* ----- End Delete 1747902 ----"1747902
ENDIF.
*
ELSE.
"1747902
ENDIF.
"1747902
i_helpamount = ( i_lwbas * is_tcurf-ffact ) * 100000. "455681
floatvalue = i_helpamount / ( i_fwbas * is_tcurf-tfact ).
*
if floatvalue < 10000.
"1015278
if floatvalue < 1000000000
"1015278
and floatvalue > 0.
"1617293
move floatvalue to ep-ex_rate.
else.
clear ep-ex_rate.
endif.
*
ENDIF.
"455681
"1747902
ENDIF.
"1747902
ELSE.
ep-ex_rate = bkpf-kursf.
ENDIF.

"455681
"OP-19
"455681

CLEAR i_lwbas.
CLEAR i_fwbas.

"561608
"561608

IF par_xcas = 'X'.
"Quittungsdaten lesen
CONDENSE bkpf-bktxt.
SPLIT bkpf-bktxt AT space INTO ep-qunum ep-qutyp ep-qudat.
CHECK ep-qunum NE space.
IF ep-qudat IS INITIAL.
WRITE bkpf-bldat TO ep-qudat DD/MM/YYYY.
ENDIF.
hlp_sort = ep-qunum.
ENDIF.
* Steuerkontrolle -----------------------------------------------------IF par_lis5 EQ 'X'.
"Steuerkontrolle
LOOP AT tab_ep.
*
PERFORM read_tax_amount
"Steuerbetrag berechnen "825186
*
USING tab_ep-mwskz tab_ep-kschl tab_ep-hwbas
"825186
*
CHANGING hlp_hwste2.
"825186
PERFORM calculate_tax_amount
"Steuerbetrag berechnen "825186
USING tab_ep-mwskz tab_ep-kschl tab_ep-ktosl
"825186
tab_ep-hwbas
"825186
CHANGING hlp_hwste2.
"825186
tab_ep-sdiff = hlp_hwste2 - tab_ep-hwste.
IF bkpf-waers <> tab_001-waers.
"1104702
PERFORM calculate_tax_amount
"1104702
USING tab_ep-mwskz tab_ep-kschl tab_ep-ktosl
"1104702
tab_ep-fwbas
"1104702
CHANGING hlp_hwste2.
"1104702

tab_ep-sdiff_fc = hlp_hwste2 - tab_ep-fwste.


ENDIF.
MODIFY tab_ep.
"Differenz merken
ENDLOOP.
ENDIF.

"1104702
"1104702

* Get Address data for stock transfer documents from SD


* (creates internal table gt_wia_adrnr)
IF NOT flg_xwia IS INITIAL.
IF ep-koart IS INITIAL
AND bkpf-awtyp = 'VBRK '.
*
PERFORM stock_transfer_address
"1035054

"1035054
"1686870
"1035054
"1035054
"1035054
"1686870

*
*

CHANGING ep-wia_adrnr
ep-stceg.

"1035054 "1686870
"1035054 "1686870

PERFORM stock_transfer_address.
ENDIF.
ENDIF.
* Get customer account for gift invoices
* (SD-dicument with output tax but no customer item)
IF ep-koart is initial
AND bkpf-awtyp = 'VBRK '
*
AND ep-wia_adrnr IS initial.
"1233225
AND gt_wia_adrnr[] IS INITIAL.
PERFORM gift_invoice_customer
CHANGING ep-koart
ep-ktnra.
ENDIF.

"1686870
"1035054
"1035054
"1233225
"1233225
"1233225
"1233225
"1686870
"1686870
"1233225
"1233225
"1233225
"1233225

* Change table TAB_EP with BADI 'fi_tax_badi_012'


IF NOT g_use_badi_12 IS INITIAL.
PERFORM badi_get_bkpf_late.
ENDIF.
* Nicht abzugsfhige Steuer auf zugehrige Zeilen verteilen
IF par_caos IS INITIAL.
CLEAR g_use_txgrp.
READ TABLE gt_isocodes INTO s_isocodes
WITH KEY bukrs = bkpf-bukrs.
IF s_isocodes-intca EQ 'IN'.
* In India tax calculation is line-wise. Only the logic
* using txgrp can work correctly.
g_use_txgrp = 'X'.
ENDIF.
IF g_linewise EQ 'X'.
* g_linewise means that bset-taxps is filled. We can safely
* rely on correct txgrp in this case.
g_use_txgrp = 'X'.
ENDIF.

-----------"OT-07
"1125117
"1125117
"1125117
"1125117
"1125117
"1125117
"1125117
"1125117
"1584037
"1584037
"1584037
"1584037
"1584037

IF bkpf-awtyp EQ 'FKKSU'.
"1584037
* TXGRP is guaranteed to be useless in documents from FI-CA."1584037
CLEAR g_use_txgrp.
"1584037
ENDIF.
"1584037

*
*

LOOP AT tab_ep.
tab_ep-hwnaf = 0.
tab_ep-fwnaf = 0.
IF tab_ep-stazf EQ 'X'.
hlp_txgrp
= tab_ep-txgrp.
"994295
hlp_txgrp
= tab_ep-txgrp.
"1125117
hlp_mwskz
= tab_ep-mwskz.
"994295
hlp_hwbas
= tab_ep-hwbas.
"994295
hlp_kschl
= tab_ep-kschl.
"1584037
hlp_shkzg
= tab_ep-shkzg.
hlp_hwnaf
= tab_ep-hwste.
hlp_fwnaf
= tab_ep-fwste.
hlp_kbetr
= tab_ep-kbetr.
hlp_sdiff
= tab_ep-sdiff.
hlp_sdiff_fc = tab_ep-sdiff_fc.
"1104702
flg_modify = 0.
LOOP AT tab_ep.
"Zugehrige Zeile suchen
IF tab_ep-txgrp EQ hlp_txgrp
"994295
IF tab_ep-mwskz EQ hlp_mwskz
"994295
AND tab_ep-hwbas EQ hlp_hwbas
"994295 "1125117
AND (
"1125117
( g_use_txgrp = space
"1125117
AND tab_ep-hwbas EQ hlp_hwbas )
"1125117
OR ( g_use_txgrp = 'X'
"1125117
AND tab_ep-txgrp EQ hlp_txgrp )
"1125117
)
"1125117
AND tab_ep-kschl NE hlp_kschl
"1584037
AND tab_ep-shkzg EQ hlp_shkzg
AND tab_ep-stgrp NE 3
AND tab_ep-stazf EQ space.
tab_ep-hwste = tab_ep-hwste + hlp_hwnaf.
tab_ep-fwste = tab_ep-fwste + hlp_fwnaf.
tab_ep-hwnaf = tab_ep-hwnaf + hlp_hwnaf.
tab_ep-fwnaf = tab_ep-fwnaf + hlp_fwnaf.
tab_ep-kbetr = tab_ep-kbetr + hlp_kbetr.
tab_ep-sdiff = tab_ep-sdiff + hlp_sdiff.
tab_ep-sdiff_fc = tab_ep-sdiff_fc
"1104702
+ hlp_sdiff_fc.
"1104702
MODIFY tab_ep.
flg_modify = 1.
EXIT.
ENDIF.
ENDLOOP.
READ TABLE tab_ep INDEX sy-tabix.
IF flg_modify EQ 1.
IF par_bsud = 'X'
AND par_xsvo = 'X'.
"859167

MOVE-CORRESPONDING tab_ep TO tab_bset_key.


"2061805
tab_bset_key-bukrs = bkpf-bukrs.
"2061805
tab_bset_key-belnr = bkpf-belnr.
"2061805
tab_bset_key-gjahr = bkpf-gjahr.
"2061805
tab_bset_key-buzei = tab_ep-buzei.
"2061805
APPEND tab_bset_key.
"Zeile merken fr BSET-Update
ENDIF.
DELETE tab_ep.
"Zeile mit n.abzugsf. lschen
ELSE.
"Zugehrige Zeile fehlte (dh 100%
"n.abzugsf.) => Zeile generieren
tab_ep-stazf = space.
tab_ep-hwnaf = tab_ep-hwste.
tab_ep-fwnaf = tab_ep-fwste.
MODIFY tab_ep.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
"par_caos IS INITIAL.
"OT-07
LOOP AT tab_ep.
"OP-01
tab_ep-hwsteaa = tab_ep-hwste - tab_ep-hwnaf.
"OP-01
tab_ep-fwsteaa = tab_ep-fwste - tab_ep-fwnaf.
"783666
MODIFY tab_ep.
"OP-01
ENDLOOP.
"OP-01

* Erwerbsteuer korrigieren --------------------------------------------* ----- begin of deletion ----- "853491


* LOOP AT tab_ep.
*
WRITE tab_ep-kbetr TO hlp_psatz NO-SIGN CURRENCY '3'.
*
IF hlp_psatz(3) EQ '100'.
"vermutlich Erwerbsteuer
*
hlp_hwste = - tab_ep-hwste.
*
hlp_txgrp =
tab_ep-txgrp.
*
flg_modify = 0.
*
LOOP AT tab_ep.
*
IF tab_ep-hwste EQ hlp_hwste
"Erwerbsteuer!
*
AND tab_ep-txgrp EQ hlp_txgrp.
*
hlp_hwbas = tab_ep-hwbas.
"Basisbetrag und Prozentsatz
*
hlp_fwbas = tab_ep-fwbas.
"merken
*
hlp_kbetr = tab_ep-kbetr.
*
flg_modify = 1.
*
EXIT.
*
ENDIF.
*
ENDLOOP.
*
IF flg_modify = 1.
*
LOOP AT tab_ep
*
WHERE txgrp EQ hlp_txgrp.
*
WRITE tab_ep-kbetr TO hlp_psatz NO-SIGN CURRENCY '3'.
*
IF hlp_psatz(3) EQ '100'.
"100%-Zeile modifizieren:
*
tab_ep-hwbas = - hlp_hwbas." Basisbetrag mit umgekehrtem
*
tab_ep-fwbas = - hlp_fwbas." Vorzeichen und
*
tab_ep-kbetr =
hlp_kbetr." Partnerzeile bernehmen
*
MODIFY tab_ep.
*
EXIT.

*
ENDIF.
*
ENDLOOP.
*
ENDIF.
*
ENDIF.
* ENDLOOP.
* ----- end of deletion ----*
*
*
*
*

"853491

With some unusual calculation procedures it is possible


to have -100% reference for output tax and non-deductible
input tax at the same time. In this case we must first
merge deductible and non-deductible input tax in table
gt_ese_bset.
PERFORM merge_ese_bset.

"1017516
"1017516
"1017516
"1017516
"1017516
"1017516

* ----- begin of insertion ----- "853491


* Erwerbsteuer korrigieren --------------------------------------------LOOP AT tab_ep.
WRITE tab_ep-kbetr TO hlp_psatz NO-SIGN CURRENCY '3'.
IF hlp_psatz(3) EQ '100'.
"vermutlich Erwerbsteuer
hlp_hwste = - tab_ep-hwste.
hlp_txgrp =
tab_ep-txgrp.
hlp_mwskz =
tab_ep-mwskz.
hlp_kschl =
tab_ep-kschl.
"912777
hlp_tabix =
sy-tabix.
flg_modify = 0.
*
LOOP AT tab_ep
"859167
LOOP AT gt_ese_bset
"859167
WHERE mwskz = hlp_mwskz.
*
IF tab_ep-hwste EQ hlp_hwste.
"Erwerbsteuer! "859167
IF gt_ese_bset-hwste EQ hlp_hwste
"Erwerbsteuer! "859167
AND gt_ese_bset-kschl NE hlp_kschl.
"912777
IF bkpf-awtyp EQ 'FKKSU'.
"document from FI-CA
PERFORM read_t007a USING tab_001-kalsm hlp_mwskz.
*(DEL)
IF tab_007a-egrkz EQ '9'.
"1489130
*(DEL)
IF tab_007a-egrkz CA '56789'.
"1489130 "1543271
IF tab_007a-egrkz CA '56789A'.
"1543271
flg_modify = 1.
ENDIF.
ELSE.
"all other documents
*
IF tab_ep-txgrp EQ hlp_txgrp.
"859167
IF gt_ese_bset-txgrp EQ hlp_txgrp.
"859167
flg_modify = 1.
ENDIF.
ENDIF.
ENDIF.
IF flg_modify = 1.
*
hlp_hwbas = tab_ep-hwbas.
"Basisbetrag und
"859167
*
hlp_fwbas = tab_ep-fwbas.
"merken
"859167
*
hlp_kbetr = tab_ep-kbetr.
"859167
hlp_hwbas = gt_ese_bset-hwbas. "Basisbetrag und
"859167
hlp_fwbas = gt_ese_bset-fwbas.
"859167
hlp_kbetr = gt_ese_bset-kbetr. "Prozentsatz merken "859167

EXIT.
ENDIF.
ENDLOOP.
IF flg_modify = 1.
tab_ep-hwbas = - hlp_hwbas." Basisbetrag mit umgekehrtem
tab_ep-fwbas = - hlp_fwbas." Vorzeichen und
tab_ep-kbetr =
hlp_kbetr." Prozentsatz bernehmen
MODIFY tab_ep INDEX hlp_tabix
TRANSPORTING hwbas
fwbas
kbetr.
ENDIF.
ENDIF.
ENDLOOP.
* ----- end of insertion ----- "853491
* No Tax-Relevant G/L-Account found: Take another Account from BSEG
IF ep-hkont IS INITIAL.
ep-hkont = hlp_gl_account.
ENDIF.
CLEAR hlp_gl_account.
* No ZUONR found on G/L-items: Take it from a tax item
IF ep-zuonr IS INITIAL.
ep-zuonr = hlp_zuonr.
ENDIF.

"938627
"938627
"938627
"938627

* Bolle Doganali: If there are only G/L-Accounts, it's a Bo.Do.Document


IF ( NOT par_bodo IS INITIAL ) AND ( NOT flg_bd_only_gl IS INITIAL ).
*
Get first G/L Account not in the BSET --> Should be Bo. Do. Account
LOOP AT tab_ep.
DELETE tab_bd_gl_accounts WHERE hkont = tab_ep-tkont.
ENDLOOP.
READ TABLE tab_bd_gl_accounts INDEX 1 INTO hlp_gl_account.
ENDIF.
IF NOT g_read_bseg IS INITIAL
AND NOT gs_any_bseg-bukrs IS INITIAL.
READ TABLE gt_more_bseg INTO wa_more_bseg
WITH TABLE KEY
bukrs = bkpf-bukrs
belnr = bkpf-belnr
gjahr = bkpf-gjahr
koart = 'S'.
IF sy-subrc <> 0.
MOVE gs_any_bseg TO bseg.
PERFORM append_bseg.
ENDIF.
ENDIF.

"1120571
"1120571
"1120571
"1120571
"1120571
"1120571
"1120571
"1120571
"1120571
"1120571
"1120571
"1120571
"1120571

* Selektierte Daten extrahieren ---------------------------------------LOOP AT tab_ep.

AT NEW mwskz.
*
IF par_lis5 EQ 'X'.
*
READ TABLE tab_diff WITH KEY mwskz = tab_ep-mwskz.
*
ENDIF.
* G/L-Account
LOOP AT it_glaccount INTO is_glaccount
WHERE mwskz = tab_ep-mwskz
AND koart = 'S'.
ep-hkont = is_glaccount-hkont.
ENDLOOP.
IF sy-subrc <> 0.
LOOP AT it_glaccount INTO is_glaccount
WHERE mwskz = tab_ep-mwskz
AND koart <> 'S'.
ep-hkont = is_glaccount-hkont.
ENDLOOP.
ENDIF.

"1104702
"1104702
"1104702

"OP-30
"992241
"OP-30
"OP-30
"992241
"992241
"992241
"992241
"992241
"992241
"992241

* In case of a stock transfer take adress data from T001(N) "1686870


* (determined in form stock_transfer_address)
"1686870
IF NOT gt_wia_adrnr[] IS INITIAL.
"1686870
READ TABLE gt_wia_adrnr INTO gs_wia_adrnr
"1686870
WITH KEY mwskz = tab_ep-mwskz.
"1686870
IF sy-subrc = 0.
"1686870
ep-wia_adrnr = gs_wia_adrnr-adrnr.
"1686870
IF gs_wia_adrnr-stceg NE space.
"1686870
ep-stceg = gs_wia_adrnr-stceg.
"1686870
ENDIF.
"1686870
ELSE.
"1686870
CLEAR ep-wia_adrnr.
"1686870
ENDIF.
"1686870
ENDIF.
"1686870
* Copy discount amounts to respective line items
* Done only once per (mwskz, ktosl).
ep-disco_hw = 0.
ep-disco_fw = 0.
READ TABLE gt_discounts INTO gs_discounts
WITH KEY mwskz = tab_ep-mwskz
ktosl = tab_ep-ktosl.
IF sy-subrc <> 0.
READ TABLE gt_discounts INTO gs_discounts
WITH KEY mwskz = tab_ep-mwskz
ktosl = space.
IF sy-subrc = 0.
ep-disco_hw = gs_discounts-dmbtr.
ep-disco_fw = gs_discounts-wrbtr.
*
convert amount to reporting currency if needed
IF gd_lwbas NE 0.
IF gd_lwbas NE gd_hwbas AND
gd_hwbas NE 0.

"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787

ep-disco_hw = ep-disco_hw
* gd_lwbas / gd_hwbas.
ENDIF.
ENDIF.
mark (mwskz, ktosl) as used
gs_discounts-ktosl = tab_ep-ktosl.
APPEND gs_discounts TO gt_discounts.
ENDIF.
ENDIF.

"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787
"1868787

ENDAT.

*
*
*
*

tab_ep-hwgross = ABS( tab_ep-hwbas ) + ABS( tab_ep-hwste )."OP-03


IF ( tab_ep-hwbas < 0 ).
"OP-10
tab_ep-hwgross = tab_ep-hwgross * -1.
"OP-10
ENDIF.
"OP-10
if ( tab_ep-mwart = 'A' ) or
( ( tab_ep-mwart = 'V' ) and ( tab_ep-ktosl = 'ESA' ) ). "OP-03
tab_ep-hwgross = tab_ep-hwgross * -1.
"OP-03
endif.
"OP-03
MODIFY tab_ep.
"OP-03

MOVE-CORRESPONDING tab_ep TO ep.


IF ( NOT par_bodo IS INITIAL )
"Bolle Doganali
AND ( NOT flg_bd_only_gl IS INITIAL ). "Bolle Doganali Document
ep-tkont = hlp_gl_account.
"Even if it is initial
IF hlp_gl_account IS INITIAL.
"1014836
ep-tkont = hlp_bodo_accnt.
"1014836
IF ep-hkont IS INITIAL.
"1014836
ep-hkont = hlp_bodo_accnt.
"1014836
ENDIF.
"1014836
ENDIF.
"1014836
ENDIF.
ep-gjahr = bkpf-gjahr.
WRITE tab_ep-kbetr TO ep-psatz NO-SIGN CURRENCY '3'.
IF par_lis5 EQ 'X'.
"Steuerkontrolle
READ TABLE tab_diff WITH KEY mwskz = tab_ep-mwskz
flg_fc = space.
IF tab_diff-rndbl GE tab_diff-rndst.
hlp_sdiff = tab_diff-rndbl.
ELSE.
hlp_sdiff = tab_diff-rndst.
ENDIF.
IF ep-sdiff GE 0.
IF ep-sdiff LE hlp_sdiff.
ep-sdiff = 0.
ENDIF.

"1104702
"1104702

ELSE.
ep-sdiff = - ep-sdiff.
IF ep-sdiff LE hlp_sdiff.
ep-sdiff = 0.
ENDIF.
ep-sdiff = - ep-sdiff.
ENDIF.
* Steuerkontrolle in Fremdwaehrung
"1104702
CLEAR ep-sdiff_fc.
"1104702
IF ep-sdiff NE 0.
"1104702
IF bkpf-waers = tab_001-waers.
"1104702
ep-sdiff_fc = ep-sdiff.
"1104702
ELSE.
"1104702
READ TABLE tab_diff
"1104702
WITH KEY mwskz = tab_ep-mwskz
"1104702
flg_fc = 'X'.
"1104702
IF tab_diff-rndbl GE tab_diff-rndst.
"1104702
hlp_sdiff_fc = tab_diff-rndbl.
"1104702
ELSE.
"1104702
hlp_sdiff_fc = tab_diff-rndst.
"1104702
ENDIF.
"1104702
hlp_hwste2 = abs( tab_ep-sdiff_fc ).
"1104702
IF hlp_hwste2 GT hlp_sdiff_fc.
"1104702
ep-sdiff_fc = tab_ep-sdiff_fc.
"1104702
ENDIF.
"1104702
ENDIF.
"1104702
ENDIF.
"1104702
* ----- Begin deletion note 1104702 ----"1104702
** Steuerkontrolle fr SD-Fakturen in Fremdwhrung
*
IF ( bkpf-glvor = 'SD00' ) AND
*
( ep-sdiff NE 0 ) AND
*
( bkpf-waers NE bkpf-hwaer ) AND
"442284
*
( bkpf-txkrs IS INITIAL OR
"838230
*
bkpf-txkrs EQ bkpf-kursf ).
"838230
** hlp_sdiff umrechnen in Fremdwhrung.
*
CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
*
EXPORTING
*
local_currency
= bkpf-hwaer
*
foreign_currency = bkpf-waers
*
local_amount
= hlp_sdiff
*
date
= bkpf-wwert
*
rate
= bkpf-kursf
*
IMPORTING
*
foreign_amount
= hlp_sdiff_fc.
*
** Ist Differenz neu berechnen
**
PERFORM read_tax_amount
"Steuerbetrag berechnen "825186
**
USING ep-mwskz tab_ep-kschl ep-fwbas
"825186
**
CHANGING hlp_hwste2.
"825186
*
PERFORM calculate_tax_amount
"Steuerbetrag berechnen "825186
*
USING ep-mwskz tab_ep-kschl ep-ktosl
"825186
*
ep-fwbas
"825186

*
CHANGING hlp_hwste2.
**
ep-sdiff = hlp_hwste2 - ep-fwste.
***vergleich soll/ist in Fremdwhrung
**
ep-sdiff = abs( ep-sdiff ).
**
IF ep-sdiff < hlp_sdiff_fc.
*
hlp_hwste2 = abs( hlp_hwste2 - ep-fwste ).
**vergleich soll/ist in Fremdwhrung
*
IF hlp_hwste2 < hlp_sdiff_fc.
*
ep-sdiff = 0.
*
ENDIF.
*
ENDIF.
* ----- End deletion note 1104702 ----ENDIF.
CASE tab_ep-stgrp.
WHEN 1.
ep-mwart = 'A'.
WHEN 2.
ep-mwart = 'V'.
ENDCASE.
IF ( par_xsau NE space AND ep-mwart EQ
( par_xsvo NE space AND ep-mwart EQ
IF ( ep-hwbas GT 0 AND ep-hwste LT 0
( ep-hwbas LT 0 AND ep-hwste GT 0
ep-hwbas = - ep-hwbas.
ep-fwbas = - ep-fwbas.
ENDIF.

"825186
"900597
"900597
"900597
"900597
"900597
"900597
"900597

"442284
"1104702

'A' ) OR
'V' ).
) OR
).

IF ( ep-hwbas GT 0 AND ep-hwgross LT 0 ) OR


( ep-hwbas LT 0 AND ep-hwgross GT 0 ).
ep-hwgross = - ep-hwgross.
ENDIF.

"OP-28
"OP-28
"OP-28

EXTRACT daten.

IF par_binp = 'X'.
"Batch-Input gewnscht
begin of note 877045
READ TABLE gt_bukrs_split_act WITH KEY bukrs = bkpf-bukrs
TRANSPORTING NO FIELDS.
wenn der buchungskreis keine BA nutzt, bleibt alles beim alten
IF sy-subrc NE 0.
CLEAR tab_bi.
tab_bi-bukrs = bkpf-bukrs.
"Buchungskreis
tab_bi-hkont = tab_ep-tkont.
"Hauptbuchkonto (Steuerkonto)
tab_bi-saldo = tab_ep-hwste - tab_ep-hwnaf.
"abzugsfhige bzw. abzufhrende
" Steuer in Hauswhrung
COLLECT tab_bi.
ELSE.
Aufbau der Tabelle, mit der die Kontierungen ermittelt werden
MOVE-CORRESPONDING bkpf TO gs_unsplitted_information.
gs_unsplitted_information-buzei = 0.
"1566235

gs_unsplitted_information-tkont =
gs_unsplitted_information-mwskz =
gs_unsplitted_information-dmbtr =
COLLECT gs_unsplitted_information
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.

tab_ep-tkont.
tab_ep-mwskz.
tab_ep-hwste - tab_ep-hwnaf.
INTO gt_unsplitted_information.

* begin of note 877045


IF par_binp = 'X'.
"Batch-Input gewnscht
READ TABLE gt_bukrs_split_act WITH KEY bukrs = bkpf-bukrs
TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
PERFORM check_and_treat_zero
USING
bkpf-awtyp
CHANGING gt_unsplitted_information.

"1566235
"1566235
"1566235

LOOP AT gt_unsplitted_information INTO gs_unsplitted_information.


REFRESH gt_splitted_inf_single_line.
CALL FUNCTION 'FI_SPLIT_TAX'
EXPORTING
is_vat_amount = gs_unsplitted_information
IMPORTING
et_vat_amounts = gt_splitted_inf_single_line
EXCEPTIONS
internal_error = 1
OTHERS
= 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
INSERT LINES OF gt_splitted_inf_single_line INTO TABLE gt_splitted_inf
_doc.
ENDLOOP.
LOOP AT gt_splitted_inf_doc INTO gs_splitted_inf_doc.
tab_bi-bukrs = gs_splitted_inf_doc-bukrs.
tab_bi-hkont = gs_splitted_inf_doc-tkont.
tab_bi-saldo = gs_splitted_inf_doc-dmbtr.
tab_bi-adaa = gs_splitted_inf_doc-addaa.
*
no MWSKZ in table tab_bi!
COLLECT tab_bi. "globale Tabelle mit Verbuchungsdaten f. BI
ENDLOOP.
ENDIF.
ENDIF.
* end of note 877045

REFRESH it_glaccount.
"OP-30
CLEAR is_glaccount.
"OP-30
REFRESH: gt_unsplitted_information, gt_splitted_inf_doc, gt_splitted_inf_sin
gle_line."877045
ENDFORM.
" GET_BKPF_LATE
*----------------------------------------------------------------------*
* Extrahieren der Daten je Beleg
*
*----------------------------------------------------------------------*
GET bkpf LATE.
PERFORM process_bkpf_late.

*----------------------------------------------------------------------*
* Verarbeitung der extrahierten Daten
*
*----------------------------------------------------------------------*
END-OF-SELECTION.
IF sy-batch <> space
AND gd_selection_stopped <> space.
MESSAGE a273
WITH bkpf-bukrs bkpf-belnr bkpf-gjahr.
ENDIF.
IF ( par_xcas IS INITIAL ).
IF ( NOT par_sort = '2' ).
SORT BY
ep-bukrs
ep-mwart
*
ep-mwskz
ep-buper
*
ep-waers
ep-budat
ep-belnr
ep-ktosl.
ELSE.
SORT BY
ep-bukrs
ep-mwart
*
ep-buper
ep-bldat
ep-belnr
ep-ktosl.
ENDIF.
ELSE.
SORT BY
ep-bukrs
ep-mwart
hlp_sort
ep-belnr
ep-mwskz

"1066663
"1066663
"1066663
"1066663
"1066663

"OP-18
"Buchungskreis
"Umsatzsteuerart
"Umsatzsteuerkennzeichen "OP-11
"Buchungsperiode
"Whrungsschlssel
"OP-02
"Buchungsdatum
"Belegnummer
"Vorgangsschlssel
"OP-18
"OP-18
"Buchungskreis
"OP-18
"Umsatzsteuerart
"OP-18
"Buchungsperiode
"OP-18
"Belegdatum
"OP-18
"Belegnummer
"OP-18
"Vorgangsschlssel "OP-18
"OP-18

"Buchungskreis
"Umsatzsteuerart
"Quittungsnr. (numerischer Teil)
"Belegnummer
"Umsatzsteuerkennzeichen

ep-ktosl.
ENDIF.

"Vorgangsschlssel

IF par_umsv = 'X'.
REFRESH tab_umsv.
CLEAR fle_umsvz.
fle_umsvz-mandt = sy-mandt.
fle_umsvz-laufd = par_laud.
fle_umsvz-laufi = par_laui.
fle_umsvz-budt1 = br_budat-low.
fle_umsvz-budt2 = br_budat-high.
fle_umsvz-mona1 = sel_mona-low.
fle_umsvz-mona2 = sel_mona-high.
fle_umsvz-gjahr = br_gjahr-low.
fle_umsvz-bldt1 = br_bldat-low.
fle_umsvz-bldt2 = br_bldat-high.
IF gd_vatdate_active = 'X'.
IF
fle_umsvz-budt1 IS INITIAL
AND fle_umsvz-budt2 IS INITIAL.
fle_umsvz-budt1 = dso_vtdt-low.
fle_umsvz-budt2 = dso_vtdt-high.
ENDIF.
ENDIF.
ENDIF.

"1023317
"1023317
"1023317
"1023317
"1023317
"1023317
"1023317

LOOP.
AT FIRST.
REFRESH tab_hwaer.
ENDAT.

AT NEW ep-bukrs.
CLEAR gt_alv.
gt_alv-bukrs = ep-bukrs.
APPEND gt_alv.
READ TABLE gt_alv INDEX sy-tabix ASSIGNING <gt_alv>.
CLEAR gd_tabalv_cnt.
REFRESH tab_bukrs.
PERFORM read_t001 USING ep-bukrs.
IF par_xcas = 'X'.
CLEAR t001z.
SELECT SINGLE * FROM t001z
WHERE bukrs EQ ep-bukrs
AND party EQ 'SAPC01'.
ENDIF.
bhdgd-bukrs
= ep-bukrs.
bhdgd-werte
= ep-bukrs.
PERFORM new-section(rsbtchh0).
ENDAT.

"928371
"928371
"928371

AT NEW ep-mwart.
REFRESH tab_mwart.
PERFORM set_lfdnr USING ep-bukrs
ep-gjahr
ep-mwart
CHANGING hlp_lfdnr.
ENDAT.

*
*
*
*
*
*
*
*

IF par_bsud = 'X'.
Save BSET-key for later
tab_bset_key-bukrs =
tab_bset_key-belnr =
tab_bset_key-gjahr =
tab_bset_key-buzei =
APPEND tab_bset_key.
ENDIF.

update on stmdt, stmti


ep-bukrs.
ep-belnr.
ep-gjahr.
ep-buzei.

IF par_bsud = 'X'.
UPDATE bset
SET stmdt = hlp_stmdt
stmti = hlp_stmti
WHERE bukrs EQ ep-bukrs
AND belnr EQ ep-belnr
AND gjahr EQ ep-gjahr
AND buzei EQ ep-buzei.

"2061805
"2061805
"2061805
"2061805
"2061805
"2061805
"2061805
"2061805

"2061805
"2061805
"2061805
"2061805
"2061805
"2061805
"2061805

Bereits zu 4.0 umgesetzte Belege markieren


LOOP AT ums40 WHERE bukrs EQ ep-bukrs.
UPDATE bkpf
SET duefl = 'A'
WHERE belnr EQ ep-belnr
AND bukrs EQ ep-bukrs
AND gjahr EQ ep-gjahr
AND duefl EQ 'X'.
cnt_updatecalls = cnt_updatecalls + 1.
"2061805
EXIT.
ENDLOOP.
cnt_updatecalls = cnt_updatecalls + 1.
"2061805
IF cnt_updatecalls >= 100.
COMMIT WORK.
cnt_updatecalls = 0.
ENDIF.
ENDIF.
IF NOT par_stru IS INITIAL.
"Rounding VAT in local currency
PERFORM round_taxes USING
ep-waers
tab_001-waers
ep-bukrs
ep-budat
ep-hwste

ep-hwnaf
CHANGING ep-hwste_r
ep-hwnaf_r.
ENDIF.
PERFORM:
append_ep,
append_sdiff USING ep-sdiff,
collect_tab_mwart,
collect_tab_bukrs.
IF par_lis1 NE space
OR par_lis3 NE space.
ADD 1 TO gd_tabalv_cnt.
IF gd_tabalv_cnt GE 100.
APPEND LINES OF gt_alv-t_auste_ep
TO <gt_alv>-t_auste_ep.
APPEND LINES OF gt_alv-t_voste_ep
TO <gt_alv>-t_voste_ep.
REFRESH: gt_alv-t_auste_ep,
gt_alv-t_voste_ep.
CLEAR gd_tabalv_cnt.
ENDIF.
ENDIF.

"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371

AT END OF ep-mwart.
SORT tab_mwart.
LOOP AT tab_mwart.
PERFORM append_mwart.
ENDLOOP.
PERFORM append_trvor USING

ep
hlp_lfdnr
CHANGING tab_trvor[].

ENDAT.

AT END
SORT
LOOP
IF

*
*
*
*
*

OF ep-bukrs.
tab_bukrs.
AT tab_bukrs.
par_umsv = 'X'
OR par_euva = 'X'.
"751603
PERFORM collect_tab_umsv.
ENDIF.
PERFORM:
append_bukrs,
collect_tab_hwaer.
ENDLOOP.
APPEND gt_alv.
"928371
This somewhat clumsy way to create table gt_alv saves
"928371
a lot of memory compared to the old method when single
"928371
items lists are selected.
"928371
More elegant solutions would have implicitly changed the "928371

*
*
*

interfaces to forms apend_ep, etc.


which is not allowed because the includes are used by
other reports like old versions of RGJVTAX2.
IF gd_tabalv_cnt NE 0.
APPEND LINES OF gt_alv-t_auste_ep
TO <gt_alv>-t_auste_ep.
APPEND LINES OF gt_alv-t_voste_ep
TO <gt_alv>-t_voste_ep.
ENDIF.
APPEND LINES OF gt_alv-t_auste_sum
TO <gt_alv>-t_auste_sum.
APPEND LINES OF gt_alv-t_voste_sum
TO <gt_alv>-t_voste_sum.
APPEND LINES OF gt_alv-t_sdiff_ep
TO <gt_alv>-t_sdiff_ep.
APPEND LINES OF gt_alv-t_bukrs
TO <gt_alv>-t_bukrs.
CLEAR gt_alv.
ENDAT.

"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371
"928371

AT LAST.
SORT tab_hwaer.
LOOP AT tab_hwaer.
AT FIRST.
bhdgd-bukrs
= space.
bhdgd-werte
= space.
PERFORM new-section(rsbtchh0).
ENDAT.
AT NEW hwaer.
cnt_bukrs_pro_hwaer = 0.
ENDAT.
AT NEW bukrs.
PERFORM read_t001 USING tab_hwaer-bukrs.
cnt_bukrs_pro_hwaer = cnt_bukrs_pro_hwaer + 1.
ENDAT.
PERFORM append_bukrs_sum.
ENDLOOP.
* ----- Begin Delete Note 2061805 ----*
IF par_bsud = 'X'.
**
BSET-Update fr aus TAB_EP gelschte Zeilen
*
cnt_updatecalls = 0.
*
LOOP AT tab_bset_key.
*
UPDATE bset
*
SET stmdt = hlp_stmdt
*
stmti = hlp_stmti
*
WHERE bukrs = tab_bset_key-bukrs

"2061805

*
AND belnr = tab_bset_key-belnr
*
AND gjahr = tab_bset_key-gjahr
*
AND buzei = tab_bset_key-buzei.
*
cnt_updatecalls = cnt_updatecalls + 1.
*
IF cnt_updatecalls >= 100.
*
COMMIT WORK.
*
cnt_updatecalls = 0.
*
ENDIF.
*
ENDLOOP.
*
COMMIT WORK.
*
ENDIF.
* ----- End Delete Note 2061805 ----*LOOP AT gt_alv.
*
lfd_number = 0.
*
sort gt_alv-t_auste_ep by belnr.
*
LOOP AT gt_alv-t_auste_ep INTO ls_modify_lfdnr.
*
add 1 to lfd_number.
*
ls_modify_lfdnr-lfdnr = lfd_number.
*
modify gt_alv-t_auste_ep from ls_modify_lfdnr
*
transporting lfdnr.
*
ENDLOOP.
*
lfd_number = 0.
*
sort gt_alv-t_voste_ep by belnr.
*
LOOP AT gt_alv-t_voste_ep INTO ls_modify_lfdnr.
*
add 1 to lfd_number.
*
ls_modify_lfdnr-lfdnr = lfd_number.
*
modify gt_alv-t_voste_ep from ls_modify_lfdnr
*
transporting lfdnr.
*
ENDLOOP.
*ENDLOOP.

"2061805
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02
"OP-02

ENDAT.
ENDLOOP.
ASSIGN gt_alv TO <gt_alv>.

"Fr die Anzeigenvariantepflege

FREE gt_more_bseg.
PERFORM kna1_lfa1_read
USING ep-koart ep-ktnra 'X'
CHANGING ep-xcpdk sy-subrc.

"1557535
"1557535
"1557535
"1557535

PERFORM
PERFORM
PERFORM
PERFORM
PERFORM
PERFORM
PERFORM

"500308

badis_for_gt_alv.
create_batch_input_mappe.
insert_umsv.
insert_trvor.
create_dta_file.
output_euva.
update_bset.

* Ausgabe
IF par_xml EQ space.

"751603
"2061805

"xml

PERFORM create_gt_excluding.
IF flg_notp = 'X'.
PERFORM print.
ELSEIF var_avp1 = 'X'.
PERFORM print_auste_ep.
ELSEIF var_avp2 = 'X'.
PERFORM print_auste_sum.
ELSEIF var_avp3 = 'X'.
PERFORM print_voste_ep.
ELSEIF var_avp4 = 'X'.
PERFORM print_voste_sum.
ELSEIF var_avp5 = 'X'.
PERFORM print_sdiff_ep.
ELSEIF var_avp6 = 'X'.
PERFORM print_bukrs.
ELSEIF var_avp7 = 'X'.
PERFORM print_bukrs_sum.
ENDIF.
ELSE.
PERFORM xml_output.
ENDIF.

"Keine Anzeigenvariantenpflege
"Anzeigenvariantenpflege AUSTE_EP
"Anzeigenvariantenpflege AUSTE_SUM
"Anzeigenvariantenpflege VOSTE_EP
"Anzeigenvariantenpflege VOSTE_SUM
"Anzeigenvariantenpflege SDIFF_EP
"Anzeigenvariantenpflege BUKRS
"Anzeigenvariantenpflege BUKRS_SUM

"xml
"xml
"xml

* Set back output language


IF NOT par_lang IS INITIAL.
IF NOT sy-batch IS INITIAL
OR NOT gd_exec_and_print IS INITIAL.
SET LOCALE LANGUAGE gd_locale_language
COUNTRY gd_locale_country.
SET LANGUAGE sy-langu.
IF NOT g_bukrs_land IS INITIAL.
SET COUNTRY space.
ENDIF.
ENDIF.
ENDIF.

"1263340
"1263340
"1263340
"1307450
"1263340
"1263340
"1263340
"1263340
"1263340
"1263340
"1263340
"1263340

PERFORM no_display.

*----------------------------------------------------------------------*
* Includes
*
*----------------------------------------------------------------------*
* Selection
INCLUDE i_rfums_selection_forms.
* Output (ABAP List Viewer)
INCLUDE i_rfums_alv_forms.
* DTA File (DME-Tool)
INCLUDE i_rfums_dme_forms.
INCLUDE i_rfums_xml_forms.
* Electronic Tax Declaration
INCLUDE i_rfums_euva_forms.

"751603

INCLUDE make_rldnr_invisible.

"871301

AT SELECTION-SCREEN ON par_trid.
par_dmea = parpdmea.
PERFORM check_dmee_button.
parpdmea = par_dmea.

"899205
"931482
"899205
"931482

*----------------------------------------------------------------------*
* PAI fr das Selektionsdynpro
*
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&
Form check_tax_audit
"925217
*&---------------------------------------------------------------------*
*
Check if the current user is a tax auditor
*
According to German law tax auditors must be granted
*
system access.
*
If the user is tax auditor
*
- access is restricted to a certain fiscal years
*
(this is handled by the logical database BRF)
*
- update functions are turned off
*
- selection parameters are written to an action log.
*
(this is handled by the logical database BRF)
*----------------------------------------------------------------------*
*
<--P_TAX_AUDITOR 'X' = user is a tax autitor
*----------------------------------------------------------------------*
FORM check_tax_audit
CHANGING p_tax_auditor TYPE xfeld.
"925217
CALL FUNCTION 'CA_USER_EXISTS'
EXPORTING
i_user
= sy-uname
EXCEPTIONS
user_missing = 1
OTHERS
= 2.
IF sy-subrc = 0.
p_tax_auditor = 'X'.
ELSEIF sy-subrc = 1.
CLEAR p_tax_auditor.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM.
" check_tax_audit
"925217
*&---------------------------------------------------------------------*
*&
Form tax_audit_clear
"925217
*&---------------------------------------------------------------------*
*
If the user is tax auditor update functions are turned off
*
Here the parameters are explicitly turned off because they

*
may be active due to selection of a report variant.
*
New update parameters should be included here.
*----------------------------------------------------------------------*
FORM tax_audit_clear.
"925217
* batch input parameters (block 2)
CLEAR:
par_binp,
par_blar,
par_bdat,
par_mona,
par_zkto,
par_fdat,
par_bina,
par_sofa,
par_adat,
par_zeit.

"Batch-Input gewnscht
"Belegart fr BI
"Buchungsdatum fr BI
"Periode fr BI
"Abweichend. Zahllastkonto
"Flligkeitsdatum fr Zahllast
"Name der BI-Mappe
"Mappe sofort abspielen
"Datum: Abspielen BI
"Uhrzeit: Abspielen BI

* output options
CLEAR par_xml.

"Ausgabe im XML-Format

* posting parameters
par_kukp = 'X'.
par_bsud = space.
par_bupl = space.
CLEAR:
par_euva,
par_corr,
par_dyea,
par_dper,

(block 5)
"Belege nicht aktualieren
"Belege aktualisieren: Echtlauf
"Belege aktual.: Testlauf
"Meldedaten erzeugen
"Berichtigte Voranmeldung
"Meldejahr
"Meldeperiode
"No BSET compress
"Formulardruck vorbereiten
"Laufdatum des Reports
"Zustzl. Laufidentifikation

par_xdta,
par_trty,
par_trid,
par_dmea,
par_tems,
par_file,

"Create DTA File


"DME tree type
"DME Tree ID
"DME additional parameters
"Temse Name
"File Name

par_udtr,
par_reid,
par_snou,
par_snin.

"Update Table TRVOR

ENDFORM.

par_caos,
par_umsv,
par_laud,
par_laui,

"Starting Number Output


"Starting Number Input
" tax_audit_clear

"925217

"Optimization
*&---------------------------------------------------------------------*

*&
Form process_result
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->C
text
*----------------------------------------------------------------------*
FORM process_result.
DATA:
lt_umsv00_bseg_bset TYPE STANDARD TABLE OF ty_umsv00_bseg_bset,
lv_exit TYPE abap_bool,
lv_index TYPE i,
lt_docs_by_belnr LIKE lt_umsv00_bseg_bset,
lt_tmp_docs_by_belnr LIKE lt_umsv00_bseg_bset,
lv_bukrs TYPE bukrs,
lv_belnr TYPE belnr_d,
lv_gjahr TYPE gjahr,
lv_failed_bkpf TYPE abap_bool,
lv_failed_bseg TYPE abap_bool,
lv_reject TYPE abap_bool,
lo_ldb_brf TYPE REF TO cl_fin_ldb_brf,
lt_bkpf_list TYPE STANDARD TABLE OF rsfs_struc,
lt_bseg_list TYPE STANDARD TABLE OF rsfs_struc,
lt_bkpf_fields TYPE if_fin_selection_types=>tt_selection_fields,
lv_column TYPE string,
lv_column_list TYPE string,
lv_table TYPE string VALUE 'bkpf',
lv_join TYPE string,
lt_trange TYPE rsds_trange,
lt_where
TYPE rsds_where_tab,
lt_twhere TYPE rsds_twhere,
c TYPE cursor.

FIELD-SYMBOLS:
<f_bseg_bset> TYPE ty_umsv00_bseg_bset,
<f_bseg_bset_line> TYPE ty_umsv00_bseg_bset,
<fs_bkpf_fields> TYPE rsfs_struc,
<ls_tab_field_range>
TYPE rsds_range,
<ls_field_range>
TYPE rsds_frange,
<ls_tab_where>
TYPE rsds_where.

CREATE OBJECT lo_ldb_brf


EXPORTING
iv_join
= abap_true
it_range_bukrs = br_bukrs[]
it_range_blart = br_blart[]
it_range_gjahr = br_gjahr[]
it_range_rldnr = br_rldnr[]
it_range_ldgrp = br_ldgrp[]
it_bkpf_list
= lt_bkpf_list
it_bseg_list
= lt_bseg_list.

APPEND LINES OF lo_ldb_brf->gt_bkpf_fields TO lt_bkpf_fields.


"1980423

*
"1980423
*

TRY.
"1980423

*
"1980423
LOOP AT lt_bkpf_fields ASSIGNING <fs_bkpf_fields>.
"1980423
*
lv_column = <fs_bkpf_fields>-line.
"1980423
*
lv_column = cl_abap_dyn_prg=>check_column_name( lv_column ).
"1980423
*
CONCATENATE lv_column_list lv_column '' INTO lv_column_list SEPARA
TED BY space.
"1980423
*
ENDLOOP.
"1980423
*
"1980423
*
CATCH cx_abap_invalid_name.
"1980423
*
RETURN.
"1980423
*
ENDTRY.
"1980423
*

CONCATENATE 'bkpf~bktxt bkpf~xmwst bkpf~xblnr bkpf~kursf bkpf~xblnr_alt bk


pf~vatdate bkpf~monat bkpf~awtyp bkpf~awkey bkpf~awsys' "1980423 "#EC NOTEXT
'bkpf~stblg bkpf~stjah bkpf~tcode bkpf~stgrd bkpf~numpg bkpf~xref1_hd bkpf
~bukrs bkpf~belnr bkpf~gjahr bkpf~blart bkpf~budat bkpf~bldat bkpf~waers' "1
980423 "#EC NOTEXT
'bset~buzei bset~mwskz bset~hkont bset~txgrp bset~shkzg'
"1980423 "#EC NOTEXT
'bset~egbld bset~eglld'
"2101269 "#EC NOTEXT
'bset~hwbas bset~fwbas bset~hwste bset~fwste bset~ktosl bset~stceg bset~ks
chl bset~stmdt bset~stmti bset~kbetr bset~lstml' "1980423 "#EC NOTEXT
'bset~lwste bset~bupla bset~taxps bset~lwbas'
"1980423 "#EC NOTEXT
'bseg~buzei AS buzei_g bseg~augdt bseg~koart bseg~umskz bseg~umsks bseg~mw
skz AS mwskz_g'
"#EC NOTEXT
'bseg~zuonr bseg~xref1 bseg~xref2 bseg~xref3 bseg~kidno bseg~xnegp bseg~mw
art bseg~xauto bseg~txgrp AS txgrp_g bseg~hkont AS hkont_g' "#EC NOTEXT
'bseg~shkzg AS shkzg_g'
"1868787 "#EC_NOTEXT
'bseg~j_1tpbupl'
"2097858 "#EC_NOTEXT
'bseg~stceg AS stceg_g bseg~lifnr bseg~kunnr bseg~dmbtr bseg~gsber bseg~wr
btr' INTO lv_column_list SEPARATED BY space.
"1980423 "#EC NOTEXT

CONCATENATE '( ( (' lv_table ' AS bkpf '


"#EC NOTEXT
'INNER JOIN bset as bset ON bkpf~bukrs = bset~bukrs AND bkpf~belnr =
bset~belnr AND bkpf~gjahr = bset~gjahr )'
"#EC NOTEXT
'INNER JOIN bseg as bseg ON bkpf~bukrs = bseg~bukrs AND bkpf~belnr =
bseg~belnr AND bkpf~gjahr = bseg~gjahr ) )'
"#EC NOTEXT
INTO lv_join SEPARATED BY space.

*
*
*
*
*
*
*
*
*

"get free selections from report


"1980423
CALL FUNCTION 'RS_REFRESH_FROM_DYNAMICAL_SEL'
"1980423
EXPORTING
"1980423
curr_report
= sy-repid
"1980423
mode_write_or_move = 'M'
"1980423
IMPORTING
"1980423
p_trange
= lt_trange
"1980423
EXCEPTIONS
"1980423
OTHERS
= 1.
"1980423

*
**
*
*
*
*
*
*
*
*
*
*

"1980423
everything is ok and there is dynamic selection
"1980423
IF sy-subrc = 0 AND lt_trange IS NOT INITIAL.
"1980423
LOOP AT lt_trange ASSIGNING <ls_tab_field_range>.
"1980423
LOOP AT <ls_tab_field_range>-frange_t ASSIGNING <ls_field_range>.
"1980423
CONCATENATE
"1980423
<ls_tab_field_range>-tablename
"1980423
'~'
"1980423
<ls_field_range>-fieldname
"1980423
INTO
"1980423
<ls_field_range>-fieldname.
"1980423
ENDLOOP.
"1980423

ENDLOOP.
"1980423

*
**
*
*
*
*
*

"1980423
convert ranges to WHERE condition
"1980423
CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE'
"1980423
EXPORTING
"1980423
field_ranges = lt_trange
"1980423
IMPORTING
"1980423
where_clauses = lt_twhere.
"1980423

*
**
*
*
*
*

"1980423
prepare WHERE clause for SELECT statement
"1980423
LOOP AT lt_twhere ASSIGNING <ls_tab_where>.
"1980423
APPEND LINES OF <ls_tab_where>-where_tab TO lt_where.
"1980423
ENDLOOP.
"1980423
ENDIF.
"1980423

OPEN CURSOR c FOR


SELECT (lv_column_list)
FROM (lv_join)
WHERE
bkpf~bukrs IN lo_ldb_brf->gt_range_bukrs
" modified by
authority check bukrs
AND
bkpf~blart IN lo_ldb_brf->gt_range_blart
"1980423
" modified by authority check blart
AND
bkpf~budat IN br_budat[]
"1980423
AND
bkpf~belnr IN br_belnr[]
AND
bkpf~gjahr IN br_gjahr[]
AND
bkpf~bstat IN gr_bstat[]
"1980423
AND
bkpf~awtyp IN br_awtyp[]
"1980423
AND
bkpf~awkey IN br_awkey[]
"1980423
AND
bkpf~awsys IN br_awsys[]
"1980423
AND
bkpf~cpudt IN br_cpudt[]
"1980423
AND
bkpf~xblnr IN br_xblnr[]
"1980423
AND
bkpf~bldat IN br_bldat[]
"1980423
AND
bkpf~usnam IN br_usnam[]
"1980423
AND
( bkpf~ldgrp IN lo_ldb_brf->gt_range_ldgrp OR bkpf~ldgrp IS N
ULL )
"1980423
" modified by NewGL Customizing
AND
( bkpf~rldnr IN lo_ldb_brf->gt_range_rldnr OR bkpf~rldnr IS N
ULL )
"1980423
" modified by NewGL Customizing

317

AND
( bkpf~vatdate IN br_vatdt[] OR bkpf~vatdate IS NULL ) "1023
"1980423
AND
(lo_ldb_brf->gt_where)
" free selections
"1980423
" AND
gsber IN lo_ldb_brf->gt_range_gsber
"1980423
AND
bkpf~monat IN sel_mona[]
ORDER BY bkpf~bukrs bkpf~gjahr bkpf~belnr.

WHILE lv_exit = abap_false.


FETCH NEXT CURSOR c INTO CORRESPONDING FIELDS OF TABLE lt_umsv00_bseg_bset
PACKAGE SIZE 10000.
IF sy-subrc <> 0.
EXIT.
ENDIF.
LOOP AT lt_umsv00_bseg_bset ASSIGNING <f_bseg_bset>.
" first doc
IF lv_bukrs IS INITIAL AND lv_gjahr IS INITIAL AND lv_belnr IS INITIAL.
lv_bukrs = <f_bseg_bset>-bukrs.
lv_gjahr = <f_bseg_bset>-gjahr.
lv_belnr = <f_bseg_bset>-belnr.
ENDIF.
" the same doc as previous
IF <f_bseg_bset>-bukrs = lv_bukrs AND <f_bseg_bset>-gjahr = lv_gjahr AND
<f_bseg_bset>-belnr = lv_belnr.
APPEND <f_bseg_bset> TO lt_docs_by_belnr.
ELSE.
"moving to next doc, process the current doc
lt_tmp_docs_by_belnr = lt_docs_by_belnr.
SORT lt_tmp_docs_by_belnr BY buzei_g.
DELETE ADJACENT DUPLICATES FROM lt_tmp_docs_by_belnr COMPARING buzei_g
.
LOOP AT lt_tmp_docs_by_belnr ASSIGNING <f_bseg_bset_line>.
AT FIRST.
MOVE-CORRESPONDING <f_bseg_bset_line> TO bkpf.
"Authority Check
lo_ldb_brf->bkpf( IMPORTING ev_failed = lv_failed_bkpf
CHANGING cs_bkpf = bkpf ).
CHECK lv_failed_bkpf = abap_false.
PERFORM t001_read USING bkpf-bukrs.
PERFORM process_bkpf
CHANGING lv_failed_bkpf.
"2103962
CHECK lv_failed_bkpf = abap_false.
"2103962
ENDAT.
IF lv_failed_bkpf = abap_true.
"2103962
EXIT.
"2103962
ENDIF.
"2103962
MOVE-CORRESPONDING <f_bseg_bset_line> TO bseg.
bseg-buzei = <f_bseg_bset_line>-buzei_g.
bseg-mwskz = <f_bseg_bset_line>-mwskz_g.

bseg-hkont = <f_bseg_bset_line>-hkont_g.
bseg-shkzg = <f_bseg_bset_line>-shkzg_g.
"1868787
bseg-txgrp = <f_bseg_bset_line>-txgrp_g.
bseg-stceg = <f_bseg_bset_line>-stceg_g.
" Authority Check
lo_ldb_brf->bseg( EXPORTING is_bkpf
= bkpf
IMPORTING ev_failed = lv_failed_bseg
CHANGING cs_bseg
= bseg ).
CHECK lv_failed_bseg = abap_false.
MOVE-CORRESPONDING bseg TO bsegh.
PERFORM got_bsega(sapbsega).
IF alcur EQ 'X'.
PERFORM convert_alt
"euro
USING 'BSEG' bkpf-waers.
ENDIF.

*
*
*
*
*

PERFORM process_bseg.
ENDLOOP.
lv_reject = abap_false.
"2103962
IF lv_failed_bkpf = abap_false.
lt_tmp_docs_by_belnr = lt_docs_by_belnr.
SORT lt_tmp_docs_by_belnr BY buzei.
"1980423
DELETE ADJACENT DUPLICATES FROM lt_tmp_docs_by_belnr COMPARING buzei
"1980423
LOOP AT lt_tmp_docs_by_belnr ASSIGNING <f_bseg_bset_line>.
MOVE-CORRESPONDING <f_bseg_bset_line> TO bset.
bset-buzei = <f_bseg_bset_line>-buzei_t.
"1980423
bset-mwskz = <f_bseg_bset_line>-mwskz_t.
"1980423
bset-hkont = <f_bseg_bset_line>-hkont_t.
"1980423
bset-txgrp = <f_bseg_bset_line>-txgrp_t.
"1980423
bset-stceg = <f_bseg_bset_line>-stceg_t.
"1980423
IF alcur EQ 'X'.
PERFORM convert_alt
"euro
USING 'BSET' bkpf-waers.
ENDIF.
PERFORM process_bset CHANGING lv_reject.
IF lv_reject = abap_true.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
IF lv_reject = abap_true
OR lv_failed_bkpf = abap_true.
"2103962

CLEAR lt_docs_by_belnr.
APPEND <f_bseg_bset> TO lt_docs_by_belnr.
lv_bukrs = <f_bseg_bset>-bukrs.
lv_gjahr = <f_bseg_bset>-gjahr.
lv_belnr = <f_bseg_bset>-belnr.
CONTINUE.
ENDIF.
PERFORM process_bkpf_late.
CLEAR lt_docs_by_belnr.
APPEND <f_bseg_bset> TO lt_docs_by_belnr.
lv_bukrs = <f_bseg_bset>-bukrs.
lv_gjahr = <f_bseg_bset>-gjahr.
lv_belnr = <f_bseg_bset>-belnr.
ENDIF.
ENDLOOP.
ENDWHILE.
" process last doc
lt_tmp_docs_by_belnr = lt_docs_by_belnr.
SORT lt_tmp_docs_by_belnr BY buzei_g.
DELETE ADJACENT DUPLICATES FROM lt_tmp_docs_by_belnr COMPARING buzei_g.
LOOP AT lt_tmp_docs_by_belnr ASSIGNING <f_bseg_bset_line>.
AT FIRST.
MOVE-CORRESPONDING <f_bseg_bset_line> TO bkpf.
"Authority Check
lo_ldb_brf->bkpf( IMPORTING ev_failed = lv_failed_bkpf
CHANGING cs_bkpf = bkpf ).
CHECK lv_failed_bkpf = abap_false.
PERFORM t001_read USING bkpf-bukrs.
PERFORM process_bkpf
CHANGING lv_failed_bkpf.
"2103962
CHECK lv_failed_bkpf = abap_false.
"2103962
ENDAT.
IF lv_failed_bkpf = abap_true.
"2103962
EXIT.
"2103962
ENDIF.
"2103962
MOVE-CORRESPONDING <f_bseg_bset_line> TO bseg.
bseg-buzei = <f_bseg_bset_line>-buzei_g.
bseg-mwskz = <f_bseg_bset_line>-mwskz_g.
bseg-hkont = <f_bseg_bset_line>-hkont_g.
bseg-shkzg = <f_bseg_bset_line>-shkzg_g.
"1868787
bseg-txgrp = <f_bseg_bset_line>-txgrp_g.
bseg-stceg = <f_bseg_bset_line>-stceg_g.
" Authority Check
lo_ldb_brf->bseg( EXPORTING is_bkpf
= bkpf
IMPORTING ev_failed = lv_failed_bseg
CHANGING cs_bseg
= bseg ).
CHECK lv_failed_bseg = abap_false.

MOVE-CORRESPONDING bseg TO bsegh.


PERFORM got_bsega(sapbsega).
IF alcur EQ 'X'.
PERFORM convert_alt
"euro
USING 'BSEG' bkpf-waers.
ENDIF.

*
*
*
*
*

PERFORM process_bseg.
ENDLOOP.
lv_reject = abap_false.
"2103962
IF lv_failed_bkpf = abap_false.
lt_tmp_docs_by_belnr = lt_docs_by_belnr.
SORT lt_tmp_docs_by_belnr BY buzei.
"1980423
DELETE ADJACENT DUPLICATES FROM lt_tmp_docs_by_belnr COMPARING buzei.
"1980423
LOOP AT lt_tmp_docs_by_belnr ASSIGNING <f_bseg_bset_line>.
MOVE-CORRESPONDING <f_bseg_bset_line> TO bset.
bset-buzei = <f_bseg_bset_line>-buzei_t.
"1980423
bset-mwskz = <f_bseg_bset_line>-mwskz_t.
"1980423
bset-hkont = <f_bseg_bset_line>-hkont_t.
"1980423
bset-txgrp = <f_bseg_bset_line>-txgrp_t.
"1980423
bset-stceg = <f_bseg_bset_line>-stceg_t.
"1980423
IF alcur EQ 'X'.
PERFORM convert_alt
"euro
USING 'BSET' bkpf-waers.
ENDIF.
PERFORM process_bset CHANGING lv_reject.
IF lv_reject = abap_true.
CLOSE CURSOR c.
"2103962
RETURN.
ENDIF.
ENDLOOP.
ENDIF.
IF lv_failed_bkpf = abap_false.
PERFORM process_bkpf_late.
ENDIF.
CLOSE CURSOR c.

ENDFORM.

"process_result

"2103962
"2103962

*&---------------------------------------------------------------------*
*&
Form READ_TEURB
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->DD_BUKRS
text
*----------------------------------------------------------------------*
FORM read_teurb TABLES dd_bukrs.
DATA: nobukrs TYPE p,
save_waers LIKE t001-waers.
nobukrs = 0.
SELECT * FROM t001 WHERE bukrs IN dd_bukrs.
nobukrs = nobukrs + 1.
CALL FUNCTION 'CHECK_PLANTS_ABROAD_ACTIVE'
EXPORTING
i_bukrs
= t001-bukrs
IMPORTING
e_fi_isactive = xwia.
IF xwia IS INITIAL.
PERFORM append_int_teurb USING nobukrs save_waers space.
ELSE.
PERFORM append_int_teurb USING nobukrs save_waers g_land.
ENDIF.
ENDSELECT.
SORT int_teurb.
ENDFORM.
"READ_TEURB

*&---------------------------------------------------------------------*
*&
Form APPEND_INT_TEURB
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->NOBUKRS
text
*
-->SAVE_WAERS text
*
-->ZLAND
text
*----------------------------------------------------------------------*
FORM append_int_teurb USING nobukrs save_waers zland LIKE t005-land1.
SELECT SINGLE * FROM teurb INTO CORRESPONDING FIELDS
OF int_teurb WHERE cprog = sy-cprog
AND bukrs = t001-bukrs
AND land1 = zland.
IF sy-subrc NE 0.
IF zland IS INITIAL.
MESSAGE e442(fr) WITH t001-bukrs sy-cprog.
ELSE.
MESSAGE e465(fr) WITH t001-bukrs sy-cprog zland.
ENDIF.
ELSE.

IF nobukrs EQ 1.
save_waers = teurb-waers.
ELSE.
IF teurb-waers NE save_waers.
MESSAGE e443(fr).
ENDIF.
ENDIF.
int_teurb-hwaer = t001-waers.
APPEND int_teurb.
ENDIF.
ENDFORM.
"APPEND_INT_TEURB
*&---------------------------------------------------------------------*
*&
Form READ_TALTWAR
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
FORM read_taltwar.
READ TABLE int_teurb WITH KEY bukrs = t001-bukrs
cprog = sy-cprog.
IF sy-subrc EQ 0.
taltwar-alwar = int_teurb-waers.
ENDIF.
ENDFORM.
"READ_TALTWAR
*&---------------------------------------------------------------------*
*&
Form CONV_TO_ALT_CURR
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->ZBUKRS
text
*
-->EXCDT
text
*
-->TWAERS
text
*
-->ZDMBTR
text

*------------------------------------------------------------------*
FORM conv_to_alt_curr USING zbukrs excdt twaers CHANGING zdmbtr.
DATA: e_dmbtr LIKE bseg-dmbtr.
READ TABLE int_teurb WITH KEY bukrs = zbukrs cprog = sy-cprog
BINARY SEARCH.
IF sy-subrc EQ 0.

* alternative Hauswhrung ungleich Belegwhrung


IF twaers NE int_teurb-waers.
CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
EXPORTING
date
= excdt
foreign_currency = int_teurb-waers
local_amount
= zdmbtr

local_currency
RATE
type_of_rate
IMPORTING
EXCHANGE_RATE
foreign_amount
zdmbtr = e_dmbtr.

ENDIF.
ENDIF.
ENDFORM.

= int_teurb-hwaer
= 0
= int_teurb-kurst
=
= e_dmbtr.

"CONV_TO_ALT_CURR

*&---------------------------------------------------------------------*
*&
Form CONV_TO_ALT_CURR_WIA
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->ZBUKRS
text
*
-->EXCDT
text
*
-->ZDMBTR
text
*----------------------------------------------------------------------*
FORM conv_to_alt_curr_wia USING zbukrs excdt CHANGING zdmbtr.
DATA: e_dmbtr LIKE bseg-dmbtr.
READ TABLE int_teurb WITH KEY bukrs = zbukrs cprog = sy-cprog
BINARY SEARCH.
IF sy-subrc EQ 0.
alternative Hauswhrung ungleich Belegwhrung
if twaers ne int_teurb-waers.
CALL FUNCTION 'CONVERT_TO_FOREIGN_CURRENCY'
EXPORTING
date
= excdt
foreign_currency = int_teurb-waers
local_amount
= zdmbtr
local_currency
= g_waers
type_of_rate
= int_teurb-kurst
IMPORTING
foreign_amount
= e_dmbtr.
zdmbtr = e_dmbtr.
*
endif.
ENDIF.
ENDFORM.
"CONV_TO_ALT_CURR_WIA
*
*

*&---------------------------------------------------------------------*
*&
Form convert_alt
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->TABNAME
text
*
-->BL_WAERS
text

*----------------------------------------------------------------------*
FORM convert_alt USING tabname bl_waers.
"euro
CASE tabname.
WHEN 'BSEG'.
READ TABLE int_teurb WITH KEY bukrs = bseg-bukrs cprog = sy-cprog
BINARY SEARCH.
IF int_teurb-waers NE sp_waers.
IF int_teurb-waers EQ bl_waers.
bseg-dmbtr = bseg-wrbtr.
bseg-mwsts = bseg-wmwst.
bseg-hwbas = bseg-fwbas.
bsega-dmsol = bsega-wrsol.
bsega-dmhab = bsega-wrhab.
bsega-dmshb = bsega-wrshb.
ELSE.
PERFORM conv_to_alt_curr USING
bseg-bukrs excdt sp_waers
CHANGING bseg-dmbtr.
PERFORM conv_to_alt_curr USING
bseg-bukrs excdt sp_waers
CHANGING bseg-mwsts.
PERFORM conv_to_alt_curr USING
bseg-bukrs excdt sp_waers
CHANGING bseg-hwbas.
PERFORM conv_to_alt_curr USING
bseg-bukrs excdt sp_waers
CHANGING bsega-dmsol.
PERFORM conv_to_alt_curr USING
bseg-bukrs excdt sp_waers
CHANGING bsega-dmhab.
PERFORM conv_to_alt_curr USING
bseg-bukrs excdt sp_waers
CHANGING bsega-dmshb.
ENDIF.
ENDIF.
WHEN 'BSET'.
READ TABLE int_teurb WITH KEY bukrs = bset-bukrs cprog = sy-cprog
BINARY SEARCH.
IF int_teurb-waers NE sp_waers.
IF int_teurb-waers EQ bl_waers.
bset-hwste = bset-fwste.
bset-hwbas = bset-fwbas.
ELSE.
PERFORM conv_to_alt_curr USING
bset-bukrs excdt sp_waers
CHANGING bset-hwste.
PERFORM conv_to_alt_curr USING
bset-bukrs excdt sp_waers
CHANGING bset-hwbas.
ENDIF.
ENDIF.
IF xwia EQ 'X' AND NOT g_waers IS INITIAL.
IF int_teurb-waers NE g_waers. "LW wurde umgesetzt
IF int_teurb-waers EQ bl_waers.
bset-lwste = bset-fwste.
bset-lwbas = bset-fwbas.
ELSE.
PERFORM conv_to_alt_curr_wia USING bset-bukrs excdt
CHANGING bset-lwste.
PERFORM conv_to_alt_curr_wia USING bset-bukrs excdt

CHANGING bset-lwbas.
ENDIF.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM.

"convert_alt

*----------------------------------------------------------------------*
* FORM T001_READ
*
* Buchungskreisdaten
*
*----------------------------------------------------------------------*
FORM t001_read USING save_bukrs TYPE bukrs.
* IF T001-BUKRS NE SAVE_BUKRS.
*
SELECT SINGLE * FROM T001
*
WHERE BUKRS = SAVE_BUKRS.
* ENDIF.
CALL FUNCTION 'READ_T001'
EXPORTING
xbukrs = save_bukrs
IMPORTING
struct = t001.
IF alcur EQ 'X'. PERFORM read_taltwar. ENDIF.
"<<<< euro
sp_waers = t001-waers.
"<<<< euro
ENDFORM.
"T001_READ
*&---------------------------------------------------------------------*
*&
Form ADAPT_TCURF_DECIMALS
"1963595
*&---------------------------------------------------------------------*
*
Decimal places of the involved currencies are taken
*
into account by changing the factors ffact, tfact in tcurf.
*----------------------------------------------------------------------*
*
<--PS_TCURF text
*----------------------------------------------------------------------*
FORM adapt_tcurf_decimals
"1963595
CHANGING ps_tcurf TYPE tcurf.
DATA: currdec_f TYPE currdec,
currdec_t TYPE currdec.
SELECT SINGLE currdec FROM tcurx INTO currdec_f
WHERE currkey = ps_tcurf-fcurr.
IF sy-subrc <> 0.
currdec_f = 2.
ENDIF.
SELECT SINGLE currdec FROM tcurx INTO currdec_t
WHERE currkey = ps_tcurf-tcurr.
IF sy-subrc <> 0.
currdec_t = 2.
ENDIF.
* only required if decimals are different
IF currdec_f <> currdec_t.

* reduce number of decimals to difference


IF currdec_f > currdec_t.
currdec_f = currdec_f - currdec_t.
currdec_t = 0.
ELSE.
currdec_t = currdec_t - currdec_f.
currdec_f = 0.
ENDIF.
* adapt factors avoiding overflows or underflows
IF currdec_f > 0.
DO currdec_f TIMES.
IF ps_tcurf-tfact >= 10.
ps_tcurf-tfact = ps_tcurf-tfact / 10.
ELSEIF ps_tcurf-ffact < '10000000'.
ps_tcurf-ffact = ps_tcurf-ffact * 10.
ENDIF.
ENDDO.
ENDIF.
IF currdec_t > 0.
DO currdec_t TIMES.
IF ps_tcurf-ffact >= 10.
ps_tcurf-ffact = ps_tcurf-ffact / 10.
ELSEIF ps_tcurf-tfact < '10000000'.
ps_tcurf-tfact = ps_tcurf-tfact * 10.
ENDIF.
ENDDO.
ENDIF.
ENDIF.
ENDFORM.
" ADAPT_TCURF_DECIMALS
"1963595
*&---------------------------------------------------------------------*
*&
Form CHECK_DEF_CTRY_OPTION
"1948319
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_BUKRS text
*
-->P_CHECK text
*
<--P_DEF_SHOW
X = show all deferred tax codes
*
<--P_DEF_SHOW_0 X = show 0% deferred tax codes
*----------------------------------------------------------------------*
FORM check_def_ctry_option
"1948319
USING
p_bukrs
TYPE bukrs
p_check
TYPE xfeld
CHANGING p_def_type
TYPE c
p_def_show
TYPE xfeld
p_def_show_0 TYPE xfeld.
STATICS: ls_t005 TYPE t005.
DATA:
ld_ctry_iso TYPE intca.

CLEAR p_def_type.

"par_def not allowed

* First get company code country, esp. for RU, UA.


READ TABLE gt_isocodes INTO s_isocodes
WITH KEY bukrs = p_bukrs.
IF sy-subrc = 0.
ld_ctry_iso = s_isocodes-intca.
* Note:
* p_def_type 2 exists for reasons of history.
* The function to always show deferred tax codes in RU, UA
* existed since note 595718 and cannot be simply replaced
* by a new parameter par_def. Here country was always
* determioned directly from company code.
IF ld_ctry_iso EQ 'RU' OR
ld_ctry_iso EQ 'UA'.
p_def_type = '2'.
"always show def'd tax codes
ENDIF.
ENDIF.

IF p_def_type EQ space.
* If reporting country is specified we use it
IF NOT sel_lstm-low IS INITIAL.
IF ls_t005-land1 IS INITIAL.
SELECT SINGLE * FROM t005 INTO ls_t005
WHERE land1 = sel_lstm-low.
ENDIF.
ld_ctry_iso = ls_t005-intca.
ENDIF.
* evaluate country
CASE ld_ctry_iso.
WHEN 'IT'
OR 'HR'
OR 'RO'
OR 'BG'
OR 'RS'
OR 'PL'
OR 'ES'.
p_def_type = '1'.
"optional via par_def
ENDCASE.
ENDIF.

* Checks performed on selection screen


IF p_check = 'X'.

IF p_def_type EQ space AND


NOT par_def IS INITIAL.
def tax codes aer not allowed in the country

"2129529
"2129529
"2129529

MESSAGE e582 WITH ld_ctry_iso.


ENDIF.

IF NOT par_def IS INITIAL AND


NOT par_binp IS INITIAL.
def tax codes not allowed together with batch input
MESSAGE e581.
ENDIF.
ENDIF.

* evaluate parameters and def_type to get a result


p_def_show = space.
IF p_def_type = '1' AND par_def = 'X'.
p_def_show = 'X'.
"def tax optional
ELSEIF p_def_type = '2'.
p_def_show = 'X'.
"def tax always
ENDIF.
IF par_binp = 'X'.
"but never with batch input
p_def_show = space.
ENDIF.
*
*
*
*

0% deferred tax codes are shown in all countries


irrespective of par_def or par_binp.
This is required for the 0% deferred tax workaround
implemented in RFUMSV25 and J_1HDTAX (updates on BSET).
p_def_show_0 = 'X'.

ENDFORM.
" CHECK_DEF_CTRY_OPTION
"1948319
*&---------------------------------------------------------------------*
*&
Form UPDATE_BSET
"2061805
*&---------------------------------------------------------------------*
*
Update fields BSET-STMDT and BSET-STMTI
*
with execution date and time.
*----------------------------------------------------------------------*
* --> using global internal table tab_bset_key
*
hlp_stmdt, hlp_stmti
*----------------------------------------------------------------------*
FORM update_bset.
"2061805
DATA: ld_counter TYPE i.
IF par_bsud = 'X'.

"if in update mode ...

LOOP AT tab_bset_key.
UPDATE bset
SET stmdt = hlp_stmdt
stmti = hlp_stmti
WHERE bukrs = tab_bset_key-bukrs
AND belnr = tab_bset_key-belnr
AND gjahr = tab_bset_key-gjahr

AND buzei = tab_bset_key-buzei.


ld_counter = ld_counter + 1.
IF ld_counter >= 100.
COMMIT WORK.
ld_counter = 0.
ENDIF.
ENDLOOP.
IF ld_counter > 0.
COMMIT WORK.
ENDIF.
ENDIF.
FREE tab_bset_key.
ENDFORM.
" update_bset
"2061805
*&---------------------------------------------------------------------*
*&
Form CHECK_CVP_ILM_1
"2073571
*&---------------------------------------------------------------------*
*
Check if BF ERP_CVP_ILM_1 is active
*----------------------------------------------------------------------*
*
<--P_CVP_ACTIVE text
*----------------------------------------------------------------------*
FORM check_cvp_ilm_1
"2073571
CHANGING p_cvp_active TYPE xfeld.
CLEAR p_cvp_active.
IF cl_vs_switch_check=>cmd_vmd_cvp_ilm_sfw_01( ) IS NOT INITIAL.
p_cvp_active = 'X'.
ENDIF.
ENDFORM.

"check_cvp_ilm_1

"2073571