Qu'on sache skc1a est une structure de SAP DB et pas une table physique, et pour ce fait, la récupération de son code source se fait de la manière suivante:
Sur le menu de SAP Easy Access, Tapez la transaction SE36
Vous aurez cette écran:
REPORT sapdbsdf DEFINING DATABASE sdf MESSAGE-ID fr.
********* ATTENTION for further global data declarations *************
* release 4.6A and greater
* initialize all global data declarations in form 'LDB_PROCESS_INIT'
* to make sure that the log. database can be processed multiple via
* function module 'LDB_PROCESS'
* -------------------------------------------------------------------*
TYPE-POOLS: rsds.
TABLES: ska1, " Kontenplan
skat, " Sachkontentexte
skb1, " Buchungskreisdaten
glt0, " GL C-Segment Summentabelle
skc1a, " Verkehrszahlen (Dummy) - Nur Hauswährungsbeträge-
skc1c, " Verkehrszahlen (Dummy) - Beträge pro Währung-
bsis, " Sekundaerindex offene Posten
bsas, " Sekundaerindex ausgeglichene Posten
admi_files,
bsisext, "40C
bkpf, " Belegkopf
vbkpf, " Belegkopf vorerfasster Belege
bseg, " Belegsegment vorerfasster Belege
v_vbsegs, " View auf VBKPF und VBSEGS
vbsegk, " Belegsegment vorerfasster Belege - Kreditoren
vbsegd, " Belegsegment vorerfasster Belege - Debitoren
vbsegs, " Belegsegment vorerfasster Belege - Sachkonten
vbsega, " Belegsegment vorerfasster Belege - Anlagen
vbsec, " Belegsegment vorerfasster Belege - CPD
bsegh, " Hilfstabelle fuer BSEGA (Dummy)
bsega, " Beleganhang (Dummy)
gseg, " Belegsegment - Gegenposition
gsega, " Beleganhang (Dummy) - Gegenposition
bsec, " Belegsegment - CPD-Daten
bsed, " Belegsegment - Wechseldaten
b0sg, " Flags
t001, " Buchungskreise
t004, " Kontenplaene
x001. " Waehrungsinformation
TABLES: sscrfields.
TABLES: taltwar. "euro
TABLES: dd03l.
TABLES: faglfreesel.
* fields for ranges in internal and external format
*----------------------------------------------------
DATA gt_dyn_trange TYPE rsds_trange.
DATA projk_eliminated(1) TYPE c.
DATA projk_tab TYPE rsds_selopt_t.
DATA imkey_eliminated(1) TYPE c.
DATA imkey_tab TYPE rsds_selopt_t.
DATA check_ok(1) TYPE c.
* Felder fuer Hilfsberechnungen
* -----------------------------
DATA: refe1 LIKE skc1a-um01k,
refe2 LIKE skc1a-um01k,
refe3 LIKE skc1a-um01k.
* Cursor-Verwaltung fuer interne Tabellen und Zaehler
DATA: cursor_t LIKE sy-tabix,
saknr_skc1a LIKE ska1-saknr,
saknr_skc1c LIKE ska1-saknr.
DATA: g_balv TYPE boolean VALUE 'X'. "usa BALV for messages log
* Zwischenpuffer
RANGES: k_saknr FOR ska1-saknr.
buffer: skb1.
DATA: cursor-skc1a LIKE sy-index,
cursor-skc1c LIKE sy-index.
DATA: count TYPE i,
max_count TYPE i VALUE 25,
count_ldb_log TYPE i. "1344830
DATA: f_bkpf_bes_subrc LIKE sy-subrc.
* Selektionsfelder fuer Plandaten
* --------------------------------
RANGES: version FOR skc1a-rvers.
DATA: styp LIKE glt0-rrcty.
* Satztyp fuer GLT0, wird intern gesetzt
* --------------------------------------
RANGES: sd_stype FOR glt0-rrcty.
* SAVE-Felder fuer KEY-Begriffe
* -----------------------------
DATA: save_ktopl LIKE ska1-ktopl,
save_saknr LIKE ska1-saknr,
save_bukrs LIKE skb1-bukrs,
save_waers LIKE skb1-waers,
save_gjahr LIKE skc1a-gjahr,
save_gsber LIKE skc1a-gsber,
save_belnr LIKE bsis-belnr,
save_buzei LIKE bsis-buzei,
save_subrc LIKE sy-subrc,
save_bstat LIKE bkpf-bstat,
prev_bukrs LIKE skb1-bukrs, "3.0F keys to avoid mult. sel
prev_belnr LIKE bsis-belnr, "3.0F
prev_gjahr LIKE skc1a-gjahr, "3.0F
bukrs-flag(1) TYPE c VALUE 'Y'.
* Key-Aufbau zum Lesen GLT0
* -------------------------
DATA: BEGIN OF glkey,
rldnr LIKE glt0-rldnr, " Ledger-Nr fix '00'
bukrs LIKE glt0-bukrs, " Bukreis aus Eingabe
racct LIKE glt0-racct, " Konto aus Eingabe
rtcur LIKE glt0-rtcur, " Waehrung aus SKB1-WAERS
drcrk LIKE glt0-drcrk, " S/H-Kennz fix 'S'
rpmax LIKE glt0-rpmax, " Bis-Perioe fix '16'
END OF glkey.
RANGES: xx_rldnr FOR glt0-rldnr.
* Quantities for optimized access to Table BKPF
* ---------------------------------------------
TYPES: BEGIN OF keybkpf,
bukrs LIKE bkpf-bukrs,
belnr LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
END OF keybkpf.
DATA: gt_save_keybkpf TYPE HASHED TABLE OF keybkpf
WITH UNIQUE KEY bukrs belnr gjahr.
DATA: gd_save_keybkpf TYPE keybkpf.
DATA: gt_save_bkpf TYPE HASHED TABLE OF bkpf
WITH UNIQUE KEY bukrs belnr gjahr.
DATA: gd_save_bkpf TYPE bkpf.
DATA: gd_opttime_bkpf TYPE c,
gd_optmemo_bkpf TYPE c,
gd_maxlines TYPE i.
* Tabelle der Kontenplaene und der zugehoerigen Buchungskreise
DATA: BEGIN OF kbtab OCCURS 10,
ktopl LIKE ska1-ktopl,
bukrs LIKE skb1-bukrs,
END OF kbtab.
* XSKAT - Tabelle zur Bereitstellung der Sachkonten-
* bezeichnung pro Kontenplan
* -------------------------------------------------------------
DATA: BEGIN OF xskat OCCURS 100.
INCLUDE STRUCTURE skat.
DATA: END OF xskat.
* XSKA1 - Tabelle zu Sammeln der Sachkonten
* --------------------------------------------------------------
DATA: BEGIN OF xska1 OCCURS 900.
INCLUDE STRUCTURE ska1.
DATA: END OF xska1.
DATA: xglt0 LIKE glt0 OCCURS 0 WITH HEADER LINE.
* XSKC1A - Tabelle zu Sammeln der Verkehrszahlen pro
* Konto, Buchungskreis, Jahr alle Gesch.Bereiche in HW
* -------------------------------------------------------------
DATA: BEGIN OF xskc1a OCCURS 50.
INCLUDE STRUCTURE skc1a.
DATA: END OF xskc1a.
* YSKC1A - Tabelle zu Sammeln der SKC1A-Tabellen
* --------------------------------------------------------------
DATA: BEGIN OF yskc1a OCCURS 500.
INCLUDE STRUCTURE skc1a.
DATA: END OF yskc1a.
* XSKC1C - Tabelle zu Sammeln der Verkehrszahlen pro
* Konto, Buchungskreis, Jahr alle Gesch.Bereiche pro FW
* --------------------------------------------------------------
DATA: BEGIN OF xskc1c OCCURS 50.
INCLUDE STRUCTURE skc1c.
DATA: END OF xskc1c.
* YSKC1C - Tabelle zu Sammeln der SKC1C-Tabellen
* --------------------------------------------------------------
DATA: BEGIN OF yskc1c OCCURS 500.
INCLUDE STRUCTURE skc1c.
DATA: END OF yskc1c.
* 3.0F Tabelle zur Vermeidung der mehrfachen Zugriffe auf BKPF
DATA: BEGIN OF xbkpf OCCURS 10.
INCLUDE STRUCTURE bkpf.
DATA: END OF xbkpf.
* Tabellen fuer dynamische Selektion und Felder
* --------------------------------------------------------------
DATA: ska1_where LIKE rsdswhere OCCURS 10,
ska1_fields LIKE rsfs_struc OCCURS 10.
DATA: skb1_where LIKE rsdswhere OCCURS 10,
skb1_fields LIKE rsfs_struc OCCURS 10.
DATA: bsis_where LIKE rsdswhere OCCURS 10,
bsis_fields LIKE rsfs_struc OCCURS 10,
vbsegs_where LIKE rsdswhere OCCURS 10,
where_line LIKE rsdswhere.
DATA: faglfreesel_where LIKE rsdswhere OCCURS 10.
DATA: bsisext_fields LIKE rsfs_struc OCCURS 10. "40C
DATA: bkpf_fields LIKE rsfs_struc OCCURS 10.
DATA: bseg_fields LIKE rsfs_struc OCCURS 10.
DATA: gseg_fields LIKE rsfs_struc OCCURS 10. "30F
DATA: test_fields LIKE rsfs_struc OCCURS 10 WITH HEADER LINE."30F
* Merker, ob Kontenplaene abgegrenzt wurden.
* ------------------------------------------
DATA: ktopl_entry TYPE p.
* Merker, ob Buchungskreise abgegrenzt wurden.
* --------------------------------------------
DATA: bukrs_entry TYPE p.
DATA: char130(130) TYPE c.
* SD_OPOPT(1) TYPE C,
* SD_APOPT(1) TYPE C.
DATA: database(1) TYPE c VALUE 'S'.
* Reading data from archives
TYPES: BEGIN OF ty_rng_archiv,
sign TYPE char1_arch,
option TYPE char2,
low TYPE arkey,
high TYPE arkey,
END OF ty_rng_archiv.
TYPES: BEGIN OF ty_doc_key, "1238122
bukrs TYPE bsis-bukrs, "1238122
belnr TYPE bsis-belnr, "1238122
gjahr TYPE bsis-gjahr, "1238122
buzei TYPE bsis-buzei, "1238122
END OF ty_doc_key. "1238122
TYPES: gt_rng_archiv TYPE TABLE OF ty_rng_archiv.
TYPES: ty_bsis TYPE bsis OCCURS 10.
DATA : ybsas TYPE bsas OCCURS 10,
ybsis TYPE bsis OCCURS 10,
ybkpf TYPE bkpf OCCURS 10,
ybseg TYPE bseg OCCURS 10.
DATA: arch_doc_key TYPE TABLE OF ty_doc_key. "1238122
DATA : cursor-ybsas TYPE sy-index.
DATA : gd_count_arch TYPE i.
DATA : gt_selections TYPE rsds_trange.
DATA : gd_arch_done TYPE c.
DATA : gd_read_memo_done TYPE c.
DATA : gd_msg601_done TYPE c.
* check date (tpc)
DATA: gd_tpc_check TYPE char1 VALUE space.
DATA: gd_tpc_stida TYPE char1 VALUE space.
DATA: gd_tpc_check_sel TYPE char1 VALUE space.
DATA: gd_tpc_log TYPE char1 VALUE space.
* expiring currencies:
DATA: gd_waers_save TYPE waers,
gd_expcur_flag TYPE c,
gd_expcur_date TYPE sydatum.
DATA: BEGIN OF ledtab OCCURS 2.
INCLUDE STRUCTURE gledtab.
DATA: END OF ledtab.
DATA: BEGIN OF f4tab OCCURS 2.
INCLUDE STRUCTURE rgse1.
DATA: END OF f4tab.
DATA: BEGIN OF c001 OCCURS 10,
bukrs LIKE t001-bukrs,
waers LIKE t001-waers,
rldnr LIKE gledtab-rldnr,
currnumber LIKE gledtab-currnumber,
END OF c001.
* Tabelle zum Speichern der selektierten Buchungskreise 3.0F
DATA: BEGIN OF xy_bukrs OCCURS 10,
bukrs LIKE skb1-bukrs,
END OF xy_bukrs.
RANGES zz_bukrs FOR skb1-bukrs.
DATA: g_flg_xx_curtp TYPE c.
*---------------------------------------------------------------------
* Flex GL
*---------------------------------------------------------------------
DATA: g_glflex_active TYPE boole_d.
DATA: g_glflex_act_cc TYPE boole_d.
DATA: g_rldnr TYPE rldnr.
DATA: g_lead_rldnr TYPE rldnr.
* Constants
CONSTANTS:
fagl_bhdgd_rldnr(16) TYPE c VALUE 'FAGL_BHDGD_RLDNR'.
INCLUDE rfdbexpc.
INCLUDE rfdbinclud1.
INCLUDE rfdbinclud2.
INCLUDE rfdbeuro. "<<<< euro
*--------------------------------------------------------------------*
* FORM INIT - Vorschalgswerte auf Selektionsbild bringen *
*--------------------------------------------------------------------*
FORM init.
* tpc
DATA ld_return TYPE char1.
FIELD-SYMBOLS: <l_f_event> LIKE LINE OF get_events. "NewGL
sd_opopt = space.
sd_apopt = space.
sd_stida = sy-datum.
b0sg-xstan = 'X'.
CLEAR: g_flg_xx_curtp.
* expiring currencies relevant for this process?
CALL FUNCTION 'CURRENCY_CHECK_FOR_PROCESS'
EXPORTING
process = 'SAPDBSDF'
EXCEPTIONS
process_not_maintained = 1
OTHERS = 2.
IF sy-subrc = 0.
gd_expcur_flag = 'X'.
ENDIF.
* check date(tpc)
CALL FUNCTION 'FI_CHECK_DATE'
EXPORTING
i_bukrs = space
i_user = sy-uname
i_program = 'SAPDBSDF'
IMPORTING
e_return = ld_return
EXCEPTIONS
no_authority_prog = 1
no_authority_date = 2
wrong_parameter = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF ld_return = 1.
gd_tpc_check = 'X'.
* log function installed: due to ABA support package
CALL FUNCTION 'FUNCTION_EXISTS'
EXPORTING
funcname = 'CA_WRITE_LOG'
EXCEPTIONS
function_not_exist = 1
OTHERS = 2.
IF sy-subrc EQ 0.
* user is tax auditor and ca_write_log is activ
gd_tpc_log = 'X'.
ENDIF.
ELSE.
gd_tpc_check = space.
ENDIF.
EXPORT gd_tpc_check TO MEMORY ID 'TPC_CHECK_FAGLL03'. "1061175
* Initialization for reading from archives.
IF sd_objec IS INITIAL.
* Archive object for itmes
sd_objec = 'FI_DOCUMNT'.
ENDIF.
IF sd_usedb IS INITIAL AND sd_usear IS INITIAL.
sd_usedb = 'X'.
sd_usear = space.
sd_useas = 'X'.
PERFORM datasource_init
CHANGING sd_objec sd_usedb sd_usear sd_useas sd_files[].
ENDIF.
sscrfields-functxt_05 = text-src.
*******************************************************
* NewGL: Reading totals from archiv
*******************************************************
* Set archive object for totals
if sd_obje1 is initial or sd_obje2 is initial.
sd_obje1 = sd_obje2 = 'FI_TF_GLF'.
endif.
read table get_events assigning <l_f_event> with key node = 'SKC1A'.
if sy-subrc eq 0 and <l_f_event>-kind ne space.
IF sd_usdb1 IS INITIAL AND sd_usar1 IS INITIAL.
sd_usdb1 = 'X'.
sd_usar1 = space.
sd_usas1 = 'X'.
PERFORM datasource_init
CHANGING sd_obje1 sd_usdb1 sd_usar1 sd_usas1 sd_file1[].
ENDIF.
endif.
read table get_events assigning <l_f_event> with key node = 'SKC1C'.
if sy-subrc eq 0 and <l_f_event>-kind ne space.
IF sd_usdb2 IS INITIAL AND sd_usar2 IS INITIAL.
sd_usdb2 = 'X'.
sd_usar2 = space.
sd_usas2 = 'X'.
PERFORM datasource_init
CHANGING sd_obje2 sd_usdb2 sd_usar2 sd_usas2 sd_file2[].
ENDIF.
endif.
* Reading totals from archiv
sscrfields-functxt_04 = text-src.
sscrfields-functxt_03 = text-src.
* Switch function keys
PERFORM status_functionkeys_change.
************************************************
* flex gl active ?
CALL FUNCTION 'FAGL_CHECK_GLFLEX_ACTIVE'
IMPORTING
e_glflex_active = g_glflex_active
EXCEPTIONS
error_in_setup = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* ccodes active ?
IF g_glflex_active IS INITIAL.
CALL FUNCTION 'FAGL_BUKRS_ACTIVE_IN_CLIENT'
IMPORTING
e_glflex_active = g_glflex_act_cc.
ENDIF.
ENDFORM. "INIT
*--------------------------------------------------------------------*
* FORM PBO - Selection Screen: Process before output *
*--------------------------------------------------------------------*
FORM pbo.
DATA s_flag.
LOOP AT SCREEN.
IF screen-name(8) = 'SD_GSB_S'.
s_flag = 'X'.
ENDIF.
IF screen-group1 = 'GSB' AND s_flag = 'X'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
CLEAR: s_flag.
LOOP AT SCREEN.
*.. if parameter for currency type at the screen ?
IF screen-name(8) = 'SD_CURTP'.
s_flag = 'X'.
ENDIF.
*.. then deactivate select options for currency type
IF screen-group1 = 'CTP' AND s_flag = 'X'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
IF g_glflex_active IS INITIAL.
* FlexGL is not active - make RLDNR invisible
LOOP AT SCREEN.
IF screen-group1 = 'LDG'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
PERFORM auth_check_for_blart_gsber CHANGING au_blart au_gsber. "<<<au40
PERFORM modify_screen_for_euro USING sy-cprog. "<<<euro
ENDFORM. "PBO
*--------------------------------------------------------------------*
* FORM PAI - Selection Screen: Process after input *
*--------------------------------------------------------------------*
FORM pai USING fname mark.
DATA: get1, get2, get3,
rc LIKE sy-subrc,
msg1 LIKE symsg.
STATICS: l_cc_at_screen LIKE sy-subrc.
STATICS: l_rldnr_at_screen LIKE sy-subrc.
DATA: ld_progname TYPE progname,
lt_objects TYPE as_t_archobj.
**********************************************************************
* NewGL: Reading totals from archíve
**********************************************************************
field-symbols: <l_f_event> like line of get_events.
**********************************************************************
* fill local currency reference field for dynamic selections:
CLEAR t001-waers.
READ TABLE sd_bukrs INDEX 1.
IF sy-subrc = 0.
SELECT SINGLE waers FROM t001 INTO t001-waers
WHERE bukrs IN sd_bukrs.
ENDIF.
CHECK mark = space.
IF sscrfields-ucomm = 'ONLI' " Online submit
OR sscrfields-ucomm = 'PRIN' " Online submit and print
OR sscrfields-ucomm = 'SJOB' " Submit as background job
OR sscrfields-ucomm = 'SPOS' " Save as Variant
OR sscrfields-ucomm = 'SAVE' " Variant maintanance
OR sscrfields-ucomm = 'EXEX' " Application execute
OR sscrfields-ucomm = space " ENTER
OR sy-ucomm = 'EXEX' " Application execute
or SSCRFIELDS-UCOMM = 'CXSP'. " search help (note 1605999)
CASE fname.
WHEN 'SD_BUKRS'.
IF sd_noaut IS INITIAL.
PERFORM company_code_at_screen_check
CHANGING l_cc_at_screen.
* authority check only if cc appears at screen.
CHECK NOT ( l_cc_at_screen IS INITIAL "1168366
AND sd_bukrs IS INITIAL ). "1168366
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = database
TABLES
xbukreis = sd_bukrs.
* Belegberechtigung auf Buchungskreisebene
READ TABLE get_events WITH KEY node = 'SKC1A'.
get1 = get_events-kind.
READ TABLE get_events WITH KEY node = 'SKC1C'.
get2 = get_events-kind.
READ TABLE get_events WITH KEY node = 'BSIS'.
get3 = get_events-kind.
IF get1 <> ' ' OR "Salden
get2 <> ' ' OR
get3 <> ' '. "Belege
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = 'B'
TABLES
xbukreis = sd_bukrs.
ENDIF.
ENDIF.
WHEN 'SD_SAKNR'.
* Konvertierung der Kontonummer
* -----------------------------
LOOP AT sd_saknr.
PERFORM alphaformat(sapfs000)
USING sd_saknr-low sd_saknr-low.
PERFORM alphaformat(sapfs000)
USING sd_saknr-high sd_saknr-high.
MODIFY sd_saknr.
ENDLOOP.
WHEN 'SD_STIDA'.
IF sd_stida EQ '00000000' OR sd_stida EQ space.
MESSAGE e109.
ENDIF.
sd_opopt = 'X'.
gd_tpc_stida = 'X'.
WHEN 'SD_AUGDT'.
sd_apopt = 'X'.
WHEN 'XX_CURTP'.
CLEAR: g_flg_xx_curtp.
*.... check, if XX_CURTP is active
LOOP AT SCREEN.
IF screen-group1 = 'CTP'
AND screen-active = '1'.
g_flg_xx_curtp = 'X'.
ENDIF.
ENDLOOP.
IF g_flg_xx_curtp = 'X'.
READ TABLE xx_curtp INDEX 1.
sd_curtp = xx_curtp-low.
IF sd_curtp = '00'.
*........ assume that GET SKC1C event has been choosen
*........ switch to curtp 10 for further process
sd_curtp = '10'.
ENDIF.
ENDIF.
WHEN '*'.
CHECK: sy-dynnr = '1000'.
*.... it is necessary if there are report individual tabstrips
*.... the following checks and messages concern only screen 1000
*.... see also internal message 1221894/1999
IF gd_tpc_check = 'X'.
PERFORM check_date.
ENDIF.
copy sd_gsb_b to sd_gsber.
LOOP AT sd_gsb_s.
sd_gsber = sd_gsb_s.
APPEND sd_gsber.
ENDLOOP.
*.... new authorithy check for company code.
*....(see message 105305/2003 for example)
PERFORM company_code_at_screen_check
CHANGING l_cc_at_screen.
* authority check only if cc appears at screen.
IF NOT ( l_cc_at_screen IS INITIAL "1168366
AND sd_bukrs IS INITIAL ). "1168366
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = database
TABLES
xbukreis = sd_bukrs.
* Belegberechtigung auf Buchungskreisebene "825411
READ TABLE get_events WITH KEY node = 'SKC1A'.
get1 = get_events-kind.
READ TABLE get_events WITH KEY node = 'SKC1C'.
get2 = get_events-kind.
READ TABLE get_events WITH KEY node = 'BSIS'.
get3 = get_events-kind.
IF get1 <> ' ' OR "Salden
get2 <> ' ' OR
get3 <> ' '. "Belege
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = 'B'
TABLES
xbukreis = sd_bukrs.
ENDIF. "825411
ENDIF.
* -----------------------------------------
* Berechtigungsprüfung Kontoart Sachkonten.
* -----------------------------------------
AUTHORITY-CHECK OBJECT 'F_BKPF_KOA'
ID 'KOART' FIELD 'S'
ID 'ACTVT' FIELD '03'.
IF sy-subrc <> 0.
MESSAGE e812 WITH text-008 'S'.
ENDIF.
* Ende-Verarbeitung
IF sd_opopt IS INITIAL
AND sd_apopt IS INITIAL.
sd_opopt = 'X'.
sd_apopt = 'X'.
sd_stida = '99991231'.
ENDIF.
REFRESH: xx_ktopl.
CLEAR: xx_ktopl.
* REFRESH: XX_BUKRS. "3.0F
* CLEAR: XX_BUKRS.
REFRESH: xy_bukrs.
CLEAR: xy_bukrs. "3.0F
CLEAR: prev_bukrs, prev_belnr, prev_gjahr. "3.0F
REFRESH: xx_rldnr.
CLEAR: xx_rldnr.
REFRESH: kbtab.
cursor_t = 0.
saknr_skc1a = space.
saknr_skc1c = space.
* Einträge in Kontenplantabelle zählen.
* -------------------------------------
DESCRIBE TABLE sd_ktopl LINES ktopl_entry.
* Einträge in Buchungskreistabelle zählen.
* ----------------------------------------
DESCRIBE TABLE sd_bukrs LINES bukrs_entry.
* Einträge in Kontenplan- o d e r Buchungskreistabelle vorhanden ?
* ----------------------------------------
IF ktopl_entry NE 0 OR bukrs_entry NE 0. "Ja
* Füllen KBTAB
*
* Zu den abgegrenzten Kontenplänen und/oder Buchungskreisen
* wird die gültige Kombination ermittelt und in den Selektions-
* tabellen KBTAB abgestellt, um auf Buchungskreisebene, für ein
* Sachkonto in einem Kontenplan nur die Buchungskreise zu selek-
* tierenen, die diesen Kontenplan verwenden.
*
* Füllen XX_KTOPL
*
* Zum Lesen der Sachkontenstammdaten SKA1 werden die gültigen
* Kontenpläne (Kontenpläne die mindestens in einem Buchungskreis
* verwendet werden) in der Tabelle XX_KTOPL abgelegt.
* ---------------------------------------------------------------
SELECT * FROM t001
WHERE ktopl IN sd_ktopl
AND bukrs IN sd_bukrs.
kbtab-ktopl = t001-ktopl.
kbtab-bukrs = t001-bukrs.
APPEND kbtab.
xx_ktopl-sign = 'I'.
xx_ktopl-option = 'EQ'.
xx_ktopl-low = kbtab-ktopl.
COLLECT xx_ktopl.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e102.
ENDIF.
ELSE. "Nein - Keine Einträge in Buktab bzw. Kontopl.tab
* Abgrenzungen Buchungskreis/Kontenplan sind initial.
* Füllen KBTAB
*
* Die gültige Schnittmenge Kontenplan/Buchungskreis rekrutiert
* sich aus der Anzahl der angelegten Buchungskreise. Jedem Buch-
* ungkreis ist genau ein Kontenplan zugeordnet. Es erfolgt ein
* Eintrag in Tabelle KBTAB, damit auf Buchungskreisebene für ein
* Sachkonto in einem Kontenplan nur die Buchungskreise selek-
* tiert werden, die diesen Kontenplan verwenden.
*
* Füllen XX_KTOPL
*
* Zum Lesen der Sachkontenstammdaten SKA1 werden a l l e vorhande-
* nen Kontenpläne, d h. auch solche Kontenpläne die in
* k e i n e m Buchungskreis verwendet werden in der Tabelle
* XX_KTOPL abgelegt. Dadurch werden zusätzliche Auswertungen über
* nicht zugeordnete Kontenpläne ermöglicht.
* ---------------------------------------------------------------
SELECT * FROM t001.
kbtab-ktopl = t001-ktopl.
kbtab-bukrs = t001-bukrs.
APPEND kbtab.
ENDSELECT.
SELECT * FROM t004.
xx_ktopl-sign = 'I'.
xx_ktopl-option = 'EQ'.
xx_ktopl-low = t004-ktopl.
APPEND xx_ktopl.
ENDSELECT.
ENDIF.
CLEAR t004.
* Zulaessigkeit des Waehrungstyps für selektierte Buchungskreis
REFRESH xx_rldnr.
REFRESH c001.
xx_rldnr-option = 'EQ'. xx_rldnr-sign = 'I'.
LOOP AT kbtab.
IF sd_curtp = ' ' OR sd_curtp = '10'.
xx_rldnr-low = '00'.
COLLECT xx_rldnr.
EXIT.
ENDIF.
DATA: l_tp_auth TYPE c.
CALL FUNCTION 'TP_VALUATION_AUTHORITY'
EXPORTING
i_bukrs = kbtab-bukrs
i_cvtyp = sd_curtp
IMPORTING
e_xauth = l_tp_auth
EXCEPTIONS
kokrs_finding_error = 1
valutyp_finding_error = 2
insufficient_input_for_kokrs = 3
insufficient_input_for_valutyp = 4
activity_not_allowed = 5
OTHERS = 6.
IF sy-subrc <> 0
OR l_tp_auth IS INITIAL.
MESSAGE e826 WITH sd_curtp kbtab-bukrs.
ENDIF.
CALL FUNCTION 'FI_CURRENCY_INFORMATION'
EXPORTING
i_bukrs = kbtab-bukrs
IMPORTING
e_x001 = x001.
IF x001-curt2 <> sd_curtp AND x001-curt3 <> sd_curtp.
IF g_flg_xx_curtp IS INITIAL
AND NOT ( l_cc_at_screen IS INITIAL ).
*............ message only if cc appears at screen.
REFRESH c001.
MESSAGE e822 WITH sd_curtp kbtab-bukrs.
ELSE.
*.......... exclude CC from selection
DELETE kbtab.
CONTINUE.
ENDIF.
ELSE.
IF sd_curtp = '30'.
ledtab-rldnr = '00'.
ledtab-currnumber = '3'.
ELSE.
IF sd_rldnr[] IS NOT INITIAL. "n1262139
*.... ledger has been specified
READ TABLE sd_rldnr INDEX 1. "n1262139
g_rldnr = sd_rldnr-low. "n1262139
ENDIF. "n1262139
CALL FUNCTION 'G_GIVE_LEDGERS_FOR_GLT0'
EXPORTING
bukrs = kbtab-bukrs
curtp = sd_curtp
ed_nledger = g_rldnr "n1262139
TABLES
ledtab = ledtab.
DESCRIBE TABLE ledtab LINES sy-tfill.
IF sy-tfill > 1
AND g_glflex_active IS INITIAL.
REFRESH: f4tab.
LOOP AT ledtab.
CLEAR: f4tab.
f4tab-sel_line = ledtab-rldnr.
f4tab-sel_line+3 = ledtab-name.
APPEND f4tab.
ENDLOOP.
PERFORM ledger_waehlen USING '1' CHANGING rc msg1.
IF sy-subrc = 0.
READ TABLE ledtab INDEX sy-tabix.
ELSE.
READ TABLE ledtab INDEX 1.
ENDIF.
ELSE.
READ TABLE ledtab INDEX 1.
ENDIF.
ENDIF.
CLEAR c001.
c001-bukrs = kbtab-bukrs.
IF x001-curt2 = sd_curtp.
c001-waers = x001-hwae2.
ELSEIF x001-curt3 = sd_curtp.
c001-waers = x001-hwae3.
ENDIF.
MOVE-CORRESPONDING ledtab TO c001.
APPEND c001.
xx_rldnr-low = ledtab-rldnr.
COLLECT xx_rldnr.
ENDIF.
ENDLOOP.
IF NOT ( g_glflex_active IS INITIAL ).
*...... flexGL is active
IF sd_rldnr[] IS INITIAL.
*........ set leading ledger
CALL FUNCTION 'FAGL_GET_LEADING_LEDGER'
IMPORTING
e_rldnr = g_lead_rldnr
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*........ set ledger
g_rldnr = g_lead_rldnr.
ELSE.
*........ ledger specified on sel screen
READ TABLE sd_rldnr INDEX 1.
g_rldnr = sd_rldnr-low.
ENDIF.
*...... check whether 'RLDNR' is a selection field
PERFORM rldnr_at_screen_check
CHANGING l_rldnr_at_screen.
* authority check only if RLDNR appears at screen.
if not ( L_RLDNR_AT_SCREEN is initial ). "1531154
*.......... Check only, if documents or balances are requested "1531154
read table GET_EVENTS with key NODE = 'SKC1A'. "1531154
GET1 = GET_EVENTS-KIND. "1531154
read table GET_EVENTS with key NODE = 'SKC1C'. "1531154
GET2 = GET_EVENTS-KIND. "1531154
read table GET_EVENTS with key NODE = 'BSIS'. "1531154
GET3 = GET_EVENTS-KIND. "1531154
if GET1 <> ' ' or "Salden "1531154
GET2 <> ' ' or "1531154
GET3 <> ' '. "Belege "1531154
loop at kbtab. "1531154
call function 'FAGL_AUTHORITY_LEDGER' "1531154
EXPORTING "1531154
i_bukrs = kbtab-bukrs "1531154
i_rldnr = g_rldnr "1531154
i_actvt = '03'. "1531154
endloop. "1531154
endif. "1531154
endif. "1531154
ENDIF.
IF NOT ( g_rldnr IS INITIAL )
AND NOT ( l_rldnr_at_screen IS INITIAL ).
*...... export ledger to memory for standard page header
*...... in program RSBTCHH0.
EXPORT fagl_bhdgd_rldnr FROM g_rldnr
TO MEMORY ID fagl_bhdgd_rldnr.
ENDIF.
*---------------------------------------------------------------------*
WHEN OTHERS.
ENDCASE.
* Selection of datasources.
ELSEIF sscrfields-ucomm = 'FC05'.
ld_progname = sy-cprog.
APPEND 'FI_DOCUMNT' TO lt_objects.
CALL FUNCTION 'AS_DATASOURCE_SELECT'
EXPORTING
i_db_and_arc = 'X'
i_no_source_select = space
i_infosys_possible = 'X'
i_documentation = 'DEFAULT'
i_report = ld_progname
i_reporttype = space
it_objects = lt_objects[]
CHANGING
c_use_database = sd_usedb
c_use_archive = sd_usear
c_use_infosys = sd_useas
c_archobj = sd_objec
ct_arch_sel = sd_files[].
CLEAR : sscrfields-ucomm.
*************************************************
* NewGL: Selection of datasources for totals
*************************************************
* 1. for SKC1A
ELSEIF sscrfields-ucomm = 'FC03'.
* check if SKC1A is called otherwise it could come to
* problem with other programs like FAGLL03
read table get_events assigning <l_f_event> with key node = 'SKC1A'.
if sy-subrc eq 0 and <l_f_event>-kind ne space.
ld_progname = sy-cprog.
APPEND 'FI_TF_GLF' TO lt_objects.
call function 'ARCHIVE_ADMIN_DEFINE_FILTER'
exporting
status_deleted_only = 'X'.
CALL FUNCTION 'AS_DATASOURCE_SELECT'
EXPORTING
i_db_and_arc = 'X'
i_no_source_select = space
i_infosys_possible = 'X'
i_documentation = 'DEFAULT'
it_objects = lt_objects[]
CHANGING
c_use_database = sd_usdb1
c_use_archive = sd_usar1
c_use_infosys = sd_usas1
c_archobj = sd_obje1
ct_arch_sel = sd_file1[].
* archive parameter should be the same for SKC1A and SKC1C otherwise
* it will lead to problems if put for both tables!
sd_usdb2 = sd_usdb1.
sd_usar2 = sd_usar1.
sd_usas2 = sd_usas1.
sd_file2[] = sd_file1[].
CLEAR : sscrfields-ucomm.
endif.
ELSEIF sscrfields-ucomm = 'FC04'.
* 2. for SKC1C
* check if SKC1C is called otherwise it could come to
* problem with other programs like FAGLL03
read table get_events assigning <l_f_event> with key node = 'SKC1C'.
if sy-subrc eq 0 and <l_f_event>-kind ne space.
ld_progname = sy-cprog.
APPEND 'FI_TF_GLF' TO lt_objects.
call function 'ARCHIVE_ADMIN_DEFINE_FILTER'
exporting
status_deleted_only = 'X'.
CALL FUNCTION 'AS_DATASOURCE_SELECT'
EXPORTING
i_db_and_arc = 'X'
i_no_source_select = space
i_infosys_possible = 'X'
i_documentation = 'DEFAULT'
it_objects = lt_objects[]
CHANGING
c_use_database = sd_usdb2
c_use_archive = sd_usar2
c_use_infosys = sd_usas2
c_archobj = sd_obje2
ct_arch_sel = sd_file2[].
* archive parameter should be the same for SKC1A and SKC1C otherwise
* it will lead to problems if put for both tables!
sd_usdb1 = sd_usdb2.
sd_usar1 = sd_usar2.
sd_usas1 = sd_usas2.
sd_file1[] = sd_file2[].
CLEAR : sscrfields-ucomm.
endif.
*****************************************************
ENDIF.
ENDFORM. "PAI
*eject.
*---------------------------------------------------------------------*
* FORM LDB_PROCESS_INIT *
*---------------------------------------------------------------------*
FORM ldb_process_init CHANGING ldb_subrc LIKE sy-subrc.
* initialize all global data declarations to make sure
* that the log. database can be processed multiple via
* function module 'LDB_PROCESS'
CLEAR: ska1, skat, skb1, glt0, skc1a, skc1c, bsis, bsas,
bsisext, bkpf, vbkpf, bseg, v_vbsegs, vbsegk, vbsegd,
vbsegs, vbsega, vbsec, bsegh, bsega, gseg, gsega,
bsec, bsed, b0sg, t001, t004, x001, taltwar, dd03l.
CLEAR: refe1, refe2, refe3.
CLEAR: cursor_t, saknr_skc1a, saknr_skc1c.
CLEAR: sd_ktopl, sd_saknr, sd_bukrs, sd_gjahr, sd_gsb_s. " EhP6 BSD
REFRESH: sd_ktopl, sd_saknr, sd_bukrs, sd_gjahr, sd_gsb_s. " EhP6 BSD
* BUFFER: SKB1.
CLEAR: cursor-skb1.
REFRESH: xskb1.
CLEAR: cursor-skc1a, cursor-skc1c, count.
REFRESH: k_saknr.
REFRESH: version.
REFRESH: sd_stype.
CLEAR: styp.
CLEAR: save_ktopl, save_saknr, save_bukrs, save_waers,
save_gjahr, save_gsber, save_belnr, save_buzei,
save_subrc, save_bstat, prev_bukrs, prev_belnr,
prev_gjahr.
CLEAR: xbkpf.
bukrs-flag = 'Y'.
CLEAR: glkey.
REFRESH: xx_rldnr.
REFRESH: kbtab, xskat, xska1, xglt0, xskc1a, yskc1a, xskc1c,
yskc1c, xbkpf.
REFRESH: ska1_where, ska1_fields,
skb1_where, skb1_fields,
bsis_where, bsis_fields,
bsisext_fields, bkpf_fields,
bseg_fields, gseg_fields,
test_fields.
REFRESH: faglfreesel_where.
CLEAR: ktopl_entry, bukrs_entry, char130,
sd_opopt, sd_apopt.
database = 'S'.
REFRESH: ledtab, f4tab, c001, xy_bukrs, zz_bukrs.
CLEAR: g_flg_xx_curtp.
* For reading from an archiv:
CLEAR: gd_count_arch.
* clear: gd_msg601_done.
PERFORM auth_check_for_blart_gsber CHANGING au_blart au_gsber.
* flex gl active ?
CALL FUNCTION 'FAGL_CHECK_GLFLEX_ACTIVE'
IMPORTING
e_glflex_active = g_glflex_active
EXCEPTIONS
error_in_setup = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* ccodes active ?
IF g_glflex_active IS INITIAL.
CALL FUNCTION 'FAGL_BUKRS_ACTIVE_IN_CLIENT'
IMPORTING
e_glflex_active = g_glflex_act_cc.
ENDIF.
ldb_subrc = 0.
ENDFORM. "LDB_PROCESS_INIT
*---------------------------------------------------------------------*
* FORM LDB_PROCESS_CHECK_SELECTIONS *
*---------------------------------------------------------------------*
FORM ldb_process_check_selections
CHANGING ldb_subrc LIKE sy-subrc
ldb_msg LIKE symsg.
DATA: rc LIKE sy-subrc.
DATA: get1, get2, get3.
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = database
TABLES
xbukreis = sd_bukrs.
* Belegberechtigung auf Buchungskreisebene
READ TABLE get_events WITH KEY node = 'SKC1A'.
get1 = get_events-kind.
READ TABLE get_events WITH KEY node = 'SKC1C'.
get2 = get_events-kind.
READ TABLE get_events WITH KEY node = 'BSIS'.
get3 = get_events-kind.
IF get1 <> ' ' OR "Salden
get2 <> ' ' OR
get3 <> ' '. "Belege
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = 'B'
TABLES
xbukreis = sd_bukrs.
ENDIF.
DESCRIBE TABLE sd_saknr LINES sy-tfill.
IF sy-tfill > 0.
* Konvertierung der Kontonummer
* -----------------------------
LOOP AT sd_saknr.
PERFORM alphaformat(sapfs000)
USING sd_saknr-low sd_saknr-low.
PERFORM alphaformat(sapfs000)
USING sd_saknr-high sd_saknr-high.
MODIFY sd_saknr.
ENDLOOP.
ENDIF.
IF NOT ( xx_curtp IS INITIAL ).
*..... assume that a single currency type arrives
READ TABLE xx_curtp INDEX 1.
sd_curtp = xx_curtp-low.
IF sd_curtp = '00'.
*........ assume that GET SKC1C event has been choosen
*........ switch to curtp 10 for further process
sd_curtp = '10'.
ENDIF.
g_flg_xx_curtp = 'X'.
ENDIF.
IF sd_nooap IS INITIAL.
PERFORM op_or_ap_selection TABLES sd_augdt
CHANGING sd_stida sd_opopt sd_apopt.
ENDIF.
copy sd_gsb_b to sd_gsber.
LOOP AT sd_gsb_s.
sd_gsber = sd_gsb_s.
APPEND sd_gsber.
ENDLOOP.
* -----------------------------------------
* Berechtigungsprüfung Kontoart Sachkonten.
* -----------------------------------------
AUTHORITY-CHECK OBJECT 'F_BKPF_KOA'
ID 'KOART' FIELD 'S'
ID 'ACTVT' FIELD '03'.
IF sy-subrc <> 0.
* message e812 with text-008 'S'.
ldb_msg-msgty = 'E'.
ldb_msg-msgid = 'FR'.
ldb_msg-msgno = '812'.
ldb_msg-msgv1 = text-008.
ldb_msg-msgv2 = 'S'.
ldb_subrc = sy-subrc.
EXIT. " >>>>>>>>>>> E X I T >>>>>>>>>>>>>>>>>>>
ENDIF.
REFRESH: xy_bukrs.
CLEAR: xy_bukrs. "3.0F
CLEAR: prev_bukrs, prev_belnr, prev_gjahr. "3.0F
REFRESH: xx_rldnr.
CLEAR: xx_rldnr.
cursor_t = 0.
saknr_skc1a = space.
saknr_skc1c = space.
PERFORM fill_kbtab_and_ktopl TABLES sd_ktopl sd_bukrs kbtab xx_ktopl
USING '2' CHANGING rc ldb_msg.
IF rc NE 0.
ldb_subrc = rc.
EXIT. " >>>>>>>>>>> E X I T >>>>>>>>>>>>>>>>>>>
ENDIF.
CLEAR t004.
* Zulaessigkeit des Waehrungstyps für selektierte Buchungskreis
REFRESH xx_rldnr.
REFRESH c001.
xx_rldnr-option = 'EQ'. xx_rldnr-sign = 'I'.
LOOP AT kbtab.
IF sd_curtp = ' ' OR sd_curtp = '10'.
xx_rldnr-low = '00'.
COLLECT xx_rldnr.
EXIT.
ENDIF.
DATA: l_tp_auth TYPE c.
CALL FUNCTION 'TP_VALUATION_AUTHORITY'
EXPORTING
i_bukrs = kbtab-bukrs
i_cvtyp = sd_curtp
IMPORTING
e_xauth = l_tp_auth
EXCEPTIONS
kokrs_finding_error = 1
valutyp_finding_error = 2
insufficient_input_for_kokrs = 3
insufficient_input_for_valutyp = 4
activity_not_allowed = 5
OTHERS = 6.
IF sy-subrc <> 0
OR l_tp_auth IS INITIAL.
* message E826 with SD_CURTP KBTAB-BUKRS.
ldb_msg-msgty = 'E'.
ldb_msg-msgid = 'FR'.
ldb_msg-msgno = '826'.
ldb_msg-msgv1 = sd_curtp.
ldb_msg-msgv2 = kbtab-bukrs.
ldb_subrc = sy-subrc.
EXIT. " >>>>>>>>>>> E X I T >>>>>>>>>>>>>>>>>>>
ENDIF.
CALL FUNCTION 'FI_CURRENCY_INFORMATION'
EXPORTING
i_bukrs = kbtab-bukrs
IMPORTING
e_x001 = x001.
IF x001-curt2 <> sd_curtp AND x001-curt3 <> sd_curtp.
IF g_flg_xx_curtp IS INITIAL.
REFRESH c001.
* message e822 with sd_curtp kbtab-bukrs.
ldb_msg-msgty = 'E'.
ldb_msg-msgid = 'FR'.
ldb_msg-msgno = '822'.
ldb_msg-msgv1 = sd_curtp.
ldb_msg-msgv2 = kbtab-bukrs.
ldb_subrc = 4.
EXIT. " >>>>>>>>>>> E X I T >>>>>>>>>>>>>>>
ELSE.
DELETE kbtab.
CONTINUE.
ENDIF.
ELSE.
IF sd_curtp = '30'.
ledtab-rldnr = '00'.
ledtab-currnumber = '3'.
ELSE.
CALL FUNCTION 'G_GIVE_LEDGERS_FOR_GLT0'
EXPORTING
bukrs = kbtab-bukrs
curtp = sd_curtp
TABLES
ledtab = ledtab.
DESCRIBE TABLE ledtab LINES sy-tfill.
IF sy-tfill > 1.
REFRESH: f4tab.
LOOP AT ledtab.
CLEAR: f4tab.
f4tab-sel_line = ledtab-rldnr.
f4tab-sel_line+3 = ledtab-name.
APPEND f4tab.
ENDLOOP.
PERFORM ledger_waehlen USING '2' CHANGING rc ldb_msg.
IF sy-subrc = 0.
READ TABLE ledtab INDEX sy-tabix.
ELSE.
READ TABLE ledtab INDEX 1.
ENDIF.
IF rc NE 0.
ldb_subrc = rc.
EXIT. " >>>>>>>>>>> E X I T >>>>>>>>>>>>>>>>>>>
ENDIF.
ELSE.
READ TABLE ledtab INDEX 1.
ENDIF.
ENDIF.
CLEAR c001.
c001-bukrs = kbtab-bukrs.
IF x001-curt2 = sd_curtp.
c001-waers = x001-hwae2.
ELSEIF x001-curt3 = sd_curtp.
c001-waers = x001-hwae3.
ENDIF.
MOVE-CORRESPONDING ledtab TO c001.
APPEND c001.
xx_rldnr-low = ledtab-rldnr.
COLLECT xx_rldnr.
ENDIF.
ENDLOOP.
IF NOT ( g_glflex_active IS INITIAL ).
*.. flexGL is active
IF sd_rldnr[] IS INITIAL.
*.... set leading ledger
CALL FUNCTION 'FAGL_GET_LEADING_LEDGER'
IMPORTING
e_rldnr = g_lead_rldnr
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*.... set ledger
g_rldnr = g_lead_rldnr.
ELSE.
*.... ledger has been specified
READ TABLE sd_rldnr INDEX 1.
g_rldnr = sd_rldnr-low.
ENDIF.
*.. Check only, if documents or balances are requested "1531154
read table GET_EVENTS with key NODE = 'SKC1A'. "1531154
GET1 = GET_EVENTS-KIND. "1531154
read table GET_EVENTS with key NODE = 'SKC1C'. "1531154
GET2 = GET_EVENTS-KIND. "1531154
read table GET_EVENTS with key NODE = 'BSIS'. "1531154
GET3 = GET_EVENTS-KIND. "1531154
if GET1 <> ' ' or "Salden "1531154
GET2 <> ' ' or "1531154
GET3 <> ' '. "Belege "1531154
*.. authority check for rldnr "1531154
loop at kbtab. "1531154
call function 'FAGL_AUTHORITY_LEDGER' "1531154
EXPORTING "1531154
i_bukrs = kbtab-bukrs "1531154
i_rldnr = g_rldnr "1531154
i_actvt = '03'. "1531154
endloop. "1531154
endif. "1531154
ENDIF.
IF NOT ( g_rldnr IS INITIAL ).
*.. export ledger to memory for standard page header
*.. in program RSBTCHH0.
EXPORT fagl_bhdgd_rldnr FROM g_rldnr
TO MEMORY ID fagl_bhdgd_rldnr.
ENDIF.
* LDB_SUBRC = 0.
ENDFORM. "LDB_PROCESS_CHECK_SELECTIONS
***********************************************************************
* Zugriffsroutinen *
***********************************************************************
*--------------------------------------------------------------------*
* FORM PUT_SKA1 *
*--------------------------------------------------------------------*
FORM put_ska1.
DATA: ldummy.
DATA: ld_arch TYPE c,
ld_n TYPE i,
ld_mess_alv TYPE c. "957486
DATA: lt_ska1 TYPE STANDARD TABLE OF ska1 WITH HEADER LINE.
DATA: BEGIN OF lt_ska1_key OCCURS 0,
mandt LIKE ska1-mandt,
ktopl LIKE ska1-ktopl,
saknr LIKE ska1-saknr,
END OF lt_ska1_key.
DATA: BEGIN OF lt_ska1_key_help OCCURS 0,
mandt LIKE ska1-mandt,
ktopl LIKE ska1-ktopl,
saknr LIKE ska1-saknr,
END OF lt_ska1_key_help.
DATA: ld_lines TYPE i,
ld_div TYPE i,
ld_mod TYPE i,
ld_max TYPE i,
ld_min TYPE i VALUE 1,
ld_i TYPE i VALUE 1.
DATA: lc_pack TYPE i VALUE 1000.
PERFORM init_tables.
GET PARAMETER ID 'LDB_MESSAGE_IN_ALV' FIELD ld_mess_alv. "957486
IF ld_mess_alv IS INITIAL.
b0sg-xnbal = 'X'.
ENDIF. "957486
* use ALV for DB Messages
IF NOT b0sg-xnbal IS INITIAL.
CLEAR g_balv.
ENDIF.
* expiring currencies:
IF NOT b0sg-xcurr IS INITIAL.
CLEAR gd_expcur_flag.
ENDIF.
IF sd_stida IS INITIAL OR sd_stida = '00010101'
OR sd_stida = '99991231'.
gd_expcur_date = sy-datlo.
ELSE.
gd_expcur_date = sd_stida.
ENDIF.
* check if sd_saknr contains a worklist. if yes, make sure that
* WHERE statement doesn't get too long
DESCRIBE TABLE sd_saknr LINES ld_n .
IF ld_n > 0.
LOOP AT sd_saknr TRANSPORTING NO FIELDS
WHERE option NE 'EQ' OR
sign NE 'I'.
EXIT.
ENDLOOP.
ENDIF.
IF ( sy-subrc = 0 ) OR ld_n = 0. " no worklist
* 1. read key data of relevant sentences into table LT_SKA1_KEY
* 2. split LT_SKA1_KEY into LD_DIV packages of size LC_PACK
* 3. for each package read all the data from SKA1
SELECT mandt ktopl saknr FROM ska1 INTO TABLE lt_ska1_key
WHERE ktopl IN xx_ktopl
AND saknr IN sd_saknr
AND (ska1_where)
ORDER BY mandt ktopl saknr.
DESCRIBE TABLE lt_ska1_key LINES ld_lines.
ld_div = ld_lines DIV lc_pack.
ld_mod = ld_lines MOD lc_pack.
IF ld_mod <> 0.
ld_div = ld_div + 1.
ENDIF.
ld_max = lc_pack.
WHILE ld_i <= ld_div.
IF ld_i <> ld_div.
APPEND LINES OF lt_ska1_key
FROM ld_min TO ld_max TO lt_ska1_key_help.
ld_min = lc_pack * ld_i + 1 .
ld_max = lc_pack * ( ld_i + 1 ) .
ELSE.
APPEND LINES OF lt_ska1_key FROM ld_min TO lt_ska1_key_help.
ENDIF.
CLEAR lt_ska1.
REFRESH lt_ska1.
SELECT (ska1_fields) FROM ska1 "#EC CI_SGLSELECT
INTO CORRESPONDING FIELDS OF TABLE lt_ska1
FOR ALL ENTRIES IN lt_ska1_key_help
WHERE ktopl = lt_ska1_key_help-ktopl AND
saknr = lt_ska1_key_help-saknr.
SORT lt_ska1 BY mandt ktopl saknr.
LOOP AT lt_ska1.
xska1 = lt_ska1.
APPEND xska1.
k_saknr-low = xska1-saknr.
APPEND k_saknr.
count = count + 1.
IF count >= max_count.
* archive has to be read
gd_arch_done = 'N'.
PERFORM process_ska1.
REFRESH xska1.
REFRESH k_saknr.
count = 0.
ENDIF.
ENDLOOP.
REFRESH lt_ska1_key_help.
CLEAR lt_ska1_key_help.
ld_i = ld_i + 1.
ENDWHILE.
ELSE.
SELECT (ska1_fields)
FROM ska1 "#EC CI_SGLSELECT
INTO CORRESPONDING FIELDS OF TABLE lt_ska1
FOR ALL ENTRIES IN sd_saknr
WHERE ktopl IN xx_ktopl
AND saknr = sd_saknr-low
AND (ska1_where).
SORT lt_ska1 BY mandt ktopl saknr.
LOOP AT lt_ska1.
xska1 = lt_ska1.
APPEND xska1.
k_saknr-low = xska1-saknr.
APPEND k_saknr.
count = count + 1.
IF count >= max_count.
* archive has to be read
gd_arch_done = 'N'.
PERFORM process_ska1.
REFRESH xska1.
REFRESH k_saknr.
count = 0.
ENDIF.
ENDLOOP.
ENDIF.
* archive has to be read
gd_arch_done = 'N'.
PERFORM process_ska1.
IF gd_count_arch <> 0.
GET PARAMETER ID 'LDB_NO_DISPL_ARCH' FIELD ld_arch.
IF ld_arch IS INITIAL.
IF g_balv = 'X'.
IF sd_iarch IS INITIAL.
MESSAGE s600 WITH
gd_count_arch text-013 INTO ldummy.
CALL FUNCTION 'LDB_LOG_WRITE'.
ELSE.
MESSAGE i010 WITH
gd_count_arch INTO ldummy.
CALL FUNCTION 'LDB_LOG_WRITE'.
ENDIF.
ELSE.
IF sd_iarch IS INITIAL.
ULINE /(60).
WRITE: / sy-vline, gd_count_arch, text-013,
60 sy-vline.
ULINE /(60).
ELSE.
MESSAGE i010 WITH gd_count_arch.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "PUT_SKA1
*--------------------------------------------------------------------*
* FORM PROCESS_SKA1 *
*--------------------------------------------------------------------*
FORM process_ska1.
CLEAR ska1.
DESCRIBE TABLE k_saknr LINES count.
IF count GT 1.
count = max_count - count.
* Fuellen von K_SAKNR mit Dummyeintraegen um ein neues Parsen des
* SQL-Statements durch das DB-System zu vermeiden
DO count TIMES.
APPEND k_saknr.
ENDDO.
ENDIF.
PERFORM init_buffers.
LOOP AT xska1.
ska1 = xska1.
IF save_ktopl NE ska1-ktopl.
PERFORM kontenplanwechsel.
ENDIF.
* KEY-Felder sichern
save_ktopl = ska1-ktopl.
save_saknr = ska1-saknr.
* Sachkontenbezeichnung dazulesen
DO.
READ TABLE xskat INDEX cursor_t.
IF sy-subrc = 0.
skat = xskat.
ELSE.
CLEAR skat.
EXIT.
ENDIF.
IF skat-saknr < save_saknr.
cursor_t = cursor_t + 1.
ENDIF.
IF skat-saknr > save_saknr.
EXIT.
ENDIF.
IF skat-saknr = save_saknr.
cursor_t = cursor_t + 1.
EXIT.
ENDIF.
ENDDO.
IF skat-saknr NE save_saknr.
* In der Anmeldesprache ist keine Sachkontenbezeichung vorhanden
* Es werden die Texte der Pflegesprache gelesen.
CLEAR skat.
IF save_ktopl NE t004-ktopl.
SELECT SINGLE * FROM t004 WHERE ktopl = save_ktopl.
ENDIF.
SELECT SINGLE * FROM skat
WHERE spras = t004-dspra
AND ktopl = save_ktopl
AND saknr = save_saknr.
ENDIF.
PUT ska1.
CLEAR ska1.
ENDLOOP.
ENDFORM. "PROCESS_SKA1
*--------------------------------------------------------------------*
* FORM INIT_BUFFERS *
*--------------------------------------------------------------------*
FORM init_buffers.
REFRESH: xskb1, xskc1a, xskc1c, yskc1a, yskc1c.
REFRESH: ybsis, ybsas, ybkpf, ybseg.
cursor-skb1 = cursor-skc1a = cursor-skc1c = 0.
cursor-ybsas = 0.
saknr_skc1a = saknr_skc1c = space.
ENDFORM. "INIT_BUFFERS
*--------------------------------------------------------------------*
* FORM PUT_SKB1 *
*--------------------------------------------------------------------*
FORM put_skb1.
CLEAR skb1.
* Buchungskreiszuordnung für Kontenplan vorhanden ?
IF bukrs-flag = 'Y'. "Ja
IF cursor-skb1 = 0.
PERFORM update_xskb1.
ENDIF.
DO.
READ TABLE xskb1 INDEX cursor-skb1.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF save_saknr < xskb1-saknr. "Eintrag nicht enthalten
EXIT.
ELSEIF save_saknr > xskb1-saknr. "Weiterlesen
cursor-skb1 = cursor-skb1 + 1.
ELSE. "Treffer
skb1 = xskb1.
CALL FUNCTION 'READ_T001'
EXPORTING
xbukrs = skb1-bukrs
IMPORTING
struct = t001.
sp_waers = t001-waers. "euro
IF alcur EQ 'X'. PERFORM read_taltwar. ENDIF. "<<<< euro
IF sd_curtp = ' ' OR sd_curtp = '10'.
c001-rldnr = '00'.
ELSE.
READ TABLE c001 WITH KEY skb1-bukrs.
ENDIF.
save_bukrs = skb1-bukrs.
save_waers = skb1-waers.
PUT skb1.
CLEAR skb1.
cursor-skb1 = cursor-skb1 + 1.
ENDIF. "SAKNR
ENDDO.
ELSE. "Nein
* BUKRS-FLAG = 'Y'.
EXIT.
ENDIF.
ENDFORM. "PUT_SKB1
*--------------------------------------------------------------------*
* FORM PUT_SKC1A - Verarbeitung der HAUSWÄHRUNG - *
*--------------------------------------------------------------------*
FORM put_skc1a.
* if user is not allowed to see line items or balances
IF f_bkpf_bes_subrc <> 0.
EXIT.
ENDIF.
IF cursor-skc1a = 0.
PERFORM update_yskc1a.
ENDIF.
DO.
READ TABLE yskc1a INDEX cursor-skc1a.
IF sy-subrc NE 0.
EXIT.
ENDIF.
skc1a = yskc1a.
* Pruefen, ob der richtige Satz gefunden wurde.
* PUT muss dabei am Ende stehen, da Felder SKC1A durch Put
* zerstoert werden.
IF skc1a-saknr > save_saknr.
EXIT.
ENDIF.
IF skc1a-saknr < save_saknr.
cursor-skc1a = cursor-skc1a + 1. "Ueberlesen
ENDIF.
IF skc1a-saknr = save_saknr.
IF skc1a-bukrs > save_bukrs.
EXIT.
ENDIF.
IF skc1a-bukrs < save_bukrs.
cursor-skc1a = cursor-skc1a + 1. "Ueberlesen
ENDIF.
IF skc1a-bukrs = save_bukrs.
IF skc1a-rldnr > c001-rldnr.
EXIT.
ENDIF.
IF skc1a-rldnr < c001-rldnr.
cursor-skc1a = cursor-skc1a + 1. "Ueberlesen
ENDIF.
IF skc1a-rldnr = c001-rldnr.
IF sd_curtp = ' ' OR sd_curtp = '10'.
skc1a-hwaer = t001-waers.
ELSE.
IF c001-bukrs <> skc1a-bukrs.
READ TABLE c001 WITH KEY skc1a-bukrs.
ENDIF.
skc1a-hwaer = c001-waers.
ENDIF.
IF sd_curtp = ' '.
skc1a-curtp = '10'.
ELSE.
skc1a-curtp = sd_curtp.
ENDIF.
PUT skc1a.
cursor-skc1a = cursor-skc1a + 1.
ENDIF.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "PUT_SKC1A
*--------------------------------------------------------------------*
* FORM PUT_SKC1C -Verarbeitung Verkehrszahlen je Währung- *
*--------------------------------------------------------------------*
FORM put_skc1c.
* if user is not allowed to see line items or balances
IF f_bkpf_bes_subrc <> 0.
EXIT.
ENDIF.
IF cursor-skc1c = 0.
PERFORM update_yskc1c.
ENDIF.
DO.
READ TABLE yskc1c INDEX cursor-skc1c.
IF sy-subrc NE 0.
EXIT.
ENDIF.
skc1c = yskc1c.
* Pruefen, ob der richtige Satz gefunden wurde.
* PUT muss dabei am Ende stehen, da Felder SKC1A durch Put
* zerstoert werden.
IF skc1c-saknr > save_saknr.
EXIT.
ENDIF.
IF skc1c-saknr < save_saknr.
cursor-skc1c = cursor-skc1c + 1. "Ueberlesen
ENDIF.
IF skc1c-saknr = save_saknr.
IF skc1c-bukrs > save_bukrs.
EXIT.
ENDIF.
IF skc1c-bukrs < save_bukrs.
cursor-skc1c = cursor-skc1c + 1. "Ueberlesen
ENDIF.
IF skc1c-bukrs = save_bukrs.
IF skc1c-rldnr > c001-rldnr.
EXIT.
ENDIF.
IF skc1c-rldnr < c001-rldnr.
cursor-skc1c = cursor-skc1c + 1. "Ueberlesen
ENDIF.
IF skc1c-rldnr = c001-rldnr.
IF sd_curtp = ' ' OR sd_curtp = '10'.
skc1c-hwaer = t001-waers.
ELSE.
IF c001-bukrs <> skc1c-bukrs.
READ TABLE c001 WITH KEY skc1c-bukrs.
ENDIF.
skc1c-hwaer = c001-waers.
ENDIF.
IF sd_curtp = ' '.
skc1c-curtp = '10'.
ELSE.
skc1c-curtp = sd_curtp.
ENDIF.
PUT skc1c.
cursor-skc1c = cursor-skc1c + 1.
ENDIF.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "PUT_SKC1C
*--------------------------------------------------------------------*
* FORM PUT_BSIS *
*--------------------------------------------------------------------*
FORM put_bsis.
DATA: ld_arch TYPE boole_d.
* if user is not allowed to see line items or balances
IF f_bkpf_bes_subrc <> 0.
EXIT.
ENDIF.
IF sd_usear IS INITIAL AND sd_usedb IS INITIAL.
sd_usedb = 'X'.
ENDIF.
IF sd_usear = 'X'.
IF gd_arch_done EQ 'N'.
PERFORM read_archive.
gd_arch_done = 'Y'.
gd_read_memo_done = 'N'.
ENDIF.
IF NOT ybsas[] IS INITIAL.
LOOP AT ybsas INTO bsis "#EC ENHOK
WHERE hkont = save_saknr
AND bukrs = save_bukrs.
ld_arch = 'X'.
PERFORM process_bsis USING ld_arch.
ENDLOOP.
ENDIF.
ENDIF.
IF NOT sd_usedb IS INITIAL.
IF b0sg-xstan = 'X' OR b0sg-xstas = 'X'. ">>>> normal documents >>>>>
save_bstat = ' '.
*----------------------------------------------------------------------*
* 1 Variante: Es sind offene Posten zu einem bestimmten Stichtag *
* gewuenscht. *
*----------------------------------------------------------------------*
IF sd_opopt EQ 'X' AND sd_apopt NE 'X'.
SELECT (bsis_fields) FROM bsis INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
* AND GJAHR IN SD_GJAHR
AND budat IN sd_budat
AND budat LE sd_stida
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
IF b0sg-xnopl = 'X'.
EXIT.
ENDIF.
SELECT (bsis_fields) FROM bsas INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
* AND GJAHR IN SD_GJAHR
AND budat IN sd_budat
AND budat LE sd_stida
AND augdt GT sd_stida
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
ENDIF.
*----------------------------------------------------------------------*
* 2 Variante: Es sind ausgeglichene Posten zu einem bestimmten Aus- *
* gleichsdatum (Intervall) gewuenscht. *
*----------------------------------------------------------------------*
IF sd_opopt NE 'X' AND sd_apopt EQ 'X'.
SELECT (bsis_fields) FROM bsas INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
* AND GJAHR IN SD_GJAHR
AND budat IN sd_budat
AND augdt IN sd_augdt
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
ENDIF.
*----------------------------------------------------------------------*
* 3 Variante: Variante 1 + 2 sind gleichzeitig gewuenscht *
*----------------------------------------------------------------------*
IF sd_opopt EQ 'X' AND sd_apopt EQ 'X'.
SELECT (bsis_fields) FROM bsis INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
* AND GJAHR IN SD_GJAHR
AND budat IN sd_budat
AND budat LE sd_stida
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
SELECT (bsis_fields) FROM bsas INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
* AND GJAHR IN SD_GJAHR
AND budat IN sd_budat
AND budat LE sd_stida
* AND AUGDT GT SD_STIDA
* OR AUGDT IN SD_AUGDT
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CHECK bsis-augdt GT sd_stida OR
bsis-augdt IN sd_augdt.
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
ENDIF.
*----------------------------------------------------------------------*
* 4 Variante: aus RFITEMGL: AP mit Stichtag und Ausgleichszeitraum *
*----------------------------------------------------------------------*
IF sd_opopt NE 'X' AND sd_apopt NE 'X'.
SELECT (bsis_fields) FROM bsas INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
AND budat IN sd_budat
AND augdt BETWEEN '00010101'
AND '99991231'
AND augdt GT sd_stida
AND augdt IN sd_augdt
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
ENDIF. " Variante 4
ENDIF. "<<<<<<<<<<<<<<<<<<<<<<<<<<< normal documents <<<<<<<<<<<<<<<<<
IF b0sg-xstav = 'X'.
* vorerfasste Belege ueber DB-Index nach SAKNR
save_bstat = 'V'.
* modification of WHERE clause: remove AUGDT, AUGBL
REFRESH: vbsegs_where.
vbsegs_where[] = bsis_where[].
PERFORM build_vbseg_where(fi_ldb_util) TABLES vbsegs_where
USING 'AUGDT'.
PERFORM build_vbseg_where(fi_ldb_util) TABLES vbsegs_where
USING 'AUGBL'.
PERFORM modify_vbseg_where(fi_ldb_util) TABLES vbsegs_where
USING 'PROJK' 'PS_PSP_PNR'.
PERFORM modify_vbseg_where_hkont(fi_ldb_util) TABLES vbsegs_where.
* BSTAT W oder Z sind nicht im VBKPF
SELECT * FROM v_vbsegs WHERE saknr = save_saknr
AND bukrs = save_bukrs
AND gjahr BETWEEN '0001' AND '9999'
AND budat IN sd_budat
AND budat LE sd_stida
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND bschl IN sd_bschl
AND shkzg IN sd_shkzg
AND (vbsegs_where).
CLEAR bsis.
MOVE-CORRESPONDING v_vbsegs TO bsis.
bsis-projk = v_vbsegs-ps_psp_pnr.
bsis-hkont = v_vbsegs-saknr.
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
ENDIF.
ENDIF. " sd_usedb
ENDFORM. "PUT_BSIS
***********************************************************************
* put_bsisext *
* Erweiterungsteil *
***********************************************************************
FORM put_bsisext.
MOVE-CORRESPONDING bsis TO bsisext.
MOVE-CORRESPONDING bsega TO bsisext.
PUT bsisext.
ENDFORM. "PUT_BSISEXT
"PUT_BSISEXT
*&---------------------------------------------------------------------*
*& Form PUT_faglfreesel
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM put_faglfreesel.
PUT faglfreesel.
ENDFORM. "PUT_FAGLFREESEL
*--------------------------------------------------------------------*
* FORM PUT_BKPF *
*--------------------------------------------------------------------*
FORM put_bkpf.
DATA: ltext TYPE text.
DATA: ldummy.
TYPES: BEGIN OF extkeybkpf,
bukrs LIKE bkpf-bukrs,
belnr LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
count TYPE i,
END OF extkeybkpf.
DATA: lt_save_extkeybkpf TYPE TABLE OF extkeybkpf,
ld_save_extkeybkpf TYPE extkeybkpf.
DATA: ld_save_bkpf VALUE ' ',
ld_read_bkpf VALUE 'L'. " Possible: Last (L),
" Table (T), Database (D)
STATICS: x_bsis_read TYPE c.
DATA: l_no_bkpf TYPE boolean VALUE ' '.
* Set standard Data for optimized access to BKPF.
gd_opttime_bkpf = ' '. " Previous BKPF lines are saved.
gd_optmemo_bkpf = 'X'. " Only BKPF lines which appears at least
gd_maxlines = '2'. " gd_maxlines times are saved (reduces
" CPU performance, since parts of BSIS
" have to be read once)
IF sd_usear = 'X'.
READ TABLE ybkpf WITH KEY bukrs = save_bukrs
belnr = save_belnr
gjahr = save_gjahr
INTO bkpf.
IF sy-subrc = 0.
save_bstat = bkpf-bstat.
* expiring currencies:
gd_waers_save = bkpf-waers.
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bkpf USING 'SAPDBSDF'
gd_expcur_date
CHANGING bkpf.
ENDIF.
PUT bkpf.
ELSE.
* if g_balv = 'X'.
* concatenate text-007 save_bukrs into ltext.
* message s600 with
* ltext
* text-002 save_belnr
* text-003 into ldummy.
* call function 'LDB_LOG_WRITE'.
* else.
*
** MESSAGE I803 WITH SAVE_BUKRS SAVE_BELNR.
* WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
* endif.
l_no_bkpf = 'X'.
ENDIF.
ENDIF.
IF sd_usedb = 'X'.
IF bsis-xarch = 'X'.
IF sd_usear = 'X'.
IF l_no_bkpf = 'X'.
IF g_balv = 'X'.
CONCATENATE text-007 save_bukrs INTO ltext.
MESSAGE s600 WITH
ltext
text-002 save_belnr
text-003 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
ENDIF.
ENDIF.
ELSE.
IF g_balv = 'X'.
CONCATENATE text-007 save_bukrs INTO ltext.
MESSAGE s600 WITH
ltext
text-002 save_belnr
text-003 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
ENDIF.
ENDIF.
EXIT.
ENDIF.
IF save_bstat <> 'V'.
* 1.try to use data from the last BKPF call.
ld_read_bkpf = 'L'.
IF save_bukrs NE xbkpf-bukrs OR
save_belnr NE xbkpf-belnr OR
save_gjahr NE xbkpf-gjahr.
* 2.If data from the last call can not be used
* try to use data from table gt_save_bkpf
* where (some) previous BKPF-Lines are stored.
ld_read_bkpf = 'D'.
IF gd_opttime_bkpf = 'X'.
READ TABLE gt_save_bkpf
WITH TABLE KEY bukrs = save_bukrs
belnr = save_belnr
gjahr = save_gjahr
INTO gd_save_bkpf .
* If appropriate previous BKPF line is found
* in gt_save_bkpf it will be used later.
IF sy-subrc = 0.
ld_read_bkpf = 'T'.
* If no previous BKPF line is found: Read BKPF entery
* and save it if required.
ELSE.
ld_save_bkpf = 'X'.
IF gd_optmemo_bkpf = 'X'.
* If memory optimization is required:
* Detecting the enteries of BKPF where saving makes sence.
IF x_bsis_read IS INITIAL.
SELECT bukrs belnr gjahr COUNT(*)
FROM bsis
INTO TABLE lt_save_extkeybkpf
WHERE bukrs IN sd_bukrs
AND hkont IN sd_saknr
AND zuonr IN sd_zuonr
AND gjahr IN sd_gjahr "war auskomm. in put_bsis
GROUP BY bukrs belnr gjahr.
LOOP AT lt_save_extkeybkpf INTO ld_save_extkeybkpf.
IF ld_save_extkeybkpf-count GE gd_maxlines.
gd_save_keybkpf-bukrs = ld_save_extkeybkpf-bukrs.
gd_save_keybkpf-belnr = ld_save_extkeybkpf-belnr.
gd_save_keybkpf-gjahr = ld_save_extkeybkpf-gjahr .
INSERT gd_save_keybkpf INTO TABLE gt_save_keybkpf.
ENDIF.
ENDLOOP.
x_bsis_read = 'X'.
ENDIF.
READ TABLE gt_save_keybkpf
WITH TABLE KEY bukrs = save_bukrs
belnr = save_belnr
gjahr = save_gjahr
TRANSPORTING NO FIELDS.
* If entery is existent the corresponding BKPF line
* appears at least gd_maxline times, but is not saved
* in gt_save_bkpf yet.
IF sy-subrc <> 0.
ld_save_bkpf = ' '.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
* Reading the required data from:
* Database (D), Table with previous entries (T) or last BKPF set (L).
CASE ld_read_bkpf.
WHEN 'D'.
CLEAR xbkpf.
REFRESH xbkpf.
SELECT SINGLE (bkpf_fields) FROM bkpf
INTO CORRESPONDING FIELDS OF xbkpf
WHERE bukrs = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr.
IF sy-subrc = 0.
MOVE-CORRESPONDING xbkpf TO bkpf.
save_bstat = bkpf-bstat.
* expiring currencies:
gd_waers_save = bkpf-waers.
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bkpf USING 'SAPDBSDF'
gd_expcur_date
CHANGING bkpf.
MOVE-CORRESPONDING bkpf TO xbkpf.
ENDIF.
ELSE.
CLEAR bkpf.
IF g_balv = 'X'.
CONCATENATE text-007 save_bukrs INTO ltext.
MESSAGE s600 WITH
ltext
text-002 save_belnr
text-003 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-007, save_bukrs,text-002, save_belnr, text-003.
ENDIF.
ENDIF.
l_no_bkpf = ' '.
* BKPF item had to be read from database but is stored in an
* internal table (gt_save_bkpf) for later use.
IF ld_save_bkpf = 'X'.
INSERT bkpf INTO TABLE gt_save_bkpf.
ENDIF.
WHEN 'T'.
MOVE-CORRESPONDING gd_save_bkpf TO bkpf.
MOVE-CORRESPONDING gd_save_bkpf TO xbkpf.
l_no_bkpf = ' '.
WHEN 'L'.
MOVE-CORRESPONDING xbkpf TO bkpf.
l_no_bkpf = ' '.
ENDCASE.
PUT bkpf.
* Parked items.
ELSE.
MOVE-CORRESPONDING v_vbsegs TO bkpf.
* expiring currencies:
gd_waers_save = bkpf-waers.
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bkpf USING 'SAPDBSDF'
gd_expcur_date
CHANGING bkpf.
ENDIF.
PUT bkpf.
ENDIF.
ENDIF.
IF l_no_bkpf = 'X'.
IF g_balv = 'X'.
CONCATENATE text-007 save_bukrs INTO ltext.
MESSAGE s600 WITH
ltext
text-002 save_belnr
text-003 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
ENDIF.
ENDIF.
ENDFORM. "PUT_BKPF
*--------------------------------------------------------------------*
* FORM PUT_BSEG *
*--------------------------------------------------------------------*
FORM put_bseg.
DATA: ltext TYPE text.
DATA: ldummy.
DATA: l_no_bseg TYPE boolean VALUE ' '.
IF sd_usear = 'X'.
READ TABLE ybseg WITH KEY bukrs = save_bukrs
belnr = save_belnr
buzei = save_buzei
gjahr = save_gjahr
INTO bseg.
IF sy-subrc NE 0.
* if g_balv = 'X'.
* concatenate text-004 save_belnr into ltext.
* message s600 with
* ltext
* text-005 save_bukrs
* text-006 into ldummy.
* call function 'LDB_LOG_WRITE'.
* else.
* WRITE: text-004, save_belnr, text-005, save_bukrs, text-006.
* endif.
l_no_bseg ='X'.
ELSE.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING bseg.
ENDIF.
MOVE-CORRESPONDING bseg TO bsegh.
PERFORM got_bsega(sapbsega).
* Euro
IF alcur EQ 'X'.
PERFORM convert_alt USING 'BSEG'.
ENDIF.
PUT bseg.
CLEAR bseg.
ENDIF.
ENDIF. "sd_usear
IF sd_usedb = 'X'.
IF save_bstat <> 'V'.
SELECT SINGLE (bseg_fields) FROM bseg
INTO CORRESPONDING FIELDS OF bseg
WHERE bukrs = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr
AND buzei = save_buzei.
IF sy-subrc NE 0.
CLEAR bseg.
IF sd_usear = 'X'.
IF l_no_bseg = 'X'.
IF g_balv = 'X'.
CONCATENATE text-004 save_belnr INTO ltext.
MESSAGE s600 WITH
ltext
text-005 save_bukrs
text-006 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-004, save_belnr, text-005, save_bukrs,
text-006.
ENDIF.
ENDIF.
ELSE.
IF g_balv = 'X'.
CONCATENATE text-004 save_belnr INTO ltext.
MESSAGE s600 WITH
ltext
text-005 save_bukrs
text-006 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-004, save_belnr, text-005, save_bukrs,
text-006.
ENDIF.
ENDIF.
EXIT.
ENDIF.
l_no_bseg = ' '.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING bseg.
ENDIF.
* Belegpositionsanhang
* --------------------
MOVE-CORRESPONDING bseg TO bsegh.
PERFORM got_bsega(sapbsega).
* CPD-DATEN
* ---------
IF bseg-xcpdd EQ 'X'.
SELECT SINGLE * FROM bsec
WHERE bukrs = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr
AND buzei = save_buzei.
IF sy-subrc NE 0.
CLEAR bsec.
ENDIF.
ELSE.
CLEAR bsec.
ENDIF.
* Wechseldaten
* ------------
IF bseg-umsks EQ 'W'.
SELECT SINGLE * FROM bsed
WHERE bukrs = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr
AND buzei = save_buzei.
IF sy-subrc NE 0.
CLEAR bsed.
ENDIF.
ELSE.
CLEAR bsed.
ENDIF.
IF alcur EQ 'X'. PERFORM convert_alt USING 'BSEG'. ENDIF. "euro
PUT bseg.
CLEAR bseg.
* vorfasste Belege
ELSE.
CLEAR bseg.
MOVE-CORRESPONDING v_vbsegs TO bseg.
bseg-hkont = v_vbsegs-saknr.
bseg-koart = 'S'.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING bseg.
ENDIF.
* Belegpositionsanhang
IF bseg-zfbdt = '00000000'.
bseg-zfbdt = bkpf-bldat.
ENDIF.
MOVE-CORRESPONDING bseg TO bsegh.
PERFORM got_bsega(sapbsega).
* CPD-Daten
CLEAR bsec.
IF bseg-xcpdd EQ 'X'.
SELECT SINGLE * FROM vbsec
WHERE ausbk = save_bukrs
AND belnr = save_belnr
AND buzei = save_buzei
AND gjahr = save_gjahr.
IF sy-subrc = 0.
MOVE-CORRESPONDING vbsec TO bsec.
ENDIF.
ENDIF.
IF alcur EQ 'X'. PERFORM convert_alt USING 'BSEG'. ENDIF. "euro
PUT bseg.
ENDIF.
ENDIF.
IF l_no_bseg = 'X' .
IF g_balv = 'X'.
CONCATENATE text-004 save_belnr INTO ltext.
MESSAGE s600 WITH
ltext
text-005 save_bukrs
text-006 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-004, save_belnr, text-005, save_bukrs,
text-006.
ENDIF.
ENDIF.
ENDFORM. "PUT_BSEG
*----------------------------------------------------------------------*
* FORM PUT_GSEG *
* Gegenpositionsverarbeitung *
*----------------------------------------------------------------------*
FORM put_gseg.
DATA: ltext TYPE text.
DATA: ldummy.
IF save_bstat <> 'V'.
SELECT (gseg_fields) FROM bseg
INTO CORRESPONDING FIELDS OF gseg
WHERE bukrs = save_bukrs
AND belnr = save_belnr
AND buzei NE save_buzei
AND gjahr = save_gjahr.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_gseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING gseg.
ENDIF.
* Belegpositionsanhang
* --------------------
MOVE-CORRESPONDING gseg TO bsegh.
PERFORM got_gsega(sapbsega).
IF alcur EQ 'X'. PERFORM convert_alt USING 'GSEG'. ENDIF. "euro
PUT gseg.
CLEAR gseg.
ENDSELECT.
IF sy-subrc NE 0.
* MESSAGE I807 WITH SAVE_BUKRS SAVE_BELNR SAVE_BUZEI.
IF g_balv = 'X'.
CONCATENATE text-004 save_belnr INTO ltext.
MESSAGE s600 WITH ltext
text-005 save_bukrs
text-006 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-004, save_belnr, text-005, save_bukrs, text-006.
ENDIF.
ENDIF.
* vorerfasste Belege
ELSE.
SELECT * FROM vbsegs WHERE
ausbk = save_bukrs
AND belnr = save_belnr
AND buzei NE save_buzei
AND gjahr = save_gjahr.
CLEAR gseg.
MOVE-CORRESPONDING vbsegs TO gseg.
gseg-projk = vbsegs-ps_psp_pnr. "1090412
gseg-hkont = vbsegs-saknr.
gseg-koart = 'S'.
IF bseg-zfbdt = '00000000'.
bseg-zfbdt = bkpf-bldat.
ENDIF.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_gseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING gseg.
ENDIF.
MOVE-CORRESPONDING gseg TO bsegh.
PERFORM got_gsega(sapbsega).
IF alcur EQ 'X'. PERFORM convert_alt USING 'GSEG'. ENDIF. "euro
PUT gseg.
ENDSELECT.
* if vbkpf-koars ca 'A'. "<<<< 31H
IF v_vbsegs-koars CA 'A'. "<<<< 31H
SELECT * FROM vbsega WHERE
ausbk = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr.
CLEAR gseg.
MOVE-CORRESPONDING vbsega TO gseg.
gseg-projk = vbsega-ps_psp_pnr. "1090412
gseg-koart = 'A'.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_gseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING gseg.
ENDIF.
MOVE-CORRESPONDING gseg TO bsegh.
PERFORM got_gsega(sapbsega).
IF alcur EQ 'X'. PERFORM convert_alt USING 'GSEG'. ENDIF. "euro
PUT gseg.
ENDSELECT.
ENDIF.
* if vbkpf-koars ca 'K'. "<<<< 31H
IF v_vbsegs-koars CA 'K'. "<<<< 31H
SELECT * FROM vbsegk WHERE
ausbk = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr.
CLEAR gseg.
MOVE-CORRESPONDING vbsegk TO gseg.
gseg-koart = 'K'.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_gseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING gseg.
ENDIF.
MOVE-CORRESPONDING gseg TO bsegh.
PERFORM got_gsega(sapbsega).
IF alcur EQ 'X'. PERFORM convert_alt USING 'GSEG'. ENDIF. "euro
PUT gseg.
ENDSELECT.
ENDIF.
* if vbkpf-koars ca 'D'. "<<<< 31H
IF v_vbsegs-koars CA 'D'. "<<<< 31H
SELECT * FROM vbsegd WHERE
ausbk = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr.
CLEAR gseg.
* move-corresponding vbsega to gseg. "<<<< 31H
MOVE-CORRESPONDING vbsegd TO gseg. "<<<< 31H
gseg-koart = 'D'.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_gseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING gseg.
ENDIF.
MOVE-CORRESPONDING gseg TO bsegh.
PERFORM got_gsega(sapbsega).
IF alcur EQ 'X'. PERFORM convert_alt USING 'GSEG'. ENDIF. "euro
PUT gseg.
ENDSELECT.
ENDIF.
ENDIF.
ENDFORM. "PUT_GSEG
*----------------------------------------------------------------------*
* FORM PUT_SDF_MATCHCODE *
* Matchcodeverarbeitung *
*----------------------------------------------------------------------*
FORM put_sdf_sp.
DATA: ldummy.
DATA yska1 LIKE ska1 OCCURS 0 WITH HEADER LINE.
PERFORM init_tables.
* expiring currencies:
IF NOT b0sg-xcurr IS INITIAL.
CLEAR gd_expcur_flag.
ENDIF.
IF sd_stida IS INITIAL OR sd_stida = '00010101'
OR sd_stida = '99991231'.
gd_expcur_date = sy-datlo.
ELSE.
gd_expcur_date = sd_stida.
ENDIF.
READ TABLE sp_tables WITH KEY 'SKB1'.
IF sp_tables-supplied = 'X'.
copy sd_bukrs to zz_bukrs.
REFRESH sd_bukrs.
sd_bukrs-sign = 'I'. sd_bukrs-option = 'EQ'.
LOOP AT sdf_sp.
* if sdf_sp-skb1_bukrs in zz_bukrs.
* sd_bukrs-low = sdf_sp-skb1_bukrs.
IF sdf_sp-bukrs IN zz_bukrs. "40sp
sd_bukrs-low = sdf_sp-bukrs. "40sp
COLLECT sd_bukrs.
ENDIF.
ENDLOOP.
ENDIF.
READ TABLE sdf_sp INDEX 1.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* if sdf_sp-ska1_ktopl <> space and sdf_sp-ska1_saknr <> space.
IF sdf_sp-ktopl <> space AND sdf_sp-saknr <> space. "40sp
SELECT (ska1_fields) FROM ska1 INTO "#EC CI_SGLSELECT
CORRESPONDING FIELDS OF TABLE yska1
FOR ALL ENTRIES IN sdf_sp
WHERE ktopl IN xx_ktopl
AND saknr IN sd_saknr
* and ktopl = sdf_sp-ska1_ktopl
* and saknr = sdf_sp-ska1_saknr
AND ktopl = sdf_sp-ktopl "40sp
AND saknr = sdf_sp-saknr "40sp
AND (ska1_where).
* elseif sdf_sp-ska1_ktopl <> space and sdf_sp-ska1_saknr = space.
ELSEIF sdf_sp-ktopl <> space AND sdf_sp-saknr = space. "40sp
SELECT (ska1_fields) FROM ska1 INTO "#EC CI_SGLSELECT
CORRESPONDING FIELDS OF TABLE yska1
FOR ALL ENTRIES IN sdf_sp
WHERE ktopl IN xx_ktopl
AND saknr IN sd_saknr
* and ktopl = sdf_sp-ska1_ktopl
AND ktopl = sdf_sp-ktopl "40sp
AND (ska1_where).
* elseif sdf_sp-ska1_ktopl = space and sdf_sp-ska1_saknr <> space.
ELSEIF sdf_sp-ktopl = space AND sdf_sp-saknr <> space. "40sp
SELECT (ska1_fields) FROM ska1 INTO "#EC CI_SGLSELECT
CORRESPONDING FIELDS OF TABLE yska1
FOR ALL ENTRIES IN sdf_sp
WHERE ktopl IN xx_ktopl
AND saknr IN sd_saknr
* and saknr = sdf_sp-ska1_saknr
AND saknr = sdf_sp-saknr "40sp
AND (ska1_where).
ELSE.
EXIT.
ENDIF.
SORT yska1 BY ktopl saknr.
LOOP AT yska1.
xska1 = yska1.
APPEND xska1.
k_saknr-low = xska1-saknr.
APPEND k_saknr.
count = count + 1.
IF count >= max_count.
gd_arch_done = 'N'. "1532097
PERFORM process_ska1.
REFRESH xska1.
REFRESH k_saknr.
count = 0.
ENDIF.
ENDLOOP.
PERFORM process_ska1.
IF gd_count_arch <> 0.
IF g_balv = 'X'.
IF sd_iarch IS INITIAL.
MESSAGE s600 WITH
gd_count_arch text-013 INTO ldummy.
CALL FUNCTION 'LDB_LOG_WRITE'.
ELSE.
MESSAGE i010 WITH gd_count_arch INTO ldummy.
CALL FUNCTION 'LDB_LOG_WRITE'.
ENDIF.
ELSE.
IF sd_iarch IS INITIAL.
ULINE /(60).
WRITE: / sy-vline, gd_count_arch, text-013,
60 sy-vline.
ULINE /(60).
ELSE.
MESSAGE i010 WITH gd_count_arch.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "PUT_SDF_SP
*eject.
***********************************************************************
* Unterroutinen *
***********************************************************************
*---------------------------------------------------------------------*
* FORM KONTENPLANWECHSEL *
* Alle Buchungskreise die den neuen Kontenplan verwenden werden*
* über die Tabelle KBTAB ermittelt und in der Tabelle XX_BUKRS *
* abgelegt. *
*---------------------------------------------------------------------*
FORM kontenplanwechsel.
DATA: ld_lines TYPE i.
* REFRESH XX_BUKRS. "30F
REFRESH xy_bukrs. "30F
LOOP AT kbtab
WHERE ktopl = ska1-ktopl
AND bukrs IN sd_bukrs.
* XX_BUKRS-SIGN = 'I'. "30F
* XX_BUKRS-OPTION = 'EQ'. "
* XX_BUKRS-LOW = KBTAB-BUKRS. "
* APPEND XX_BUKRS. "
xy_bukrs = kbtab-bukrs. "
APPEND xy_bukrs. "30F
ENDLOOP.
IF sy-subrc NE 0.
* Buchungskreiszuordnung für Kontenplan vorhanden ?
bukrs-flag = 'N'. "Nein
ELSE.
bukrs-flag = 'Y'. "Ja
ENDIF.
* Immer ueber Index 2 (SAKNR,BUKRS) lesen wegen 'order by'.
* READ TABLE XX_BUKRS INDEX 2. "30F
* IF SY-SUBRC = 0.
* LOOP AT XX_BUKRS
* WHERE OPTION NE 'EQ'.
* ENDLOOP.
* IF SY-SUBRC NE 0.
* READ TABLE XX_BUKRS INDEX 2.
* IF XX_BUKRS-OPTION = 'EQ'.
* XX_BUKRS-OPTION = 'BT'. "erzwingt lesen ueber Index 2
* XX_BUKRS-HIGH = XX_BUKRS-LOW.
* MODIFY XX_BUKRS INDEX 2.
* ENDIF.
* ENDIF.
* ENDIF. "30F
* Pro Kontenplan werden die Sachkontenbezeichungen gelesen.
REFRESH xskat.
DESCRIBE TABLE sd_saknr LINES ld_lines.
IF ld_lines > 0.
LOOP AT sd_saknr TRANSPORTING NO FIELDS
WHERE option NE 'EQ' OR
sign NE 'I'.
EXIT.
ENDLOOP.
ENDIF.
IF ( sy-subrc = 0 ) OR ld_lines = 0.
SELECT * FROM skat "#EC CI_SGLSELECT
APPENDING TABLE xskat
WHERE spras = sy-langu
AND ktopl = ska1-ktopl
AND saknr IN sd_saknr.
ELSE.
SELECT * FROM skat "#EC CI_SGLSELECT
INTO CORRESPONDING FIELDS OF xskat
FOR ALL ENTRIES IN sd_saknr
WHERE spras = sy-langu
AND ktopl = ska1-ktopl
AND saknr = sd_saknr-low.
APPEND xskat.
ENDSELECT.
ENDIF.
SORT xskat BY mandt saknr.
cursor_t = 1.
* Interne Tabellen und Felder und Pointer zuruecksetzen.
REFRESH: xskb1, xskc1a, xskc1c, yskc1a, yskc1c. "886527
cursor-skb1 = cursor-skc1a = cursor-skc1c = 0. "886527
saknr_skc1a = saknr_skc1c = space. "886527
* PERFORM init_buffers. "886527
ENDFORM. "KONTENPLANWECHSEL
*EJECT
*--------------------------------------------------------------------*
* FORM UPDATE_XSKB1 *
*--------------------------------------------------------------------*
FORM update_xskb1.
SELECT (skb1_fields) FROM skb1 INTO CORRESPONDING FIELDS "#EC CI_SGLSELECT
OF TABLE xskb1
FOR ALL ENTRIES IN xy_bukrs "<--3.0F
WHERE saknr IN k_saknr
* AND BUKRS IN XX_BUKRS "
AND bukrs = xy_bukrs-bukrs "<--3.0F
AND (skb1_where).
SORT xskb1 BY mandt saknr bukrs.
cursor-skb1 = 1.
ENDFORM. "UPDATE_XSKB1
*EJECT
*--------------------------------------------------------------------*
* FORM UPDATE_YSKC1A *
*--------------------------------------------------------------------*
FORM update_yskc1a.
DATA: ld_clas_bal_fs10n TYPE boole_d. "1168430
DATA: lt_glt0 TYPE FAGL_T_GLT0. "NewGL: arch. totals
REFRESH: xskc1a, yskc1a.
saknr_skc1a = space.
CLEAR ld_clas_bal_fs10n. "1168430
IMPORT ld_clas_bal_fs10n FROM "1168430
MEMORY ID 'CLASSIC_BALANCE_SDF'. "1168430
IF g_glflex_active IS INITIAL
OR NOT ld_clas_bal_fs10n IS INITIAL. "1168430
SELECT * FROM glt0 INTO TABLE xglt0
FOR ALL ENTRIES IN xy_bukrs "<-- 3.0F
WHERE rldnr IN xx_rldnr " Ledger-Nr
AND rrcty IN sd_stype " Satztyp
AND rvers IN version " Version
* AND BUKRS IN XX_BUKRS " Bukreis aus SKB1-BU
AND bukrs = xy_bukrs-bukrs "<-- 3.0F
AND ryear IN sd_gjahr " Ges.Jahr aus Eingabe
AND racct IN k_saknr
AND rbusa IN sd_gsber. " Gesch.Ber aus Eingab
ELSE.
***********************************************************
* NewGL: Read totals from archive
***********************************************************
if sd_usar1 is initial and sd_usdb1 is initial.
sd_usdb1 = 'X'.
endif.
if sd_usar1 = 'X'.
if gd_arch_done eq 'N'.
* refresh archive file when archiv-info-system is used
if not sd_usas1 is initial.
refresh sd_file1.
endif.
CALL FUNCTION 'FAGL_GET_SUM_ARCH'
EXPORTING
I_GLT0_RLDNR = xx_rldnr-low
I_RLDNR = g_rldnr
I_RANGE_RRCTY = sd_stype[]
I_RANGE_RVERS = version[]
I_RANGE_BUKRS = sd_bukrs[]
I_RANGE_RYEAR = sd_gjahr[]
I_RANGE_RBUSA = sd_gsber[]
I_RANGE_RACCT = k_saknr[]
IT_WHERE_CLAUSE = faglfreesel_where
I_AUTHORITY_CHECK = 'X'
IMPORTING
ET_GLT0 = lt_glt0
TABLES
I_ARCH_SEL = sd_file1[]
exceptions
no_infostruc_found = 1
selections_error = 2.
case sy-subrc.
when '0'.
gd_arch_done = 'Y'.
gd_read_memo_done = 'N'.
refresh xglt0.
when '1'.
if gd_msg601_done is initial.
message i601.
* Fehler beim Lesen aus dem Archiv: Infostruktur nicht gefunden.
gd_msg601_done = 'X'.
endif.
when '2'.
message i602.
* Fehler beim Lesen aus dem Archiv: Selektionsbedingungen falsch.
endcase.
endif.
endif.
***********************************************************
if not sd_usdb1 is initial.
READ TABLE xx_rldnr INDEX 1.
CALL FUNCTION 'FAGL_GET_GLT0'
EXPORTING
i_glt0_rldnr = xx_rldnr-low
i_rldnr = g_rldnr
* I_RRCTY =
* I_RVERS =
* i_bukrs =
* I_RYEAR =
* I_RACCT =
* I_RBUSA =
* I_RTCUR =
* I_DRCRK =
* I_RPMAX =
i_range_rrcty = sd_stype[]
i_range_rvers = version[]
i_range_bukrs = sd_bukrs[]
i_range_ryear = sd_gjahr[]
i_range_rbusa = sd_gsber[]
i_range_racct = k_saknr[]
* I_RANGE_RTCUR =
* I_RANGE_DRCRK =
* I_RANGE_RPMAX =
it_where_clause = faglfreesel_where
i_authority_check = 'X'
IMPORTING
et_glt0 = xglt0[].
endif.
ENDIF.
***********************************************************
* NewGL: append archived data
***********************************************************
append lines of lt_glt0 to xglt0.
***********************************************************
SORT xglt0 BY rclnt racct bukrs rldnr rrcty rvers.
LOOP AT xglt0.
glt0 = xglt0.
IF glt0-rrcty = '1'.
CHECK glt0-rvers IN sd_vers.
ENDIF.
IF glt0-rrcty = '0'.
CHECK glt0-rvers = '001'.
ENDIF.
IF NOT glt0-rbusa IS INITIAL. " HK (171296)
AUTHORITY-CHECK OBJECT 'F_BKPF_GSB'
ID 'GSBER' FIELD glt0-rbusa
ID 'ACTVT' FIELD '03'.
CHECK sy-subrc = 0.
ENDIF. " HK
IF glt0-racct NE saknr_skc1a.
PERFORM saldo_des_monats_skc1a.
PERFORM saldo_zum_gm_ende_skc1a.
LOOP AT xskc1a.
yskc1a = xskc1a.
APPEND yskc1a.
ENDLOOP.
REFRESH: xskc1a.
ENDIF.
PERFORM xskc1a_aufbauen USING glt0-drcrk.
saknr_skc1a = glt0-racct.
ENDLOOP.
PERFORM saldo_des_monats_skc1a.
PERFORM saldo_zum_gm_ende_skc1a.
LOOP AT xskc1a.
yskc1a = xskc1a.
APPEND yskc1a.
ENDLOOP.
cursor-skc1a = 1.
ENDFORM. "UPDATE_YSKC1A
*EJECT
*--------------------------------------------------------------------*
* FORM UPDATE_YSKC1C *
*--------------------------------------------------------------------*
FORM update_yskc1c.
DATA: ld_clas_bal_fs10n TYPE boole_d. "1168430
data: lt_glt0 type fagl_t_glt0. "NewGL: arch. totals
REFRESH: xskc1c, yskc1c.
saknr_skc1c = space.
CLEAR ld_clas_bal_fs10n. "1168430
IMPORT ld_clas_bal_fs10n FROM "1168430
MEMORY ID 'CLASSIC_BALANCE_SDF'. "1168430
IF g_glflex_active IS INITIAL
OR NOT ld_clas_bal_fs10n IS INITIAL. "1168430
SELECT * FROM glt0 INTO TABLE xglt0
FOR ALL ENTRIES IN xy_bukrs "<-- 3.0F
WHERE rldnr IN xx_rldnr " Ledger-Nr
AND rrcty IN sd_stype " Satztyp
AND rvers IN version " Version
* AND BUKRS IN XX_BUKRS " Bukreis aus SKB1-BU
AND bukrs = xy_bukrs-bukrs "<-- 3.0F
AND ryear IN sd_gjahr " Ges.Jahr aus Eingabe
AND racct IN k_saknr
AND rbusa IN sd_gsber. " Gesch.Ber aus Eingab
ELSE.
***********************************************************
* NewGL: Read totals from archive
***********************************************************
if sd_usar2 is initial and sd_usdb2 is initial.
sd_usdb2 = 'X'.
endif.
if sd_usar2 = 'X'.
if gd_arch_done eq 'N'.
call function 'FAGL_GET_SUM_ARCH'
exporting
i_glt0_rldnr = xx_rldnr-low
i_rldnr = g_rldnr
i_range_rrcty = sd_stype[]
i_range_rvers = version[]
i_range_bukrs = sd_bukrs[]
i_range_ryear = sd_gjahr[]
i_range_rbusa = sd_gsber[]
i_range_racct = k_saknr[]
it_where_clause = faglfreesel_where
i_authority_check = 'X'
importing
et_glt0 = lt_glt0
tables
i_arch_sel = sd_file2[].
gd_arch_done = 'Y'.
gd_read_memo_done = 'N'.
endif.
endif.
***********************************************************
if not sd_usdb2 is initial.
READ TABLE xx_rldnr INDEX 1.
CALL FUNCTION 'FAGL_GET_GLT0'
EXPORTING
i_glt0_rldnr = xx_rldnr-low
i_rldnr = g_rldnr
* I_RRCTY =
* I_RVERS =
* i_bukrs =
* I_RYEAR =
* I_RACCT =
* I_RBUSA =
* I_RTCUR =
* I_DRCRK =
* I_RPMAX =
i_range_rrcty = sd_stype[]
i_range_rvers = version[]
i_range_bukrs = sd_bukrs[]
i_range_ryear = sd_gjahr[]
i_range_rbusa = sd_gsber[]
i_range_racct = k_saknr[]
* I_RANGE_RTCUR =
* I_RANGE_DRCRK =
* I_RANGE_RPMAX =
it_where_clause = faglfreesel_where
IMPORTING
et_glt0 = xglt0[].
endif.
ENDIF.
***********************************************************
* NewGL: append archived data
***********************************************************
append lines of lt_glt0 to xglt0.
delete adjacent duplicates from xglt0.
***********************************************************
SORT xglt0 BY rclnt racct bukrs rldnr rrcty rvers.
LOOP AT xglt0.
glt0 = xglt0.
IF glt0-rrcty = '1'.
CHECK glt0-rvers IN sd_vers.
ENDIF.
IF glt0-rrcty = '0'.
CHECK glt0-rvers = '001'.
ENDIF.
IF NOT glt0-rbusa IS INITIAL. " HK (171296)
AUTHORITY-CHECK OBJECT 'F_BKPF_GSB'
ID 'GSBER' FIELD glt0-rbusa
ID 'ACTVT' FIELD '03'.
CHECK sy-subrc = 0.
ENDIF. " HK
IF glt0-racct NE saknr_skc1c.
PERFORM saldo_des_monats_skc1c.
PERFORM saldo_zum_gm_ende_skc1c.
LOOP AT xskc1c.
yskc1c = xskc1c.
APPEND yskc1c.
ENDLOOP.
REFRESH: xskc1c.
ENDIF.
PERFORM xskc1c_aufbauen USING glt0-drcrk.
saknr_skc1c = glt0-racct.
ENDLOOP.
PERFORM saldo_des_monats_skc1c.
PERFORM saldo_zum_gm_ende_skc1c.
LOOP AT xskc1c.
yskc1c = xskc1c.
APPEND yskc1c.
ENDLOOP.
cursor-skc1c = 1.
ENDFORM. "UPDATE_YSKC1C
*--------------------------------------------------------------------*
* FORM XSKC1A_AUFBAUEN *
* Soll- und Haben-Verkehrszahlen pro Gesch-Ber. *
*--------------------------------------------------------------------*
FORM xskc1a_aufbauen USING xskc1a_drcrk.
CASE xskc1a_drcrk.
WHEN 'S'.
* Soll-Buchungen
* --------------
CLEAR: xskc1a.
xskc1a-mandt = glt0-rclnt.
xskc1a-bukrs = glt0-bukrs.
xskc1a-saknr = glt0-racct.
xskc1a-gjahr = glt0-ryear.
xskc1a-gsber = glt0-rbusa.
* XSKC1A-HWAER = GLT0-RTCUR.
* XSKC1A-HWAER = T001-WAERS.
xskc1a-rrcty = glt0-rrcty.
xskc1a-rvers = glt0-rvers.
xskc1a-rldnr = glt0-rldnr.
* Hauswaehrung uebertragen
* ------------------------
IF sd_curtp = ' ' OR sd_curtp = '10'.
xskc1a-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1a-um01s NEXT xskc1a-um02s.
refe2 = refe1.
ENDDO.
ELSE. "Zusatzwährung
READ TABLE c001 WITH KEY glt0-bukrs.
CASE c001-currnumber.
WHEN '2'.
xskc1a-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1a-um01s NEXT xskc1a-um02s.
refe2 = refe1.
ENDDO.
WHEN '3'.
xskc1a-umsav = glt0-kslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-ksl01 NEXT glt0-ksl02
VARYING refe2 FROM xskc1a-um01s NEXT xskc1a-um02s.
refe2 = refe1.
ENDDO.
ENDCASE.
ENDIF.
COLLECT xskc1a.
WHEN 'H'.
* Haben-Buchungen
* ---------------
CLEAR: xskc1a.
xskc1a-mandt = glt0-rclnt.
xskc1a-bukrs = glt0-bukrs.
xskc1a-saknr = glt0-racct.
xskc1a-gjahr = glt0-ryear.
xskc1a-gsber = glt0-rbusa.
* XSKC1A-HWAER = GLT0-RTCUR.
* XSKC1A-HWAER = T001-WAERS.
xskc1a-rrcty = glt0-rrcty.
xskc1a-rvers = glt0-rvers.
xskc1a-rldnr = glt0-rldnr.
* Hauswaehrung uebertragen
* ------------------------
IF sd_curtp = ' ' OR sd_curtp = '10'.
xskc1a-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1a-um01h NEXT xskc1a-um02h.
refe2 = refe1 * -1.
ENDDO.
ELSE. "Zusatzwährung
READ TABLE c001 WITH KEY glt0-bukrs.
CASE c001-currnumber.
WHEN '2'.
xskc1a-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1a-um01h NEXT xskc1a-um02h.
refe2 = refe1 * -1.
ENDDO.
WHEN '3'.
xskc1a-umsav = glt0-kslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-ksl01 NEXT glt0-ksl02
VARYING refe2 FROM xskc1a-um01h NEXT xskc1a-um02h.
refe2 = refe1 * -1.
ENDDO.
ENDCASE.
ENDIF.
COLLECT xskc1a.
ENDCASE.
ENDFORM. "XSKC1A_AUFBAUEN
*--------------------------------------------------------------------*
* FORM XSKC1C_AUFBAUEN *
* Soll- und Haben-Verkehrszahlen pro Gesch-Ber und Währung *
*--------------------------------------------------------------------*
FORM xskc1c_aufbauen USING xskc1c_drcrk.
CASE xskc1c_drcrk.
WHEN 'S'.
* Soll-Buchungen
* --------------
CLEAR: xskc1c.
xskc1c-mandt = glt0-rclnt.
xskc1c-bukrs = glt0-bukrs.
xskc1c-saknr = glt0-racct.
xskc1c-gjahr = glt0-ryear.
xskc1c-gsber = glt0-rbusa.
* XSKC1C-HWAER = GLT0-RTCUR.
* XSKC1C-HWAER = T001-WAERS.
xskc1c-fwaer = glt0-rtcur.
xskc1c-rrcty = glt0-rrcty.
xskc1c-rvers = glt0-rvers.
xskc1c-rldnr = glt0-rldnr.
* Hauswaehrung uebertragen
* ------------------------
IF sd_curtp = ' ' OR sd_curtp = '10'.
xskc1c-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1c-um01s NEXT xskc1c-um02s.
refe2 = refe1.
ENDDO.
ELSE. "Zusatzwaehrung
READ TABLE c001 WITH KEY glt0-bukrs.
CASE c001-currnumber.
WHEN '2'.
xskc1c-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1c-um01s NEXT xskc1c-um02s.
refe2 = refe1.
ENDDO.
WHEN '3'.
xskc1c-umsav = glt0-kslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-ksl01 NEXT glt0-ksl02
VARYING refe2 FROM xskc1c-um01s NEXT xskc1c-um02s.
refe2 = refe1.
ENDDO.
ENDCASE.
ENDIF.
* Fremdwaehrung uebertragen
* -------------------------
* IF SAVE_WAERS NE T001-WAERS.
* Übertragung der Beträge für das Währungskennzeichen aus B-Segment.
* IF SAVE_WAERS EQ GLT0-RTCUR.
xskc1c-slvfw = glt0-tslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-tsl01 NEXT glt0-tsl02
VARYING refe2 FROM xskc1c-wm01s NEXT xskc1c-wm02s.
refe2 = refe1.
ENDDO.
* ENDIF.
COLLECT xskc1c.
WHEN 'H'.
* Haben-Buchungen
* ---------------
CLEAR: xskc1c.
xskc1c-mandt = glt0-rclnt.
xskc1c-bukrs = glt0-bukrs.
xskc1c-saknr = glt0-racct.
xskc1c-gjahr = glt0-ryear.
xskc1c-gsber = glt0-rbusa.
* XSKC1C-HWAER = GLT0-RTCUR.
* XSKC1C-HWAER = T001-WAERS.
xskc1c-fwaer = glt0-rtcur.
xskc1c-rrcty = glt0-rrcty.
xskc1c-rvers = glt0-rvers.
xskc1c-rldnr = glt0-rldnr.
* Hauswaehrung uebertragen
* ------------------------
IF sd_curtp = ' ' OR sd_curtp = '10'.
xskc1c-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1c-um01h NEXT xskc1c-um02h.
refe2 = refe1 * -1.
ENDDO.
ELSE. "Zusatzwaehrung
READ TABLE c001 WITH KEY glt0-bukrs.
CASE c001-currnumber.
WHEN '2'.
xskc1c-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1c-um01h NEXT xskc1c-um02h.
refe2 = refe1 * -1.
ENDDO.
WHEN '3'.
xskc1c-umsav = glt0-kslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-ksl01 NEXT glt0-ksl02
VARYING refe2 FROM xskc1c-um01h NEXT xskc1c-um02h.
refe2 = refe1 * -1.
ENDDO.
ENDCASE.
ENDIF.
* Fremdwaehrung uebertragen
* -------------------------
* IF SAVE_WAERS NE T001-WAERS.
* Übertragung der Beträge für das Währungskennzeichen aus B-Segment.
* IF SAVE_WAERS EQ GLT0-RTCUR.
xskc1c-slvfw = glt0-tslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-tsl01 NEXT glt0-tsl02
VARYING refe2 FROM xskc1c-wm01h NEXT xskc1c-wm02h.
refe2 = refe1 * -1.
ENDDO.
* ENDIF.
COLLECT xskc1c.
ENDCASE.
ENDFORM. "XSKC1C_AUFBAUEN
*--------------------------------------------------------------------*
* FORM SALDO_DES_MONATS_SKC1A *
* Saldo des Monats (UM01O - UM16O) *
*--------------------------------------------------------------------*
FORM saldo_des_monats_skc1a.
LOOP AT xskc1a.
* Hauswaehrungs-Salden
* --------------------
DO 16 TIMES
VARYING refe1 FROM xskc1a-um01s NEXT xskc1a-um02s
VARYING refe2 FROM xskc1a-um01h NEXT xskc1a-um02h
VARYING refe3 FROM xskc1a-um01o NEXT xskc1a-um02o.
refe3 = refe1 - refe2.
ENDDO.
MODIFY xskc1a INDEX sy-tabix.
ENDLOOP.
ENDFORM. "SALDO_DES_MONATS_SKC1A
*--------------------------------------------------------------------*
* FORM SALDO_DES_MONATS_SKC1C *
* Saldo des Monats (UM01O - UM16O) (WM01O - WM16O) *
*--------------------------------------------------------------------*
FORM saldo_des_monats_skc1c.
LOOP AT xskc1c.
* Hauswaehrungs-Salden
* --------------------
DO 16 TIMES
VARYING refe1 FROM xskc1c-um01s NEXT xskc1c-um02s
VARYING refe2 FROM xskc1c-um01h NEXT xskc1c-um02h
VARYING refe3 FROM xskc1c-um01o NEXT xskc1c-um02o.
refe3 = refe1 - refe2.
ENDDO.
* Fremdwaehrungs-Salden
* ---------------------
DO 16 TIMES
VARYING refe1 FROM xskc1c-wm01s NEXT xskc1c-wm02s
VARYING refe2 FROM xskc1c-wm01h NEXT xskc1c-wm02h
VARYING refe3 FROM xskc1c-wm01o NEXT xskc1c-wm02o.
refe3 = refe1 - refe2.
ENDDO.
MODIFY xskc1c INDEX sy-tabix.
ENDLOOP.
ENDFORM. "SALDO_DES_MONATS_SKC1C
*EJECT
*--------------------------------------------------------------------*
* FORM SALDO_ZUM_GM_ENDE_SKC1A *
* Saldo zum GM-Ende (UM01K - UM16K) *
*--------------------------------------------------------------------*
FORM saldo_zum_gm_ende_skc1a.
* local data declaration
DATA: l_umo LIKE skc1a-um01o.
DATA: l_slk LIKE skc1a-um01k.
DATA: l_umk LIKE skc1a-um01k.
LOOP AT xskc1a.
* Hauswaehrungs-Salden
* --------------------
CLEAR: l_slk.
DO 16 TIMES
VARYING l_umo FROM xskc1a-um01o NEXT xskc1a-um02o
VARYING l_umk FROM xskc1a-um01k NEXT xskc1a-um02k.
l_slk = l_slk + l_umo.
l_umk = l_slk + xskc1a-umsav.
ENDDO.
MODIFY xskc1a INDEX sy-tabix.
ENDLOOP.
ENDFORM. "SALDO_ZUM_GM_ENDE_SKC1A
*--------------------------------------------------------------------*
* FORM SALDO_ZUM_GM_ENDE_SKC1C *
* Saldo zum GM-Ende (UM01K - UM16K) (WM01K - WM16K) *
*--------------------------------------------------------------------*
FORM saldo_zum_gm_ende_skc1c.
* local data declaration
DATA: l_umo LIKE skc1c-um01o.
DATA: l_slk LIKE skc1c-um01k.
DATA: l_umk LIKE skc1c-um01k.
LOOP AT xskc1c.
* Hauswaehrungs-Salden
* --------------------
CLEAR: l_slk.
DO 16 TIMES
VARYING l_umo FROM xskc1c-um01o NEXT xskc1c-um02o
VARYING l_umk FROM xskc1c-um01k NEXT xskc1c-um02k.
l_slk = l_slk + l_umo.
l_umk = l_slk + xskc1c-umsav.
ENDDO.
* Fremdwaehrungs-Salden
* ---------------------
CLEAR: l_slk.
DO 16 TIMES
VARYING l_umo FROM xskc1c-wm01o NEXT xskc1c-wm02o
VARYING l_umk FROM xskc1c-wm01k NEXT xskc1c-wm02k.
l_slk = l_slk + l_umo.
l_umk = l_slk + xskc1c-slvfw.
ENDDO.
MODIFY xskc1c INDEX sy-tabix.
ENDLOOP.
ENDFORM. "SALDO_ZUM_GM_ENDE_SKC1C
*--------------------------------------------------------------------*
* FORM INIT_TABLES *
* Initialisierung interner Arbeitsbereiche *
*--------------------------------------------------------------------*
FORM init_tables.
DATA: l_ds_clauses TYPE rsds_where,
l_tab_fields TYPE rsfs_tab_fields.
CALL FUNCTION 'INIT_T001'
TABLES
xbukreis = sd_bukrs.
IF alcur EQ 'X'. PERFORM read_teurb TABLES sd_bukrs. ENDIF. "<<<<euro
REFRESH version.
REFRESH sd_stype.
* If SD_PLAN has a different value then SPACE, ALL record
* types and versions are selected, so also 'plan' data
IF sd_plan EQ space.
MOVE '0' TO sd_stype-low. "Ist-Daten in GLT0
move 'EQ' to SD_STYPE-OPTION.
move 'I' to SD_STYPE-SIGN.
append SD_STYPE.
move '001' to VERSION-LOW.
move 'EQ' to VERSION-OPTION.
move 'I' to VERSION-SIGN.
append VERSION.
endif.
* New logic for SD_PLAN in related to special year end "1687347
* closing postings (GLYEC) "1687347
if SD_PLAN = '1'.
move '5' to SD_STYPE-LOW.
move 'EQ' to SD_STYPE-OPTION.
move 'I' to SD_STYPE-SIGN.
append SD_STYPE.
move '001' to VERSION-LOW.
move 'EQ' to VERSION-OPTION.
move 'I' to VERSION-SIGN.
append VERSION.
endif.
if SD_PLAN = '2'.
move '0' to SD_STYPE-LOW.
move 'EQ' to SD_STYPE-OPTION.
move 'I' to SD_STYPE-SIGN.
append SD_STYPE.
move '5' to SD_STYPE-LOW.
MOVE 'EQ' TO sd_stype-option.
MOVE 'I' TO sd_stype-sign.
APPEND sd_stype.
MOVE '001' TO version-low.
MOVE 'EQ' TO version-option.
MOVE 'I' TO version-sign.
APPEND version.
ENDIF.
* In SD_VERS Versionen zum Lesen von Plandaten vorhanden ?
DESCRIBE TABLE sd_vers LINES sy-tfill.
IF sy-tfill NE 0.
MOVE '1' TO sd_stype-low. "Plan-Daten in GLT0
MOVE 'EQ' TO sd_stype-option.
MOVE 'I' TO sd_stype-sign.
APPEND sd_stype.
LOOP AT sd_vers.
version = sd_vers.
APPEND version.
ENDLOOP.
ENDIF.
k_saknr-option = 'EQ'.
k_saknr-sign = 'I'.
* Und hier muss das Oracle dazu bewegt werden, ueber
* Index GLT0____1 zu lesen.
* read table sd_stype index 2. "note 78503
* if sy-subrc ne 0. "note 78503
* read table sd_stype index 1. "note 78503
* append sd_stype. "note 78503
* endif. "note 78503
* Dynamische Select-Options und Felder
init_where: ska1, skb1, bsis, faglfreesel.
init_fields: ska1, skb1, bsis, bkpf, bseg, gseg, bsisext. "40C
*... get report dynamic selections:
CALL FUNCTION 'RS_REFRESH_FROM_DYNAMICAL_SEL'
EXPORTING
curr_report = sy-cprog
mode_write_or_move = 'M'
IMPORTING
p_trange = gt_dyn_trange
EXCEPTIONS
not_found = 1
wrong_type = 2
OTHERS = 3.
IF sy-subrc > 1.
EXIT.
ENDIF.
* check and convert projk into external format
projk_eliminated = space.
PERFORM eliminate_field_where(fi_ldb_util) TABLES bsis_where
USING 'PROJK'
CHANGING projk_eliminated.
IF projk_eliminated EQ 'X'.
PERFORM convert_int_ext(fi_ldb_util) TABLES gt_dyn_trange
projk_tab
USING 'BSIS'
'PROJK'
'KONPR'.
ENDIF.
* check and convert imkey into external format
imkey_eliminated = space.
PERFORM eliminate_field_where(fi_ldb_util) TABLES bsis_where
USING 'IMKEY'
CHANGING imkey_eliminated.
IF imkey_eliminated EQ 'X'.
PERFORM convert_int_ext(fi_ldb_util) TABLES gt_dyn_trange
imkey_tab
USING 'BSIS'
'IMKEY'
'IMKEY'.
ENDIF.
* die Felder für Berechtigungsprüfung hinzufügen "45A
DESCRIBE TABLE skb1_fields LINES sy-tfill.
IF sy-tfill > 0.
PERFORM add_field_to_table TABLES skb1_fields USING 'BEGRU'."45A
ENDIF.
* die Schlüsselfelder gegebenfalls in Gseg_fields hinzufügen "30F
DESCRIBE TABLE gseg_fields LINES sy-tfill.
IF sy-tfill > 0.
PERFORM add_key_fields_to_gseg TABLES gseg_fields.
ENDIF.
* Die Felder zur Berechnung von BSEGA hinzufügen
DESCRIBE TABLE bsis_fields LINES sy-tfill.
IF sy-tfill > 0.
PERFORM add_auth_check_fields TABLES bsis_fields USING 'BSIS'.
PERFORM add_bsega_fields TABLES bsis_fields USING 'BSIS'.
PERFORM add_field_to_table TABLES bsis_fields USING 'XARCH'."40C
* new for bsisext.
DESCRIBE TABLE bsisext_fields LINES sy-tfill. "40C
IF sy-tfill > 0. "40C
PERFORM combine_fsel_tab1_to_tab2 "40C
TABLES bsisext_fields bsis_fields USING 'BSIS'."40C
ENDIF. "40C
ENDIF.
DESCRIBE TABLE bseg_fields LINES sy-tfill.
IF sy-tfill > 0.
PERFORM add_bsega_fields TABLES bseg_fields USING 'BSEG'.
ENDIF.
DESCRIBE TABLE gseg_fields LINES sy-tfill.
IF sy-tfill > 0.
PERFORM add_bsega_fields TABLES gseg_fields USING 'BSEG'.
ENDIF.
CLEAR: bsis, bseg, gseg.
ENDFORM. "INIT_TABLES
*---------------------------------------------------------------------*
* FORM AUTHORITYCHECK_SKA1 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM authoritycheck_ska1.
ENDFORM. "AUTHORITYCHECK_SKA1
*---------------------------------------------------------------------*
* FORM AUTHORITYCHECK_SKB1 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM authoritycheck_skb1.
* AUTHORITY-CHECK OBJECT 'F_SKA1_BUK'
* ID 'BUKRS' FIELD SAVE_BUKRS
* ID 'ACTVT' FIELD '03'.
* IF SY-SUBRC = 0.
CLEAR f_bkpf_bes_subrc.
IF NOT skb1-begru IS INITIAL.
AUTHORITY-CHECK OBJECT 'F_BKPF_BES' " this information will be
ID 'BRGRU' FIELD skb1-begru " used later in put_bsis,
ID 'ACTVT' FIELD '03'. " put_skc1a and put_skc1c.
IF sy-subrc <> 0.
f_bkpf_bes_subrc = sy-subrc.
sy-subrc = 0.
ENDIF.
AUTHORITY-CHECK OBJECT 'F_SKA1_BES' " this information is used
ID 'BRGRU' FIELD skb1-begru " immediately
ID 'ACTVT' FIELD '03'.
ENDIF.
* ENDIF.
ENDFORM. "AUTHORITYCHECK_SKB1
*---------------------------------------------------------------------*
* FORM AUTHORITYCHECK_SKC1A *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM authoritycheck_skc1a. "<<<< au40
DATA: zrc1 TYPE n.
zrc1 = 0.
IF au_gsber = 'X'.
PERFORM auth_gsber USING skc1a-gsber CHANGING zrc1.
ENDIF.
IF zrc1 NE 0.
sy-subrc = 4.
EXIT.
ELSE.
sy-subrc = 0.
ENDIF.
* tpc
IF gd_tpc_check = 'X' AND gd_tpc_check_sel NE 'X'.
CALL FUNCTION 'FI_CHECK_DATE'
EXPORTING
i_bukrs = skc1a-bukrs
i_user = sy-uname
i_program = 'SAPDBSDF'
i_from_year = skc1a-gjahr
EXCEPTIONS
no_authority_prog = 1
no_authority_date = 2
wrong_parameter = 3
OTHERS = 4.
CASE sy-subrc.
WHEN 0.
WHEN 2.
sy-subrc = 4.
WHEN OTHERS.
sy-subrc = 4.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDCASE.
ENDIF.
ENDFORM. "AUTHORITYCHECK_SKC1A
*---------------------------------------------------------------------*
* FORM AUTHORITYCHECK_SKC1C *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM authoritycheck_skc1c. "<<<< au40
DATA: zrc1 TYPE n.
zrc1 = 0.
IF au_gsber = 'X'.
PERFORM auth_gsber USING skc1c-gsber CHANGING zrc1.
ENDIF.
IF zrc1 NE 0.
sy-subrc = 4.
EXIT.
ELSE.
sy-subrc = 0.
ENDIF.
* tpc
IF gd_tpc_check = 'X' AND gd_tpc_check_sel NE 'X'.
CALL FUNCTION 'FI_CHECK_DATE'
EXPORTING
i_bukrs = skc1c-bukrs
i_user = sy-uname
i_program = 'SAPDBSDF'
i_from_year = skc1c-gjahr
EXCEPTIONS
no_authority_prog = 1
no_authority_date = 2
wrong_parameter = 3
OTHERS = 4.
CASE sy-subrc.
WHEN 0.
WHEN 2.
sy-subrc = 4.
WHEN OTHERS.
sy-subrc = 4.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDCASE.
ENDIF.
ENDFORM. "AUTHORITYCHECK_SKC1C
*---------------------------------------------------------------------*
* FORM AUTHORITYCHECK_BSIS *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM authoritycheck_bsis. " HK (171296)
* if not bsis-gsber is initial.
* authority-check object 'F_BKPF_GSB'
* id 'GSBER' field bsis-gsber
* id 'ACTVT' field '03'.
* endif.
DATA: zrc1 TYPE n, zrc2 TYPE n. "<<<< au40
DATA: ld_date TYPE dats.
zrc1 = 0.
zrc2 = 0.
IF au_gsber = 'X'.
PERFORM auth_gsber USING bsis-gsber CHANGING zrc1.
ENDIF.
IF au_blart = 'X'.
PERFORM auth_blart USING bsis-blart CHANGING zrc2.
ENDIF.
IF zrc1 NE 0 OR zrc2 NE 0.
sy-subrc = 4.
EXIT.
ELSE.
sy-subrc = 0.
ENDIF.
* tpc
* pai check already done by report?
IF sd_tpc = 'X'.
gd_tpc_check_sel = 'X'.
ENDIF.
IF gd_tpc_check = 'X' AND gd_tpc_check_sel NE 'X'.
* key date list
IF sd_opopt = 'X' AND
sd_apopt = space AND
sd_stida NE '00000000' AND
sd_stida NE '99991231' AND
sd_stida NE '00010101' AND
bsis-xopvw NE space.
ld_date = sd_stida.
ELSE.
ld_date = bsis-budat.
ENDIF.
CALL FUNCTION 'FI_CHECK_DATE'
EXPORTING
i_bukrs = bsis-bukrs
i_user = sy-uname
i_program = 'SAPDBSDF'
i_from_date = ld_date
EXCEPTIONS
no_authority_prog = 1
no_authority_date = 2
wrong_parameter = 3
OTHERS = 4.
CASE sy-subrc.
WHEN 0.
WHEN 2.
sy-subrc = 4.
WHEN OTHERS.
sy-subrc = 4.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDCASE.
ENDIF.
ENDFORM. "AUTHORITYCHECK_BSIS
*EJECT
*--------------------------------------------------------------------*
* FORM SD_CURTP_VAL *
* F4-Hilfe für Feld SD_CURTP *
*--------------------------------------------------------------------*
FORM sd_curtp_val.
CALL FUNCTION 'FI_F4_CURTP'
EXPORTING
i_xct10 = 'X'
IMPORTING
e_curtp = sd_curtp.
ENDFORM. "SD_CURTP_VAL
*--------------------------------------------------------------------*
* FORM SD_CURTP-LOW_VAL *
* F4-Hilfe für Feld XX_CURTP *
*--------------------------------------------------------------------*
FORM xx_curtp-low_val.
CALL FUNCTION 'FI_F4_CURTP'
EXPORTING
i_xct00 = 'X'
i_xct10 = 'X'
IMPORTING
e_curtp = xx_curtp-low.
ENDFORM. "XX_CURTP-LOW_VAL
*--------------------------------------------------------------------*
* FORM SD_CURTP-HIGH_VAL *
* F4-Hilfe für Feld XX_CURTP *
*--------------------------------------------------------------------*
FORM xx_curtp-high_val.
CALL FUNCTION 'FI_F4_CURTP'
EXPORTING
i_xct00 = 'X'
i_xct10 = 'X'
IMPORTING
e_curtp = xx_curtp-high.
ENDFORM. "XX_CURTP-HIGH_VAL
*---------------------------------------------------------------------*
* FORM LEDGER_WAEHLEN *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> MODE *
* --> RC *
* --> MSG *
*---------------------------------------------------------------------*
FORM ledger_waehlen USING mode CHANGING rc msg LIKE symsg.
DATA: title LIKE rgsel-dynp_title,
title1 LIKE rgsel-sel_title1,
title2 LIKE rgsel-sel_title2.
CLEAR rc.
title = text-060.
title1 = text-061.
title2 = text-062.
CALL FUNCTION 'G_DISPLAY_SELECTION_DYNPRO'
EXPORTING
dynp_title = title
sel_title1 = title1
sel_title2 = title2
start_column = 05
start_row = 08
without_selection = ' '
IMPORTING
sel_index = sy-tabix
TABLES
sel_table = f4tab
EXCEPTIONS
no_lines = 4
no_line_picked = 8.
CASE sy-subrc.
WHEN 0.
READ TABLE f4tab INDEX sy-tabix.
WHEN 4.
IF mode EQ '1'.
MESSAGE e056(f4).
ELSE.
msg-msgty = 'E'.
msg-msgid = 'F4'.
msg-msgno = '056'.
rc = 4.
ENDIF.
WHEN 8.
IF mode EQ '1'.
MESSAGE e057(f4).
ELSE.
msg-msgty = 'E'.
msg-msgid = 'F4'.
msg-msgno = '057'.
rc = 4.
ENDIF.
ENDCASE.
ENDFORM. "LEDGER_WAEHLEN
*---------------------------------------------------------------------*
* FORM CONVERT_ALT *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> TABNAME *
*---------------------------------------------------------------------*
FORM convert_alt USING tabname.
CASE tabname.
WHEN 'BSIS'.
PERFORM conv_to_alt_curr USING bsis-bukrs excdt sp_waers
CHANGING bsis-dmbtr.
PERFORM conv_to_alt_curr USING bsis-bukrs excdt sp_waers
CHANGING bsis-mwsts.
PERFORM conv_to_alt_curr USING bsis-bukrs excdt sp_waers
CHANGING bsega-dmsol.
PERFORM conv_to_alt_curr USING bsis-bukrs excdt sp_waers
CHANGING bsega-dmhab.
PERFORM conv_to_alt_curr USING bsis-bukrs excdt sp_waers
CHANGING bsega-dmshb.
WHEN 'BSEG'.
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.
WHEN 'GSEG'.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gseg-dmbtr.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gseg-mwsts.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gseg-hwbas.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gsega-dmsol.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gsega-dmhab.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gsega-dmshb.
ENDCASE.
ENDFORM. "CONVERT_ALT
*---------------------------------------------------------------------*
* FORM FILL_KBTAB_AND_KTOPL *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> SD_KTOPL *
* --> SD_BUKRS *
* --> KBTAB *
* --> KTOPL *
* --> MODE *
* --> RC *
* --> MSG *
*---------------------------------------------------------------------*
FORM fill_kbtab_and_ktopl TABLES sd_ktopl STRUCTURE sd_ktopl
sd_bukrs STRUCTURE sd_bukrs
kbtab STRUCTURE kbtab
ktopl STRUCTURE sd_ktopl
USING mode CHANGING rc LIKE sy-subrc msg LIKE symsg.
DATA: ktopl_entry LIKE sy-tfill,
bukrs_entry LIKE sy-tfill.
REFRESH: kbtab.
REFRESH: xx_ktopl.
CLEAR: xx_ktopl, rc.
* Einträge in Kontenplantabelle zählen.
DESCRIBE TABLE sd_ktopl LINES ktopl_entry.
* Einträge in Buchungskreistabelle zählen.
DESCRIBE TABLE sd_bukrs LINES bukrs_entry.
* Einträge in Kontenplan- o d e r Buchungskreistabelle vorhanden ?
* ----------------------------------------
IF ktopl_entry NE 0 OR bukrs_entry NE 0. "Ja
* Füllen KBTAB
*
* Zu den abgegrenzten Kontenplänen und/oder Buchungskreisen
* wird die gültige Kombination ermittelt und in den Selektions-
* tabellen KBTAB abgestellt, um auf Buchungskreisebene, für ein
* Sachkonto in einem Kontenplan nur die Buchungskreise zu selek-
* tierenen, die diesen Kontenplan verwenden.
*
* Füllen XX_KTOPL
*
* Zum Lesen der Sachkontenstammdaten SKA1 werden die gültigen
* Kontenpläne (Kontenpläne die mindestens in einem Buchungskreis
* verwendet werden) in der Tabelle XX_KTOPL abgelegt.
* ---------------------------------------------------------------
SELECT * FROM t001
WHERE ktopl IN sd_ktopl
AND bukrs IN sd_bukrs.
kbtab-ktopl = t001-ktopl.
kbtab-bukrs = t001-bukrs.
APPEND kbtab.
xx_ktopl-sign = 'I'.
xx_ktopl-option = 'EQ'.
xx_ktopl-low = kbtab-ktopl.
COLLECT xx_ktopl.
ENDSELECT.
IF sy-subrc NE 0.
IF mode EQ '1'.
MESSAGE e102.
ELSE.
* message e102.
msg-msgty = 'E'.
msg-msgid = 'FR'.
msg-msgno = '102'.
rc = 4.
EXIT.
ENDIF.
ENDIF.
ELSE. "Nein - Keine Einträge in Buktab bzw. Kontopl.tab
* Abgrenzungen Buchungskreis/Kontenplan sind initial.
* Füllen KBTAB
*
* Die gültige Schnittmenge Kontenplan/Buchungskreis rekrutiert
* sich aus der Anzahl der angelegten Buchungskreise. Jedem Buch-
* ungkreis ist genau ein Kontenplan zugeordnet. Es erfolgt ein
* Eintrag in Tabelle KBTAB, damit auf Buchungskreisebene für ein
* Sachkonto in einem Kontenplan nur die Buchungskreise selek-
* tiert werden, die diesen Kontenplan verwenden.
*
* Füllen XX_KTOPL
*
* Zum Lesen der Sachkontenstammdaten SKA1 werden a l l e vorhande-
* nen Kontenpläne, d h. auch solche Kontenpläne die in
* k e i n e m Buchungskreis verwendet werden in der Tabelle
* XX_KTOPL abgelegt. Dadurch werden zusätzliche Auswertungen über
* nicht zugeordnete Kontenpläne ermöglicht.
* ---------------------------------------------------------------
SELECT * FROM t001.
kbtab-ktopl = t001-ktopl.
kbtab-bukrs = t001-bukrs.
APPEND kbtab.
ENDSELECT.
SELECT * FROM t004.
xx_ktopl-sign = 'I'.
xx_ktopl-option = 'EQ'.
xx_ktopl-low = t004-ktopl.
APPEND xx_ktopl.
ENDSELECT.
ENDIF.
ENDFORM. "FILL_KBTAB_AND_KTOPL
*&--------------------------------------------------------------------*
*& Form COMPANY_CODE_AT_SCREEN_CHECK
*&--------------------------------------------------------------------*
* If CC is fixed in the form or drill-down report then it doesn't
* appear at the selection screen.
* In that case the authority check for CC shouldn't be done.
* See also FORM SCREEN_OUTPUT_EXIT (RFSRRI2F)
*&--------------------------------------------------------------------*
FORM company_code_at_screen_check CHANGING p_cc_at_screen.
LOOP AT SCREEN.
IF screen-name CS 'BUKRS'
AND screen-active = 1.
p_cc_at_screen = 1.
ENDIF.
ENDLOOP.
ENDFORM. " COMPANY_CODE_AT_SCREEN_CHECK
*&--------------------------------------------------------------------*
*& Form RLDNR_AT_SCREEN_CHECK
*&--------------------------------------------------------------------*
* There are some reports like RFSKPL00 without a selection field
* for Ledger (RLDNR). In this cases an authority check for Ledger
* should not be executed.
*&--------------------------------------------------------------------*
FORM rldnr_at_screen_check CHANGING p_rldnr_at_screen.
LOOP AT SCREEN.
IF screen-name CS 'RLDNR'
AND screen-active = 1.
p_rldnr_at_screen = 1.
ENDIF.
ENDLOOP.
ENDFORM. " RLDNR_AT_SCREEN_CHECK
*&---------------------------------------------------------------------*
*& Form check_date
*&---------------------------------------------------------------------*
* check gjahr and bukrs...
* check key date and BUKRS...
* ...to avoid check on item level
* if flag gd_tpc_check_sel = 'X': no further check necessary
*----------------------------------------------------------------------*
FORM check_date .
DATA: it001 TYPE t001 OCCURS 0 WITH HEADER LINE.
* bukrs specified?
READ TABLE sd_bukrs INDEX 1.
IF sy-subrc <> 0.
EXIT.
ENDIF.
SELECT * FROM t001 INTO TABLE it001
WHERE bukrs IN sd_bukrs.
* check key date and BUKRS
IF gd_tpc_stida = 'X' AND
sd_opopt = 'X' AND
sd_apopt = space.
ELSE.
* check gjahr und bukrs
LOOP AT it001.
LOOP AT sd_gjahr.
IF sd_gjahr-sign = 'I' AND
( sd_gjahr-option = 'BT' OR sd_gjahr-option = 'EQ' ).
gd_tpc_check_sel = 'X'.
CALL FUNCTION 'FI_CHECK_DATE'
EXPORTING
i_bukrs = it001-bukrs
i_user = sy-uname
i_program = 'SAPDBSDF'
i_from_year = sd_gjahr-low
i_to_year = sd_gjahr-high
EXCEPTIONS
no_authority_prog = 1
no_authority_date = 2
wrong_parameter = 3
OTHERS = 4.
IF sy-subrc <> 0.
gd_tpc_check_sel = space.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
ENDFORM. " check_date
**********************************************************************
* !!! PLEASE DO NOT CHANGE MANUALLY (BEGIN OF BLOCK) !!!!!!!!!!!!!!! *
*----------------------------------------------------------------------*
* Data structures for search pattern selection *
*----------------------------------------------------------------------*
* SDF_SP : Search pattern values. *
* After START-OF-SELECTION table SDF_SP is filled *
* with all keys of entries of the search pattern table *
* which correspond to the search string on the selection screen. *
* There must be defined a parameter for search pattern selection *
* (e.g. PARAMETER p_sp AS SEARCH PATTERN FOR NODE SPFLI), *
* and the user must have filled all fields on the selection-screen *
* (i.e. p_sp-NAME and p_sp-STRING). *
* Table SDF_SP will be used in subroutine PUT_SDF_SP. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SDF_SP OCCURS 1000, *
* SAKNR LIKE SKA1-SAKNR, *
* BUKRS LIKE SKB1-BUKRS, *
* KTOPL LIKE SKA1-KTOPL, *
* END OF SDF_SP . *
*----------------------------------------------------------------------*
* SP_FIELDS: Search Pattern fields. *
* After search pattern selection the table SP_FIELDS is modified: *
* SP_FIELDS-SUPPLIED NE SPACE if and only if the field *
* SP_FIELDS-FIELDNAME of SDF_SP, e.g. SDF_SP-CARRID, *
* is supplied by the search pattern interface. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SP_FIELDS OCCURS 10. *
* INCLUDE STRUCTURE RSSPFIELDS. *
* DATA: END OF SP_FIELDS. *
*----------------------------------------------------------------------*
* SP_TABLES: Search Pattern tables. *
* After search pattern selection the table SP_TABLES is modified: *
* SP_TABLES-SUPPLIED NE SPACE if and only if the keys of table *
* SP_TABLES-TABNAME are supplied by the search pattern interface. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SP_TABLES OCCURS 10. *
* INCLUDE STRUCTURE RSSPTABS. *
* DATA: END OF SP_TABLES. *
*----------------------------------------------------------------------*
* !!! PLEASE DO NOT CHANGE MANUALLY (END OF BLOCK) !!!!!!!!!!!!!!!!! *
**********************************************************************
*----------------------------------------------------------------------*
* FORM BEFORE_EVENT *
* Will be called before event 'event' *
*----------------------------------------------------------------------*
FORM before_event USING event.
CASE event.
WHEN 'START-OF-SELECTION'.
IF gd_tpc_log NE space.
CALL FUNCTION 'CA_WRITE_LOG' "#EC EXISTS
EXPORTING
i_program = sy-cprog
EXCEPTIONS
write_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e006(ca_check_date).
ENDIF.
ENDIF.
CALL FUNCTION 'LDB_LOG_INIT'.
ENDCASE.
ENDFORM. "before_event
*&---------------------------------------------------------------------*
*& Form after_event
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->EVENT text
*----------------------------------------------------------------------*
FORM after_event USING event.
CASE event.
WHEN 'END-OF-SELECTION'.
CALL FUNCTION 'LDB_LOG_DISPLAY'.
ENDCASE.
ENDFORM. "after_event
**********************************************************************
* !!! PLEASE DO NOT CHANGE MANUALLY (BEGIN OF BLOCK) !!!!!!!!!!!!!!! *
*----------------------------------------------------------------------*
* Data structures for search pattern selection *
*----------------------------------------------------------------------*
* SDF_SP : Search pattern values. *
* After START-OF-SELECTION table SDF_SP is filled *
* with all keys of entries of the search pattern table *
* which correspond to the search string on the selection screen. *
* There must be defined a parameter for search pattern selection *
* (e.g. PARAMETER p_sp AS SEARCH PATTERN FOR NODE SPFLI), *
* and the user must have filled all fields on the selection-screen *
* (i.e. p_sp-NAME and p_sp-STRING). *
* Table SDF_SP will be used in subroutine PUT_SDF_SP. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SDF_SP OCCURS 1000, *
* SAKNR LIKE SKB1-SAKNR, *
* BUKRS LIKE SKB1-BUKRS, *
* KTOPL LIKE SKB1-BUKRS, *
* END OF SDF_SP . *
*----------------------------------------------------------------------*
* SP_FIELDS: Search Pattern fields. *
* After search pattern selection the table SP_FIELDS is modified: *
* SP_FIELDS-SUPPLIED NE SPACE if and only if the field *
* SP_FIELDS-FIELDNAME of SDF_SP, e.g. SDF_SP-CARRID, *
* is supplied by the search pattern interface. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SP_FIELDS OCCURS 10. *
* INCLUDE STRUCTURE RSSPFIELDS. *
* DATA: END OF SP_FIELDS. *
*----------------------------------------------------------------------*
* SP_TABLES: Search Pattern tables. *
* After search pattern selection the table SP_TABLES is modified: *
* SP_TABLES-SUPPLIED NE SPACE if and only if the keys of table *
* SP_TABLES-TABNAME are supplied by the search pattern interface. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SP_TABLES OCCURS 10. *
* INCLUDE STRUCTURE RSSPTABS. *
* DATA: END OF SP_TABLES. *
*----------------------------------------------------------------------*
* !!! PLEASE DO NOT CHANGE MANUALLY (END OF BLOCK) !!!!!!!!!!!!!!!!! *
**********************************************************************
*---------------------------------------------------------------------*
* FORM put_admi_files *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM put_admi_files.
ENDFORM. "put_admi_files
*---------------------------------------------------------------------*
* FORM datasource_init *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> r_object *
* --> r_usedb *
* --> r_usear *
* --> r_useas *
* --> rt_files *
*---------------------------------------------------------------------*
FORM datasource_init CHANGING r_object TYPE arch_obj-object
r_usedb TYPE boole_d
r_usear TYPE boole_d
r_useas TYPE boole_d
rt_files TYPE gt_rng_archiv.
DATA: l_progname TYPE progname.
l_progname = sy-cprog.
CALL FUNCTION 'AS_DATASOURCE_INIT'
EXPORTING
i_report = l_progname
i_reporttype = space
IMPORTING
e_use_database = r_usedb
e_use_archive = r_usear
e_use_infosys = r_useas
et_arch_sel = rt_files[].
ENDFORM. "datasource_init
*---------------------------------------------------------------------*
* FORM read_archive *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM read_archive.
DATA : ld_errors TYPE boole,
ld_progress TYPE boole,
ld_convert_currency TYPE boole.
DATA: ls_bsis TYPE bsis. "1238122
DATA: ls_arch_key TYPE ty_doc_key. "1238122
* Create selection table.
REFRESH gt_selections.
PERFORM seltab_from_regular_sel.
PERFORM seltab_from_dyn_sel.
* 'LDB_NO_DISPL_ERROR' has to be created first (TA SM30, Tabelle TPARA)
* get parameter id 'LDB_NO_DISPL_ERROR' field LD_ERRORS.
* default has to be 'show errors'.
* if LD_ERRORS = 'X'.
* clear LD_ERRORS.
* else.
ld_errors = 'X'.
* endif.
ld_progress = 'X'.
ld_convert_currency = 'X'.
IF NOT sd_useas IS INITIAL.
REFRESH sd_files.
ENDIF.
CALL FUNCTION 'FI_DOCUMENT_ARCH_AS_ITEMS_READ' "#EC ENHOK
EXPORTING
i_selections = gt_selections
i_convert_currency = ld_convert_currency
i_show_errors = ld_errors
i_show_progess = ld_progress
TABLES
e_bkpf = ybkpf
e_bseg = ybseg
e_bsis = ybsis
e_bsas = ybsas
i_arch_sel = sd_files[]
EXCEPTIONS
no_infostruc_found = 1
selections_error = 2.
CASE sy-subrc.
WHEN '0'.
APPEND LINES OF ybsis TO ybsas. "#EC ENHOK
SORT ybsas BY mandt hkont bukrs.
LOOP AT ybsas INTO ls_bsis. "1238122
MOVE-CORRESPONDING ls_bsis TO ls_arch_key. "1238122
APPEND ls_arch_key TO arch_doc_key. "1238122
ENDLOOP. "1238122
SORT arch_doc_key BY bukrs belnr gjahr buzei. "1238122
WHEN '1'.
IF gd_msg601_done IS INITIAL.
MESSAGE i601.
gd_msg601_done = 'X'.
ENDIF.
REFRESH: ybkpf, ybseg, ybsas, ybsis.
WHEN '2'.
MESSAGE i602.
REFRESH: ybkpf, ybseg, ybsas, ybsis.
WHEN OTHERS.
MESSAGE i604.
REFRESH: ybkpf, ybseg, ybsas, ybsis.
ENDCASE.
cursor-ybsas = 1.
IF sd_memor = 'X'.
EXPORT ybkpf TO MEMORY ID 'YBKPF'.
EXPORT ybseg TO MEMORY ID 'YBSEG'.
ENDIF.
ENDFORM. "read_archive
*---------------------------------------------------------------------*
* FORM seltab_from_regular_sel *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM seltab_from_regular_sel.
DATA: ld_selopt LIKE rsdsselopt,
lt_selopt TYPE rsds_selopt_t,
ld_frange TYPE rsds_frange,
lt_frange TYPE rsds_frange_t,
ld_trange TYPE rsds_range,
lt_trange TYPE rsds_trange,
l_stida LIKE rfpdo-allgstid.
REFRESH:lt_frange.
ld_trange-tablename = 'BKPF'.
IF NOT sd_bukrs[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'BUKRS'.
LOOP AT sd_bukrs.
MOVE-CORRESPONDING sd_bukrs TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF NOT sd_budat[] IS INITIAL.
REFRESH: lt_selopt.
ld_frange-fieldname = 'BUDAT'.
LOOP AT sd_budat.
MOVE-CORRESPONDING sd_budat TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF ( sd_opopt = 'X' AND sd_apopt = 'X' )
OR ( sd_opopt = 'X' AND sd_apopt IS INITIAL ) .
IF sd_stida NE '99991231'.
REFRESH: lt_selopt.
ld_frange-fieldname = 'BUDAT'.
ld_selopt-sign = 'I'.
ld_selopt-option = 'BT'.
ld_selopt-low = '00010101'.
ld_selopt-high = sd_stida.
APPEND ld_selopt TO lt_selopt.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
ENDIF.
IF NOT lt_frange[] IS INITIAL .
ld_trange-frange_t = lt_frange[].
APPEND ld_trange TO lt_trange.
ENDIF.
REFRESH:lt_frange.
ld_trange-tablename = 'BSEG'.
IF NOT k_saknr[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'HKONT'.
LOOP AT k_saknr.
MOVE-CORRESPONDING k_saknr TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF NOT sd_augdt[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'AUGDT'.
LOOP AT sd_augdt.
MOVE-CORRESPONDING sd_augdt TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF ( sd_opopt IS INITIAL AND sd_apopt IS INITIAL )
OR ( sd_opopt = 'X' AND sd_apopt IS INITIAL ) .
IF sd_stida NE '00010101'.
REFRESH:lt_selopt.
IF sd_stida NE '99991231'.
l_stida = sd_stida + 1.
ELSE.
l_stida = sd_stida.
ENDIF.
ld_frange-fieldname = 'AUGDT'.
ld_selopt-sign = 'I'.
ld_selopt-option = 'BT'.
ld_selopt-low = l_stida.
ld_selopt-high = '99991231'.
APPEND ld_selopt TO lt_selopt.
CLEAR ld_selopt.
ld_selopt-sign = 'I'.
ld_selopt-option = 'EQ'.
ld_selopt-low = '00000000'.
APPEND ld_selopt TO lt_selopt.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
ENDIF.
IF NOT sd_zuonr[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'ZUONR'.
LOOP AT sd_zuonr.
MOVE-CORRESPONDING sd_zuonr TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF NOT sd_gsber[] IS INITIAL. "831568
REFRESH:lt_selopt.
ld_frange-fieldname = 'GSBER'.
LOOP AT sd_gsber.
MOVE-CORRESPONDING sd_gsber TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF. "831568
IF NOT sd_shkzg[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'SHKZG'.
LOOP AT sd_shkzg.
MOVE-CORRESPONDING sd_shkzg TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF NOT sd_bschl[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'BSCHL'.
LOOP AT sd_bschl.
MOVE-CORRESPONDING sd_bschl TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
* NOTE 792515
* REFRESH:lt_selopt.
* ld_frange-fieldname = 'KOART'.
* ld_selopt-sign = 'I'.
* ld_selopt-option = 'EQ'.
* ld_selopt-low = 'S'.
* APPEND ld_selopt TO lt_selopt. "Note 776164
* ld_selopt-sign = 'I'.
* ld_selopt-option = 'EQ'.
* ld_selopt-low = 'M'.
* APPEND ld_selopt TO lt_selopt.
* ld_selopt-sign = 'I'.
* ld_selopt-option = 'EQ'.
* ld_selopt-low = 'A'. "Note 776164
* APPEND ld_selopt TO lt_selopt.
* ld_frange-selopt_t = lt_selopt[].
* APPEND ld_frange TO lt_frange.
* NOTE 792515
IF NOT lt_frange[] IS INITIAL.
ld_trange-frange_t = lt_frange[].
APPEND ld_trange TO lt_trange.
ENDIF.
APPEND LINES OF lt_trange TO gt_selections.
ENDFORM. "seltab_from_regular_sel
*---------------------------------------------------------------------*
* FORM seltab_from_dyn_sel *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM seltab_from_dyn_sel.
DATA : lt_where TYPE rsds_twhere,
ld_where TYPE rsds_where,
lt_trange TYPE rsds_trange,
ld_trange TYPE rsds_range,
lt_frange TYPE rsds_frange_t,
ld_frange TYPE rsds_frange,
ld_selopt LIKE rsdsselopt.
* ld_tablename LIKE RSDSTABS-PRIM_TAB.
DATA : ld_selections TYPE rsds_range.
DATA : ls_dfies TYPE dfies,
ld_tablename LIKE dcobjdef-name,
ld_fieldname LIKE dfies-lfieldname.
DATA : ld_tabix LIKE sy-tabix.
* transforming bsis-where into ranges format
ld_where-tablename = 'BSIS'.
ld_where-where_tab = bsis_where.
APPEND ld_where TO lt_where.
CALL FUNCTION 'FREE_SELECTIONS_WHERE_2_RANGE'
EXPORTING
where_clauses = lt_where
IMPORTING
field_ranges = lt_trange
EXCEPTIONS
expression_not_supported = 1
incorrect_expression = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE e601 .
ENDIF.
* splitting ranges for bsis into ranges for BKPF and BSEG
CLEAR : ld_trange , lt_frange , ld_frange .
REFRESH : lt_frange .
ld_tablename = 'BSIS'.
READ TABLE lt_trange WITH KEY tablename = ld_tablename INTO ld_trange.
IF sy-subrc = 0.
ld_tabix = sy-tabix.
ld_tablename = 'BKPF'.
LOOP AT ld_trange-frange_t INTO ld_frange.
ld_fieldname = ld_frange-fieldname .
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = ld_tablename
lfieldname = ld_fieldname
IMPORTING
dfies_wa = ls_dfies
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 1.
APPEND ld_frange TO lt_frange.
DELETE TABLE ld_trange-frange_t FROM ld_frange.
ELSEIF sy-subrc <> 0 .
MESSAGE e601 .
ENDIF.
ENDLOOP.
IF NOT ld_trange-frange_t IS INITIAL.
ld_trange-tablename = 'BKPF'.
MODIFY lt_trange INDEX ld_tabix FROM ld_trange.
ELSE.
DELETE lt_trange INDEX ld_tabix.
ENDIF.
IF NOT lt_frange[] IS INITIAL.
CLEAR ld_trange.
ld_trange-tablename = 'BSEG'.
ld_trange-frange_t = lt_frange[].
APPEND ld_trange TO lt_trange.
ENDIF.
* finally append local selection table lt_trange to global
* selection table gt_selections.
APPEND LINES OF lt_trange TO gt_selections.
SORT gt_selections BY tablename.
ENDIF.
ENDFORM. "seltab_from_dyn_sel
*---------------------------------------------------------------------*
* FORM process_bsis *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> i_arch *
*---------------------------------------------------------------------*
FORM process_bsis USING i_arch TYPE boole_d.
IF bsis-xarch = 'X'
AND i_arch IS INITIAL
AND sd_usear = 'X'.
READ TABLE arch_doc_key WITH KEY bukrs = bsis-bukrs "1238122
belnr = bsis-belnr "1238122
gjahr = bsis-gjahr "1238122
buzei = bsis-buzei "1238122
* TRANSPORTING NO FIELDS. "1238122
TRANSPORTING NO FIELDS BINARY SEARCH. "1238122
IF sy-subrc = 0.
CLEAR bsis.
EXIT.
ENDIF.
ENDIF.
save_belnr = bsis-belnr.
save_buzei = bsis-buzei.
save_gsber = bsis-gsber.
save_gjahr = bsis-gjahr.
* check projk range
IF projk_eliminated EQ 'X'.
PERFORM check_int_ext(fi_ldb_util) TABLES projk_tab
USING bsis-projk
'KONPR'
CHANGING check_ok.
IF check_ok = 'N'.
EXIT.
ENDIF.
ENDIF.
* check imkey range
IF imkey_eliminated EQ 'X'.
PERFORM check_int_ext(fi_ldb_util) TABLES imkey_tab
USING bsis-imkey
'IMKEY'
CHANGING check_ok.
IF check_ok = 'N'.
EXIT.
ENDIF.
ENDIF.
* expiring currencies:
gd_waers_save = bsis-waers.
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bsis USING 'SAPDBSDF'
t001-waers
gd_expcur_date
CHANGING bsis.
ENDIF.
MOVE-CORRESPONDING bsis TO bsegh.
bsegh-koart = 'S'.
PERFORM got_bsega(sapbsega).
IF alcur EQ 'X'. " Euro
PERFORM convert_alt USING 'BSIS'.
ENDIF.
* count archived items
IF bsis-xarch = 'X'.
gd_count_arch = gd_count_arch + 1.
ENDIF.
IF i_arch = 'X' AND sd_usear = 'X'.
EXPORT gd_read_memo_done TO MEMORY ID 'GD_READ_MEMO_DONE'.
gd_read_memo_done = 'Y'.
ENDIF.
*
PUT bsis.
CLEAR bsis.
ENDFORM. "process_bsis
*---------------------------------------------------------------------*
* FORM modif_dyn_sel *
*---------------------------------------------------------------------*
* Form for setting the dynamic selections of log. DB by the *
* programm using the log. DB *
* Form can be used between start-of-selection and the first get *
*---------------------------------------------------------------------*
* --> i_dyn_sel *
*---------------------------------------------------------------------*
FORM modif_dyn_sel USING i_dyn_sel TYPE rsds_type.
dyn_sel = i_dyn_sel.
ENDFORM. "modif_dyn_sel
*&---------------------------------------------------------------------*
*& Form STATUS_FUNCTIONKEYS_CHANGE
*&---------------------------------------------------------------------*
* NewGL: Deactivate function keys if switch FAGL_CI_3_RS is
* is not on
*---------------------------------------------------------------------*
FORM status_functionkeys_change .
FIELD-SYMBOLS: <l_f_event> LIKE LINE OF get_events.
* If both nodes are used one function key should be deactivated:
* To deactivate the right function key two different function modules have
* to be called. (If both function modules are called only the last one will
* be executed!)
* 1. Deactivate SKC1C when node SKC1A is used
READ TABLE get_events ASSIGNING <l_f_event> WITH KEY node = 'SKC1A'.
IF sy-subrc = 0 AND NOT <l_f_event>-kind IS INITIAL.
CALL FUNCTION 'RS_EXTERNAL_SELSCREEN_STATUS'
EXPORTING
p_fb = 'FAGL_EXTERNAL_STATUS_SET_SKC1A'.
ENDIF.
* 2. Deactivate SKC1A when node SKC1C is used
READ TABLE get_events ASSIGNING <l_f_event> WITH KEY node = 'SKC1C'.
IF sy-subrc = 0 AND NOT <l_f_event>-kind IS INITIAL.
CALL FUNCTION 'RS_EXTERNAL_SELSCREEN_STATUS'
EXPORTING
p_fb = 'FAGL_EXTERNAL_STATUS_SET_SKC1C'.
ENDIF.
ENDFORM. " STATUS_FUNCTIONKEYS_CHANGE
Sur le menu de SAP Easy Access, Tapez la transaction SE36
Vous aurez cette écran:
Vous tapez dans le champs de BD logique SDF, cliquez après sur Afficher et vous aurez cette écran qui s'affiche:
Cliquez après sur le texte source pour affichez le code de la structure.
ci dessous le code source de la structure skc1a :
REPORT sapdbsdf DEFINING DATABASE sdf MESSAGE-ID fr.
********* ATTENTION for further global data declarations *************
* release 4.6A and greater
* initialize all global data declarations in form 'LDB_PROCESS_INIT'
* to make sure that the log. database can be processed multiple via
* function module 'LDB_PROCESS'
* -------------------------------------------------------------------*
TYPE-POOLS: rsds.
TABLES: ska1, " Kontenplan
skat, " Sachkontentexte
skb1, " Buchungskreisdaten
glt0, " GL C-Segment Summentabelle
skc1a, " Verkehrszahlen (Dummy) - Nur Hauswährungsbeträge-
skc1c, " Verkehrszahlen (Dummy) - Beträge pro Währung-
bsis, " Sekundaerindex offene Posten
bsas, " Sekundaerindex ausgeglichene Posten
admi_files,
bsisext, "40C
bkpf, " Belegkopf
vbkpf, " Belegkopf vorerfasster Belege
bseg, " Belegsegment vorerfasster Belege
v_vbsegs, " View auf VBKPF und VBSEGS
vbsegk, " Belegsegment vorerfasster Belege - Kreditoren
vbsegd, " Belegsegment vorerfasster Belege - Debitoren
vbsegs, " Belegsegment vorerfasster Belege - Sachkonten
vbsega, " Belegsegment vorerfasster Belege - Anlagen
vbsec, " Belegsegment vorerfasster Belege - CPD
bsegh, " Hilfstabelle fuer BSEGA (Dummy)
bsega, " Beleganhang (Dummy)
gseg, " Belegsegment - Gegenposition
gsega, " Beleganhang (Dummy) - Gegenposition
bsec, " Belegsegment - CPD-Daten
bsed, " Belegsegment - Wechseldaten
b0sg, " Flags
t001, " Buchungskreise
t004, " Kontenplaene
x001. " Waehrungsinformation
TABLES: sscrfields.
TABLES: taltwar. "euro
TABLES: dd03l.
TABLES: faglfreesel.
* fields for ranges in internal and external format
*----------------------------------------------------
DATA gt_dyn_trange TYPE rsds_trange.
DATA projk_eliminated(1) TYPE c.
DATA projk_tab TYPE rsds_selopt_t.
DATA imkey_eliminated(1) TYPE c.
DATA imkey_tab TYPE rsds_selopt_t.
DATA check_ok(1) TYPE c.
* Felder fuer Hilfsberechnungen
* -----------------------------
DATA: refe1 LIKE skc1a-um01k,
refe2 LIKE skc1a-um01k,
refe3 LIKE skc1a-um01k.
* Cursor-Verwaltung fuer interne Tabellen und Zaehler
DATA: cursor_t LIKE sy-tabix,
saknr_skc1a LIKE ska1-saknr,
saknr_skc1c LIKE ska1-saknr.
DATA: g_balv TYPE boolean VALUE 'X'. "usa BALV for messages log
* Zwischenpuffer
RANGES: k_saknr FOR ska1-saknr.
buffer: skb1.
DATA: cursor-skc1a LIKE sy-index,
cursor-skc1c LIKE sy-index.
DATA: count TYPE i,
max_count TYPE i VALUE 25,
count_ldb_log TYPE i. "1344830
DATA: f_bkpf_bes_subrc LIKE sy-subrc.
* Selektionsfelder fuer Plandaten
* --------------------------------
RANGES: version FOR skc1a-rvers.
DATA: styp LIKE glt0-rrcty.
* Satztyp fuer GLT0, wird intern gesetzt
* --------------------------------------
RANGES: sd_stype FOR glt0-rrcty.
* SAVE-Felder fuer KEY-Begriffe
* -----------------------------
DATA: save_ktopl LIKE ska1-ktopl,
save_saknr LIKE ska1-saknr,
save_bukrs LIKE skb1-bukrs,
save_waers LIKE skb1-waers,
save_gjahr LIKE skc1a-gjahr,
save_gsber LIKE skc1a-gsber,
save_belnr LIKE bsis-belnr,
save_buzei LIKE bsis-buzei,
save_subrc LIKE sy-subrc,
save_bstat LIKE bkpf-bstat,
prev_bukrs LIKE skb1-bukrs, "3.0F keys to avoid mult. sel
prev_belnr LIKE bsis-belnr, "3.0F
prev_gjahr LIKE skc1a-gjahr, "3.0F
bukrs-flag(1) TYPE c VALUE 'Y'.
* Key-Aufbau zum Lesen GLT0
* -------------------------
DATA: BEGIN OF glkey,
rldnr LIKE glt0-rldnr, " Ledger-Nr fix '00'
bukrs LIKE glt0-bukrs, " Bukreis aus Eingabe
racct LIKE glt0-racct, " Konto aus Eingabe
rtcur LIKE glt0-rtcur, " Waehrung aus SKB1-WAERS
drcrk LIKE glt0-drcrk, " S/H-Kennz fix 'S'
rpmax LIKE glt0-rpmax, " Bis-Perioe fix '16'
END OF glkey.
RANGES: xx_rldnr FOR glt0-rldnr.
* Quantities for optimized access to Table BKPF
* ---------------------------------------------
TYPES: BEGIN OF keybkpf,
bukrs LIKE bkpf-bukrs,
belnr LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
END OF keybkpf.
DATA: gt_save_keybkpf TYPE HASHED TABLE OF keybkpf
WITH UNIQUE KEY bukrs belnr gjahr.
DATA: gd_save_keybkpf TYPE keybkpf.
DATA: gt_save_bkpf TYPE HASHED TABLE OF bkpf
WITH UNIQUE KEY bukrs belnr gjahr.
DATA: gd_save_bkpf TYPE bkpf.
DATA: gd_opttime_bkpf TYPE c,
gd_optmemo_bkpf TYPE c,
gd_maxlines TYPE i.
* Tabelle der Kontenplaene und der zugehoerigen Buchungskreise
DATA: BEGIN OF kbtab OCCURS 10,
ktopl LIKE ska1-ktopl,
bukrs LIKE skb1-bukrs,
END OF kbtab.
* XSKAT - Tabelle zur Bereitstellung der Sachkonten-
* bezeichnung pro Kontenplan
* -------------------------------------------------------------
DATA: BEGIN OF xskat OCCURS 100.
INCLUDE STRUCTURE skat.
DATA: END OF xskat.
* XSKA1 - Tabelle zu Sammeln der Sachkonten
* --------------------------------------------------------------
DATA: BEGIN OF xska1 OCCURS 900.
INCLUDE STRUCTURE ska1.
DATA: END OF xska1.
DATA: xglt0 LIKE glt0 OCCURS 0 WITH HEADER LINE.
* XSKC1A - Tabelle zu Sammeln der Verkehrszahlen pro
* Konto, Buchungskreis, Jahr alle Gesch.Bereiche in HW
* -------------------------------------------------------------
DATA: BEGIN OF xskc1a OCCURS 50.
INCLUDE STRUCTURE skc1a.
DATA: END OF xskc1a.
* YSKC1A - Tabelle zu Sammeln der SKC1A-Tabellen
* --------------------------------------------------------------
DATA: BEGIN OF yskc1a OCCURS 500.
INCLUDE STRUCTURE skc1a.
DATA: END OF yskc1a.
* XSKC1C - Tabelle zu Sammeln der Verkehrszahlen pro
* Konto, Buchungskreis, Jahr alle Gesch.Bereiche pro FW
* --------------------------------------------------------------
DATA: BEGIN OF xskc1c OCCURS 50.
INCLUDE STRUCTURE skc1c.
DATA: END OF xskc1c.
* YSKC1C - Tabelle zu Sammeln der SKC1C-Tabellen
* --------------------------------------------------------------
DATA: BEGIN OF yskc1c OCCURS 500.
INCLUDE STRUCTURE skc1c.
DATA: END OF yskc1c.
* 3.0F Tabelle zur Vermeidung der mehrfachen Zugriffe auf BKPF
DATA: BEGIN OF xbkpf OCCURS 10.
INCLUDE STRUCTURE bkpf.
DATA: END OF xbkpf.
* Tabellen fuer dynamische Selektion und Felder
* --------------------------------------------------------------
DATA: ska1_where LIKE rsdswhere OCCURS 10,
ska1_fields LIKE rsfs_struc OCCURS 10.
DATA: skb1_where LIKE rsdswhere OCCURS 10,
skb1_fields LIKE rsfs_struc OCCURS 10.
DATA: bsis_where LIKE rsdswhere OCCURS 10,
bsis_fields LIKE rsfs_struc OCCURS 10,
vbsegs_where LIKE rsdswhere OCCURS 10,
where_line LIKE rsdswhere.
DATA: faglfreesel_where LIKE rsdswhere OCCURS 10.
DATA: bsisext_fields LIKE rsfs_struc OCCURS 10. "40C
DATA: bkpf_fields LIKE rsfs_struc OCCURS 10.
DATA: bseg_fields LIKE rsfs_struc OCCURS 10.
DATA: gseg_fields LIKE rsfs_struc OCCURS 10. "30F
DATA: test_fields LIKE rsfs_struc OCCURS 10 WITH HEADER LINE."30F
* Merker, ob Kontenplaene abgegrenzt wurden.
* ------------------------------------------
DATA: ktopl_entry TYPE p.
* Merker, ob Buchungskreise abgegrenzt wurden.
* --------------------------------------------
DATA: bukrs_entry TYPE p.
DATA: char130(130) TYPE c.
* SD_OPOPT(1) TYPE C,
* SD_APOPT(1) TYPE C.
DATA: database(1) TYPE c VALUE 'S'.
* Reading data from archives
TYPES: BEGIN OF ty_rng_archiv,
sign TYPE char1_arch,
option TYPE char2,
low TYPE arkey,
high TYPE arkey,
END OF ty_rng_archiv.
TYPES: BEGIN OF ty_doc_key, "1238122
bukrs TYPE bsis-bukrs, "1238122
belnr TYPE bsis-belnr, "1238122
gjahr TYPE bsis-gjahr, "1238122
buzei TYPE bsis-buzei, "1238122
END OF ty_doc_key. "1238122
TYPES: gt_rng_archiv TYPE TABLE OF ty_rng_archiv.
TYPES: ty_bsis TYPE bsis OCCURS 10.
DATA : ybsas TYPE bsas OCCURS 10,
ybsis TYPE bsis OCCURS 10,
ybkpf TYPE bkpf OCCURS 10,
ybseg TYPE bseg OCCURS 10.
DATA: arch_doc_key TYPE TABLE OF ty_doc_key. "1238122
DATA : cursor-ybsas TYPE sy-index.
DATA : gd_count_arch TYPE i.
DATA : gt_selections TYPE rsds_trange.
DATA : gd_arch_done TYPE c.
DATA : gd_read_memo_done TYPE c.
DATA : gd_msg601_done TYPE c.
* check date (tpc)
DATA: gd_tpc_check TYPE char1 VALUE space.
DATA: gd_tpc_stida TYPE char1 VALUE space.
DATA: gd_tpc_check_sel TYPE char1 VALUE space.
DATA: gd_tpc_log TYPE char1 VALUE space.
* expiring currencies:
DATA: gd_waers_save TYPE waers,
gd_expcur_flag TYPE c,
gd_expcur_date TYPE sydatum.
DATA: BEGIN OF ledtab OCCURS 2.
INCLUDE STRUCTURE gledtab.
DATA: END OF ledtab.
DATA: BEGIN OF f4tab OCCURS 2.
INCLUDE STRUCTURE rgse1.
DATA: END OF f4tab.
DATA: BEGIN OF c001 OCCURS 10,
bukrs LIKE t001-bukrs,
waers LIKE t001-waers,
rldnr LIKE gledtab-rldnr,
currnumber LIKE gledtab-currnumber,
END OF c001.
* Tabelle zum Speichern der selektierten Buchungskreise 3.0F
DATA: BEGIN OF xy_bukrs OCCURS 10,
bukrs LIKE skb1-bukrs,
END OF xy_bukrs.
RANGES zz_bukrs FOR skb1-bukrs.
DATA: g_flg_xx_curtp TYPE c.
*---------------------------------------------------------------------
* Flex GL
*---------------------------------------------------------------------
DATA: g_glflex_active TYPE boole_d.
DATA: g_glflex_act_cc TYPE boole_d.
DATA: g_rldnr TYPE rldnr.
DATA: g_lead_rldnr TYPE rldnr.
* Constants
CONSTANTS:
fagl_bhdgd_rldnr(16) TYPE c VALUE 'FAGL_BHDGD_RLDNR'.
INCLUDE rfdbexpc.
INCLUDE rfdbinclud1.
INCLUDE rfdbinclud2.
INCLUDE rfdbeuro. "<<<< euro
*--------------------------------------------------------------------*
* FORM INIT - Vorschalgswerte auf Selektionsbild bringen *
*--------------------------------------------------------------------*
FORM init.
* tpc
DATA ld_return TYPE char1.
FIELD-SYMBOLS: <l_f_event> LIKE LINE OF get_events. "NewGL
sd_opopt = space.
sd_apopt = space.
sd_stida = sy-datum.
b0sg-xstan = 'X'.
CLEAR: g_flg_xx_curtp.
* expiring currencies relevant for this process?
CALL FUNCTION 'CURRENCY_CHECK_FOR_PROCESS'
EXPORTING
process = 'SAPDBSDF'
EXCEPTIONS
process_not_maintained = 1
OTHERS = 2.
IF sy-subrc = 0.
gd_expcur_flag = 'X'.
ENDIF.
* check date(tpc)
CALL FUNCTION 'FI_CHECK_DATE'
EXPORTING
i_bukrs = space
i_user = sy-uname
i_program = 'SAPDBSDF'
IMPORTING
e_return = ld_return
EXCEPTIONS
no_authority_prog = 1
no_authority_date = 2
wrong_parameter = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
IF ld_return = 1.
gd_tpc_check = 'X'.
* log function installed: due to ABA support package
CALL FUNCTION 'FUNCTION_EXISTS'
EXPORTING
funcname = 'CA_WRITE_LOG'
EXCEPTIONS
function_not_exist = 1
OTHERS = 2.
IF sy-subrc EQ 0.
* user is tax auditor and ca_write_log is activ
gd_tpc_log = 'X'.
ENDIF.
ELSE.
gd_tpc_check = space.
ENDIF.
EXPORT gd_tpc_check TO MEMORY ID 'TPC_CHECK_FAGLL03'. "1061175
* Initialization for reading from archives.
IF sd_objec IS INITIAL.
* Archive object for itmes
sd_objec = 'FI_DOCUMNT'.
ENDIF.
IF sd_usedb IS INITIAL AND sd_usear IS INITIAL.
sd_usedb = 'X'.
sd_usear = space.
sd_useas = 'X'.
PERFORM datasource_init
CHANGING sd_objec sd_usedb sd_usear sd_useas sd_files[].
ENDIF.
sscrfields-functxt_05 = text-src.
*******************************************************
* NewGL: Reading totals from archiv
*******************************************************
* Set archive object for totals
if sd_obje1 is initial or sd_obje2 is initial.
sd_obje1 = sd_obje2 = 'FI_TF_GLF'.
endif.
read table get_events assigning <l_f_event> with key node = 'SKC1A'.
if sy-subrc eq 0 and <l_f_event>-kind ne space.
IF sd_usdb1 IS INITIAL AND sd_usar1 IS INITIAL.
sd_usdb1 = 'X'.
sd_usar1 = space.
sd_usas1 = 'X'.
PERFORM datasource_init
CHANGING sd_obje1 sd_usdb1 sd_usar1 sd_usas1 sd_file1[].
ENDIF.
endif.
read table get_events assigning <l_f_event> with key node = 'SKC1C'.
if sy-subrc eq 0 and <l_f_event>-kind ne space.
IF sd_usdb2 IS INITIAL AND sd_usar2 IS INITIAL.
sd_usdb2 = 'X'.
sd_usar2 = space.
sd_usas2 = 'X'.
PERFORM datasource_init
CHANGING sd_obje2 sd_usdb2 sd_usar2 sd_usas2 sd_file2[].
ENDIF.
endif.
* Reading totals from archiv
sscrfields-functxt_04 = text-src.
sscrfields-functxt_03 = text-src.
* Switch function keys
PERFORM status_functionkeys_change.
************************************************
* flex gl active ?
CALL FUNCTION 'FAGL_CHECK_GLFLEX_ACTIVE'
IMPORTING
e_glflex_active = g_glflex_active
EXCEPTIONS
error_in_setup = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* ccodes active ?
IF g_glflex_active IS INITIAL.
CALL FUNCTION 'FAGL_BUKRS_ACTIVE_IN_CLIENT'
IMPORTING
e_glflex_active = g_glflex_act_cc.
ENDIF.
ENDFORM. "INIT
*--------------------------------------------------------------------*
* FORM PBO - Selection Screen: Process before output *
*--------------------------------------------------------------------*
FORM pbo.
DATA s_flag.
LOOP AT SCREEN.
IF screen-name(8) = 'SD_GSB_S'.
s_flag = 'X'.
ENDIF.
IF screen-group1 = 'GSB' AND s_flag = 'X'.
screen-active = 0.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
CLEAR: s_flag.
LOOP AT SCREEN.
*.. if parameter for currency type at the screen ?
IF screen-name(8) = 'SD_CURTP'.
s_flag = 'X'.
ENDIF.
*.. then deactivate select options for currency type
IF screen-group1 = 'CTP' AND s_flag = 'X'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
IF g_glflex_active IS INITIAL.
* FlexGL is not active - make RLDNR invisible
LOOP AT SCREEN.
IF screen-group1 = 'LDG'.
screen-active = '0'.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDIF.
PERFORM auth_check_for_blart_gsber CHANGING au_blart au_gsber. "<<<au40
PERFORM modify_screen_for_euro USING sy-cprog. "<<<euro
ENDFORM. "PBO
*--------------------------------------------------------------------*
* FORM PAI - Selection Screen: Process after input *
*--------------------------------------------------------------------*
FORM pai USING fname mark.
DATA: get1, get2, get3,
rc LIKE sy-subrc,
msg1 LIKE symsg.
STATICS: l_cc_at_screen LIKE sy-subrc.
STATICS: l_rldnr_at_screen LIKE sy-subrc.
DATA: ld_progname TYPE progname,
lt_objects TYPE as_t_archobj.
**********************************************************************
* NewGL: Reading totals from archíve
**********************************************************************
field-symbols: <l_f_event> like line of get_events.
**********************************************************************
* fill local currency reference field for dynamic selections:
CLEAR t001-waers.
READ TABLE sd_bukrs INDEX 1.
IF sy-subrc = 0.
SELECT SINGLE waers FROM t001 INTO t001-waers
WHERE bukrs IN sd_bukrs.
ENDIF.
CHECK mark = space.
IF sscrfields-ucomm = 'ONLI' " Online submit
OR sscrfields-ucomm = 'PRIN' " Online submit and print
OR sscrfields-ucomm = 'SJOB' " Submit as background job
OR sscrfields-ucomm = 'SPOS' " Save as Variant
OR sscrfields-ucomm = 'SAVE' " Variant maintanance
OR sscrfields-ucomm = 'EXEX' " Application execute
OR sscrfields-ucomm = space " ENTER
OR sy-ucomm = 'EXEX' " Application execute
or SSCRFIELDS-UCOMM = 'CXSP'. " search help (note 1605999)
CASE fname.
WHEN 'SD_BUKRS'.
IF sd_noaut IS INITIAL.
PERFORM company_code_at_screen_check
CHANGING l_cc_at_screen.
* authority check only if cc appears at screen.
CHECK NOT ( l_cc_at_screen IS INITIAL "1168366
AND sd_bukrs IS INITIAL ). "1168366
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = database
TABLES
xbukreis = sd_bukrs.
* Belegberechtigung auf Buchungskreisebene
READ TABLE get_events WITH KEY node = 'SKC1A'.
get1 = get_events-kind.
READ TABLE get_events WITH KEY node = 'SKC1C'.
get2 = get_events-kind.
READ TABLE get_events WITH KEY node = 'BSIS'.
get3 = get_events-kind.
IF get1 <> ' ' OR "Salden
get2 <> ' ' OR
get3 <> ' '. "Belege
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = 'B'
TABLES
xbukreis = sd_bukrs.
ENDIF.
ENDIF.
WHEN 'SD_SAKNR'.
* Konvertierung der Kontonummer
* -----------------------------
LOOP AT sd_saknr.
PERFORM alphaformat(sapfs000)
USING sd_saknr-low sd_saknr-low.
PERFORM alphaformat(sapfs000)
USING sd_saknr-high sd_saknr-high.
MODIFY sd_saknr.
ENDLOOP.
WHEN 'SD_STIDA'.
IF sd_stida EQ '00000000' OR sd_stida EQ space.
MESSAGE e109.
ENDIF.
sd_opopt = 'X'.
gd_tpc_stida = 'X'.
WHEN 'SD_AUGDT'.
sd_apopt = 'X'.
WHEN 'XX_CURTP'.
CLEAR: g_flg_xx_curtp.
*.... check, if XX_CURTP is active
LOOP AT SCREEN.
IF screen-group1 = 'CTP'
AND screen-active = '1'.
g_flg_xx_curtp = 'X'.
ENDIF.
ENDLOOP.
IF g_flg_xx_curtp = 'X'.
READ TABLE xx_curtp INDEX 1.
sd_curtp = xx_curtp-low.
IF sd_curtp = '00'.
*........ assume that GET SKC1C event has been choosen
*........ switch to curtp 10 for further process
sd_curtp = '10'.
ENDIF.
ENDIF.
WHEN '*'.
CHECK: sy-dynnr = '1000'.
*.... it is necessary if there are report individual tabstrips
*.... the following checks and messages concern only screen 1000
*.... see also internal message 1221894/1999
IF gd_tpc_check = 'X'.
PERFORM check_date.
ENDIF.
copy sd_gsb_b to sd_gsber.
LOOP AT sd_gsb_s.
sd_gsber = sd_gsb_s.
APPEND sd_gsber.
ENDLOOP.
*.... new authorithy check for company code.
*....(see message 105305/2003 for example)
PERFORM company_code_at_screen_check
CHANGING l_cc_at_screen.
* authority check only if cc appears at screen.
IF NOT ( l_cc_at_screen IS INITIAL "1168366
AND sd_bukrs IS INITIAL ). "1168366
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = database
TABLES
xbukreis = sd_bukrs.
* Belegberechtigung auf Buchungskreisebene "825411
READ TABLE get_events WITH KEY node = 'SKC1A'.
get1 = get_events-kind.
READ TABLE get_events WITH KEY node = 'SKC1C'.
get2 = get_events-kind.
READ TABLE get_events WITH KEY node = 'BSIS'.
get3 = get_events-kind.
IF get1 <> ' ' OR "Salden
get2 <> ' ' OR
get3 <> ' '. "Belege
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = 'B'
TABLES
xbukreis = sd_bukrs.
ENDIF. "825411
ENDIF.
* -----------------------------------------
* Berechtigungsprüfung Kontoart Sachkonten.
* -----------------------------------------
AUTHORITY-CHECK OBJECT 'F_BKPF_KOA'
ID 'KOART' FIELD 'S'
ID 'ACTVT' FIELD '03'.
IF sy-subrc <> 0.
MESSAGE e812 WITH text-008 'S'.
ENDIF.
* Ende-Verarbeitung
IF sd_opopt IS INITIAL
AND sd_apopt IS INITIAL.
sd_opopt = 'X'.
sd_apopt = 'X'.
sd_stida = '99991231'.
ENDIF.
REFRESH: xx_ktopl.
CLEAR: xx_ktopl.
* REFRESH: XX_BUKRS. "3.0F
* CLEAR: XX_BUKRS.
REFRESH: xy_bukrs.
CLEAR: xy_bukrs. "3.0F
CLEAR: prev_bukrs, prev_belnr, prev_gjahr. "3.0F
REFRESH: xx_rldnr.
CLEAR: xx_rldnr.
REFRESH: kbtab.
cursor_t = 0.
saknr_skc1a = space.
saknr_skc1c = space.
* Einträge in Kontenplantabelle zählen.
* -------------------------------------
DESCRIBE TABLE sd_ktopl LINES ktopl_entry.
* Einträge in Buchungskreistabelle zählen.
* ----------------------------------------
DESCRIBE TABLE sd_bukrs LINES bukrs_entry.
* Einträge in Kontenplan- o d e r Buchungskreistabelle vorhanden ?
* ----------------------------------------
IF ktopl_entry NE 0 OR bukrs_entry NE 0. "Ja
* Füllen KBTAB
*
* Zu den abgegrenzten Kontenplänen und/oder Buchungskreisen
* wird die gültige Kombination ermittelt und in den Selektions-
* tabellen KBTAB abgestellt, um auf Buchungskreisebene, für ein
* Sachkonto in einem Kontenplan nur die Buchungskreise zu selek-
* tierenen, die diesen Kontenplan verwenden.
*
* Füllen XX_KTOPL
*
* Zum Lesen der Sachkontenstammdaten SKA1 werden die gültigen
* Kontenpläne (Kontenpläne die mindestens in einem Buchungskreis
* verwendet werden) in der Tabelle XX_KTOPL abgelegt.
* ---------------------------------------------------------------
SELECT * FROM t001
WHERE ktopl IN sd_ktopl
AND bukrs IN sd_bukrs.
kbtab-ktopl = t001-ktopl.
kbtab-bukrs = t001-bukrs.
APPEND kbtab.
xx_ktopl-sign = 'I'.
xx_ktopl-option = 'EQ'.
xx_ktopl-low = kbtab-ktopl.
COLLECT xx_ktopl.
ENDSELECT.
IF sy-subrc NE 0.
MESSAGE e102.
ENDIF.
ELSE. "Nein - Keine Einträge in Buktab bzw. Kontopl.tab
* Abgrenzungen Buchungskreis/Kontenplan sind initial.
* Füllen KBTAB
*
* Die gültige Schnittmenge Kontenplan/Buchungskreis rekrutiert
* sich aus der Anzahl der angelegten Buchungskreise. Jedem Buch-
* ungkreis ist genau ein Kontenplan zugeordnet. Es erfolgt ein
* Eintrag in Tabelle KBTAB, damit auf Buchungskreisebene für ein
* Sachkonto in einem Kontenplan nur die Buchungskreise selek-
* tiert werden, die diesen Kontenplan verwenden.
*
* Füllen XX_KTOPL
*
* Zum Lesen der Sachkontenstammdaten SKA1 werden a l l e vorhande-
* nen Kontenpläne, d h. auch solche Kontenpläne die in
* k e i n e m Buchungskreis verwendet werden in der Tabelle
* XX_KTOPL abgelegt. Dadurch werden zusätzliche Auswertungen über
* nicht zugeordnete Kontenpläne ermöglicht.
* ---------------------------------------------------------------
SELECT * FROM t001.
kbtab-ktopl = t001-ktopl.
kbtab-bukrs = t001-bukrs.
APPEND kbtab.
ENDSELECT.
SELECT * FROM t004.
xx_ktopl-sign = 'I'.
xx_ktopl-option = 'EQ'.
xx_ktopl-low = t004-ktopl.
APPEND xx_ktopl.
ENDSELECT.
ENDIF.
CLEAR t004.
* Zulaessigkeit des Waehrungstyps für selektierte Buchungskreis
REFRESH xx_rldnr.
REFRESH c001.
xx_rldnr-option = 'EQ'. xx_rldnr-sign = 'I'.
LOOP AT kbtab.
IF sd_curtp = ' ' OR sd_curtp = '10'.
xx_rldnr-low = '00'.
COLLECT xx_rldnr.
EXIT.
ENDIF.
DATA: l_tp_auth TYPE c.
CALL FUNCTION 'TP_VALUATION_AUTHORITY'
EXPORTING
i_bukrs = kbtab-bukrs
i_cvtyp = sd_curtp
IMPORTING
e_xauth = l_tp_auth
EXCEPTIONS
kokrs_finding_error = 1
valutyp_finding_error = 2
insufficient_input_for_kokrs = 3
insufficient_input_for_valutyp = 4
activity_not_allowed = 5
OTHERS = 6.
IF sy-subrc <> 0
OR l_tp_auth IS INITIAL.
MESSAGE e826 WITH sd_curtp kbtab-bukrs.
ENDIF.
CALL FUNCTION 'FI_CURRENCY_INFORMATION'
EXPORTING
i_bukrs = kbtab-bukrs
IMPORTING
e_x001 = x001.
IF x001-curt2 <> sd_curtp AND x001-curt3 <> sd_curtp.
IF g_flg_xx_curtp IS INITIAL
AND NOT ( l_cc_at_screen IS INITIAL ).
*............ message only if cc appears at screen.
REFRESH c001.
MESSAGE e822 WITH sd_curtp kbtab-bukrs.
ELSE.
*.......... exclude CC from selection
DELETE kbtab.
CONTINUE.
ENDIF.
ELSE.
IF sd_curtp = '30'.
ledtab-rldnr = '00'.
ledtab-currnumber = '3'.
ELSE.
IF sd_rldnr[] IS NOT INITIAL. "n1262139
*.... ledger has been specified
READ TABLE sd_rldnr INDEX 1. "n1262139
g_rldnr = sd_rldnr-low. "n1262139
ENDIF. "n1262139
CALL FUNCTION 'G_GIVE_LEDGERS_FOR_GLT0'
EXPORTING
bukrs = kbtab-bukrs
curtp = sd_curtp
ed_nledger = g_rldnr "n1262139
TABLES
ledtab = ledtab.
DESCRIBE TABLE ledtab LINES sy-tfill.
IF sy-tfill > 1
AND g_glflex_active IS INITIAL.
REFRESH: f4tab.
LOOP AT ledtab.
CLEAR: f4tab.
f4tab-sel_line = ledtab-rldnr.
f4tab-sel_line+3 = ledtab-name.
APPEND f4tab.
ENDLOOP.
PERFORM ledger_waehlen USING '1' CHANGING rc msg1.
IF sy-subrc = 0.
READ TABLE ledtab INDEX sy-tabix.
ELSE.
READ TABLE ledtab INDEX 1.
ENDIF.
ELSE.
READ TABLE ledtab INDEX 1.
ENDIF.
ENDIF.
CLEAR c001.
c001-bukrs = kbtab-bukrs.
IF x001-curt2 = sd_curtp.
c001-waers = x001-hwae2.
ELSEIF x001-curt3 = sd_curtp.
c001-waers = x001-hwae3.
ENDIF.
MOVE-CORRESPONDING ledtab TO c001.
APPEND c001.
xx_rldnr-low = ledtab-rldnr.
COLLECT xx_rldnr.
ENDIF.
ENDLOOP.
IF NOT ( g_glflex_active IS INITIAL ).
*...... flexGL is active
IF sd_rldnr[] IS INITIAL.
*........ set leading ledger
CALL FUNCTION 'FAGL_GET_LEADING_LEDGER'
IMPORTING
e_rldnr = g_lead_rldnr
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*........ set ledger
g_rldnr = g_lead_rldnr.
ELSE.
*........ ledger specified on sel screen
READ TABLE sd_rldnr INDEX 1.
g_rldnr = sd_rldnr-low.
ENDIF.
*...... check whether 'RLDNR' is a selection field
PERFORM rldnr_at_screen_check
CHANGING l_rldnr_at_screen.
* authority check only if RLDNR appears at screen.
if not ( L_RLDNR_AT_SCREEN is initial ). "1531154
*.......... Check only, if documents or balances are requested "1531154
read table GET_EVENTS with key NODE = 'SKC1A'. "1531154
GET1 = GET_EVENTS-KIND. "1531154
read table GET_EVENTS with key NODE = 'SKC1C'. "1531154
GET2 = GET_EVENTS-KIND. "1531154
read table GET_EVENTS with key NODE = 'BSIS'. "1531154
GET3 = GET_EVENTS-KIND. "1531154
if GET1 <> ' ' or "Salden "1531154
GET2 <> ' ' or "1531154
GET3 <> ' '. "Belege "1531154
loop at kbtab. "1531154
call function 'FAGL_AUTHORITY_LEDGER' "1531154
EXPORTING "1531154
i_bukrs = kbtab-bukrs "1531154
i_rldnr = g_rldnr "1531154
i_actvt = '03'. "1531154
endloop. "1531154
endif. "1531154
endif. "1531154
ENDIF.
IF NOT ( g_rldnr IS INITIAL )
AND NOT ( l_rldnr_at_screen IS INITIAL ).
*...... export ledger to memory for standard page header
*...... in program RSBTCHH0.
EXPORT fagl_bhdgd_rldnr FROM g_rldnr
TO MEMORY ID fagl_bhdgd_rldnr.
ENDIF.
*---------------------------------------------------------------------*
WHEN OTHERS.
ENDCASE.
* Selection of datasources.
ELSEIF sscrfields-ucomm = 'FC05'.
ld_progname = sy-cprog.
APPEND 'FI_DOCUMNT' TO lt_objects.
CALL FUNCTION 'AS_DATASOURCE_SELECT'
EXPORTING
i_db_and_arc = 'X'
i_no_source_select = space
i_infosys_possible = 'X'
i_documentation = 'DEFAULT'
i_report = ld_progname
i_reporttype = space
it_objects = lt_objects[]
CHANGING
c_use_database = sd_usedb
c_use_archive = sd_usear
c_use_infosys = sd_useas
c_archobj = sd_objec
ct_arch_sel = sd_files[].
CLEAR : sscrfields-ucomm.
*************************************************
* NewGL: Selection of datasources for totals
*************************************************
* 1. for SKC1A
ELSEIF sscrfields-ucomm = 'FC03'.
* check if SKC1A is called otherwise it could come to
* problem with other programs like FAGLL03
read table get_events assigning <l_f_event> with key node = 'SKC1A'.
if sy-subrc eq 0 and <l_f_event>-kind ne space.
ld_progname = sy-cprog.
APPEND 'FI_TF_GLF' TO lt_objects.
call function 'ARCHIVE_ADMIN_DEFINE_FILTER'
exporting
status_deleted_only = 'X'.
CALL FUNCTION 'AS_DATASOURCE_SELECT'
EXPORTING
i_db_and_arc = 'X'
i_no_source_select = space
i_infosys_possible = 'X'
i_documentation = 'DEFAULT'
it_objects = lt_objects[]
CHANGING
c_use_database = sd_usdb1
c_use_archive = sd_usar1
c_use_infosys = sd_usas1
c_archobj = sd_obje1
ct_arch_sel = sd_file1[].
* archive parameter should be the same for SKC1A and SKC1C otherwise
* it will lead to problems if put for both tables!
sd_usdb2 = sd_usdb1.
sd_usar2 = sd_usar1.
sd_usas2 = sd_usas1.
sd_file2[] = sd_file1[].
CLEAR : sscrfields-ucomm.
endif.
ELSEIF sscrfields-ucomm = 'FC04'.
* 2. for SKC1C
* check if SKC1C is called otherwise it could come to
* problem with other programs like FAGLL03
read table get_events assigning <l_f_event> with key node = 'SKC1C'.
if sy-subrc eq 0 and <l_f_event>-kind ne space.
ld_progname = sy-cprog.
APPEND 'FI_TF_GLF' TO lt_objects.
call function 'ARCHIVE_ADMIN_DEFINE_FILTER'
exporting
status_deleted_only = 'X'.
CALL FUNCTION 'AS_DATASOURCE_SELECT'
EXPORTING
i_db_and_arc = 'X'
i_no_source_select = space
i_infosys_possible = 'X'
i_documentation = 'DEFAULT'
it_objects = lt_objects[]
CHANGING
c_use_database = sd_usdb2
c_use_archive = sd_usar2
c_use_infosys = sd_usas2
c_archobj = sd_obje2
ct_arch_sel = sd_file2[].
* archive parameter should be the same for SKC1A and SKC1C otherwise
* it will lead to problems if put for both tables!
sd_usdb1 = sd_usdb2.
sd_usar1 = sd_usar2.
sd_usas1 = sd_usas2.
sd_file1[] = sd_file2[].
CLEAR : sscrfields-ucomm.
endif.
*****************************************************
ENDIF.
ENDFORM. "PAI
*eject.
*---------------------------------------------------------------------*
* FORM LDB_PROCESS_INIT *
*---------------------------------------------------------------------*
FORM ldb_process_init CHANGING ldb_subrc LIKE sy-subrc.
* initialize all global data declarations to make sure
* that the log. database can be processed multiple via
* function module 'LDB_PROCESS'
CLEAR: ska1, skat, skb1, glt0, skc1a, skc1c, bsis, bsas,
bsisext, bkpf, vbkpf, bseg, v_vbsegs, vbsegk, vbsegd,
vbsegs, vbsega, vbsec, bsegh, bsega, gseg, gsega,
bsec, bsed, b0sg, t001, t004, x001, taltwar, dd03l.
CLEAR: refe1, refe2, refe3.
CLEAR: cursor_t, saknr_skc1a, saknr_skc1c.
CLEAR: sd_ktopl, sd_saknr, sd_bukrs, sd_gjahr, sd_gsb_s. " EhP6 BSD
REFRESH: sd_ktopl, sd_saknr, sd_bukrs, sd_gjahr, sd_gsb_s. " EhP6 BSD
* BUFFER: SKB1.
CLEAR: cursor-skb1.
REFRESH: xskb1.
CLEAR: cursor-skc1a, cursor-skc1c, count.
REFRESH: k_saknr.
REFRESH: version.
REFRESH: sd_stype.
CLEAR: styp.
CLEAR: save_ktopl, save_saknr, save_bukrs, save_waers,
save_gjahr, save_gsber, save_belnr, save_buzei,
save_subrc, save_bstat, prev_bukrs, prev_belnr,
prev_gjahr.
CLEAR: xbkpf.
bukrs-flag = 'Y'.
CLEAR: glkey.
REFRESH: xx_rldnr.
REFRESH: kbtab, xskat, xska1, xglt0, xskc1a, yskc1a, xskc1c,
yskc1c, xbkpf.
REFRESH: ska1_where, ska1_fields,
skb1_where, skb1_fields,
bsis_where, bsis_fields,
bsisext_fields, bkpf_fields,
bseg_fields, gseg_fields,
test_fields.
REFRESH: faglfreesel_where.
CLEAR: ktopl_entry, bukrs_entry, char130,
sd_opopt, sd_apopt.
database = 'S'.
REFRESH: ledtab, f4tab, c001, xy_bukrs, zz_bukrs.
CLEAR: g_flg_xx_curtp.
* For reading from an archiv:
CLEAR: gd_count_arch.
* clear: gd_msg601_done.
PERFORM auth_check_for_blart_gsber CHANGING au_blart au_gsber.
* flex gl active ?
CALL FUNCTION 'FAGL_CHECK_GLFLEX_ACTIVE'
IMPORTING
e_glflex_active = g_glflex_active
EXCEPTIONS
error_in_setup = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
* ccodes active ?
IF g_glflex_active IS INITIAL.
CALL FUNCTION 'FAGL_BUKRS_ACTIVE_IN_CLIENT'
IMPORTING
e_glflex_active = g_glflex_act_cc.
ENDIF.
ldb_subrc = 0.
ENDFORM. "LDB_PROCESS_INIT
*---------------------------------------------------------------------*
* FORM LDB_PROCESS_CHECK_SELECTIONS *
*---------------------------------------------------------------------*
FORM ldb_process_check_selections
CHANGING ldb_subrc LIKE sy-subrc
ldb_msg LIKE symsg.
DATA: rc LIKE sy-subrc.
DATA: get1, get2, get3.
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = database
TABLES
xbukreis = sd_bukrs.
* Belegberechtigung auf Buchungskreisebene
READ TABLE get_events WITH KEY node = 'SKC1A'.
get1 = get_events-kind.
READ TABLE get_events WITH KEY node = 'SKC1C'.
get2 = get_events-kind.
READ TABLE get_events WITH KEY node = 'BSIS'.
get3 = get_events-kind.
IF get1 <> ' ' OR "Salden
get2 <> ' ' OR
get3 <> ' '. "Belege
CALL FUNCTION 'BUKRS_AUTHORITY_CHECK'
EXPORTING
xdatabase = 'B'
TABLES
xbukreis = sd_bukrs.
ENDIF.
DESCRIBE TABLE sd_saknr LINES sy-tfill.
IF sy-tfill > 0.
* Konvertierung der Kontonummer
* -----------------------------
LOOP AT sd_saknr.
PERFORM alphaformat(sapfs000)
USING sd_saknr-low sd_saknr-low.
PERFORM alphaformat(sapfs000)
USING sd_saknr-high sd_saknr-high.
MODIFY sd_saknr.
ENDLOOP.
ENDIF.
IF NOT ( xx_curtp IS INITIAL ).
*..... assume that a single currency type arrives
READ TABLE xx_curtp INDEX 1.
sd_curtp = xx_curtp-low.
IF sd_curtp = '00'.
*........ assume that GET SKC1C event has been choosen
*........ switch to curtp 10 for further process
sd_curtp = '10'.
ENDIF.
g_flg_xx_curtp = 'X'.
ENDIF.
IF sd_nooap IS INITIAL.
PERFORM op_or_ap_selection TABLES sd_augdt
CHANGING sd_stida sd_opopt sd_apopt.
ENDIF.
copy sd_gsb_b to sd_gsber.
LOOP AT sd_gsb_s.
sd_gsber = sd_gsb_s.
APPEND sd_gsber.
ENDLOOP.
* -----------------------------------------
* Berechtigungsprüfung Kontoart Sachkonten.
* -----------------------------------------
AUTHORITY-CHECK OBJECT 'F_BKPF_KOA'
ID 'KOART' FIELD 'S'
ID 'ACTVT' FIELD '03'.
IF sy-subrc <> 0.
* message e812 with text-008 'S'.
ldb_msg-msgty = 'E'.
ldb_msg-msgid = 'FR'.
ldb_msg-msgno = '812'.
ldb_msg-msgv1 = text-008.
ldb_msg-msgv2 = 'S'.
ldb_subrc = sy-subrc.
EXIT. " >>>>>>>>>>> E X I T >>>>>>>>>>>>>>>>>>>
ENDIF.
REFRESH: xy_bukrs.
CLEAR: xy_bukrs. "3.0F
CLEAR: prev_bukrs, prev_belnr, prev_gjahr. "3.0F
REFRESH: xx_rldnr.
CLEAR: xx_rldnr.
cursor_t = 0.
saknr_skc1a = space.
saknr_skc1c = space.
PERFORM fill_kbtab_and_ktopl TABLES sd_ktopl sd_bukrs kbtab xx_ktopl
USING '2' CHANGING rc ldb_msg.
IF rc NE 0.
ldb_subrc = rc.
EXIT. " >>>>>>>>>>> E X I T >>>>>>>>>>>>>>>>>>>
ENDIF.
CLEAR t004.
* Zulaessigkeit des Waehrungstyps für selektierte Buchungskreis
REFRESH xx_rldnr.
REFRESH c001.
xx_rldnr-option = 'EQ'. xx_rldnr-sign = 'I'.
LOOP AT kbtab.
IF sd_curtp = ' ' OR sd_curtp = '10'.
xx_rldnr-low = '00'.
COLLECT xx_rldnr.
EXIT.
ENDIF.
DATA: l_tp_auth TYPE c.
CALL FUNCTION 'TP_VALUATION_AUTHORITY'
EXPORTING
i_bukrs = kbtab-bukrs
i_cvtyp = sd_curtp
IMPORTING
e_xauth = l_tp_auth
EXCEPTIONS
kokrs_finding_error = 1
valutyp_finding_error = 2
insufficient_input_for_kokrs = 3
insufficient_input_for_valutyp = 4
activity_not_allowed = 5
OTHERS = 6.
IF sy-subrc <> 0
OR l_tp_auth IS INITIAL.
* message E826 with SD_CURTP KBTAB-BUKRS.
ldb_msg-msgty = 'E'.
ldb_msg-msgid = 'FR'.
ldb_msg-msgno = '826'.
ldb_msg-msgv1 = sd_curtp.
ldb_msg-msgv2 = kbtab-bukrs.
ldb_subrc = sy-subrc.
EXIT. " >>>>>>>>>>> E X I T >>>>>>>>>>>>>>>>>>>
ENDIF.
CALL FUNCTION 'FI_CURRENCY_INFORMATION'
EXPORTING
i_bukrs = kbtab-bukrs
IMPORTING
e_x001 = x001.
IF x001-curt2 <> sd_curtp AND x001-curt3 <> sd_curtp.
IF g_flg_xx_curtp IS INITIAL.
REFRESH c001.
* message e822 with sd_curtp kbtab-bukrs.
ldb_msg-msgty = 'E'.
ldb_msg-msgid = 'FR'.
ldb_msg-msgno = '822'.
ldb_msg-msgv1 = sd_curtp.
ldb_msg-msgv2 = kbtab-bukrs.
ldb_subrc = 4.
EXIT. " >>>>>>>>>>> E X I T >>>>>>>>>>>>>>>
ELSE.
DELETE kbtab.
CONTINUE.
ENDIF.
ELSE.
IF sd_curtp = '30'.
ledtab-rldnr = '00'.
ledtab-currnumber = '3'.
ELSE.
CALL FUNCTION 'G_GIVE_LEDGERS_FOR_GLT0'
EXPORTING
bukrs = kbtab-bukrs
curtp = sd_curtp
TABLES
ledtab = ledtab.
DESCRIBE TABLE ledtab LINES sy-tfill.
IF sy-tfill > 1.
REFRESH: f4tab.
LOOP AT ledtab.
CLEAR: f4tab.
f4tab-sel_line = ledtab-rldnr.
f4tab-sel_line+3 = ledtab-name.
APPEND f4tab.
ENDLOOP.
PERFORM ledger_waehlen USING '2' CHANGING rc ldb_msg.
IF sy-subrc = 0.
READ TABLE ledtab INDEX sy-tabix.
ELSE.
READ TABLE ledtab INDEX 1.
ENDIF.
IF rc NE 0.
ldb_subrc = rc.
EXIT. " >>>>>>>>>>> E X I T >>>>>>>>>>>>>>>>>>>
ENDIF.
ELSE.
READ TABLE ledtab INDEX 1.
ENDIF.
ENDIF.
CLEAR c001.
c001-bukrs = kbtab-bukrs.
IF x001-curt2 = sd_curtp.
c001-waers = x001-hwae2.
ELSEIF x001-curt3 = sd_curtp.
c001-waers = x001-hwae3.
ENDIF.
MOVE-CORRESPONDING ledtab TO c001.
APPEND c001.
xx_rldnr-low = ledtab-rldnr.
COLLECT xx_rldnr.
ENDIF.
ENDLOOP.
IF NOT ( g_glflex_active IS INITIAL ).
*.. flexGL is active
IF sd_rldnr[] IS INITIAL.
*.... set leading ledger
CALL FUNCTION 'FAGL_GET_LEADING_LEDGER'
IMPORTING
e_rldnr = g_lead_rldnr
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*.... set ledger
g_rldnr = g_lead_rldnr.
ELSE.
*.... ledger has been specified
READ TABLE sd_rldnr INDEX 1.
g_rldnr = sd_rldnr-low.
ENDIF.
*.. Check only, if documents or balances are requested "1531154
read table GET_EVENTS with key NODE = 'SKC1A'. "1531154
GET1 = GET_EVENTS-KIND. "1531154
read table GET_EVENTS with key NODE = 'SKC1C'. "1531154
GET2 = GET_EVENTS-KIND. "1531154
read table GET_EVENTS with key NODE = 'BSIS'. "1531154
GET3 = GET_EVENTS-KIND. "1531154
if GET1 <> ' ' or "Salden "1531154
GET2 <> ' ' or "1531154
GET3 <> ' '. "Belege "1531154
*.. authority check for rldnr "1531154
loop at kbtab. "1531154
call function 'FAGL_AUTHORITY_LEDGER' "1531154
EXPORTING "1531154
i_bukrs = kbtab-bukrs "1531154
i_rldnr = g_rldnr "1531154
i_actvt = '03'. "1531154
endloop. "1531154
endif. "1531154
ENDIF.
IF NOT ( g_rldnr IS INITIAL ).
*.. export ledger to memory for standard page header
*.. in program RSBTCHH0.
EXPORT fagl_bhdgd_rldnr FROM g_rldnr
TO MEMORY ID fagl_bhdgd_rldnr.
ENDIF.
* LDB_SUBRC = 0.
ENDFORM. "LDB_PROCESS_CHECK_SELECTIONS
***********************************************************************
* Zugriffsroutinen *
***********************************************************************
*--------------------------------------------------------------------*
* FORM PUT_SKA1 *
*--------------------------------------------------------------------*
FORM put_ska1.
DATA: ldummy.
DATA: ld_arch TYPE c,
ld_n TYPE i,
ld_mess_alv TYPE c. "957486
DATA: lt_ska1 TYPE STANDARD TABLE OF ska1 WITH HEADER LINE.
DATA: BEGIN OF lt_ska1_key OCCURS 0,
mandt LIKE ska1-mandt,
ktopl LIKE ska1-ktopl,
saknr LIKE ska1-saknr,
END OF lt_ska1_key.
DATA: BEGIN OF lt_ska1_key_help OCCURS 0,
mandt LIKE ska1-mandt,
ktopl LIKE ska1-ktopl,
saknr LIKE ska1-saknr,
END OF lt_ska1_key_help.
DATA: ld_lines TYPE i,
ld_div TYPE i,
ld_mod TYPE i,
ld_max TYPE i,
ld_min TYPE i VALUE 1,
ld_i TYPE i VALUE 1.
DATA: lc_pack TYPE i VALUE 1000.
PERFORM init_tables.
GET PARAMETER ID 'LDB_MESSAGE_IN_ALV' FIELD ld_mess_alv. "957486
IF ld_mess_alv IS INITIAL.
b0sg-xnbal = 'X'.
ENDIF. "957486
* use ALV for DB Messages
IF NOT b0sg-xnbal IS INITIAL.
CLEAR g_balv.
ENDIF.
* expiring currencies:
IF NOT b0sg-xcurr IS INITIAL.
CLEAR gd_expcur_flag.
ENDIF.
IF sd_stida IS INITIAL OR sd_stida = '00010101'
OR sd_stida = '99991231'.
gd_expcur_date = sy-datlo.
ELSE.
gd_expcur_date = sd_stida.
ENDIF.
* check if sd_saknr contains a worklist. if yes, make sure that
* WHERE statement doesn't get too long
DESCRIBE TABLE sd_saknr LINES ld_n .
IF ld_n > 0.
LOOP AT sd_saknr TRANSPORTING NO FIELDS
WHERE option NE 'EQ' OR
sign NE 'I'.
EXIT.
ENDLOOP.
ENDIF.
IF ( sy-subrc = 0 ) OR ld_n = 0. " no worklist
* 1. read key data of relevant sentences into table LT_SKA1_KEY
* 2. split LT_SKA1_KEY into LD_DIV packages of size LC_PACK
* 3. for each package read all the data from SKA1
SELECT mandt ktopl saknr FROM ska1 INTO TABLE lt_ska1_key
WHERE ktopl IN xx_ktopl
AND saknr IN sd_saknr
AND (ska1_where)
ORDER BY mandt ktopl saknr.
DESCRIBE TABLE lt_ska1_key LINES ld_lines.
ld_div = ld_lines DIV lc_pack.
ld_mod = ld_lines MOD lc_pack.
IF ld_mod <> 0.
ld_div = ld_div + 1.
ENDIF.
ld_max = lc_pack.
WHILE ld_i <= ld_div.
IF ld_i <> ld_div.
APPEND LINES OF lt_ska1_key
FROM ld_min TO ld_max TO lt_ska1_key_help.
ld_min = lc_pack * ld_i + 1 .
ld_max = lc_pack * ( ld_i + 1 ) .
ELSE.
APPEND LINES OF lt_ska1_key FROM ld_min TO lt_ska1_key_help.
ENDIF.
CLEAR lt_ska1.
REFRESH lt_ska1.
SELECT (ska1_fields) FROM ska1 "#EC CI_SGLSELECT
INTO CORRESPONDING FIELDS OF TABLE lt_ska1
FOR ALL ENTRIES IN lt_ska1_key_help
WHERE ktopl = lt_ska1_key_help-ktopl AND
saknr = lt_ska1_key_help-saknr.
SORT lt_ska1 BY mandt ktopl saknr.
LOOP AT lt_ska1.
xska1 = lt_ska1.
APPEND xska1.
k_saknr-low = xska1-saknr.
APPEND k_saknr.
count = count + 1.
IF count >= max_count.
* archive has to be read
gd_arch_done = 'N'.
PERFORM process_ska1.
REFRESH xska1.
REFRESH k_saknr.
count = 0.
ENDIF.
ENDLOOP.
REFRESH lt_ska1_key_help.
CLEAR lt_ska1_key_help.
ld_i = ld_i + 1.
ENDWHILE.
ELSE.
SELECT (ska1_fields)
FROM ska1 "#EC CI_SGLSELECT
INTO CORRESPONDING FIELDS OF TABLE lt_ska1
FOR ALL ENTRIES IN sd_saknr
WHERE ktopl IN xx_ktopl
AND saknr = sd_saknr-low
AND (ska1_where).
SORT lt_ska1 BY mandt ktopl saknr.
LOOP AT lt_ska1.
xska1 = lt_ska1.
APPEND xska1.
k_saknr-low = xska1-saknr.
APPEND k_saknr.
count = count + 1.
IF count >= max_count.
* archive has to be read
gd_arch_done = 'N'.
PERFORM process_ska1.
REFRESH xska1.
REFRESH k_saknr.
count = 0.
ENDIF.
ENDLOOP.
ENDIF.
* archive has to be read
gd_arch_done = 'N'.
PERFORM process_ska1.
IF gd_count_arch <> 0.
GET PARAMETER ID 'LDB_NO_DISPL_ARCH' FIELD ld_arch.
IF ld_arch IS INITIAL.
IF g_balv = 'X'.
IF sd_iarch IS INITIAL.
MESSAGE s600 WITH
gd_count_arch text-013 INTO ldummy.
CALL FUNCTION 'LDB_LOG_WRITE'.
ELSE.
MESSAGE i010 WITH
gd_count_arch INTO ldummy.
CALL FUNCTION 'LDB_LOG_WRITE'.
ENDIF.
ELSE.
IF sd_iarch IS INITIAL.
ULINE /(60).
WRITE: / sy-vline, gd_count_arch, text-013,
60 sy-vline.
ULINE /(60).
ELSE.
MESSAGE i010 WITH gd_count_arch.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "PUT_SKA1
*--------------------------------------------------------------------*
* FORM PROCESS_SKA1 *
*--------------------------------------------------------------------*
FORM process_ska1.
CLEAR ska1.
DESCRIBE TABLE k_saknr LINES count.
IF count GT 1.
count = max_count - count.
* Fuellen von K_SAKNR mit Dummyeintraegen um ein neues Parsen des
* SQL-Statements durch das DB-System zu vermeiden
DO count TIMES.
APPEND k_saknr.
ENDDO.
ENDIF.
PERFORM init_buffers.
LOOP AT xska1.
ska1 = xska1.
IF save_ktopl NE ska1-ktopl.
PERFORM kontenplanwechsel.
ENDIF.
* KEY-Felder sichern
save_ktopl = ska1-ktopl.
save_saknr = ska1-saknr.
* Sachkontenbezeichnung dazulesen
DO.
READ TABLE xskat INDEX cursor_t.
IF sy-subrc = 0.
skat = xskat.
ELSE.
CLEAR skat.
EXIT.
ENDIF.
IF skat-saknr < save_saknr.
cursor_t = cursor_t + 1.
ENDIF.
IF skat-saknr > save_saknr.
EXIT.
ENDIF.
IF skat-saknr = save_saknr.
cursor_t = cursor_t + 1.
EXIT.
ENDIF.
ENDDO.
IF skat-saknr NE save_saknr.
* In der Anmeldesprache ist keine Sachkontenbezeichung vorhanden
* Es werden die Texte der Pflegesprache gelesen.
CLEAR skat.
IF save_ktopl NE t004-ktopl.
SELECT SINGLE * FROM t004 WHERE ktopl = save_ktopl.
ENDIF.
SELECT SINGLE * FROM skat
WHERE spras = t004-dspra
AND ktopl = save_ktopl
AND saknr = save_saknr.
ENDIF.
PUT ska1.
CLEAR ska1.
ENDLOOP.
ENDFORM. "PROCESS_SKA1
*--------------------------------------------------------------------*
* FORM INIT_BUFFERS *
*--------------------------------------------------------------------*
FORM init_buffers.
REFRESH: xskb1, xskc1a, xskc1c, yskc1a, yskc1c.
REFRESH: ybsis, ybsas, ybkpf, ybseg.
cursor-skb1 = cursor-skc1a = cursor-skc1c = 0.
cursor-ybsas = 0.
saknr_skc1a = saknr_skc1c = space.
ENDFORM. "INIT_BUFFERS
*--------------------------------------------------------------------*
* FORM PUT_SKB1 *
*--------------------------------------------------------------------*
FORM put_skb1.
CLEAR skb1.
* Buchungskreiszuordnung für Kontenplan vorhanden ?
IF bukrs-flag = 'Y'. "Ja
IF cursor-skb1 = 0.
PERFORM update_xskb1.
ENDIF.
DO.
READ TABLE xskb1 INDEX cursor-skb1.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF save_saknr < xskb1-saknr. "Eintrag nicht enthalten
EXIT.
ELSEIF save_saknr > xskb1-saknr. "Weiterlesen
cursor-skb1 = cursor-skb1 + 1.
ELSE. "Treffer
skb1 = xskb1.
CALL FUNCTION 'READ_T001'
EXPORTING
xbukrs = skb1-bukrs
IMPORTING
struct = t001.
sp_waers = t001-waers. "euro
IF alcur EQ 'X'. PERFORM read_taltwar. ENDIF. "<<<< euro
IF sd_curtp = ' ' OR sd_curtp = '10'.
c001-rldnr = '00'.
ELSE.
READ TABLE c001 WITH KEY skb1-bukrs.
ENDIF.
save_bukrs = skb1-bukrs.
save_waers = skb1-waers.
PUT skb1.
CLEAR skb1.
cursor-skb1 = cursor-skb1 + 1.
ENDIF. "SAKNR
ENDDO.
ELSE. "Nein
* BUKRS-FLAG = 'Y'.
EXIT.
ENDIF.
ENDFORM. "PUT_SKB1
*--------------------------------------------------------------------*
* FORM PUT_SKC1A - Verarbeitung der HAUSWÄHRUNG - *
*--------------------------------------------------------------------*
FORM put_skc1a.
* if user is not allowed to see line items or balances
IF f_bkpf_bes_subrc <> 0.
EXIT.
ENDIF.
IF cursor-skc1a = 0.
PERFORM update_yskc1a.
ENDIF.
DO.
READ TABLE yskc1a INDEX cursor-skc1a.
IF sy-subrc NE 0.
EXIT.
ENDIF.
skc1a = yskc1a.
* Pruefen, ob der richtige Satz gefunden wurde.
* PUT muss dabei am Ende stehen, da Felder SKC1A durch Put
* zerstoert werden.
IF skc1a-saknr > save_saknr.
EXIT.
ENDIF.
IF skc1a-saknr < save_saknr.
cursor-skc1a = cursor-skc1a + 1. "Ueberlesen
ENDIF.
IF skc1a-saknr = save_saknr.
IF skc1a-bukrs > save_bukrs.
EXIT.
ENDIF.
IF skc1a-bukrs < save_bukrs.
cursor-skc1a = cursor-skc1a + 1. "Ueberlesen
ENDIF.
IF skc1a-bukrs = save_bukrs.
IF skc1a-rldnr > c001-rldnr.
EXIT.
ENDIF.
IF skc1a-rldnr < c001-rldnr.
cursor-skc1a = cursor-skc1a + 1. "Ueberlesen
ENDIF.
IF skc1a-rldnr = c001-rldnr.
IF sd_curtp = ' ' OR sd_curtp = '10'.
skc1a-hwaer = t001-waers.
ELSE.
IF c001-bukrs <> skc1a-bukrs.
READ TABLE c001 WITH KEY skc1a-bukrs.
ENDIF.
skc1a-hwaer = c001-waers.
ENDIF.
IF sd_curtp = ' '.
skc1a-curtp = '10'.
ELSE.
skc1a-curtp = sd_curtp.
ENDIF.
PUT skc1a.
cursor-skc1a = cursor-skc1a + 1.
ENDIF.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "PUT_SKC1A
*--------------------------------------------------------------------*
* FORM PUT_SKC1C -Verarbeitung Verkehrszahlen je Währung- *
*--------------------------------------------------------------------*
FORM put_skc1c.
* if user is not allowed to see line items or balances
IF f_bkpf_bes_subrc <> 0.
EXIT.
ENDIF.
IF cursor-skc1c = 0.
PERFORM update_yskc1c.
ENDIF.
DO.
READ TABLE yskc1c INDEX cursor-skc1c.
IF sy-subrc NE 0.
EXIT.
ENDIF.
skc1c = yskc1c.
* Pruefen, ob der richtige Satz gefunden wurde.
* PUT muss dabei am Ende stehen, da Felder SKC1A durch Put
* zerstoert werden.
IF skc1c-saknr > save_saknr.
EXIT.
ENDIF.
IF skc1c-saknr < save_saknr.
cursor-skc1c = cursor-skc1c + 1. "Ueberlesen
ENDIF.
IF skc1c-saknr = save_saknr.
IF skc1c-bukrs > save_bukrs.
EXIT.
ENDIF.
IF skc1c-bukrs < save_bukrs.
cursor-skc1c = cursor-skc1c + 1. "Ueberlesen
ENDIF.
IF skc1c-bukrs = save_bukrs.
IF skc1c-rldnr > c001-rldnr.
EXIT.
ENDIF.
IF skc1c-rldnr < c001-rldnr.
cursor-skc1c = cursor-skc1c + 1. "Ueberlesen
ENDIF.
IF skc1c-rldnr = c001-rldnr.
IF sd_curtp = ' ' OR sd_curtp = '10'.
skc1c-hwaer = t001-waers.
ELSE.
IF c001-bukrs <> skc1c-bukrs.
READ TABLE c001 WITH KEY skc1c-bukrs.
ENDIF.
skc1c-hwaer = c001-waers.
ENDIF.
IF sd_curtp = ' '.
skc1c-curtp = '10'.
ELSE.
skc1c-curtp = sd_curtp.
ENDIF.
PUT skc1c.
cursor-skc1c = cursor-skc1c + 1.
ENDIF.
ENDIF.
ENDIF.
ENDDO.
ENDFORM. "PUT_SKC1C
*--------------------------------------------------------------------*
* FORM PUT_BSIS *
*--------------------------------------------------------------------*
FORM put_bsis.
DATA: ld_arch TYPE boole_d.
* if user is not allowed to see line items or balances
IF f_bkpf_bes_subrc <> 0.
EXIT.
ENDIF.
IF sd_usear IS INITIAL AND sd_usedb IS INITIAL.
sd_usedb = 'X'.
ENDIF.
IF sd_usear = 'X'.
IF gd_arch_done EQ 'N'.
PERFORM read_archive.
gd_arch_done = 'Y'.
gd_read_memo_done = 'N'.
ENDIF.
IF NOT ybsas[] IS INITIAL.
LOOP AT ybsas INTO bsis "#EC ENHOK
WHERE hkont = save_saknr
AND bukrs = save_bukrs.
ld_arch = 'X'.
PERFORM process_bsis USING ld_arch.
ENDLOOP.
ENDIF.
ENDIF.
IF NOT sd_usedb IS INITIAL.
IF b0sg-xstan = 'X' OR b0sg-xstas = 'X'. ">>>> normal documents >>>>>
save_bstat = ' '.
*----------------------------------------------------------------------*
* 1 Variante: Es sind offene Posten zu einem bestimmten Stichtag *
* gewuenscht. *
*----------------------------------------------------------------------*
IF sd_opopt EQ 'X' AND sd_apopt NE 'X'.
SELECT (bsis_fields) FROM bsis INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
* AND GJAHR IN SD_GJAHR
AND budat IN sd_budat
AND budat LE sd_stida
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
IF b0sg-xnopl = 'X'.
EXIT.
ENDIF.
SELECT (bsis_fields) FROM bsas INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
* AND GJAHR IN SD_GJAHR
AND budat IN sd_budat
AND budat LE sd_stida
AND augdt GT sd_stida
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
ENDIF.
*----------------------------------------------------------------------*
* 2 Variante: Es sind ausgeglichene Posten zu einem bestimmten Aus- *
* gleichsdatum (Intervall) gewuenscht. *
*----------------------------------------------------------------------*
IF sd_opopt NE 'X' AND sd_apopt EQ 'X'.
SELECT (bsis_fields) FROM bsas INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
* AND GJAHR IN SD_GJAHR
AND budat IN sd_budat
AND augdt IN sd_augdt
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
ENDIF.
*----------------------------------------------------------------------*
* 3 Variante: Variante 1 + 2 sind gleichzeitig gewuenscht *
*----------------------------------------------------------------------*
IF sd_opopt EQ 'X' AND sd_apopt EQ 'X'.
SELECT (bsis_fields) FROM bsis INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
* AND GJAHR IN SD_GJAHR
AND budat IN sd_budat
AND budat LE sd_stida
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
SELECT (bsis_fields) FROM bsas INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
* AND GJAHR IN SD_GJAHR
AND budat IN sd_budat
AND budat LE sd_stida
* AND AUGDT GT SD_STIDA
* OR AUGDT IN SD_AUGDT
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CHECK bsis-augdt GT sd_stida OR
bsis-augdt IN sd_augdt.
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
ENDIF.
*----------------------------------------------------------------------*
* 4 Variante: aus RFITEMGL: AP mit Stichtag und Ausgleichszeitraum *
*----------------------------------------------------------------------*
IF sd_opopt NE 'X' AND sd_apopt NE 'X'.
SELECT (bsis_fields) FROM bsas INTO CORRESPONDING FIELDS OF bsis
WHERE bukrs EQ save_bukrs
AND hkont EQ save_saknr
AND budat IN sd_budat
AND augdt BETWEEN '00010101'
AND '99991231'
AND augdt GT sd_stida
AND augdt IN sd_augdt
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
AND vbund IN sd_vbund
AND bschl IN sd_bschl
AND kostl IN sd_kostl
AND werks IN sd_werks
AND shkzg IN sd_shkzg
AND (bsis_where).
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
ENDIF. " Variante 4
ENDIF. "<<<<<<<<<<<<<<<<<<<<<<<<<<< normal documents <<<<<<<<<<<<<<<<<
IF b0sg-xstav = 'X'.
* vorerfasste Belege ueber DB-Index nach SAKNR
save_bstat = 'V'.
* modification of WHERE clause: remove AUGDT, AUGBL
REFRESH: vbsegs_where.
vbsegs_where[] = bsis_where[].
PERFORM build_vbseg_where(fi_ldb_util) TABLES vbsegs_where
USING 'AUGDT'.
PERFORM build_vbseg_where(fi_ldb_util) TABLES vbsegs_where
USING 'AUGBL'.
PERFORM modify_vbseg_where(fi_ldb_util) TABLES vbsegs_where
USING 'PROJK' 'PS_PSP_PNR'.
PERFORM modify_vbseg_where_hkont(fi_ldb_util) TABLES vbsegs_where.
* BSTAT W oder Z sind nicht im VBKPF
SELECT * FROM v_vbsegs WHERE saknr = save_saknr
AND bukrs = save_bukrs
AND gjahr BETWEEN '0001' AND '9999'
AND budat IN sd_budat
AND budat LE sd_stida
AND zuonr IN sd_zuonr
AND gsber IN sd_gsber
* and blart in sd_blart "<<<< au40
AND bschl IN sd_bschl
AND shkzg IN sd_shkzg
AND (vbsegs_where).
CLEAR bsis.
MOVE-CORRESPONDING v_vbsegs TO bsis.
bsis-projk = v_vbsegs-ps_psp_pnr.
bsis-hkont = v_vbsegs-saknr.
CLEAR ld_arch.
PERFORM process_bsis USING ld_arch.
ENDSELECT.
ENDIF.
ENDIF. " sd_usedb
ENDFORM. "PUT_BSIS
***********************************************************************
* put_bsisext *
* Erweiterungsteil *
***********************************************************************
FORM put_bsisext.
MOVE-CORRESPONDING bsis TO bsisext.
MOVE-CORRESPONDING bsega TO bsisext.
PUT bsisext.
ENDFORM. "PUT_BSISEXT
"PUT_BSISEXT
*&---------------------------------------------------------------------*
*& Form PUT_faglfreesel
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM put_faglfreesel.
PUT faglfreesel.
ENDFORM. "PUT_FAGLFREESEL
*--------------------------------------------------------------------*
* FORM PUT_BKPF *
*--------------------------------------------------------------------*
FORM put_bkpf.
DATA: ltext TYPE text.
DATA: ldummy.
TYPES: BEGIN OF extkeybkpf,
bukrs LIKE bkpf-bukrs,
belnr LIKE bkpf-belnr,
gjahr LIKE bkpf-gjahr,
count TYPE i,
END OF extkeybkpf.
DATA: lt_save_extkeybkpf TYPE TABLE OF extkeybkpf,
ld_save_extkeybkpf TYPE extkeybkpf.
DATA: ld_save_bkpf VALUE ' ',
ld_read_bkpf VALUE 'L'. " Possible: Last (L),
" Table (T), Database (D)
STATICS: x_bsis_read TYPE c.
DATA: l_no_bkpf TYPE boolean VALUE ' '.
* Set standard Data for optimized access to BKPF.
gd_opttime_bkpf = ' '. " Previous BKPF lines are saved.
gd_optmemo_bkpf = 'X'. " Only BKPF lines which appears at least
gd_maxlines = '2'. " gd_maxlines times are saved (reduces
" CPU performance, since parts of BSIS
" have to be read once)
IF sd_usear = 'X'.
READ TABLE ybkpf WITH KEY bukrs = save_bukrs
belnr = save_belnr
gjahr = save_gjahr
INTO bkpf.
IF sy-subrc = 0.
save_bstat = bkpf-bstat.
* expiring currencies:
gd_waers_save = bkpf-waers.
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bkpf USING 'SAPDBSDF'
gd_expcur_date
CHANGING bkpf.
ENDIF.
PUT bkpf.
ELSE.
* if g_balv = 'X'.
* concatenate text-007 save_bukrs into ltext.
* message s600 with
* ltext
* text-002 save_belnr
* text-003 into ldummy.
* call function 'LDB_LOG_WRITE'.
* else.
*
** MESSAGE I803 WITH SAVE_BUKRS SAVE_BELNR.
* WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
* endif.
l_no_bkpf = 'X'.
ENDIF.
ENDIF.
IF sd_usedb = 'X'.
IF bsis-xarch = 'X'.
IF sd_usear = 'X'.
IF l_no_bkpf = 'X'.
IF g_balv = 'X'.
CONCATENATE text-007 save_bukrs INTO ltext.
MESSAGE s600 WITH
ltext
text-002 save_belnr
text-003 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
ENDIF.
ENDIF.
ELSE.
IF g_balv = 'X'.
CONCATENATE text-007 save_bukrs INTO ltext.
MESSAGE s600 WITH
ltext
text-002 save_belnr
text-003 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
ENDIF.
ENDIF.
EXIT.
ENDIF.
IF save_bstat <> 'V'.
* 1.try to use data from the last BKPF call.
ld_read_bkpf = 'L'.
IF save_bukrs NE xbkpf-bukrs OR
save_belnr NE xbkpf-belnr OR
save_gjahr NE xbkpf-gjahr.
* 2.If data from the last call can not be used
* try to use data from table gt_save_bkpf
* where (some) previous BKPF-Lines are stored.
ld_read_bkpf = 'D'.
IF gd_opttime_bkpf = 'X'.
READ TABLE gt_save_bkpf
WITH TABLE KEY bukrs = save_bukrs
belnr = save_belnr
gjahr = save_gjahr
INTO gd_save_bkpf .
* If appropriate previous BKPF line is found
* in gt_save_bkpf it will be used later.
IF sy-subrc = 0.
ld_read_bkpf = 'T'.
* If no previous BKPF line is found: Read BKPF entery
* and save it if required.
ELSE.
ld_save_bkpf = 'X'.
IF gd_optmemo_bkpf = 'X'.
* If memory optimization is required:
* Detecting the enteries of BKPF where saving makes sence.
IF x_bsis_read IS INITIAL.
SELECT bukrs belnr gjahr COUNT(*)
FROM bsis
INTO TABLE lt_save_extkeybkpf
WHERE bukrs IN sd_bukrs
AND hkont IN sd_saknr
AND zuonr IN sd_zuonr
AND gjahr IN sd_gjahr "war auskomm. in put_bsis
GROUP BY bukrs belnr gjahr.
LOOP AT lt_save_extkeybkpf INTO ld_save_extkeybkpf.
IF ld_save_extkeybkpf-count GE gd_maxlines.
gd_save_keybkpf-bukrs = ld_save_extkeybkpf-bukrs.
gd_save_keybkpf-belnr = ld_save_extkeybkpf-belnr.
gd_save_keybkpf-gjahr = ld_save_extkeybkpf-gjahr .
INSERT gd_save_keybkpf INTO TABLE gt_save_keybkpf.
ENDIF.
ENDLOOP.
x_bsis_read = 'X'.
ENDIF.
READ TABLE gt_save_keybkpf
WITH TABLE KEY bukrs = save_bukrs
belnr = save_belnr
gjahr = save_gjahr
TRANSPORTING NO FIELDS.
* If entery is existent the corresponding BKPF line
* appears at least gd_maxline times, but is not saved
* in gt_save_bkpf yet.
IF sy-subrc <> 0.
ld_save_bkpf = ' '.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
* Reading the required data from:
* Database (D), Table with previous entries (T) or last BKPF set (L).
CASE ld_read_bkpf.
WHEN 'D'.
CLEAR xbkpf.
REFRESH xbkpf.
SELECT SINGLE (bkpf_fields) FROM bkpf
INTO CORRESPONDING FIELDS OF xbkpf
WHERE bukrs = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr.
IF sy-subrc = 0.
MOVE-CORRESPONDING xbkpf TO bkpf.
save_bstat = bkpf-bstat.
* expiring currencies:
gd_waers_save = bkpf-waers.
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bkpf USING 'SAPDBSDF'
gd_expcur_date
CHANGING bkpf.
MOVE-CORRESPONDING bkpf TO xbkpf.
ENDIF.
ELSE.
CLEAR bkpf.
IF g_balv = 'X'.
CONCATENATE text-007 save_bukrs INTO ltext.
MESSAGE s600 WITH
ltext
text-002 save_belnr
text-003 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-007, save_bukrs,text-002, save_belnr, text-003.
ENDIF.
ENDIF.
l_no_bkpf = ' '.
* BKPF item had to be read from database but is stored in an
* internal table (gt_save_bkpf) for later use.
IF ld_save_bkpf = 'X'.
INSERT bkpf INTO TABLE gt_save_bkpf.
ENDIF.
WHEN 'T'.
MOVE-CORRESPONDING gd_save_bkpf TO bkpf.
MOVE-CORRESPONDING gd_save_bkpf TO xbkpf.
l_no_bkpf = ' '.
WHEN 'L'.
MOVE-CORRESPONDING xbkpf TO bkpf.
l_no_bkpf = ' '.
ENDCASE.
PUT bkpf.
* Parked items.
ELSE.
MOVE-CORRESPONDING v_vbsegs TO bkpf.
* expiring currencies:
gd_waers_save = bkpf-waers.
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bkpf USING 'SAPDBSDF'
gd_expcur_date
CHANGING bkpf.
ENDIF.
PUT bkpf.
ENDIF.
ENDIF.
IF l_no_bkpf = 'X'.
IF g_balv = 'X'.
CONCATENATE text-007 save_bukrs INTO ltext.
MESSAGE s600 WITH
ltext
text-002 save_belnr
text-003 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
ENDIF.
ENDIF.
ENDFORM. "PUT_BKPF
*--------------------------------------------------------------------*
* FORM PUT_BSEG *
*--------------------------------------------------------------------*
FORM put_bseg.
DATA: ltext TYPE text.
DATA: ldummy.
DATA: l_no_bseg TYPE boolean VALUE ' '.
IF sd_usear = 'X'.
READ TABLE ybseg WITH KEY bukrs = save_bukrs
belnr = save_belnr
buzei = save_buzei
gjahr = save_gjahr
INTO bseg.
IF sy-subrc NE 0.
* if g_balv = 'X'.
* concatenate text-004 save_belnr into ltext.
* message s600 with
* ltext
* text-005 save_bukrs
* text-006 into ldummy.
* call function 'LDB_LOG_WRITE'.
* else.
* WRITE: text-004, save_belnr, text-005, save_bukrs, text-006.
* endif.
l_no_bseg ='X'.
ELSE.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING bseg.
ENDIF.
MOVE-CORRESPONDING bseg TO bsegh.
PERFORM got_bsega(sapbsega).
* Euro
IF alcur EQ 'X'.
PERFORM convert_alt USING 'BSEG'.
ENDIF.
PUT bseg.
CLEAR bseg.
ENDIF.
ENDIF. "sd_usear
IF sd_usedb = 'X'.
IF save_bstat <> 'V'.
SELECT SINGLE (bseg_fields) FROM bseg
INTO CORRESPONDING FIELDS OF bseg
WHERE bukrs = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr
AND buzei = save_buzei.
IF sy-subrc NE 0.
CLEAR bseg.
IF sd_usear = 'X'.
IF l_no_bseg = 'X'.
IF g_balv = 'X'.
CONCATENATE text-004 save_belnr INTO ltext.
MESSAGE s600 WITH
ltext
text-005 save_bukrs
text-006 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-004, save_belnr, text-005, save_bukrs,
text-006.
ENDIF.
ENDIF.
ELSE.
IF g_balv = 'X'.
CONCATENATE text-004 save_belnr INTO ltext.
MESSAGE s600 WITH
ltext
text-005 save_bukrs
text-006 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-004, save_belnr, text-005, save_bukrs,
text-006.
ENDIF.
ENDIF.
EXIT.
ENDIF.
l_no_bseg = ' '.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING bseg.
ENDIF.
* Belegpositionsanhang
* --------------------
MOVE-CORRESPONDING bseg TO bsegh.
PERFORM got_bsega(sapbsega).
* CPD-DATEN
* ---------
IF bseg-xcpdd EQ 'X'.
SELECT SINGLE * FROM bsec
WHERE bukrs = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr
AND buzei = save_buzei.
IF sy-subrc NE 0.
CLEAR bsec.
ENDIF.
ELSE.
CLEAR bsec.
ENDIF.
* Wechseldaten
* ------------
IF bseg-umsks EQ 'W'.
SELECT SINGLE * FROM bsed
WHERE bukrs = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr
AND buzei = save_buzei.
IF sy-subrc NE 0.
CLEAR bsed.
ENDIF.
ELSE.
CLEAR bsed.
ENDIF.
IF alcur EQ 'X'. PERFORM convert_alt USING 'BSEG'. ENDIF. "euro
PUT bseg.
CLEAR bseg.
* vorfasste Belege
ELSE.
CLEAR bseg.
MOVE-CORRESPONDING v_vbsegs TO bseg.
bseg-hkont = v_vbsegs-saknr.
bseg-koart = 'S'.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING bseg.
ENDIF.
* Belegpositionsanhang
IF bseg-zfbdt = '00000000'.
bseg-zfbdt = bkpf-bldat.
ENDIF.
MOVE-CORRESPONDING bseg TO bsegh.
PERFORM got_bsega(sapbsega).
* CPD-Daten
CLEAR bsec.
IF bseg-xcpdd EQ 'X'.
SELECT SINGLE * FROM vbsec
WHERE ausbk = save_bukrs
AND belnr = save_belnr
AND buzei = save_buzei
AND gjahr = save_gjahr.
IF sy-subrc = 0.
MOVE-CORRESPONDING vbsec TO bsec.
ENDIF.
ENDIF.
IF alcur EQ 'X'. PERFORM convert_alt USING 'BSEG'. ENDIF. "euro
PUT bseg.
ENDIF.
ENDIF.
IF l_no_bseg = 'X' .
IF g_balv = 'X'.
CONCATENATE text-004 save_belnr INTO ltext.
MESSAGE s600 WITH
ltext
text-005 save_bukrs
text-006 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-004, save_belnr, text-005, save_bukrs,
text-006.
ENDIF.
ENDIF.
ENDFORM. "PUT_BSEG
*----------------------------------------------------------------------*
* FORM PUT_GSEG *
* Gegenpositionsverarbeitung *
*----------------------------------------------------------------------*
FORM put_gseg.
DATA: ltext TYPE text.
DATA: ldummy.
IF save_bstat <> 'V'.
SELECT (gseg_fields) FROM bseg
INTO CORRESPONDING FIELDS OF gseg
WHERE bukrs = save_bukrs
AND belnr = save_belnr
AND buzei NE save_buzei
AND gjahr = save_gjahr.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_gseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING gseg.
ENDIF.
* Belegpositionsanhang
* --------------------
MOVE-CORRESPONDING gseg TO bsegh.
PERFORM got_gsega(sapbsega).
IF alcur EQ 'X'. PERFORM convert_alt USING 'GSEG'. ENDIF. "euro
PUT gseg.
CLEAR gseg.
ENDSELECT.
IF sy-subrc NE 0.
* MESSAGE I807 WITH SAVE_BUKRS SAVE_BELNR SAVE_BUZEI.
IF g_balv = 'X'.
CONCATENATE text-004 save_belnr INTO ltext.
MESSAGE s600 WITH ltext
text-005 save_bukrs
text-006 INTO ldummy.
IF count_ldb_log LT '999999'. "1344830
count_ldb_log = count_ldb_log + 1. "1344830
CALL FUNCTION 'LDB_LOG_WRITE'. "1344830
ENDIF. "1344830
ELSE.
WRITE: text-004, save_belnr, text-005, save_bukrs, text-006.
ENDIF.
ENDIF.
* vorerfasste Belege
ELSE.
SELECT * FROM vbsegs WHERE
ausbk = save_bukrs
AND belnr = save_belnr
AND buzei NE save_buzei
AND gjahr = save_gjahr.
CLEAR gseg.
MOVE-CORRESPONDING vbsegs TO gseg.
gseg-projk = vbsegs-ps_psp_pnr. "1090412
gseg-hkont = vbsegs-saknr.
gseg-koart = 'S'.
IF bseg-zfbdt = '00000000'.
bseg-zfbdt = bkpf-bldat.
ENDIF.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_gseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING gseg.
ENDIF.
MOVE-CORRESPONDING gseg TO bsegh.
PERFORM got_gsega(sapbsega).
IF alcur EQ 'X'. PERFORM convert_alt USING 'GSEG'. ENDIF. "euro
PUT gseg.
ENDSELECT.
* if vbkpf-koars ca 'A'. "<<<< 31H
IF v_vbsegs-koars CA 'A'. "<<<< 31H
SELECT * FROM vbsega WHERE
ausbk = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr.
CLEAR gseg.
MOVE-CORRESPONDING vbsega TO gseg.
gseg-projk = vbsega-ps_psp_pnr. "1090412
gseg-koart = 'A'.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_gseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING gseg.
ENDIF.
MOVE-CORRESPONDING gseg TO bsegh.
PERFORM got_gsega(sapbsega).
IF alcur EQ 'X'. PERFORM convert_alt USING 'GSEG'. ENDIF. "euro
PUT gseg.
ENDSELECT.
ENDIF.
* if vbkpf-koars ca 'K'. "<<<< 31H
IF v_vbsegs-koars CA 'K'. "<<<< 31H
SELECT * FROM vbsegk WHERE
ausbk = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr.
CLEAR gseg.
MOVE-CORRESPONDING vbsegk TO gseg.
gseg-koart = 'K'.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_gseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING gseg.
ENDIF.
MOVE-CORRESPONDING gseg TO bsegh.
PERFORM got_gsega(sapbsega).
IF alcur EQ 'X'. PERFORM convert_alt USING 'GSEG'. ENDIF. "euro
PUT gseg.
ENDSELECT.
ENDIF.
* if vbkpf-koars ca 'D'. "<<<< 31H
IF v_vbsegs-koars CA 'D'. "<<<< 31H
SELECT * FROM vbsegd WHERE
ausbk = save_bukrs
AND belnr = save_belnr
AND gjahr = save_gjahr.
CLEAR gseg.
* move-corresponding vbsega to gseg. "<<<< 31H
MOVE-CORRESPONDING vbsegd TO gseg. "<<<< 31H
gseg-koart = 'D'.
* expiring currencies:
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_gseg USING 'SAPDBSDF'
t001-waers
gd_waers_save
gd_expcur_date
CHANGING gseg.
ENDIF.
MOVE-CORRESPONDING gseg TO bsegh.
PERFORM got_gsega(sapbsega).
IF alcur EQ 'X'. PERFORM convert_alt USING 'GSEG'. ENDIF. "euro
PUT gseg.
ENDSELECT.
ENDIF.
ENDIF.
ENDFORM. "PUT_GSEG
*----------------------------------------------------------------------*
* FORM PUT_SDF_MATCHCODE *
* Matchcodeverarbeitung *
*----------------------------------------------------------------------*
FORM put_sdf_sp.
DATA: ldummy.
DATA yska1 LIKE ska1 OCCURS 0 WITH HEADER LINE.
PERFORM init_tables.
* expiring currencies:
IF NOT b0sg-xcurr IS INITIAL.
CLEAR gd_expcur_flag.
ENDIF.
IF sd_stida IS INITIAL OR sd_stida = '00010101'
OR sd_stida = '99991231'.
gd_expcur_date = sy-datlo.
ELSE.
gd_expcur_date = sd_stida.
ENDIF.
READ TABLE sp_tables WITH KEY 'SKB1'.
IF sp_tables-supplied = 'X'.
copy sd_bukrs to zz_bukrs.
REFRESH sd_bukrs.
sd_bukrs-sign = 'I'. sd_bukrs-option = 'EQ'.
LOOP AT sdf_sp.
* if sdf_sp-skb1_bukrs in zz_bukrs.
* sd_bukrs-low = sdf_sp-skb1_bukrs.
IF sdf_sp-bukrs IN zz_bukrs. "40sp
sd_bukrs-low = sdf_sp-bukrs. "40sp
COLLECT sd_bukrs.
ENDIF.
ENDLOOP.
ENDIF.
READ TABLE sdf_sp INDEX 1.
IF sy-subrc <> 0.
EXIT.
ENDIF.
* if sdf_sp-ska1_ktopl <> space and sdf_sp-ska1_saknr <> space.
IF sdf_sp-ktopl <> space AND sdf_sp-saknr <> space. "40sp
SELECT (ska1_fields) FROM ska1 INTO "#EC CI_SGLSELECT
CORRESPONDING FIELDS OF TABLE yska1
FOR ALL ENTRIES IN sdf_sp
WHERE ktopl IN xx_ktopl
AND saknr IN sd_saknr
* and ktopl = sdf_sp-ska1_ktopl
* and saknr = sdf_sp-ska1_saknr
AND ktopl = sdf_sp-ktopl "40sp
AND saknr = sdf_sp-saknr "40sp
AND (ska1_where).
* elseif sdf_sp-ska1_ktopl <> space and sdf_sp-ska1_saknr = space.
ELSEIF sdf_sp-ktopl <> space AND sdf_sp-saknr = space. "40sp
SELECT (ska1_fields) FROM ska1 INTO "#EC CI_SGLSELECT
CORRESPONDING FIELDS OF TABLE yska1
FOR ALL ENTRIES IN sdf_sp
WHERE ktopl IN xx_ktopl
AND saknr IN sd_saknr
* and ktopl = sdf_sp-ska1_ktopl
AND ktopl = sdf_sp-ktopl "40sp
AND (ska1_where).
* elseif sdf_sp-ska1_ktopl = space and sdf_sp-ska1_saknr <> space.
ELSEIF sdf_sp-ktopl = space AND sdf_sp-saknr <> space. "40sp
SELECT (ska1_fields) FROM ska1 INTO "#EC CI_SGLSELECT
CORRESPONDING FIELDS OF TABLE yska1
FOR ALL ENTRIES IN sdf_sp
WHERE ktopl IN xx_ktopl
AND saknr IN sd_saknr
* and saknr = sdf_sp-ska1_saknr
AND saknr = sdf_sp-saknr "40sp
AND (ska1_where).
ELSE.
EXIT.
ENDIF.
SORT yska1 BY ktopl saknr.
LOOP AT yska1.
xska1 = yska1.
APPEND xska1.
k_saknr-low = xska1-saknr.
APPEND k_saknr.
count = count + 1.
IF count >= max_count.
gd_arch_done = 'N'. "1532097
PERFORM process_ska1.
REFRESH xska1.
REFRESH k_saknr.
count = 0.
ENDIF.
ENDLOOP.
PERFORM process_ska1.
IF gd_count_arch <> 0.
IF g_balv = 'X'.
IF sd_iarch IS INITIAL.
MESSAGE s600 WITH
gd_count_arch text-013 INTO ldummy.
CALL FUNCTION 'LDB_LOG_WRITE'.
ELSE.
MESSAGE i010 WITH gd_count_arch INTO ldummy.
CALL FUNCTION 'LDB_LOG_WRITE'.
ENDIF.
ELSE.
IF sd_iarch IS INITIAL.
ULINE /(60).
WRITE: / sy-vline, gd_count_arch, text-013,
60 sy-vline.
ULINE /(60).
ELSE.
MESSAGE i010 WITH gd_count_arch.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "PUT_SDF_SP
*eject.
***********************************************************************
* Unterroutinen *
***********************************************************************
*---------------------------------------------------------------------*
* FORM KONTENPLANWECHSEL *
* Alle Buchungskreise die den neuen Kontenplan verwenden werden*
* über die Tabelle KBTAB ermittelt und in der Tabelle XX_BUKRS *
* abgelegt. *
*---------------------------------------------------------------------*
FORM kontenplanwechsel.
DATA: ld_lines TYPE i.
* REFRESH XX_BUKRS. "30F
REFRESH xy_bukrs. "30F
LOOP AT kbtab
WHERE ktopl = ska1-ktopl
AND bukrs IN sd_bukrs.
* XX_BUKRS-SIGN = 'I'. "30F
* XX_BUKRS-OPTION = 'EQ'. "
* XX_BUKRS-LOW = KBTAB-BUKRS. "
* APPEND XX_BUKRS. "
xy_bukrs = kbtab-bukrs. "
APPEND xy_bukrs. "30F
ENDLOOP.
IF sy-subrc NE 0.
* Buchungskreiszuordnung für Kontenplan vorhanden ?
bukrs-flag = 'N'. "Nein
ELSE.
bukrs-flag = 'Y'. "Ja
ENDIF.
* Immer ueber Index 2 (SAKNR,BUKRS) lesen wegen 'order by'.
* READ TABLE XX_BUKRS INDEX 2. "30F
* IF SY-SUBRC = 0.
* LOOP AT XX_BUKRS
* WHERE OPTION NE 'EQ'.
* ENDLOOP.
* IF SY-SUBRC NE 0.
* READ TABLE XX_BUKRS INDEX 2.
* IF XX_BUKRS-OPTION = 'EQ'.
* XX_BUKRS-OPTION = 'BT'. "erzwingt lesen ueber Index 2
* XX_BUKRS-HIGH = XX_BUKRS-LOW.
* MODIFY XX_BUKRS INDEX 2.
* ENDIF.
* ENDIF.
* ENDIF. "30F
* Pro Kontenplan werden die Sachkontenbezeichungen gelesen.
REFRESH xskat.
DESCRIBE TABLE sd_saknr LINES ld_lines.
IF ld_lines > 0.
LOOP AT sd_saknr TRANSPORTING NO FIELDS
WHERE option NE 'EQ' OR
sign NE 'I'.
EXIT.
ENDLOOP.
ENDIF.
IF ( sy-subrc = 0 ) OR ld_lines = 0.
SELECT * FROM skat "#EC CI_SGLSELECT
APPENDING TABLE xskat
WHERE spras = sy-langu
AND ktopl = ska1-ktopl
AND saknr IN sd_saknr.
ELSE.
SELECT * FROM skat "#EC CI_SGLSELECT
INTO CORRESPONDING FIELDS OF xskat
FOR ALL ENTRIES IN sd_saknr
WHERE spras = sy-langu
AND ktopl = ska1-ktopl
AND saknr = sd_saknr-low.
APPEND xskat.
ENDSELECT.
ENDIF.
SORT xskat BY mandt saknr.
cursor_t = 1.
* Interne Tabellen und Felder und Pointer zuruecksetzen.
REFRESH: xskb1, xskc1a, xskc1c, yskc1a, yskc1c. "886527
cursor-skb1 = cursor-skc1a = cursor-skc1c = 0. "886527
saknr_skc1a = saknr_skc1c = space. "886527
* PERFORM init_buffers. "886527
ENDFORM. "KONTENPLANWECHSEL
*EJECT
*--------------------------------------------------------------------*
* FORM UPDATE_XSKB1 *
*--------------------------------------------------------------------*
FORM update_xskb1.
SELECT (skb1_fields) FROM skb1 INTO CORRESPONDING FIELDS "#EC CI_SGLSELECT
OF TABLE xskb1
FOR ALL ENTRIES IN xy_bukrs "<--3.0F
WHERE saknr IN k_saknr
* AND BUKRS IN XX_BUKRS "
AND bukrs = xy_bukrs-bukrs "<--3.0F
AND (skb1_where).
SORT xskb1 BY mandt saknr bukrs.
cursor-skb1 = 1.
ENDFORM. "UPDATE_XSKB1
*EJECT
*--------------------------------------------------------------------*
* FORM UPDATE_YSKC1A *
*--------------------------------------------------------------------*
FORM update_yskc1a.
DATA: ld_clas_bal_fs10n TYPE boole_d. "1168430
DATA: lt_glt0 TYPE FAGL_T_GLT0. "NewGL: arch. totals
REFRESH: xskc1a, yskc1a.
saknr_skc1a = space.
CLEAR ld_clas_bal_fs10n. "1168430
IMPORT ld_clas_bal_fs10n FROM "1168430
MEMORY ID 'CLASSIC_BALANCE_SDF'. "1168430
IF g_glflex_active IS INITIAL
OR NOT ld_clas_bal_fs10n IS INITIAL. "1168430
SELECT * FROM glt0 INTO TABLE xglt0
FOR ALL ENTRIES IN xy_bukrs "<-- 3.0F
WHERE rldnr IN xx_rldnr " Ledger-Nr
AND rrcty IN sd_stype " Satztyp
AND rvers IN version " Version
* AND BUKRS IN XX_BUKRS " Bukreis aus SKB1-BU
AND bukrs = xy_bukrs-bukrs "<-- 3.0F
AND ryear IN sd_gjahr " Ges.Jahr aus Eingabe
AND racct IN k_saknr
AND rbusa IN sd_gsber. " Gesch.Ber aus Eingab
ELSE.
***********************************************************
* NewGL: Read totals from archive
***********************************************************
if sd_usar1 is initial and sd_usdb1 is initial.
sd_usdb1 = 'X'.
endif.
if sd_usar1 = 'X'.
if gd_arch_done eq 'N'.
* refresh archive file when archiv-info-system is used
if not sd_usas1 is initial.
refresh sd_file1.
endif.
CALL FUNCTION 'FAGL_GET_SUM_ARCH'
EXPORTING
I_GLT0_RLDNR = xx_rldnr-low
I_RLDNR = g_rldnr
I_RANGE_RRCTY = sd_stype[]
I_RANGE_RVERS = version[]
I_RANGE_BUKRS = sd_bukrs[]
I_RANGE_RYEAR = sd_gjahr[]
I_RANGE_RBUSA = sd_gsber[]
I_RANGE_RACCT = k_saknr[]
IT_WHERE_CLAUSE = faglfreesel_where
I_AUTHORITY_CHECK = 'X'
IMPORTING
ET_GLT0 = lt_glt0
TABLES
I_ARCH_SEL = sd_file1[]
exceptions
no_infostruc_found = 1
selections_error = 2.
case sy-subrc.
when '0'.
gd_arch_done = 'Y'.
gd_read_memo_done = 'N'.
refresh xglt0.
when '1'.
if gd_msg601_done is initial.
message i601.
* Fehler beim Lesen aus dem Archiv: Infostruktur nicht gefunden.
gd_msg601_done = 'X'.
endif.
when '2'.
message i602.
* Fehler beim Lesen aus dem Archiv: Selektionsbedingungen falsch.
endcase.
endif.
endif.
***********************************************************
if not sd_usdb1 is initial.
READ TABLE xx_rldnr INDEX 1.
CALL FUNCTION 'FAGL_GET_GLT0'
EXPORTING
i_glt0_rldnr = xx_rldnr-low
i_rldnr = g_rldnr
* I_RRCTY =
* I_RVERS =
* i_bukrs =
* I_RYEAR =
* I_RACCT =
* I_RBUSA =
* I_RTCUR =
* I_DRCRK =
* I_RPMAX =
i_range_rrcty = sd_stype[]
i_range_rvers = version[]
i_range_bukrs = sd_bukrs[]
i_range_ryear = sd_gjahr[]
i_range_rbusa = sd_gsber[]
i_range_racct = k_saknr[]
* I_RANGE_RTCUR =
* I_RANGE_DRCRK =
* I_RANGE_RPMAX =
it_where_clause = faglfreesel_where
i_authority_check = 'X'
IMPORTING
et_glt0 = xglt0[].
endif.
ENDIF.
***********************************************************
* NewGL: append archived data
***********************************************************
append lines of lt_glt0 to xglt0.
***********************************************************
SORT xglt0 BY rclnt racct bukrs rldnr rrcty rvers.
LOOP AT xglt0.
glt0 = xglt0.
IF glt0-rrcty = '1'.
CHECK glt0-rvers IN sd_vers.
ENDIF.
IF glt0-rrcty = '0'.
CHECK glt0-rvers = '001'.
ENDIF.
IF NOT glt0-rbusa IS INITIAL. " HK (171296)
AUTHORITY-CHECK OBJECT 'F_BKPF_GSB'
ID 'GSBER' FIELD glt0-rbusa
ID 'ACTVT' FIELD '03'.
CHECK sy-subrc = 0.
ENDIF. " HK
IF glt0-racct NE saknr_skc1a.
PERFORM saldo_des_monats_skc1a.
PERFORM saldo_zum_gm_ende_skc1a.
LOOP AT xskc1a.
yskc1a = xskc1a.
APPEND yskc1a.
ENDLOOP.
REFRESH: xskc1a.
ENDIF.
PERFORM xskc1a_aufbauen USING glt0-drcrk.
saknr_skc1a = glt0-racct.
ENDLOOP.
PERFORM saldo_des_monats_skc1a.
PERFORM saldo_zum_gm_ende_skc1a.
LOOP AT xskc1a.
yskc1a = xskc1a.
APPEND yskc1a.
ENDLOOP.
cursor-skc1a = 1.
ENDFORM. "UPDATE_YSKC1A
*EJECT
*--------------------------------------------------------------------*
* FORM UPDATE_YSKC1C *
*--------------------------------------------------------------------*
FORM update_yskc1c.
DATA: ld_clas_bal_fs10n TYPE boole_d. "1168430
data: lt_glt0 type fagl_t_glt0. "NewGL: arch. totals
REFRESH: xskc1c, yskc1c.
saknr_skc1c = space.
CLEAR ld_clas_bal_fs10n. "1168430
IMPORT ld_clas_bal_fs10n FROM "1168430
MEMORY ID 'CLASSIC_BALANCE_SDF'. "1168430
IF g_glflex_active IS INITIAL
OR NOT ld_clas_bal_fs10n IS INITIAL. "1168430
SELECT * FROM glt0 INTO TABLE xglt0
FOR ALL ENTRIES IN xy_bukrs "<-- 3.0F
WHERE rldnr IN xx_rldnr " Ledger-Nr
AND rrcty IN sd_stype " Satztyp
AND rvers IN version " Version
* AND BUKRS IN XX_BUKRS " Bukreis aus SKB1-BU
AND bukrs = xy_bukrs-bukrs "<-- 3.0F
AND ryear IN sd_gjahr " Ges.Jahr aus Eingabe
AND racct IN k_saknr
AND rbusa IN sd_gsber. " Gesch.Ber aus Eingab
ELSE.
***********************************************************
* NewGL: Read totals from archive
***********************************************************
if sd_usar2 is initial and sd_usdb2 is initial.
sd_usdb2 = 'X'.
endif.
if sd_usar2 = 'X'.
if gd_arch_done eq 'N'.
call function 'FAGL_GET_SUM_ARCH'
exporting
i_glt0_rldnr = xx_rldnr-low
i_rldnr = g_rldnr
i_range_rrcty = sd_stype[]
i_range_rvers = version[]
i_range_bukrs = sd_bukrs[]
i_range_ryear = sd_gjahr[]
i_range_rbusa = sd_gsber[]
i_range_racct = k_saknr[]
it_where_clause = faglfreesel_where
i_authority_check = 'X'
importing
et_glt0 = lt_glt0
tables
i_arch_sel = sd_file2[].
gd_arch_done = 'Y'.
gd_read_memo_done = 'N'.
endif.
endif.
***********************************************************
if not sd_usdb2 is initial.
READ TABLE xx_rldnr INDEX 1.
CALL FUNCTION 'FAGL_GET_GLT0'
EXPORTING
i_glt0_rldnr = xx_rldnr-low
i_rldnr = g_rldnr
* I_RRCTY =
* I_RVERS =
* i_bukrs =
* I_RYEAR =
* I_RACCT =
* I_RBUSA =
* I_RTCUR =
* I_DRCRK =
* I_RPMAX =
i_range_rrcty = sd_stype[]
i_range_rvers = version[]
i_range_bukrs = sd_bukrs[]
i_range_ryear = sd_gjahr[]
i_range_rbusa = sd_gsber[]
i_range_racct = k_saknr[]
* I_RANGE_RTCUR =
* I_RANGE_DRCRK =
* I_RANGE_RPMAX =
it_where_clause = faglfreesel_where
IMPORTING
et_glt0 = xglt0[].
endif.
ENDIF.
***********************************************************
* NewGL: append archived data
***********************************************************
append lines of lt_glt0 to xglt0.
delete adjacent duplicates from xglt0.
***********************************************************
SORT xglt0 BY rclnt racct bukrs rldnr rrcty rvers.
LOOP AT xglt0.
glt0 = xglt0.
IF glt0-rrcty = '1'.
CHECK glt0-rvers IN sd_vers.
ENDIF.
IF glt0-rrcty = '0'.
CHECK glt0-rvers = '001'.
ENDIF.
IF NOT glt0-rbusa IS INITIAL. " HK (171296)
AUTHORITY-CHECK OBJECT 'F_BKPF_GSB'
ID 'GSBER' FIELD glt0-rbusa
ID 'ACTVT' FIELD '03'.
CHECK sy-subrc = 0.
ENDIF. " HK
IF glt0-racct NE saknr_skc1c.
PERFORM saldo_des_monats_skc1c.
PERFORM saldo_zum_gm_ende_skc1c.
LOOP AT xskc1c.
yskc1c = xskc1c.
APPEND yskc1c.
ENDLOOP.
REFRESH: xskc1c.
ENDIF.
PERFORM xskc1c_aufbauen USING glt0-drcrk.
saknr_skc1c = glt0-racct.
ENDLOOP.
PERFORM saldo_des_monats_skc1c.
PERFORM saldo_zum_gm_ende_skc1c.
LOOP AT xskc1c.
yskc1c = xskc1c.
APPEND yskc1c.
ENDLOOP.
cursor-skc1c = 1.
ENDFORM. "UPDATE_YSKC1C
*--------------------------------------------------------------------*
* FORM XSKC1A_AUFBAUEN *
* Soll- und Haben-Verkehrszahlen pro Gesch-Ber. *
*--------------------------------------------------------------------*
FORM xskc1a_aufbauen USING xskc1a_drcrk.
CASE xskc1a_drcrk.
WHEN 'S'.
* Soll-Buchungen
* --------------
CLEAR: xskc1a.
xskc1a-mandt = glt0-rclnt.
xskc1a-bukrs = glt0-bukrs.
xskc1a-saknr = glt0-racct.
xskc1a-gjahr = glt0-ryear.
xskc1a-gsber = glt0-rbusa.
* XSKC1A-HWAER = GLT0-RTCUR.
* XSKC1A-HWAER = T001-WAERS.
xskc1a-rrcty = glt0-rrcty.
xskc1a-rvers = glt0-rvers.
xskc1a-rldnr = glt0-rldnr.
* Hauswaehrung uebertragen
* ------------------------
IF sd_curtp = ' ' OR sd_curtp = '10'.
xskc1a-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1a-um01s NEXT xskc1a-um02s.
refe2 = refe1.
ENDDO.
ELSE. "Zusatzwährung
READ TABLE c001 WITH KEY glt0-bukrs.
CASE c001-currnumber.
WHEN '2'.
xskc1a-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1a-um01s NEXT xskc1a-um02s.
refe2 = refe1.
ENDDO.
WHEN '3'.
xskc1a-umsav = glt0-kslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-ksl01 NEXT glt0-ksl02
VARYING refe2 FROM xskc1a-um01s NEXT xskc1a-um02s.
refe2 = refe1.
ENDDO.
ENDCASE.
ENDIF.
COLLECT xskc1a.
WHEN 'H'.
* Haben-Buchungen
* ---------------
CLEAR: xskc1a.
xskc1a-mandt = glt0-rclnt.
xskc1a-bukrs = glt0-bukrs.
xskc1a-saknr = glt0-racct.
xskc1a-gjahr = glt0-ryear.
xskc1a-gsber = glt0-rbusa.
* XSKC1A-HWAER = GLT0-RTCUR.
* XSKC1A-HWAER = T001-WAERS.
xskc1a-rrcty = glt0-rrcty.
xskc1a-rvers = glt0-rvers.
xskc1a-rldnr = glt0-rldnr.
* Hauswaehrung uebertragen
* ------------------------
IF sd_curtp = ' ' OR sd_curtp = '10'.
xskc1a-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1a-um01h NEXT xskc1a-um02h.
refe2 = refe1 * -1.
ENDDO.
ELSE. "Zusatzwährung
READ TABLE c001 WITH KEY glt0-bukrs.
CASE c001-currnumber.
WHEN '2'.
xskc1a-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1a-um01h NEXT xskc1a-um02h.
refe2 = refe1 * -1.
ENDDO.
WHEN '3'.
xskc1a-umsav = glt0-kslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-ksl01 NEXT glt0-ksl02
VARYING refe2 FROM xskc1a-um01h NEXT xskc1a-um02h.
refe2 = refe1 * -1.
ENDDO.
ENDCASE.
ENDIF.
COLLECT xskc1a.
ENDCASE.
ENDFORM. "XSKC1A_AUFBAUEN
*--------------------------------------------------------------------*
* FORM XSKC1C_AUFBAUEN *
* Soll- und Haben-Verkehrszahlen pro Gesch-Ber und Währung *
*--------------------------------------------------------------------*
FORM xskc1c_aufbauen USING xskc1c_drcrk.
CASE xskc1c_drcrk.
WHEN 'S'.
* Soll-Buchungen
* --------------
CLEAR: xskc1c.
xskc1c-mandt = glt0-rclnt.
xskc1c-bukrs = glt0-bukrs.
xskc1c-saknr = glt0-racct.
xskc1c-gjahr = glt0-ryear.
xskc1c-gsber = glt0-rbusa.
* XSKC1C-HWAER = GLT0-RTCUR.
* XSKC1C-HWAER = T001-WAERS.
xskc1c-fwaer = glt0-rtcur.
xskc1c-rrcty = glt0-rrcty.
xskc1c-rvers = glt0-rvers.
xskc1c-rldnr = glt0-rldnr.
* Hauswaehrung uebertragen
* ------------------------
IF sd_curtp = ' ' OR sd_curtp = '10'.
xskc1c-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1c-um01s NEXT xskc1c-um02s.
refe2 = refe1.
ENDDO.
ELSE. "Zusatzwaehrung
READ TABLE c001 WITH KEY glt0-bukrs.
CASE c001-currnumber.
WHEN '2'.
xskc1c-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1c-um01s NEXT xskc1c-um02s.
refe2 = refe1.
ENDDO.
WHEN '3'.
xskc1c-umsav = glt0-kslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-ksl01 NEXT glt0-ksl02
VARYING refe2 FROM xskc1c-um01s NEXT xskc1c-um02s.
refe2 = refe1.
ENDDO.
ENDCASE.
ENDIF.
* Fremdwaehrung uebertragen
* -------------------------
* IF SAVE_WAERS NE T001-WAERS.
* Übertragung der Beträge für das Währungskennzeichen aus B-Segment.
* IF SAVE_WAERS EQ GLT0-RTCUR.
xskc1c-slvfw = glt0-tslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-tsl01 NEXT glt0-tsl02
VARYING refe2 FROM xskc1c-wm01s NEXT xskc1c-wm02s.
refe2 = refe1.
ENDDO.
* ENDIF.
COLLECT xskc1c.
WHEN 'H'.
* Haben-Buchungen
* ---------------
CLEAR: xskc1c.
xskc1c-mandt = glt0-rclnt.
xskc1c-bukrs = glt0-bukrs.
xskc1c-saknr = glt0-racct.
xskc1c-gjahr = glt0-ryear.
xskc1c-gsber = glt0-rbusa.
* XSKC1C-HWAER = GLT0-RTCUR.
* XSKC1C-HWAER = T001-WAERS.
xskc1c-fwaer = glt0-rtcur.
xskc1c-rrcty = glt0-rrcty.
xskc1c-rvers = glt0-rvers.
xskc1c-rldnr = glt0-rldnr.
* Hauswaehrung uebertragen
* ------------------------
IF sd_curtp = ' ' OR sd_curtp = '10'.
xskc1c-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1c-um01h NEXT xskc1c-um02h.
refe2 = refe1 * -1.
ENDDO.
ELSE. "Zusatzwaehrung
READ TABLE c001 WITH KEY glt0-bukrs.
CASE c001-currnumber.
WHEN '2'.
xskc1c-umsav = glt0-hslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-hsl01 NEXT glt0-hsl02
VARYING refe2 FROM xskc1c-um01h NEXT xskc1c-um02h.
refe2 = refe1 * -1.
ENDDO.
WHEN '3'.
xskc1c-umsav = glt0-kslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-ksl01 NEXT glt0-ksl02
VARYING refe2 FROM xskc1c-um01h NEXT xskc1c-um02h.
refe2 = refe1 * -1.
ENDDO.
ENDCASE.
ENDIF.
* Fremdwaehrung uebertragen
* -------------------------
* IF SAVE_WAERS NE T001-WAERS.
* Übertragung der Beträge für das Währungskennzeichen aus B-Segment.
* IF SAVE_WAERS EQ GLT0-RTCUR.
xskc1c-slvfw = glt0-tslvt.
DO 16 TIMES
VARYING refe1 FROM glt0-tsl01 NEXT glt0-tsl02
VARYING refe2 FROM xskc1c-wm01h NEXT xskc1c-wm02h.
refe2 = refe1 * -1.
ENDDO.
* ENDIF.
COLLECT xskc1c.
ENDCASE.
ENDFORM. "XSKC1C_AUFBAUEN
*--------------------------------------------------------------------*
* FORM SALDO_DES_MONATS_SKC1A *
* Saldo des Monats (UM01O - UM16O) *
*--------------------------------------------------------------------*
FORM saldo_des_monats_skc1a.
LOOP AT xskc1a.
* Hauswaehrungs-Salden
* --------------------
DO 16 TIMES
VARYING refe1 FROM xskc1a-um01s NEXT xskc1a-um02s
VARYING refe2 FROM xskc1a-um01h NEXT xskc1a-um02h
VARYING refe3 FROM xskc1a-um01o NEXT xskc1a-um02o.
refe3 = refe1 - refe2.
ENDDO.
MODIFY xskc1a INDEX sy-tabix.
ENDLOOP.
ENDFORM. "SALDO_DES_MONATS_SKC1A
*--------------------------------------------------------------------*
* FORM SALDO_DES_MONATS_SKC1C *
* Saldo des Monats (UM01O - UM16O) (WM01O - WM16O) *
*--------------------------------------------------------------------*
FORM saldo_des_monats_skc1c.
LOOP AT xskc1c.
* Hauswaehrungs-Salden
* --------------------
DO 16 TIMES
VARYING refe1 FROM xskc1c-um01s NEXT xskc1c-um02s
VARYING refe2 FROM xskc1c-um01h NEXT xskc1c-um02h
VARYING refe3 FROM xskc1c-um01o NEXT xskc1c-um02o.
refe3 = refe1 - refe2.
ENDDO.
* Fremdwaehrungs-Salden
* ---------------------
DO 16 TIMES
VARYING refe1 FROM xskc1c-wm01s NEXT xskc1c-wm02s
VARYING refe2 FROM xskc1c-wm01h NEXT xskc1c-wm02h
VARYING refe3 FROM xskc1c-wm01o NEXT xskc1c-wm02o.
refe3 = refe1 - refe2.
ENDDO.
MODIFY xskc1c INDEX sy-tabix.
ENDLOOP.
ENDFORM. "SALDO_DES_MONATS_SKC1C
*EJECT
*--------------------------------------------------------------------*
* FORM SALDO_ZUM_GM_ENDE_SKC1A *
* Saldo zum GM-Ende (UM01K - UM16K) *
*--------------------------------------------------------------------*
FORM saldo_zum_gm_ende_skc1a.
* local data declaration
DATA: l_umo LIKE skc1a-um01o.
DATA: l_slk LIKE skc1a-um01k.
DATA: l_umk LIKE skc1a-um01k.
LOOP AT xskc1a.
* Hauswaehrungs-Salden
* --------------------
CLEAR: l_slk.
DO 16 TIMES
VARYING l_umo FROM xskc1a-um01o NEXT xskc1a-um02o
VARYING l_umk FROM xskc1a-um01k NEXT xskc1a-um02k.
l_slk = l_slk + l_umo.
l_umk = l_slk + xskc1a-umsav.
ENDDO.
MODIFY xskc1a INDEX sy-tabix.
ENDLOOP.
ENDFORM. "SALDO_ZUM_GM_ENDE_SKC1A
*--------------------------------------------------------------------*
* FORM SALDO_ZUM_GM_ENDE_SKC1C *
* Saldo zum GM-Ende (UM01K - UM16K) (WM01K - WM16K) *
*--------------------------------------------------------------------*
FORM saldo_zum_gm_ende_skc1c.
* local data declaration
DATA: l_umo LIKE skc1c-um01o.
DATA: l_slk LIKE skc1c-um01k.
DATA: l_umk LIKE skc1c-um01k.
LOOP AT xskc1c.
* Hauswaehrungs-Salden
* --------------------
CLEAR: l_slk.
DO 16 TIMES
VARYING l_umo FROM xskc1c-um01o NEXT xskc1c-um02o
VARYING l_umk FROM xskc1c-um01k NEXT xskc1c-um02k.
l_slk = l_slk + l_umo.
l_umk = l_slk + xskc1c-umsav.
ENDDO.
* Fremdwaehrungs-Salden
* ---------------------
CLEAR: l_slk.
DO 16 TIMES
VARYING l_umo FROM xskc1c-wm01o NEXT xskc1c-wm02o
VARYING l_umk FROM xskc1c-wm01k NEXT xskc1c-wm02k.
l_slk = l_slk + l_umo.
l_umk = l_slk + xskc1c-slvfw.
ENDDO.
MODIFY xskc1c INDEX sy-tabix.
ENDLOOP.
ENDFORM. "SALDO_ZUM_GM_ENDE_SKC1C
*--------------------------------------------------------------------*
* FORM INIT_TABLES *
* Initialisierung interner Arbeitsbereiche *
*--------------------------------------------------------------------*
FORM init_tables.
DATA: l_ds_clauses TYPE rsds_where,
l_tab_fields TYPE rsfs_tab_fields.
CALL FUNCTION 'INIT_T001'
TABLES
xbukreis = sd_bukrs.
IF alcur EQ 'X'. PERFORM read_teurb TABLES sd_bukrs. ENDIF. "<<<<euro
REFRESH version.
REFRESH sd_stype.
* If SD_PLAN has a different value then SPACE, ALL record
* types and versions are selected, so also 'plan' data
IF sd_plan EQ space.
MOVE '0' TO sd_stype-low. "Ist-Daten in GLT0
move 'EQ' to SD_STYPE-OPTION.
move 'I' to SD_STYPE-SIGN.
append SD_STYPE.
move '001' to VERSION-LOW.
move 'EQ' to VERSION-OPTION.
move 'I' to VERSION-SIGN.
append VERSION.
endif.
* New logic for SD_PLAN in related to special year end "1687347
* closing postings (GLYEC) "1687347
if SD_PLAN = '1'.
move '5' to SD_STYPE-LOW.
move 'EQ' to SD_STYPE-OPTION.
move 'I' to SD_STYPE-SIGN.
append SD_STYPE.
move '001' to VERSION-LOW.
move 'EQ' to VERSION-OPTION.
move 'I' to VERSION-SIGN.
append VERSION.
endif.
if SD_PLAN = '2'.
move '0' to SD_STYPE-LOW.
move 'EQ' to SD_STYPE-OPTION.
move 'I' to SD_STYPE-SIGN.
append SD_STYPE.
move '5' to SD_STYPE-LOW.
MOVE 'EQ' TO sd_stype-option.
MOVE 'I' TO sd_stype-sign.
APPEND sd_stype.
MOVE '001' TO version-low.
MOVE 'EQ' TO version-option.
MOVE 'I' TO version-sign.
APPEND version.
ENDIF.
* In SD_VERS Versionen zum Lesen von Plandaten vorhanden ?
DESCRIBE TABLE sd_vers LINES sy-tfill.
IF sy-tfill NE 0.
MOVE '1' TO sd_stype-low. "Plan-Daten in GLT0
MOVE 'EQ' TO sd_stype-option.
MOVE 'I' TO sd_stype-sign.
APPEND sd_stype.
LOOP AT sd_vers.
version = sd_vers.
APPEND version.
ENDLOOP.
ENDIF.
k_saknr-option = 'EQ'.
k_saknr-sign = 'I'.
* Und hier muss das Oracle dazu bewegt werden, ueber
* Index GLT0____1 zu lesen.
* read table sd_stype index 2. "note 78503
* if sy-subrc ne 0. "note 78503
* read table sd_stype index 1. "note 78503
* append sd_stype. "note 78503
* endif. "note 78503
* Dynamische Select-Options und Felder
init_where: ska1, skb1, bsis, faglfreesel.
init_fields: ska1, skb1, bsis, bkpf, bseg, gseg, bsisext. "40C
*... get report dynamic selections:
CALL FUNCTION 'RS_REFRESH_FROM_DYNAMICAL_SEL'
EXPORTING
curr_report = sy-cprog
mode_write_or_move = 'M'
IMPORTING
p_trange = gt_dyn_trange
EXCEPTIONS
not_found = 1
wrong_type = 2
OTHERS = 3.
IF sy-subrc > 1.
EXIT.
ENDIF.
* check and convert projk into external format
projk_eliminated = space.
PERFORM eliminate_field_where(fi_ldb_util) TABLES bsis_where
USING 'PROJK'
CHANGING projk_eliminated.
IF projk_eliminated EQ 'X'.
PERFORM convert_int_ext(fi_ldb_util) TABLES gt_dyn_trange
projk_tab
USING 'BSIS'
'PROJK'
'KONPR'.
ENDIF.
* check and convert imkey into external format
imkey_eliminated = space.
PERFORM eliminate_field_where(fi_ldb_util) TABLES bsis_where
USING 'IMKEY'
CHANGING imkey_eliminated.
IF imkey_eliminated EQ 'X'.
PERFORM convert_int_ext(fi_ldb_util) TABLES gt_dyn_trange
imkey_tab
USING 'BSIS'
'IMKEY'
'IMKEY'.
ENDIF.
* die Felder für Berechtigungsprüfung hinzufügen "45A
DESCRIBE TABLE skb1_fields LINES sy-tfill.
IF sy-tfill > 0.
PERFORM add_field_to_table TABLES skb1_fields USING 'BEGRU'."45A
ENDIF.
* die Schlüsselfelder gegebenfalls in Gseg_fields hinzufügen "30F
DESCRIBE TABLE gseg_fields LINES sy-tfill.
IF sy-tfill > 0.
PERFORM add_key_fields_to_gseg TABLES gseg_fields.
ENDIF.
* Die Felder zur Berechnung von BSEGA hinzufügen
DESCRIBE TABLE bsis_fields LINES sy-tfill.
IF sy-tfill > 0.
PERFORM add_auth_check_fields TABLES bsis_fields USING 'BSIS'.
PERFORM add_bsega_fields TABLES bsis_fields USING 'BSIS'.
PERFORM add_field_to_table TABLES bsis_fields USING 'XARCH'."40C
* new for bsisext.
DESCRIBE TABLE bsisext_fields LINES sy-tfill. "40C
IF sy-tfill > 0. "40C
PERFORM combine_fsel_tab1_to_tab2 "40C
TABLES bsisext_fields bsis_fields USING 'BSIS'."40C
ENDIF. "40C
ENDIF.
DESCRIBE TABLE bseg_fields LINES sy-tfill.
IF sy-tfill > 0.
PERFORM add_bsega_fields TABLES bseg_fields USING 'BSEG'.
ENDIF.
DESCRIBE TABLE gseg_fields LINES sy-tfill.
IF sy-tfill > 0.
PERFORM add_bsega_fields TABLES gseg_fields USING 'BSEG'.
ENDIF.
CLEAR: bsis, bseg, gseg.
ENDFORM. "INIT_TABLES
*---------------------------------------------------------------------*
* FORM AUTHORITYCHECK_SKA1 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM authoritycheck_ska1.
ENDFORM. "AUTHORITYCHECK_SKA1
*---------------------------------------------------------------------*
* FORM AUTHORITYCHECK_SKB1 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM authoritycheck_skb1.
* AUTHORITY-CHECK OBJECT 'F_SKA1_BUK'
* ID 'BUKRS' FIELD SAVE_BUKRS
* ID 'ACTVT' FIELD '03'.
* IF SY-SUBRC = 0.
CLEAR f_bkpf_bes_subrc.
IF NOT skb1-begru IS INITIAL.
AUTHORITY-CHECK OBJECT 'F_BKPF_BES' " this information will be
ID 'BRGRU' FIELD skb1-begru " used later in put_bsis,
ID 'ACTVT' FIELD '03'. " put_skc1a and put_skc1c.
IF sy-subrc <> 0.
f_bkpf_bes_subrc = sy-subrc.
sy-subrc = 0.
ENDIF.
AUTHORITY-CHECK OBJECT 'F_SKA1_BES' " this information is used
ID 'BRGRU' FIELD skb1-begru " immediately
ID 'ACTVT' FIELD '03'.
ENDIF.
* ENDIF.
ENDFORM. "AUTHORITYCHECK_SKB1
*---------------------------------------------------------------------*
* FORM AUTHORITYCHECK_SKC1A *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM authoritycheck_skc1a. "<<<< au40
DATA: zrc1 TYPE n.
zrc1 = 0.
IF au_gsber = 'X'.
PERFORM auth_gsber USING skc1a-gsber CHANGING zrc1.
ENDIF.
IF zrc1 NE 0.
sy-subrc = 4.
EXIT.
ELSE.
sy-subrc = 0.
ENDIF.
* tpc
IF gd_tpc_check = 'X' AND gd_tpc_check_sel NE 'X'.
CALL FUNCTION 'FI_CHECK_DATE'
EXPORTING
i_bukrs = skc1a-bukrs
i_user = sy-uname
i_program = 'SAPDBSDF'
i_from_year = skc1a-gjahr
EXCEPTIONS
no_authority_prog = 1
no_authority_date = 2
wrong_parameter = 3
OTHERS = 4.
CASE sy-subrc.
WHEN 0.
WHEN 2.
sy-subrc = 4.
WHEN OTHERS.
sy-subrc = 4.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDCASE.
ENDIF.
ENDFORM. "AUTHORITYCHECK_SKC1A
*---------------------------------------------------------------------*
* FORM AUTHORITYCHECK_SKC1C *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM authoritycheck_skc1c. "<<<< au40
DATA: zrc1 TYPE n.
zrc1 = 0.
IF au_gsber = 'X'.
PERFORM auth_gsber USING skc1c-gsber CHANGING zrc1.
ENDIF.
IF zrc1 NE 0.
sy-subrc = 4.
EXIT.
ELSE.
sy-subrc = 0.
ENDIF.
* tpc
IF gd_tpc_check = 'X' AND gd_tpc_check_sel NE 'X'.
CALL FUNCTION 'FI_CHECK_DATE'
EXPORTING
i_bukrs = skc1c-bukrs
i_user = sy-uname
i_program = 'SAPDBSDF'
i_from_year = skc1c-gjahr
EXCEPTIONS
no_authority_prog = 1
no_authority_date = 2
wrong_parameter = 3
OTHERS = 4.
CASE sy-subrc.
WHEN 0.
WHEN 2.
sy-subrc = 4.
WHEN OTHERS.
sy-subrc = 4.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDCASE.
ENDIF.
ENDFORM. "AUTHORITYCHECK_SKC1C
*---------------------------------------------------------------------*
* FORM AUTHORITYCHECK_BSIS *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM authoritycheck_bsis. " HK (171296)
* if not bsis-gsber is initial.
* authority-check object 'F_BKPF_GSB'
* id 'GSBER' field bsis-gsber
* id 'ACTVT' field '03'.
* endif.
DATA: zrc1 TYPE n, zrc2 TYPE n. "<<<< au40
DATA: ld_date TYPE dats.
zrc1 = 0.
zrc2 = 0.
IF au_gsber = 'X'.
PERFORM auth_gsber USING bsis-gsber CHANGING zrc1.
ENDIF.
IF au_blart = 'X'.
PERFORM auth_blart USING bsis-blart CHANGING zrc2.
ENDIF.
IF zrc1 NE 0 OR zrc2 NE 0.
sy-subrc = 4.
EXIT.
ELSE.
sy-subrc = 0.
ENDIF.
* tpc
* pai check already done by report?
IF sd_tpc = 'X'.
gd_tpc_check_sel = 'X'.
ENDIF.
IF gd_tpc_check = 'X' AND gd_tpc_check_sel NE 'X'.
* key date list
IF sd_opopt = 'X' AND
sd_apopt = space AND
sd_stida NE '00000000' AND
sd_stida NE '99991231' AND
sd_stida NE '00010101' AND
bsis-xopvw NE space.
ld_date = sd_stida.
ELSE.
ld_date = bsis-budat.
ENDIF.
CALL FUNCTION 'FI_CHECK_DATE'
EXPORTING
i_bukrs = bsis-bukrs
i_user = sy-uname
i_program = 'SAPDBSDF'
i_from_date = ld_date
EXCEPTIONS
no_authority_prog = 1
no_authority_date = 2
wrong_parameter = 3
OTHERS = 4.
CASE sy-subrc.
WHEN 0.
WHEN 2.
sy-subrc = 4.
WHEN OTHERS.
sy-subrc = 4.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDCASE.
ENDIF.
ENDFORM. "AUTHORITYCHECK_BSIS
*EJECT
*--------------------------------------------------------------------*
* FORM SD_CURTP_VAL *
* F4-Hilfe für Feld SD_CURTP *
*--------------------------------------------------------------------*
FORM sd_curtp_val.
CALL FUNCTION 'FI_F4_CURTP'
EXPORTING
i_xct10 = 'X'
IMPORTING
e_curtp = sd_curtp.
ENDFORM. "SD_CURTP_VAL
*--------------------------------------------------------------------*
* FORM SD_CURTP-LOW_VAL *
* F4-Hilfe für Feld XX_CURTP *
*--------------------------------------------------------------------*
FORM xx_curtp-low_val.
CALL FUNCTION 'FI_F4_CURTP'
EXPORTING
i_xct00 = 'X'
i_xct10 = 'X'
IMPORTING
e_curtp = xx_curtp-low.
ENDFORM. "XX_CURTP-LOW_VAL
*--------------------------------------------------------------------*
* FORM SD_CURTP-HIGH_VAL *
* F4-Hilfe für Feld XX_CURTP *
*--------------------------------------------------------------------*
FORM xx_curtp-high_val.
CALL FUNCTION 'FI_F4_CURTP'
EXPORTING
i_xct00 = 'X'
i_xct10 = 'X'
IMPORTING
e_curtp = xx_curtp-high.
ENDFORM. "XX_CURTP-HIGH_VAL
*---------------------------------------------------------------------*
* FORM LEDGER_WAEHLEN *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> MODE *
* --> RC *
* --> MSG *
*---------------------------------------------------------------------*
FORM ledger_waehlen USING mode CHANGING rc msg LIKE symsg.
DATA: title LIKE rgsel-dynp_title,
title1 LIKE rgsel-sel_title1,
title2 LIKE rgsel-sel_title2.
CLEAR rc.
title = text-060.
title1 = text-061.
title2 = text-062.
CALL FUNCTION 'G_DISPLAY_SELECTION_DYNPRO'
EXPORTING
dynp_title = title
sel_title1 = title1
sel_title2 = title2
start_column = 05
start_row = 08
without_selection = ' '
IMPORTING
sel_index = sy-tabix
TABLES
sel_table = f4tab
EXCEPTIONS
no_lines = 4
no_line_picked = 8.
CASE sy-subrc.
WHEN 0.
READ TABLE f4tab INDEX sy-tabix.
WHEN 4.
IF mode EQ '1'.
MESSAGE e056(f4).
ELSE.
msg-msgty = 'E'.
msg-msgid = 'F4'.
msg-msgno = '056'.
rc = 4.
ENDIF.
WHEN 8.
IF mode EQ '1'.
MESSAGE e057(f4).
ELSE.
msg-msgty = 'E'.
msg-msgid = 'F4'.
msg-msgno = '057'.
rc = 4.
ENDIF.
ENDCASE.
ENDFORM. "LEDGER_WAEHLEN
*---------------------------------------------------------------------*
* FORM CONVERT_ALT *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> TABNAME *
*---------------------------------------------------------------------*
FORM convert_alt USING tabname.
CASE tabname.
WHEN 'BSIS'.
PERFORM conv_to_alt_curr USING bsis-bukrs excdt sp_waers
CHANGING bsis-dmbtr.
PERFORM conv_to_alt_curr USING bsis-bukrs excdt sp_waers
CHANGING bsis-mwsts.
PERFORM conv_to_alt_curr USING bsis-bukrs excdt sp_waers
CHANGING bsega-dmsol.
PERFORM conv_to_alt_curr USING bsis-bukrs excdt sp_waers
CHANGING bsega-dmhab.
PERFORM conv_to_alt_curr USING bsis-bukrs excdt sp_waers
CHANGING bsega-dmshb.
WHEN 'BSEG'.
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.
WHEN 'GSEG'.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gseg-dmbtr.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gseg-mwsts.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gseg-hwbas.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gsega-dmsol.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gsega-dmhab.
PERFORM conv_to_alt_curr USING gseg-bukrs excdt sp_waers
CHANGING gsega-dmshb.
ENDCASE.
ENDFORM. "CONVERT_ALT
*---------------------------------------------------------------------*
* FORM FILL_KBTAB_AND_KTOPL *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> SD_KTOPL *
* --> SD_BUKRS *
* --> KBTAB *
* --> KTOPL *
* --> MODE *
* --> RC *
* --> MSG *
*---------------------------------------------------------------------*
FORM fill_kbtab_and_ktopl TABLES sd_ktopl STRUCTURE sd_ktopl
sd_bukrs STRUCTURE sd_bukrs
kbtab STRUCTURE kbtab
ktopl STRUCTURE sd_ktopl
USING mode CHANGING rc LIKE sy-subrc msg LIKE symsg.
DATA: ktopl_entry LIKE sy-tfill,
bukrs_entry LIKE sy-tfill.
REFRESH: kbtab.
REFRESH: xx_ktopl.
CLEAR: xx_ktopl, rc.
* Einträge in Kontenplantabelle zählen.
DESCRIBE TABLE sd_ktopl LINES ktopl_entry.
* Einträge in Buchungskreistabelle zählen.
DESCRIBE TABLE sd_bukrs LINES bukrs_entry.
* Einträge in Kontenplan- o d e r Buchungskreistabelle vorhanden ?
* ----------------------------------------
IF ktopl_entry NE 0 OR bukrs_entry NE 0. "Ja
* Füllen KBTAB
*
* Zu den abgegrenzten Kontenplänen und/oder Buchungskreisen
* wird die gültige Kombination ermittelt und in den Selektions-
* tabellen KBTAB abgestellt, um auf Buchungskreisebene, für ein
* Sachkonto in einem Kontenplan nur die Buchungskreise zu selek-
* tierenen, die diesen Kontenplan verwenden.
*
* Füllen XX_KTOPL
*
* Zum Lesen der Sachkontenstammdaten SKA1 werden die gültigen
* Kontenpläne (Kontenpläne die mindestens in einem Buchungskreis
* verwendet werden) in der Tabelle XX_KTOPL abgelegt.
* ---------------------------------------------------------------
SELECT * FROM t001
WHERE ktopl IN sd_ktopl
AND bukrs IN sd_bukrs.
kbtab-ktopl = t001-ktopl.
kbtab-bukrs = t001-bukrs.
APPEND kbtab.
xx_ktopl-sign = 'I'.
xx_ktopl-option = 'EQ'.
xx_ktopl-low = kbtab-ktopl.
COLLECT xx_ktopl.
ENDSELECT.
IF sy-subrc NE 0.
IF mode EQ '1'.
MESSAGE e102.
ELSE.
* message e102.
msg-msgty = 'E'.
msg-msgid = 'FR'.
msg-msgno = '102'.
rc = 4.
EXIT.
ENDIF.
ENDIF.
ELSE. "Nein - Keine Einträge in Buktab bzw. Kontopl.tab
* Abgrenzungen Buchungskreis/Kontenplan sind initial.
* Füllen KBTAB
*
* Die gültige Schnittmenge Kontenplan/Buchungskreis rekrutiert
* sich aus der Anzahl der angelegten Buchungskreise. Jedem Buch-
* ungkreis ist genau ein Kontenplan zugeordnet. Es erfolgt ein
* Eintrag in Tabelle KBTAB, damit auf Buchungskreisebene für ein
* Sachkonto in einem Kontenplan nur die Buchungskreise selek-
* tiert werden, die diesen Kontenplan verwenden.
*
* Füllen XX_KTOPL
*
* Zum Lesen der Sachkontenstammdaten SKA1 werden a l l e vorhande-
* nen Kontenpläne, d h. auch solche Kontenpläne die in
* k e i n e m Buchungskreis verwendet werden in der Tabelle
* XX_KTOPL abgelegt. Dadurch werden zusätzliche Auswertungen über
* nicht zugeordnete Kontenpläne ermöglicht.
* ---------------------------------------------------------------
SELECT * FROM t001.
kbtab-ktopl = t001-ktopl.
kbtab-bukrs = t001-bukrs.
APPEND kbtab.
ENDSELECT.
SELECT * FROM t004.
xx_ktopl-sign = 'I'.
xx_ktopl-option = 'EQ'.
xx_ktopl-low = t004-ktopl.
APPEND xx_ktopl.
ENDSELECT.
ENDIF.
ENDFORM. "FILL_KBTAB_AND_KTOPL
*&--------------------------------------------------------------------*
*& Form COMPANY_CODE_AT_SCREEN_CHECK
*&--------------------------------------------------------------------*
* If CC is fixed in the form or drill-down report then it doesn't
* appear at the selection screen.
* In that case the authority check for CC shouldn't be done.
* See also FORM SCREEN_OUTPUT_EXIT (RFSRRI2F)
*&--------------------------------------------------------------------*
FORM company_code_at_screen_check CHANGING p_cc_at_screen.
LOOP AT SCREEN.
IF screen-name CS 'BUKRS'
AND screen-active = 1.
p_cc_at_screen = 1.
ENDIF.
ENDLOOP.
ENDFORM. " COMPANY_CODE_AT_SCREEN_CHECK
*&--------------------------------------------------------------------*
*& Form RLDNR_AT_SCREEN_CHECK
*&--------------------------------------------------------------------*
* There are some reports like RFSKPL00 without a selection field
* for Ledger (RLDNR). In this cases an authority check for Ledger
* should not be executed.
*&--------------------------------------------------------------------*
FORM rldnr_at_screen_check CHANGING p_rldnr_at_screen.
LOOP AT SCREEN.
IF screen-name CS 'RLDNR'
AND screen-active = 1.
p_rldnr_at_screen = 1.
ENDIF.
ENDLOOP.
ENDFORM. " RLDNR_AT_SCREEN_CHECK
*&---------------------------------------------------------------------*
*& Form check_date
*&---------------------------------------------------------------------*
* check gjahr and bukrs...
* check key date and BUKRS...
* ...to avoid check on item level
* if flag gd_tpc_check_sel = 'X': no further check necessary
*----------------------------------------------------------------------*
FORM check_date .
DATA: it001 TYPE t001 OCCURS 0 WITH HEADER LINE.
* bukrs specified?
READ TABLE sd_bukrs INDEX 1.
IF sy-subrc <> 0.
EXIT.
ENDIF.
SELECT * FROM t001 INTO TABLE it001
WHERE bukrs IN sd_bukrs.
* check key date and BUKRS
IF gd_tpc_stida = 'X' AND
sd_opopt = 'X' AND
sd_apopt = space.
ELSE.
* check gjahr und bukrs
LOOP AT it001.
LOOP AT sd_gjahr.
IF sd_gjahr-sign = 'I' AND
( sd_gjahr-option = 'BT' OR sd_gjahr-option = 'EQ' ).
gd_tpc_check_sel = 'X'.
CALL FUNCTION 'FI_CHECK_DATE'
EXPORTING
i_bukrs = it001-bukrs
i_user = sy-uname
i_program = 'SAPDBSDF'
i_from_year = sd_gjahr-low
i_to_year = sd_gjahr-high
EXCEPTIONS
no_authority_prog = 1
no_authority_date = 2
wrong_parameter = 3
OTHERS = 4.
IF sy-subrc <> 0.
gd_tpc_check_sel = space.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
ENDIF.
ENDFORM. " check_date
**********************************************************************
* !!! PLEASE DO NOT CHANGE MANUALLY (BEGIN OF BLOCK) !!!!!!!!!!!!!!! *
*----------------------------------------------------------------------*
* Data structures for search pattern selection *
*----------------------------------------------------------------------*
* SDF_SP : Search pattern values. *
* After START-OF-SELECTION table SDF_SP is filled *
* with all keys of entries of the search pattern table *
* which correspond to the search string on the selection screen. *
* There must be defined a parameter for search pattern selection *
* (e.g. PARAMETER p_sp AS SEARCH PATTERN FOR NODE SPFLI), *
* and the user must have filled all fields on the selection-screen *
* (i.e. p_sp-NAME and p_sp-STRING). *
* Table SDF_SP will be used in subroutine PUT_SDF_SP. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SDF_SP OCCURS 1000, *
* SAKNR LIKE SKA1-SAKNR, *
* BUKRS LIKE SKB1-BUKRS, *
* KTOPL LIKE SKA1-KTOPL, *
* END OF SDF_SP . *
*----------------------------------------------------------------------*
* SP_FIELDS: Search Pattern fields. *
* After search pattern selection the table SP_FIELDS is modified: *
* SP_FIELDS-SUPPLIED NE SPACE if and only if the field *
* SP_FIELDS-FIELDNAME of SDF_SP, e.g. SDF_SP-CARRID, *
* is supplied by the search pattern interface. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SP_FIELDS OCCURS 10. *
* INCLUDE STRUCTURE RSSPFIELDS. *
* DATA: END OF SP_FIELDS. *
*----------------------------------------------------------------------*
* SP_TABLES: Search Pattern tables. *
* After search pattern selection the table SP_TABLES is modified: *
* SP_TABLES-SUPPLIED NE SPACE if and only if the keys of table *
* SP_TABLES-TABNAME are supplied by the search pattern interface. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SP_TABLES OCCURS 10. *
* INCLUDE STRUCTURE RSSPTABS. *
* DATA: END OF SP_TABLES. *
*----------------------------------------------------------------------*
* !!! PLEASE DO NOT CHANGE MANUALLY (END OF BLOCK) !!!!!!!!!!!!!!!!! *
**********************************************************************
*----------------------------------------------------------------------*
* FORM BEFORE_EVENT *
* Will be called before event 'event' *
*----------------------------------------------------------------------*
FORM before_event USING event.
CASE event.
WHEN 'START-OF-SELECTION'.
IF gd_tpc_log NE space.
CALL FUNCTION 'CA_WRITE_LOG' "#EC EXISTS
EXPORTING
i_program = sy-cprog
EXCEPTIONS
write_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e006(ca_check_date).
ENDIF.
ENDIF.
CALL FUNCTION 'LDB_LOG_INIT'.
ENDCASE.
ENDFORM. "before_event
*&---------------------------------------------------------------------*
*& Form after_event
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->EVENT text
*----------------------------------------------------------------------*
FORM after_event USING event.
CASE event.
WHEN 'END-OF-SELECTION'.
CALL FUNCTION 'LDB_LOG_DISPLAY'.
ENDCASE.
ENDFORM. "after_event
**********************************************************************
* !!! PLEASE DO NOT CHANGE MANUALLY (BEGIN OF BLOCK) !!!!!!!!!!!!!!! *
*----------------------------------------------------------------------*
* Data structures for search pattern selection *
*----------------------------------------------------------------------*
* SDF_SP : Search pattern values. *
* After START-OF-SELECTION table SDF_SP is filled *
* with all keys of entries of the search pattern table *
* which correspond to the search string on the selection screen. *
* There must be defined a parameter for search pattern selection *
* (e.g. PARAMETER p_sp AS SEARCH PATTERN FOR NODE SPFLI), *
* and the user must have filled all fields on the selection-screen *
* (i.e. p_sp-NAME and p_sp-STRING). *
* Table SDF_SP will be used in subroutine PUT_SDF_SP. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SDF_SP OCCURS 1000, *
* SAKNR LIKE SKB1-SAKNR, *
* BUKRS LIKE SKB1-BUKRS, *
* KTOPL LIKE SKB1-BUKRS, *
* END OF SDF_SP . *
*----------------------------------------------------------------------*
* SP_FIELDS: Search Pattern fields. *
* After search pattern selection the table SP_FIELDS is modified: *
* SP_FIELDS-SUPPLIED NE SPACE if and only if the field *
* SP_FIELDS-FIELDNAME of SDF_SP, e.g. SDF_SP-CARRID, *
* is supplied by the search pattern interface. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SP_FIELDS OCCURS 10. *
* INCLUDE STRUCTURE RSSPFIELDS. *
* DATA: END OF SP_FIELDS. *
*----------------------------------------------------------------------*
* SP_TABLES: Search Pattern tables. *
* After search pattern selection the table SP_TABLES is modified: *
* SP_TABLES-SUPPLIED NE SPACE if and only if the keys of table *
* SP_TABLES-TABNAME are supplied by the search pattern interface. *
*----------------------------------------------------------------------*
* DATA: BEGIN OF SP_TABLES OCCURS 10. *
* INCLUDE STRUCTURE RSSPTABS. *
* DATA: END OF SP_TABLES. *
*----------------------------------------------------------------------*
* !!! PLEASE DO NOT CHANGE MANUALLY (END OF BLOCK) !!!!!!!!!!!!!!!!! *
**********************************************************************
*---------------------------------------------------------------------*
* FORM put_admi_files *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM put_admi_files.
ENDFORM. "put_admi_files
*---------------------------------------------------------------------*
* FORM datasource_init *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> r_object *
* --> r_usedb *
* --> r_usear *
* --> r_useas *
* --> rt_files *
*---------------------------------------------------------------------*
FORM datasource_init CHANGING r_object TYPE arch_obj-object
r_usedb TYPE boole_d
r_usear TYPE boole_d
r_useas TYPE boole_d
rt_files TYPE gt_rng_archiv.
DATA: l_progname TYPE progname.
l_progname = sy-cprog.
CALL FUNCTION 'AS_DATASOURCE_INIT'
EXPORTING
i_report = l_progname
i_reporttype = space
IMPORTING
e_use_database = r_usedb
e_use_archive = r_usear
e_use_infosys = r_useas
et_arch_sel = rt_files[].
ENDFORM. "datasource_init
*---------------------------------------------------------------------*
* FORM read_archive *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM read_archive.
DATA : ld_errors TYPE boole,
ld_progress TYPE boole,
ld_convert_currency TYPE boole.
DATA: ls_bsis TYPE bsis. "1238122
DATA: ls_arch_key TYPE ty_doc_key. "1238122
* Create selection table.
REFRESH gt_selections.
PERFORM seltab_from_regular_sel.
PERFORM seltab_from_dyn_sel.
* 'LDB_NO_DISPL_ERROR' has to be created first (TA SM30, Tabelle TPARA)
* get parameter id 'LDB_NO_DISPL_ERROR' field LD_ERRORS.
* default has to be 'show errors'.
* if LD_ERRORS = 'X'.
* clear LD_ERRORS.
* else.
ld_errors = 'X'.
* endif.
ld_progress = 'X'.
ld_convert_currency = 'X'.
IF NOT sd_useas IS INITIAL.
REFRESH sd_files.
ENDIF.
CALL FUNCTION 'FI_DOCUMENT_ARCH_AS_ITEMS_READ' "#EC ENHOK
EXPORTING
i_selections = gt_selections
i_convert_currency = ld_convert_currency
i_show_errors = ld_errors
i_show_progess = ld_progress
TABLES
e_bkpf = ybkpf
e_bseg = ybseg
e_bsis = ybsis
e_bsas = ybsas
i_arch_sel = sd_files[]
EXCEPTIONS
no_infostruc_found = 1
selections_error = 2.
CASE sy-subrc.
WHEN '0'.
APPEND LINES OF ybsis TO ybsas. "#EC ENHOK
SORT ybsas BY mandt hkont bukrs.
LOOP AT ybsas INTO ls_bsis. "1238122
MOVE-CORRESPONDING ls_bsis TO ls_arch_key. "1238122
APPEND ls_arch_key TO arch_doc_key. "1238122
ENDLOOP. "1238122
SORT arch_doc_key BY bukrs belnr gjahr buzei. "1238122
WHEN '1'.
IF gd_msg601_done IS INITIAL.
MESSAGE i601.
gd_msg601_done = 'X'.
ENDIF.
REFRESH: ybkpf, ybseg, ybsas, ybsis.
WHEN '2'.
MESSAGE i602.
REFRESH: ybkpf, ybseg, ybsas, ybsis.
WHEN OTHERS.
MESSAGE i604.
REFRESH: ybkpf, ybseg, ybsas, ybsis.
ENDCASE.
cursor-ybsas = 1.
IF sd_memor = 'X'.
EXPORT ybkpf TO MEMORY ID 'YBKPF'.
EXPORT ybseg TO MEMORY ID 'YBSEG'.
ENDIF.
ENDFORM. "read_archive
*---------------------------------------------------------------------*
* FORM seltab_from_regular_sel *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM seltab_from_regular_sel.
DATA: ld_selopt LIKE rsdsselopt,
lt_selopt TYPE rsds_selopt_t,
ld_frange TYPE rsds_frange,
lt_frange TYPE rsds_frange_t,
ld_trange TYPE rsds_range,
lt_trange TYPE rsds_trange,
l_stida LIKE rfpdo-allgstid.
REFRESH:lt_frange.
ld_trange-tablename = 'BKPF'.
IF NOT sd_bukrs[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'BUKRS'.
LOOP AT sd_bukrs.
MOVE-CORRESPONDING sd_bukrs TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF NOT sd_budat[] IS INITIAL.
REFRESH: lt_selopt.
ld_frange-fieldname = 'BUDAT'.
LOOP AT sd_budat.
MOVE-CORRESPONDING sd_budat TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF ( sd_opopt = 'X' AND sd_apopt = 'X' )
OR ( sd_opopt = 'X' AND sd_apopt IS INITIAL ) .
IF sd_stida NE '99991231'.
REFRESH: lt_selopt.
ld_frange-fieldname = 'BUDAT'.
ld_selopt-sign = 'I'.
ld_selopt-option = 'BT'.
ld_selopt-low = '00010101'.
ld_selopt-high = sd_stida.
APPEND ld_selopt TO lt_selopt.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
ENDIF.
IF NOT lt_frange[] IS INITIAL .
ld_trange-frange_t = lt_frange[].
APPEND ld_trange TO lt_trange.
ENDIF.
REFRESH:lt_frange.
ld_trange-tablename = 'BSEG'.
IF NOT k_saknr[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'HKONT'.
LOOP AT k_saknr.
MOVE-CORRESPONDING k_saknr TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF NOT sd_augdt[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'AUGDT'.
LOOP AT sd_augdt.
MOVE-CORRESPONDING sd_augdt TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF ( sd_opopt IS INITIAL AND sd_apopt IS INITIAL )
OR ( sd_opopt = 'X' AND sd_apopt IS INITIAL ) .
IF sd_stida NE '00010101'.
REFRESH:lt_selopt.
IF sd_stida NE '99991231'.
l_stida = sd_stida + 1.
ELSE.
l_stida = sd_stida.
ENDIF.
ld_frange-fieldname = 'AUGDT'.
ld_selopt-sign = 'I'.
ld_selopt-option = 'BT'.
ld_selopt-low = l_stida.
ld_selopt-high = '99991231'.
APPEND ld_selopt TO lt_selopt.
CLEAR ld_selopt.
ld_selopt-sign = 'I'.
ld_selopt-option = 'EQ'.
ld_selopt-low = '00000000'.
APPEND ld_selopt TO lt_selopt.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
ENDIF.
IF NOT sd_zuonr[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'ZUONR'.
LOOP AT sd_zuonr.
MOVE-CORRESPONDING sd_zuonr TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF NOT sd_gsber[] IS INITIAL. "831568
REFRESH:lt_selopt.
ld_frange-fieldname = 'GSBER'.
LOOP AT sd_gsber.
MOVE-CORRESPONDING sd_gsber TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF. "831568
IF NOT sd_shkzg[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'SHKZG'.
LOOP AT sd_shkzg.
MOVE-CORRESPONDING sd_shkzg TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
IF NOT sd_bschl[] IS INITIAL.
REFRESH:lt_selopt.
ld_frange-fieldname = 'BSCHL'.
LOOP AT sd_bschl.
MOVE-CORRESPONDING sd_bschl TO ld_selopt.
APPEND ld_selopt TO lt_selopt.
ENDLOOP.
ld_frange-selopt_t = lt_selopt[].
APPEND ld_frange TO lt_frange.
ENDIF.
* NOTE 792515
* REFRESH:lt_selopt.
* ld_frange-fieldname = 'KOART'.
* ld_selopt-sign = 'I'.
* ld_selopt-option = 'EQ'.
* ld_selopt-low = 'S'.
* APPEND ld_selopt TO lt_selopt. "Note 776164
* ld_selopt-sign = 'I'.
* ld_selopt-option = 'EQ'.
* ld_selopt-low = 'M'.
* APPEND ld_selopt TO lt_selopt.
* ld_selopt-sign = 'I'.
* ld_selopt-option = 'EQ'.
* ld_selopt-low = 'A'. "Note 776164
* APPEND ld_selopt TO lt_selopt.
* ld_frange-selopt_t = lt_selopt[].
* APPEND ld_frange TO lt_frange.
* NOTE 792515
IF NOT lt_frange[] IS INITIAL.
ld_trange-frange_t = lt_frange[].
APPEND ld_trange TO lt_trange.
ENDIF.
APPEND LINES OF lt_trange TO gt_selections.
ENDFORM. "seltab_from_regular_sel
*---------------------------------------------------------------------*
* FORM seltab_from_dyn_sel *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM seltab_from_dyn_sel.
DATA : lt_where TYPE rsds_twhere,
ld_where TYPE rsds_where,
lt_trange TYPE rsds_trange,
ld_trange TYPE rsds_range,
lt_frange TYPE rsds_frange_t,
ld_frange TYPE rsds_frange,
ld_selopt LIKE rsdsselopt.
* ld_tablename LIKE RSDSTABS-PRIM_TAB.
DATA : ld_selections TYPE rsds_range.
DATA : ls_dfies TYPE dfies,
ld_tablename LIKE dcobjdef-name,
ld_fieldname LIKE dfies-lfieldname.
DATA : ld_tabix LIKE sy-tabix.
* transforming bsis-where into ranges format
ld_where-tablename = 'BSIS'.
ld_where-where_tab = bsis_where.
APPEND ld_where TO lt_where.
CALL FUNCTION 'FREE_SELECTIONS_WHERE_2_RANGE'
EXPORTING
where_clauses = lt_where
IMPORTING
field_ranges = lt_trange
EXCEPTIONS
expression_not_supported = 1
incorrect_expression = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE e601 .
ENDIF.
* splitting ranges for bsis into ranges for BKPF and BSEG
CLEAR : ld_trange , lt_frange , ld_frange .
REFRESH : lt_frange .
ld_tablename = 'BSIS'.
READ TABLE lt_trange WITH KEY tablename = ld_tablename INTO ld_trange.
IF sy-subrc = 0.
ld_tabix = sy-tabix.
ld_tablename = 'BKPF'.
LOOP AT ld_trange-frange_t INTO ld_frange.
ld_fieldname = ld_frange-fieldname .
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = ld_tablename
lfieldname = ld_fieldname
IMPORTING
dfies_wa = ls_dfies
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc = 1.
APPEND ld_frange TO lt_frange.
DELETE TABLE ld_trange-frange_t FROM ld_frange.
ELSEIF sy-subrc <> 0 .
MESSAGE e601 .
ENDIF.
ENDLOOP.
IF NOT ld_trange-frange_t IS INITIAL.
ld_trange-tablename = 'BKPF'.
MODIFY lt_trange INDEX ld_tabix FROM ld_trange.
ELSE.
DELETE lt_trange INDEX ld_tabix.
ENDIF.
IF NOT lt_frange[] IS INITIAL.
CLEAR ld_trange.
ld_trange-tablename = 'BSEG'.
ld_trange-frange_t = lt_frange[].
APPEND ld_trange TO lt_trange.
ENDIF.
* finally append local selection table lt_trange to global
* selection table gt_selections.
APPEND LINES OF lt_trange TO gt_selections.
SORT gt_selections BY tablename.
ENDIF.
ENDFORM. "seltab_from_dyn_sel
*---------------------------------------------------------------------*
* FORM process_bsis *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> i_arch *
*---------------------------------------------------------------------*
FORM process_bsis USING i_arch TYPE boole_d.
IF bsis-xarch = 'X'
AND i_arch IS INITIAL
AND sd_usear = 'X'.
READ TABLE arch_doc_key WITH KEY bukrs = bsis-bukrs "1238122
belnr = bsis-belnr "1238122
gjahr = bsis-gjahr "1238122
buzei = bsis-buzei "1238122
* TRANSPORTING NO FIELDS. "1238122
TRANSPORTING NO FIELDS BINARY SEARCH. "1238122
IF sy-subrc = 0.
CLEAR bsis.
EXIT.
ENDIF.
ENDIF.
save_belnr = bsis-belnr.
save_buzei = bsis-buzei.
save_gsber = bsis-gsber.
save_gjahr = bsis-gjahr.
* check projk range
IF projk_eliminated EQ 'X'.
PERFORM check_int_ext(fi_ldb_util) TABLES projk_tab
USING bsis-projk
'KONPR'
CHANGING check_ok.
IF check_ok = 'N'.
EXIT.
ENDIF.
ENDIF.
* check imkey range
IF imkey_eliminated EQ 'X'.
PERFORM check_int_ext(fi_ldb_util) TABLES imkey_tab
USING bsis-imkey
'IMKEY'
CHANGING check_ok.
IF check_ok = 'N'.
EXIT.
ENDIF.
ENDIF.
* expiring currencies:
gd_waers_save = bsis-waers.
IF NOT gd_expcur_flag IS INITIAL.
PERFORM item_curr_convert_bsis USING 'SAPDBSDF'
t001-waers
gd_expcur_date
CHANGING bsis.
ENDIF.
MOVE-CORRESPONDING bsis TO bsegh.
bsegh-koart = 'S'.
PERFORM got_bsega(sapbsega).
IF alcur EQ 'X'. " Euro
PERFORM convert_alt USING 'BSIS'.
ENDIF.
* count archived items
IF bsis-xarch = 'X'.
gd_count_arch = gd_count_arch + 1.
ENDIF.
IF i_arch = 'X' AND sd_usear = 'X'.
EXPORT gd_read_memo_done TO MEMORY ID 'GD_READ_MEMO_DONE'.
gd_read_memo_done = 'Y'.
ENDIF.
*
PUT bsis.
CLEAR bsis.
ENDFORM. "process_bsis
*---------------------------------------------------------------------*
* FORM modif_dyn_sel *
*---------------------------------------------------------------------*
* Form for setting the dynamic selections of log. DB by the *
* programm using the log. DB *
* Form can be used between start-of-selection and the first get *
*---------------------------------------------------------------------*
* --> i_dyn_sel *
*---------------------------------------------------------------------*
FORM modif_dyn_sel USING i_dyn_sel TYPE rsds_type.
dyn_sel = i_dyn_sel.
ENDFORM. "modif_dyn_sel
*&---------------------------------------------------------------------*
*& Form STATUS_FUNCTIONKEYS_CHANGE
*&---------------------------------------------------------------------*
* NewGL: Deactivate function keys if switch FAGL_CI_3_RS is
* is not on
*---------------------------------------------------------------------*
FORM status_functionkeys_change .
FIELD-SYMBOLS: <l_f_event> LIKE LINE OF get_events.
* If both nodes are used one function key should be deactivated:
* To deactivate the right function key two different function modules have
* to be called. (If both function modules are called only the last one will
* be executed!)
* 1. Deactivate SKC1C when node SKC1A is used
READ TABLE get_events ASSIGNING <l_f_event> WITH KEY node = 'SKC1A'.
IF sy-subrc = 0 AND NOT <l_f_event>-kind IS INITIAL.
CALL FUNCTION 'RS_EXTERNAL_SELSCREEN_STATUS'
EXPORTING
p_fb = 'FAGL_EXTERNAL_STATUS_SET_SKC1A'.
ENDIF.
* 2. Deactivate SKC1A when node SKC1C is used
READ TABLE get_events ASSIGNING <l_f_event> WITH KEY node = 'SKC1C'.
IF sy-subrc = 0 AND NOT <l_f_event>-kind IS INITIAL.
CALL FUNCTION 'RS_EXTERNAL_SELSCREEN_STATUS'
EXPORTING
p_fb = 'FAGL_EXTERNAL_STATUS_SET_SKC1C'.
ENDIF.
ENDFORM. " STATUS_FUNCTIONKEYS_CHANGE
Aucun commentaire:
Enregistrer un commentaire