SAP OSS Notes

596865 SAP OSS Note - Archive connection for FI line item lists








SAP OSS Note 596865 version 0009 contains details of a know issue related to Archive connection for FI line item lists. This includes any associated symptoms and instructions on how to fix it, see below for full details. Also check out the comments section to view/add related contributions, questions or screen shots, based on real life experience of this oss note and problem.

...For more information about the SAP support system known as OSS please check out the SAP OSS NOTES SECTION, whih includes how to download & implement them onto your SAP system using transaction code SNOTE.

Note 596865 Details:






When does this problem occur

You want to execute FI line item reports for archived documents the secondary indexes of which have already been deleted.The items the secondary indexes of which have already been deleted are missing in the lists since there is no archive connection.
The absence of the archive connection prevents an early deletion of the FI secondary indexes so that the related tables grow very large.


Description of problem

Archiving, ADK, SARA
Archiving object: FI_DOCUMNT
Transactions: FBL1N ,FBL2N, FBL3N, FBL4N, FBL5N, FBL6N, SARA, SARI
Programs: RFITEMAP, RFITEMAR, RFITEMGL
Tables: BSAD, BSAK, BSIS, BSAS
Archive Information System, SAP AS
Field catalog SAP_FI_DOC_002, infostructure SAP_FI_DOC_002



Cause of the problem and Pre-requisites

No archive connection has been implemented.


Solution instructions

Import the Support Packages specified in the attachment or implement the attached advance corrections - this will enable an archive connection for the FI line item reports.


Short description
The archive connection for the FI line item lists enables you to carry out a complete overview of line items via the database and archive, even after documents have been archived and FI secondary indexes have been deleted. The archive access is possible via the Archive Information System or via manual archive selection.The access via the Archive Information System can be set as a system-wide default setting.The default setting as delivered via this note is access only to the database, so that the mere implementation of the note does not change anything with regard to the way the line item reports work.


Data sources
The new function can be accessed on the initial screens of the line item lists via the "Data sources" pushbutton in the application toolbar. When you choose "Data sources", the system displays a dialog box, on which you can make a selection as to whether the system is to read the line items via database, archive or both database and archive.The default setting is reading the database only (only "Database" selected).With this setting, the functions and performance of the line item lists are exactly the same as prior to the import of the new functions.
If you select "Archive", you have to decide between two more options for the archive access.If you select "Archive Information System", the system reads via archive indexes of the Archive Information System into the archive.The affected documents are selected automatically.Please note that the system can read no more than 100,000 items via the Archive Information System.If you select "Select Files Manually", the system displays another dialog box, on which you must select archive files for the analysis, which will be read sequentially and from which the selected documents will be filtered out.In this case, you have to see to it that all documents of interest are included in the archive selection.
If you select both "Database" and "Archive", the system first reads the archived items and then the items from the database.Items that are found both in the database and in the archive are displayed only once.


Preconditions
For the general use of the archive connection for FI line item lists, the access via the Archive Information System is the only reasonable access for performance reasons.For a working archive connection, you have to create an archive information structure that meets specific requirements.
  • Infostructure

  • In principle, you can decide on your own which fields to include into the infostructure.However, it must be based on field catalog SAP_FI_DOC_002 and contain at least the following fields for the tables to be archived in addition to their fixed key fields.
  • Vendor Line Item Display - field LIFNR

  • Customer Line Item Display - field KUNNR

  • General Ledger Line Item Display - field HKONT

  • In addition, the infostructure should contain the fields BUDAT for date selections and AUGDT for lists with open items for the key date.You may be able to use SAP standard infostructure SAP_FI_DOC_002, which contains some more fields.This infostructure has been especially designed for the use in the FI line item lists and for the Document Relationship Browser.
  • Performance

  • If you permanently use archiving, the number of the entries in the infostructure will exceed by far the entries of the items in the database, so that for performance reasons it is necessary to define database indexes for the infostructure used.For information on how to create a database index for an info structure, refer to Note 164704.Specifially, you are to create the following indexes:
  • Vendor Line Item Display - field MANDT, LIFNR, BUKRS

  • Customer Line Item Display - field MANDT, KUNNR, BUKRS

  • G/L Account Line Item Display - field MANDT, HKONT, BUKRS

  • Document Relationship Browser - fields MANDT, AWKEY

  • The SAP standard infostructure SAP_FI_DOC_002 contains exactly these database indexes.
  • Completeness

  • Infostructures can be constructed or deconstructed subsequently so that completeness of the infostructure is not always ensured.The line item displays do not find items for which no corresponding record has been constructed in the infostructure.This may cause problems, in particular if lists of cleared items are displayed, which ought to balance at zero, or if the totals of the line items no longer match the balances of the transaction figures owing to the items the system has not found.
    Therefore, you should always ensure that the infostructure has been constructed completely for the period for which the line item lists are managed.
  • Storage of archive files

  • The archive files should always be contained in a globally mounted file system - at least as a copy.This is the only way to achieve an acceptable performance for archived data reporting.


    Customizing
    You can make settings for both the default values for the data source dialog and for the way errors are processed by the system (error handling).If a system contains a completely constructed infostructure, which meets the requirements of the archive connection for a line item list, it is useful, for example, to make a systemwide default setting for reading from the archive via the Archive Information System.
  • Tables ASACCESS01 and ASDATASRC1

  • The default values for the data source dialog can be defined in table ASACCESS01 (up to and including Release 4.6C) or in table ASDATASRC1 (as of Release 4.70).
    If table ASACCESS01 or ASDATASRC1 does not contain any entry for a specific report or if field ASACCESS or USE_INFSYS is empty for an entry, only the database is used as a data source.
    If ASACCESS or USE_INFSYS has been filled with the value 'X', both the database and the archive are used as data sources.Moreover, the default setting in the dialog box for the specification of data sources is "Archive Information System".
    The default values for the data source dialog of the FI line item lists can be changed via the following entries.Since there is no separate maintenance transaction yet, the entries must be made using Transaction SE16.If the entries must be transported, you can include them into a transport request in Transaction SE16 via the menu option "Table Entry -> Transport Entries".
    For the FI line item lists, for example, the following entries are possible in table ASACCESS01 or ASDATASRC1:
    Table ASACCESS01 (up to and including Release 4.6C):
    MANDT REPORTTYPE REPORT ASACCESS
    001 RE RFITEMAP X
    001 RE RFITEMAR X
    001 RE RFITEMGL X
    Table ASACCESS01 (as of Release 4.70):
    MANDT REPORTTYPE REPORT USE_INFSYS
    001 RFITEMAP X
    001 RFITEMAR X
    001 RFITEMGL X

    The entry in field REPORT with RFITEMAP controls the dialog of the Vendor Line Item Display, RFITEMAR that of the Customer Line Item Display and RFITEMGL that of the G/L Accounts Line Item Display.

  • SET/GET parameter LDB_NO_DISPL_ERROR

  • If errors occur during the access to the archive files, they are displayed as a log in a dialog box.You can suppress the display of these errors by setting the user-dependent parameter LDB_NO_DISPL_ERROR to 'X'. Setting the data is always only possible via the menu "System -> User Profile -> Own Data".On the "Parameters" tab page, you have to enter parameter LDB_NO_DISPL_ERROR with value 'X'.
    Likewise, you can suppress the message on the number of the archived line items read (message FR010) via parameter LDB_NO_DISPL_ARCH.


    Error handling
  • You have selected "Archive Information System", but no info structure is active

  • If you select "Archive Information System" in the data source dialog box (or if this option has been selected for other reasons, for example via flag ASACCESS), the system assumes that archived data is to be read exclusively via the Archive Information System.If no suitable infostructure is active, the system does not read from the archive at all. It does not display a corresponding message.
  • Errors during access to archive files

  • If errors occur during access to archive files, all readable items are listed, and additionally all errors per archive file in a dialog box.This error log is important in particular if you expect a complete list, but receive only an incomplete list due to access errors.As described above, the error log can be deactivated via the user-dependent parameter LDB_NO_DISPL_ERROR.


    Direct implementation of this note
    If you do not want to import the Support Package assigned to this note into your system, you can implement the note according to the attached correction instructions. Be advised that SAP Note 445148 is also prerequisite for this purpose in addition to the SAP notes specified below, or that for Release 4.6B the minimum Support Package level is SAPKH46B41, and for Release 4.6C the minimum Support Package level is SAPKH46C32, if the special transport from SAP Note 445148 is not implemented.
    In addition to implementing the correction from the correction instructions, make the following manual changes in your system:
  • Enhance the logical databases SDF, DDF, KDF.

  • Here, this enhancement is described for SDF, the enhancement for DDF and KDF can be made along the same lines.
  • Start Transaction SE36, enter logical database "SDF", select "Structure", choose "Change".

  • Select node "BSIS", then choose "Insert node".

  • Enter the following values on the subsequent dialog box:

  • Node name: ADMI_FILES
    Text: Archive Files
    Database table: ADMI_FILES
    Choose "Insert new node".
    In the structure of the logical database, the node ADMI_FILES should now appear directly below node BSIS.
  • Save the structure of the logical database.

  • Create text symbol SRC.

  • Start Transaction SE38, enter program SAPDBSDF (or SAPDBDDF, SAPDBKDF respectively), select "Text elements", choose "Change".

  • Create text symbol SRC with the long text "Data sources". Save.

  • Create message texts.

  • Start Transaction SE91, enter message class FR and F9, choose "Change".

  • Enter the following messages for message class FR:

  • Message number: 601
    Message short text: Error reading from archive: Info structure not found
    Message number: 602
    Message short text: Error reading from archive:Selection criteria incorrect
    Message number: 603
    Message short text: Error reading from archive: Conversion not possible
    Message number: 604
    Message short text: Error reading from archive
  • Enter the following message for message class F9:

  • Message number: 022
    Message short text: Archived documents to be read &1/&2 already read
  • Save the texts.

  • Create parameter: LDB_NO_DISPL_ERROR

  • Start Transaction SM30, enter table/view: TPARA, choose "Maintain".

  • Enter Set/Get parameter ID LDB_NO_DISPL_ERROR. Choose "Enter".

  • Enter the text "No errors are displayed when reading from archives", choose "Save".

  • Now save and activate all new and changed objects.You should now be able to use the line item display for archived documents.
  • Note 596865 Correction instructions:



    NOTE: Only source text changes are displayed here

    *$*$----------------------------------------------------------------$*$*
    *$ CORRECTION INSTRUCTIONS 0120061532 0000584729 $*
    *$ Prerequisite corr. inst. 0120061532 0000407162 Note 0000521848 $*
    *$ 0120061532 0000413545 Note 0000523959 $*
    *$ 0120061532 0000421053 Note 0000530455 $*
    *$ 0120061532 0000427278 Note 0000533696 $*
    *$ 0120061532 0000429205 Note 0000535363 $*
    *$ 0120061532 0000431230 Note 0000536700 $*
    *$ 0120061532 0000432374 Note 0000536859 $*
    *$ 0120061532 0000435032 Note 0000539205 $*
    *$ 0120061532 0000437905 Note 0000541087 $*
    *$ 0120061532 0000444984 Note 0000529637 $*
    *$ 0120061532 0000469799 Note 0000563780 $*
    *$ 0120061532 0000486777 Note 0000574220 $*
    *$ 0120061532 0000504976 Note 0000587843 $*
    *$ 0120061532 0000511428 Note 0000592679 $*
    *$ 0120061532 0000522315 Note 0000599404 $*
    *$ 0120061532 0000526143 Note 0000602278 $*
    *$ 0120061532 0000531357 Note 0000605422 $*
    *$ 0120061532 0000531845 Note 0000606261 $*
    *$ 0120061532 0000538896 Note 0000610741 $*
    *$ 0120061532 0000542517 Note 0000613377 $*
    *$ 0120061532 0000543380 Note 0000613798 $*
    *$ 0120061532 0000551250 Note 0000619362 $*
    *$ 0120061532 0000579466 Note 0000637359 $*
    *$ 0120061532 0000585090 Note 0000643168 $*
    *$--------------------------------------------------------------------$*
    *$ VALID FOR : $*
    *$ Software Component SAP_APPL SAP Application $*
    *$ Release 470 To SAPKH47013 $*
    *$*$----------------------------------------------------------------$*$*
    *&---------------------------------------------------------------------*
    *& Object FUNC FI_DOCUMENT_ARCH_AS_ITEMS_READ
    *& Object header FUGR FAR1
    *&---------------------------------------------------------------------*
    *& FUNCTION FI_DOCUMENT_ARCH_AS_ITEMS_READ
    *&---------------------------------------------------------------------*
    ...
    FUNCTION fi_document_arch_as_items_read .
    *"----------------------------------------------------------------------
    *"*"Lokale Schnittstelle:
    *" IMPORTING
    *" REFERENCE(I_SELECTIONS) TYPE RSDS_TRANGE
    *" VALUE(I_CONVERT_CURRENCY) TYPE BOOLE OPTIONAL
    *" VALUE(I_USE_ACCOUNT_CONTRL) TYPE BOOLE OPTIONAL
    *" VALUE(I_SHOW_ERRORS) TYPE BOOLE OPTIONAL
    *" VALUE(I_SHOW_PROGESS) TYPE BOOLE DEFAULT 'X'
    *" EXPORTING
    *" REFERENCE(E_LOG_HANDLE) TYPE BALLOGHNDL
    *" TABLES
    *" E_BKPF STRUCTURE BKPF OPTIONAL
    *" E_BSEG STRUCTURE BSEG OPTIONAL
    *" E_BSIS STRUCTURE BSIS OPTIONAL
    *" E_BSAS STRUCTURE BSAS OPTIONAL
    *" E_BSAD STRUCTURE BSAD OPTIONAL
    *" E_BSAK STRUCTURE BSAK OPTIONAL
    *" E_BSIP STRUCTURE BSIP OPTIONAL
    *" E_BSIM STRUCTURE BSIM OPTIONAL
    *>>>> START OF DELETION <<<<<
    *" EXCEPTIONS
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    *" I_ARCH_SEL STRUCTURE RNG_ARCHIV OPTIONAL
    *" EXCEPTIONS
    *>>>> END OF INSERTION <<<<<<
    ...
    *" NO_INFOSTRUC_FOUND
    *" SELECTIONS_ERROR
    *" CONVERSION_ERROR
    *"----------------------------------------------------------------------

    CONSTANTS: lc_limit TYPE f VALUE 3,
    *>>>> START OF DELETION <<<<<
    lc_infstruc TYPE aind_desc VALUE 'SAP_FI_DOC_002',
    lc_fieldcat TYPE aind_fcat VALUE 'SAP_FI_DOC_002'.

    DATA: l_infostruc LIKE aind_str1-archindex,
    l_handle LIKE sy-tabix,
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    lc_fieldcat TYPE aind_fcat VALUE 'SAP_FI_DOC_002'.

    DATA: l_infostruc LIKE aind_str1-archindex,
    l_handle LIKE sy-tabix,
    l_arkey TYPE arkey,
    l_offst TYPE admi_offst,
    *>>>> END OF INSERTION <<<<<<
    ...
    l_error_flag TYPE c,
    l_continue_flag TYPE c,
    l_end_of_scan TYPE c,
    l_reset TYPE c,
    l_sum TYPE i,
    l_log_handle TYPE balloghndl,
    lw_bkpf LIKE bkpf,
    lw_bseg LIKE bseg,
    lw_result TYPE gty_result,
    lw_seq_range TYPE gty_seq_range,
    lw_skb1 TYPE gty_skb1,
    lw_lfb1 LIKE lfb1,
    lt_all_fields TYPE gty_t_all_fields,
    lt_obligatory_fields LIKE aind_str3-fieldname OCCURS 0,
    lt_selections_as TYPE rsds_frange_t,
    lt_bkpf LIKE bkpf OCCURS 0,
    lt_bseg LIKE bseg OCCURS 0,
    lt_result TYPE gty_t_result,
    lt_sequential_range TYPE gty_t_seq_range,
    lt_result_single TYPE gty_t_result,
    lt_result_seq_hash TYPE gty_t_result_hash,
    lt_result_sequential TYPE gty_t_result.

    *>>>> START OF DELETION <<<<<
    * check and initialize
    PERFORM selections_confirm USING i_selections.
    REFRESH: e_bkpf, e_bseg, e_bsis, e_bsas,
    e_bsad, e_bsak, e_bsip, e_bsim.

    * find infostructure
    SELECT SINGLE archindex FROM aind_str2 INTO l_infostruc
    WHERE archindex = lc_infstruc
    AND active = 'X'.
    IF sy-subrc = 0.
    l_infostruc = lc_infstruc.
    ELSE.
    APPEND 'BUKRS' TO lt_obligatory_fields.
    APPEND 'BELNR' TO lt_obligatory_fields.
    APPEND 'GJAHR' TO lt_obligatory_fields.
    APPEND 'BUZEI' TO lt_obligatory_fields.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    PERFORM selections_confirm USING i_selections.
    REFRESH: e_bkpf, e_bseg, e_bsis, e_bsas,
    e_bsad, e_bsak, e_bsip, e_bsim.

    IF NOT i_arch_sel[] IS INITIAL.
    * full scan
    CALL FUNCTION 'ARCHIVE_OPEN_FOR_READ'
    EXPORTING
    object = 'FI_DOCUMNT'
    IMPORTING
    archive_handle = l_handle
    TABLES
    archive_files = i_arch_sel[].

    SELECT SUM( obj_count ) FROM admi_files INTO l_sum
    WHERE archiv_key IN i_arch_sel.

    DO.
    CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
    EXPORTING
    archive_handle = l_handle
    IMPORTING
    object_offset = l_offst
    archive_name = l_arkey
    EXCEPTIONS
    end_of_file = 1.
    IF sy-subrc = 1.
    EXIT.
    ENDIF.

    PERFORM single_object_read TABLES i_selections
    lt_bkpf
    lt_bseg
    USING l_handle
    l_arkey
    l_offst
    i_convert_currency.

    * Build up index
    INCLUDE lfar1idx.

    * show progress
    PERFORM progress_show USING i_show_progess
    l_sum
    l_reset.

    ENDDO.

    * close file
    IF NOT l_handle IS INITIAL.
    CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
    EXPORTING
    archive_handle = l_handle
    EXCEPTIONS
    OTHERS = 0.
    ENDIF.
    ELSE.
    * find AS infostructure
    APPEND 'BUKRS' TO lt_obligatory_fields.
    APPEND 'BELNR' TO lt_obligatory_fields.
    APPEND 'GJAHR' TO lt_obligatory_fields.
    APPEND 'BUZEI' TO lt_obligatory_fields.

    *>>>> END OF INSERTION <<<<<<
    ...
    CALL FUNCTION 'AS_API_INFOSTRUC_FIND'
    EXPORTING
    i_fieldcat = lc_fieldcat
    i_obligatory_fields = lt_obligatory_fields
    IMPORTING
    e_infostruc = l_infostruc
    e_all_fields = lt_all_fields
    EXCEPTIONS
    no_infostruc_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
    RAISING no_infostruc_found.
    *>>>> START OF DELETION <<<<<
    ENDIF.
    ENDIF.

    * read infostructure
    PERFORM selections_for_as_create TABLES i_selections
    USING lt_all_fields
    CHANGING lt_selections_as.
    PERFORM infostructure_read USING l_infostruc
    lt_selections_as
    CHANGING lt_result.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDIF.

    * read infostructure
    PERFORM selections_for_as_create TABLES i_selections
    USING lt_all_fields
    CHANGING lt_selections_as.

    PERFORM infostructure_read USING l_infostruc
    lt_selections_as
    CHANGING lt_result.

    *>>>> END OF INSERTION <<<<<<
    ...
    PERFORM access_kind_get USING lt_result
    lc_limit
    CHANGING lt_result_single
    lt_result_sequential
    lt_sequential_range.
    *>>>> START OF DELETION <<<<<
    REFRESH lt_result.
    lt_result_seq_hash[] = lt_result_sequential[].
    REFRESH lt_result_sequential.


    * read archives / single object access
    LOOP AT lt_result_single INTO lw_result.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<


    REFRESH lt_result.
    lt_result_seq_hash[] = lt_result_sequential[].
    REFRESH lt_result_sequential.

    * read archives / single object access
    LOOP AT lt_result_single INTO lw_result.

    *>>>> END OF INSERTION <<<<<<
    ...
    PERFORM archive_open USING lw_result-archivekey
    lw_result-archiveofs
    CHANGING l_handle
    l_log_handle
    l_error_flag
    l_continue_flag.
    *>>>> START OF DELETION <<<<<
    IF l_continue_flag = 'X'.
    CONTINUE.
    ENDIF.
    PERFORM single_object_read TABLES i_selections
    lt_bkpf
    lt_bseg
    USING l_handle
    lw_result
    i_convert_currency.
    *- Build up index
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    IF l_continue_flag = 'X'.
    CONTINUE.
    ENDIF.

    PERFORM single_object_read TABLES i_selections
    lt_bkpf
    lt_bseg
    USING l_handle
    lw_result-archivekey
    lw_result-archiveofs
    i_convert_currency.

    * Build up index
    *>>>> END OF INSERTION <<<<<<
    ...
    CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
    EXPORTING
    archive_handle = l_handle
    EXCEPTIONS
    OTHERS = 0.
    ENDIF.
    *>>>> START OF DELETION <<<<<
    *- show progress
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * show progress
    *>>>> END OF INSERTION <<<<<<
    ...
    PERFORM progress_show USING i_show_progess
    l_sum
    l_reset.
    ENDLOOP.

    *>>>> START OF DELETION <<<<<

    * read archives / sequential read
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * read archives / sequential read
    *>>>> END OF INSERTION <<<<<<
    ...
    PERFORM archive_open USING lw_seq_range-archivekey
    lw_seq_range-offset_min
    CHANGING l_handle
    l_log_handle
    l_error_flag
    l_continue_flag.
    *>>>> START OF DELETION <<<<<
    IF l_continue_flag = 'X'.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    IF l_continue_flag = 'X'.
    *>>>> END OF INSERTION <<<<<<
    ...
    IF sy-index = 1.
    PERFORM single_object_read TABLES i_selections
    lt_bkpf
    lt_bseg
    USING l_handle
    *>>>> START OF DELETION <<<<<
    lw_result
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    lw_result-archivekey
    lw_result-archiveofs
    *>>>> END OF INSERTION <<<<<<
    ...
    PERFORM next_object_scan TABLES i_selections
    lt_bkpf
    lt_bseg
    USING l_handle
    lw_seq_range
    i_convert_currency
    lt_result_seq_hash
    CHANGING l_end_of_scan
    l_continue_flag
    l_error_flag
    l_log_handle.
    *>>>> START OF DELETION <<<<<
    IF l_continue_flag = 'X'.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    IF l_continue_flag = 'X'.
    *>>>> END OF INSERTION <<<<<<
    ...
    IF l_end_of_scan = 'X'.
    EXIT.
    ENDIF.
    ENDIF.

    *>>>> START OF DELETION <<<<<
    *-- Build up index
    INCLUDE lfar1idx.

    *-- show progress
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * Build up index
    INCLUDE lfar1idx.

    * show progress
    *>>>> END OF INSERTION <<<<<<
    ...
    PERFORM progress_show USING i_show_progess
    l_sum
    l_reset.
    ENDDO.

    *>>>> START OF DELETION <<<<<
    *- close file
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * close file
    *>>>> END OF INSERTION <<<<<<
    ...
    CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
    EXPORTING
    archive_handle = l_handle
    EXCEPTIONS
    OTHERS = 0.
    ENDIF.
    ENDLOOP.
    *>>>> START OF DELETION <<<<<

    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDIF.

    *>>>> END OF INSERTION <<<<<<
    ...
    * show progress and reset counters for next call
    l_reset = 'X'.
    PERFORM progress_show USING i_show_progess
    l_sum
    l_reset.
    *>>>> START OF DELETION <<<<<
    * provide error handling
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS DBDDFSEL
    *& Object header LDBA DDF
    *&---------------------------------------------------------------------*
    ...
    SELECTION-SCREEN FIELD SELECTION FOR TABLE BSIDEXT. "40C
    SELECTION-SCREEN FIELD SELECTION FOR TABLE BKPF.
    SELECTION-SCREEN FIELD SELECTION FOR TABLE BSEG.
    SELECTION-SCREEN FIELD SELECTION FOR TABLE GSEG. "30F

    *>>>> START OF DELETION <<<<<
    SELECTION-SCREEN BEGIN OF BLOCK DD_0 WITH FRAME TITLE TEXT-000.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    SELECTION-SCREEN BEGIN OF BLOCK DD_0 WITH FRAME TITLE TEXT-000.
    *>>>> END OF INSERTION <<<<<<
    ...
    SELECT-OPTIONS: DD_LAND1 FOR KNA1-LAND1 NO-DISPLAY,
    DD_KONZS FOR KNA1-KONZS NO-DISPLAY,
    DD_VBUND FOR KNA1-VBUND NO-DISPLAY,
    DD_AKONT FOR KNB1-AKONT NO-DISPLAY,
    DD_BUSAB FOR KNB1-BUSAB NO-DISPLAY,
    DD_HKONT FOR BSID-HKONT NO-DISPLAY,
    DD_GSBER FOR BSID-GSBER NO-DISPLAY,
    DD_BLART FOR BSID-BLART NO-DISPLAY,
    DD_BLDAT FOR BSID-BLDAT NO-DISPLAY,
    DD_BSCHL FOR BSID-BSCHL NO-DISPLAY,
    DD_WAERS FOR BSID-WAERS NO-DISPLAY,
    DD_MANST FOR BSID-MANST NO-DISPLAY,
    DD_ZLSCH FOR BSID-ZLSCH NO-DISPLAY,
    DD_MSCHL FOR BSID-MSCHL NO-DISPLAY,
    DD_BUDAT FOR BSID-BUDAT NO-DISPLAY,
    DD_ZUONR FOR BSID-ZUONR NO-DISPLAY,
    DD_UMSKZ FOR BSID-UMSKZ NO-DISPLAY,
    DD_SHKZG FOR BSID-SHKZG NO-DISPLAY.
    PARAMETERS: DD_OPOPT TYPE C FOR TABLE BSID NO-DISPLAY,
    DD_APOPT TYPE C FOR TABLE BSID NO-DISPLAY,
    *>>>> START OF DELETION <<<<<
    DD_IARCH TYPE C FOR TABLE BSID NO-DISPLAY,
    DD_TPC TYPE C FOR TABLE BSID NO-DISPLAY.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    DD_TPC TYPE C FOR TABLE BSID NO-DISPLAY.

    * For reading items from archive:
    SELECTION-SCREEN FUNCTION KEY 5 for table KNA1.
    PARAMETERS: dd_objec TYPE arch_obj-object
    FOR TABLE BSID NO-DISPLAY,
    dd_usedb TYPE boole_d
    FOR TABLE BSID NO-DISPLAY,
    dd_usear TYPE boole_d
    FOR TABLE BSID NO-DISPLAY,
    dd_useas TYPE boole_d
    FOR TABLE BSID NO-DISPLAY,
    dd_memor TYPE C
    FOR TABLE BSID NO-DISPLAY.
    SELECT-OPTIONS: dd_files FOR admi_files-archiv_key NO-DISPLAY.
    Parameters : DD_IARCH TYPE C
    FOR TABLE BSID NO-DISPLAY.
    *
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS DBKDFSEL
    *& Object header LDBA KDF
    *&---------------------------------------------------------------------*
    ...
    SELECTION-SCREEN FIELD SELECTION FOR TABLE BSIKEXT. "40C
    SELECTION-SCREEN FIELD SELECTION FOR TABLE BKPF.
    SELECTION-SCREEN FIELD SELECTION FOR TABLE BSEG.
    SELECTION-SCREEN FIELD SELECTION FOR TABLE GSEG. "30F

    *>>>> START OF DELETION <<<<<
    SELECTION-SCREEN BEGIN OF BLOCK KD_0 WITH FRAME TITLE TEXT-000.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    SELECTION-SCREEN BEGIN OF BLOCK KD_0 WITH FRAME TITLE TEXT-000.
    *>>>> END OF INSERTION <<<<<<
    ...
    SELECT-OPTIONS: KD_LAND1 FOR LFA1-LAND1 NO-DISPLAY,
    KD_KONZS FOR LFA1-KONZS NO-DISPLAY,
    KD_VBUND FOR LFA1-VBUND NO-DISPLAY,
    KD_AKONT FOR LFB1-AKONT NO-DISPLAY,
    KD_BUSAB FOR LFB1-BUSAB NO-DISPLAY,
    KD_HKONT FOR BSIK-HKONT NO-DISPLAY,
    KD_GSBER FOR BSIK-GSBER NO-DISPLAY,
    KD_BLART FOR BSIK-BLART NO-DISPLAY,
    KD_BLDAT FOR BSIK-BLDAT NO-DISPLAY,
    KD_BSCHL FOR BSIK-BSCHL NO-DISPLAY,
    KD_WAERS FOR BSIK-WAERS NO-DISPLAY,
    KD_ZLSPR FOR BSIK-ZLSPR NO-DISPLAY,
    KD_ZLSCH FOR BSIK-ZLSCH NO-DISPLAY,
    KD_BUDAT FOR BSIK-BUDAT NO-DISPLAY,
    KD_ZUONR FOR BSIK-ZUONR NO-DISPLAY,
    KD_UMSKZ FOR BSIK-UMSKZ NO-DISPLAY,
    KD_SHKZG FOR BSIK-SHKZG NO-DISPLAY.

    PARAMETERS: KD_OPOPT TYPE C FOR TABLE BSIK NO-DISPLAY,
    KD_APOPT TYPE C FOR TABLE BSIK NO-DISPLAY,
    *>>>> START OF DELETION <<<<<
    KD_IARCH TYPE C FOR TABLE BSIK NO-DISPLAY,
    KD_TPC TYPE C FOR TABLE BSIK NO-DISPLAY.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    KD_TPC TYPE C FOR TABLE BSIK NO-DISPLAY.

    * For reading items from archive
    SELECTION-SCREEN FUNCTION KEY 5 for table LFA1.
    PARAMETERS: kd_objec TYPE arch_obj-object
    FOR TABLE BSIK NO-DISPLAY,
    kd_usedb TYPE boole_d
    FOR TABLE BSIK NO-DISPLAY,
    kd_usear TYPE boole_d
    FOR TABLE BSIK NO-DISPLAY,
    kd_useas TYPE boole_d
    FOR TABLE BSIK NO-DISPLAY,
    kd_memor TYPE C
    FOR TABLE BSIK NO-DISPLAY.
    SELECT-OPTIONS: kd_files FOR admi_files-archiv_key NO-DISPLAY.
    Parameters : kD_IARCH TYPE C
    FOR TABLE BSIK NO-DISPLAY.
    *
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS DBSDFSEL
    *& Object header LDBA SDF
    *&---------------------------------------------------------------------*
    ...
    SELECTION-SCREEN FIELD SELECTION FOR TABLE BSISEXT. "40C
    SELECTION-SCREEN FIELD SELECTION FOR TABLE BKPF.
    SELECTION-SCREEN FIELD SELECTION FOR TABLE BSEG.
    SELECTION-SCREEN FIELD SELECTION FOR TABLE GSEG. "3.0F

    *>>>> START OF DELETION <<<<<
    SELECTION-SCREEN BEGIN OF BLOCK SD_0 WITH FRAME TITLE TEXT-000.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    SELECTION-SCREEN BEGIN OF BLOCK SD_0 WITH FRAME TITLE TEXT-000.
    *>>>> END OF INSERTION <<<<<<
    ...
    SELECT-OPTIONS: SD_SHKZG FOR BSIS-SHKZG NO-DISPLAY.
    SELECT-OPTIONS: SD_ZUONR FOR BSIS-ZUONR NO-DISPLAY.
    SELECT-OPTIONS: SD_GSBER FOR SKA1-KTOKS NO-DISPLAY.
    PARAMETERS: SD_OPOPT TYPE C FOR TABLE BSIS NO-DISPLAY,
    SD_APOPT TYPE C FOR TABLE BSIS NO-DISPLAY,
    *>>>> START OF DELETION <<<<<
    SD_IARCH TYPE C FOR TABLE BSIS NO-DISPLAY,
    SD_TPC TYPE C FOR TABLE BSIS NO-DISPLAY.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    SD_TPC TYPE C FOR TABLE BSIS NO-DISPLAY.

    * For reading items from archive:
    SELECTION-SCREEN FUNCTION KEY 5 for table SKA1.
    PARAMETERS: sd_objec TYPE arch_obj-object
    FOR TABLE BSIS NO-DISPLAY,
    sd_usedb TYPE boole_d
    FOR TABLE BSIS NO-DISPLAY,
    sd_usear TYPE boole_d
    FOR TABLE BSIS NO-DISPLAY,
    sd_useas TYPE boole_d
    FOR TABLE BSIS NO-DISPLAY,
    sd_memor TYPE C
    FOR TABLE BSIS NO-DISPLAY.
    SELECT-OPTIONS: sd_files FOR admi_files-archiv_key NO-DISPLAY.
    Parameters : sd_IARCH TYPE C
    FOR TABLE BSIS NO-DISPLAY.
    *
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS LFAR1F05
    *& Object header FUGR FAR1
    *&---------------------------------------------------------------------*
    *& FORM SELECTIONS_CONFIRM
    *&---------------------------------------------------------------------*
    ...
    READ TABLE lt_dfies WITH KEY fieldname = l_frange-fieldname
    TRANSPORTING NO FIELDS.
    IF NOT sy-subrc IS INITIAL.
    RAISE selections_error.
    ENDIF.
    ENDLOOP.
    *>>>> START OF DELETION <<<<<
    ENDLOOP.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    refresh: lt_frange.
    ENDLOOP.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SELECTIONS_FOR_AS_CREATE
    *&---------------------------------------------------------------------*
    ...
    ENDIF.
    ENDLOOP.
    ENDLOOP.

    ENDFORM. " SELECTIONS_FOR_AS_CREATE
    *>>>> START OF INSERTION <<<<

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SELECTIONS_CHECK
    *&---------------------------------------------------------------------*
    ...
    * criteria and delete the entries from t_data which do not meet
    *----------------------------------------------------------------------*
    FORM selections_check TABLES t_data TYPE table
    USING value(p_selections) TYPE rsds_range.

    *>>>> START OF DELETION <<<<<
    DATA: l_tabref TYPE REF TO data,
    l_fieldref TYPE REF TO data,
    l_tabfld TYPE c LENGTH 61,
    lt_frange TYPE rsds_frange_t,
    l_frange TYPE rsds_frange,
    lv_data_tabix LIKE sy-tabix.

    FIELD-SYMBOLS: TYPE ANY,
    TYPE ANY.

    APPEND LINES OF p_selections-frange_t TO lt_frange.
    CREATE DATA l_tabref TYPE (p_selections-tablename).
    ASSIGN l_tabref->* TO
    .

    LOOP AT t_data ASSIGNING
    .
    lv_data_tabix = sy-tabix.
    LOOP AT lt_frange INTO l_frange.
    CONCATENATE p_selections-tablename '-'
    l_frange-fieldname INTO l_tabfld.
    CREATE DATA l_fieldref TYPE (l_tabfld).
    ASSIGN l_fieldref->* TO .
    ASSIGN COMPONENT l_frange-fieldname
    OF STRUCTURE
    TO .
    IF NOT IN l_frange-selopt_t.
    DELETE t_data INDEX lv_data_tabix.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    DATA: lt_frange TYPE rsds_frange_t,
    l_frange TYPE rsds_frange,
    lv_data_tabix LIKE sy-tabix.

    FIELD-SYMBOLS: TYPE ANY,
    TYPE ANY.

    APPEND LINES OF p_selections-frange_t TO lt_frange.

    LOOP AT t_data ASSIGNING .
    lv_data_tabix = sy-tabix.
    LOOP AT lt_frange INTO l_frange.
    ASSIGN COMPONENT l_frange-fieldname
    OF STRUCTURE TO .
    IF NOT IN l_frange-selopt_t.
    DELETE t_data INDEX lv_data_tabix.
    EXIT.
    *>>>> END OF INSERTION <<<<<<
    ...
    ENDIF.
    ENDLOOP.
    ENDLOOP.

    ENDFORM. " SELECTIONS_CHECK
    *>>>> START OF INSERTION <<<<

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM ACCESS_KIND_GET
    *&---------------------------------------------------------------------*
    ...
    CLEAR: l_result_cnt, l_obj_cnt.
    REFRESH: lt_result.
    ENDAT.
    ENDLOOP.
    ENDFORM. " ACCESS_KIND_GET
    *>>>> START OF INSERTION <<<<

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SINGLE_OBJECT_READ
    *&---------------------------------------------------------------------*
    ...
    *----------------------------------------------------------------------*
    FORM single_object_read TABLES pt_selections TYPE rsds_trange
    pt_bkpf TYPE gty_t_bkpf
    pt_bseg TYPE gty_t_bseg
    USING p_handle LIKE sy-tabix
    *>>>> START OF DELETION <<<<<
    p_result TYPE gty_result
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    p_arkey TYPE arkey
    p_offst TYPE admi_offst
    *>>>> END OF INSERTION <<<<<<
    ...
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    LOOP AT pt_bkpf INTO lw_bkpf.
    MOVE-CORRESPONDING lw_bkpf TO lt_abkpf.
    *>>>> START OF DELETION <<<<<
    lt_abkpf-archiv_key = p_result-archivekey.
    lt_abkpf-offst = p_result-archiveofs.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    lt_abkpf-archiv_key = p_arkey.
    lt_abkpf-offst = p_offst.
    *>>>> END OF INSERTION <<<<<<
    ...
    ENDLOOP.
    REFRESH lt_abkpf.
    ENDIF.
    ENDIF.
    ENDIF.
    *>>>> START OF DELETION <<<<<
    ENDFORM. " SINGLE_OBJECT_READ
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    IF pt_bseg[] IS INITIAL.
    REFRESH pt_bkpf.
    ENDIF.
    ENDFORM. " SINGLE_OBJECT_READ

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM ARCHIVE_OPEN
    *&---------------------------------------------------------------------*
    ...
    CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
    EXPORTING
    archive_handle = p_handle
    EXCEPTIONS
    OTHERS = 0.
    ENDIF.
    p_continue_flag = 'X'.
    ENDIF.
    ENDFORM. " ARCHIVE_OPEN
    *>>>> START OF INSERTION <<<<

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM NEXT_OBJECT_SCAN
    *&---------------------------------------------------------------------*
    ...
    ENDIF.

    PERFORM single_object_read TABLES pt_selections
    pt_bkpf
    pt_bseg
    USING p_handle
    *>>>> START OF DELETION <<<<<
    lw_result
    p_convert_currency.

    ENDFORM. " NEXT_OBJECT_SCAN
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    lw_result-archivekey
    lw_result-archiveofs
    p_convert_currency.

    ENDFORM. " NEXT_OBJECT_SCAN

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PROGRESS_SHOW
    *&---------------------------------------------------------------------*
    ...
    *&---------------------------------------------------------------------*
    *& Form PROGRESS_SHOW
    *&---------------------------------------------------------------------*
    *>>>> START OF DELETION <<<<<
    FORM progress_show USING p_show_progess TYPE boole
    p_sum TYPE i
    p_reset TYPE c.

    DATA: l_percentage TYPE p.
    STATICS: l_cnt TYPE i,
    l_cut_cnt TYPE i,
    l_msg_cnt TYPE i.

    CHECK NOT p_show_progess IS INITIAL.
    IF p_reset = 'X'.
    l_percentage = 100 * l_cnt / p_sum.
    CALL FUNCTION 'FI_PROGRESS_INDICATOR'
    EXPORTING
    percentage = l_percentage
    messageclass = 'F9'
    messagenumber = '021'
    messagepar1 = l_cnt
    messagepar2 = p_sum
    EXCEPTIONS
    OTHERS = 0.
    CLEAR: l_cnt, l_cut_cnt, l_msg_cnt.
    ELSE.
    ADD 1 TO l_cnt.
    ADD 1 TO l_msg_cnt.
    IF l_msg_cnt >= l_cut_cnt.
    l_percentage = 100 * l_cnt / p_sum.
    CALL FUNCTION 'FI_PROGRESS_INDICATOR'
    EXPORTING
    percentage = l_percentage
    messageclass = 'F9'
    messagenumber = '021'
    messagepar1 = l_cnt
    messagepar2 = p_sum
    EXCEPTIONS
    OTHERS = 0.
    CLEAR l_msg_cnt.
    IF l_cnt >= 10.
    l_cut_cnt = 10.
    ENDIF.
    IF l_cnt >= 100.
    l_cut_cnt = 100.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDFORM. " PROGRESS_SHOW
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * Dialog: progress indicator every 10 seconds and at begin/end of call
    * Batch : s-message every 30 minutes and at begin/end of call
    *----------------------------------------------------------------------*
    FORM progress_show USING p_show_progess TYPE boole
    p_sum TYPE i
    p_reset TYPE c.

    DATA: l_time LIKE sy-uzeit,
    l_percentage TYPE p.
    STATICS: s_time_next LIKE sy-uzeit,
    s_datum_next LIKE sy-datum,
    s_cnt TYPE i.

    CHECK NOT p_show_progess IS INITIAL AND NOT p_sum IS INITIAL.

    IF p_reset IS INITIAL.
    ADD 1 TO s_cnt.
    ENDIF.

    GET TIME FIELD l_time.
    IF s_time_next IS INITIAL AND s_datum_next IS INITIAL.
    s_time_next = l_time.
    s_datum_next = sy-datum.
    ENDIF.

    IF l_time >= s_time_next AND sy-datum = s_datum_next OR
    sy-datum > s_datum_next OR p_reset = 'X' OR s_cnt = 1.

    l_percentage = 100 * s_cnt / p_sum.
    CALL FUNCTION 'FI_PROGRESS_INDICATOR'
    EXPORTING
    percentage = l_percentage
    messageclass = 'F9'
    messagenumber = '022'
    messagepar1 = p_sum
    messagepar2 = s_cnt
    EXCEPTIONS
    OTHERS = 0.

    IF p_reset = 'X'.
    CLEAR: s_cnt.
    ENDIF.

    IF sy-batch IS INITIAL.
    s_time_next = l_time + 10.
    ELSE.
    s_time_next = l_time + 1800.
    ENDIF.

    IF sy-datum > s_datum_next.
    s_datum_next = sy-datum.
    ENDIF.
    IF s_time_next < l_time.
    s_datum_next = sy-datum + 1.
    ENDIF.
    ENDIF.

    ENDFORM. " PROGRESS_SHOW

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS LFAR1IDX
    *& Object header FUGR FAR1
    *&---------------------------------------------------------------------*
    *>>>> START OF DELETION <<<<<
    *&---------------------------------------------------------------------*
    *& Include LFAR1IDX *
    *&---------------------------------------------------------------------*
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    *----------------------------------------------------------------------*
    * INCLUDE LFAR1IDX *
    *----------------------------------------------------------------------*
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS RFITEMAP
    *& Object header PROG RFITEMAP
    *&---------------------------------------------------------------------*
    *& REPORT RFITEMAP
    *&---------------------------------------------------------------------*
    ...
    report rfitemap message-id msitem no standard page heading.

    *... general data definitions:
    include rfitem_def.
    *... icons and symbols:
    include .

    *>>>> START OF DELETION <<<<<
    tables: lfa1, lfb1, bsik, bsid.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    tables: lfa1, lfb1, bsik, bsid, admi_files.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& START-OF-SELECTION
    *&---------------------------------------------------------------------*
    ...
    start-of-selection.
    ***

    clear: x_stop.
    *>>>> START OF DELETION <<<<<
    * number of archived items as i-message:
    kd_iarch = 'X'.
    * set parameters:
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * set parameters:
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& GET BSIK
    *&---------------------------------------------------------------------*
    ...
    get bsik.
    *>>>> START OF DELETION <<<<<
    * line items, basic fields:
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * importing BKPF and BSEG data from archive
    PERFORM import_arch_from_memory.
    * line items, basic fields:
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM MAP_SEL_TO_LDB
    *&---------------------------------------------------------------------*
    ...
    kd_budat[] = so_budat[].
    kd_opopt = 'X'.
    kd_apopt = 'X'.
    endcase.
    pa_stida_default = kd_stida.
    *>>>> START OF DELETION <<<<<
    endform. "map_sel_to_ldb
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * For reading from archives:
    * number of archived items as i-message:
    kd_iarch = 'X'.
    kd_memor = 'X'.

    endform. "map_sel_to_ldb
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SET_PARAMETERS
    *&---------------------------------------------------------------------*
    ...
    if sy-subrc = 0 and so_wlbuk-sign = 'I' and so_wlbuk-option = 'EQ'
    and not so_wlbuk-low is initial.
    set parameter id 'BUK' field so_wlbuk-low.
    endif.
    endif.

    *>>>> START OF DELETION <<<<<
    endform. "set_parameters
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * Set parameters for reading from archiv
    gd_usear = kd_usear.
    gd_usedb = kd_usedb.
    gd_memor = 'X'.

    endform. "set_parameters
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM READ_CUSTOMER_ITEMS
    *&---------------------------------------------------------------------*
    ...
    call function 'LDB_PROCESS'
    EXPORTING
    ldbname = 'DDF'
    expressions = it_dyn_texpr[]
    TABLES
    callback = it_callback
    selections = it_selscreen
    EXCEPTIONS
    ldb_selections_error = 1
    ldb_selections_not_accepted = 2
    free_selections_error = 3
    callback_no_event = 4
    callback_no_program = 5
    callback_no_cbform = 6
    others = 7.
    if sy-subrc ne 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *>>>> START OF DELETION <<<<<
    endif.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    else.
    PERFORM import_arch_from_memory.
    endif.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM READ_CENTRAL_ITEMS
    *&---------------------------------------------------------------------*
    ...
    call function 'LDB_PROCESS'
    exporting
    ldbname = 'KDF'
    expressions = it_dyn_texpr[]
    * DYN_NODE_TYPES =
    tables
    callback = it_callback
    selections = it_selscreen
    exceptions
    ldb_not_reentrant = 1
    ldb_incorrect = 2
    ldb_already_running = 3
    ldb_error = 4
    ldb_selections_error = 5
    ldb_selections_not_accepted = 6
    free_selections_error = 10
    callback_no_event = 11
    callback_node_duplicate = 12
    callback_no_program = 13
    callback_no_cbform = 14
    *>>>> START OF DELETION <<<<<
    .
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    others = 17.
    if sy-subrc = 0 .
    PERFORM import_arch_from_memory.
    endif.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM DDF_SELSCREEN
    *&---------------------------------------------------------------------*
    ...
    append it_selscreen.
    endloop.
    if sy-subrc <> 0.
    sy-subrc = 0.
    endif.
    *>>>> START OF DELETION <<<<<
    endif.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * Parameters and Select Options for Archives
    clear it_selscreen.
    it_selscreen-selname = 'DD_USEDB'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = kd_usedb.
    append it_selscreen.
    clear it_selscreen.
    it_selscreen-selname = 'DD_USEAR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = kd_usear.
    append it_selscreen.
    clear it_selscreen.
    it_selscreen-selname = 'DD_USEAS'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = kd_useas.
    append it_selscreen.
    if not kd_files[] is initial.
    loop at kd_files.
    clear it_selscreen.
    it_selscreen-selname = 'DD_FILES'.
    it_selscreen-kind = 'S'.
    move-corresponding kd_files to it_selscreen.
    append it_selscreen.
    endloop.
    endif.
    clear it_selscreen.
    it_selscreen-selname = 'DD_MEMOR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = kd_memor.
    append it_selscreen.
    clear it_selscreen.
    it_selscreen-selname = 'DD_IARCH'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = kd_iarch.
    append it_selscreen.

    endif.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM KDF_SELSCREEN
    *&---------------------------------------------------------------------*
    ...
    it_selscreen-kind = 'S'.
    move-corresponding kd_budat to it_selscreen.
    append it_selscreen.
    endloop.

    *>>>> START OF DELETION <<<<<
    endform. " KDF_SELSCREEN
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * Parameters and Select Options for Archives
    CLEAR it_selscreen.
    it_selscreen-selname = 'KD_USEDB'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = kd_usedb.
    APPEND it_selscreen.
    CLEAR it_selscreen.
    it_selscreen-selname = 'KD_USEAR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = kd_usear.
    APPEND it_selscreen.
    CLEAR it_selscreen.
    it_selscreen-selname = 'KD_USEAS'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = kd_useas.
    APPEND it_selscreen.
    if not kd_files[] is initial.
    LOOP AT kd_files.
    CLEAR it_selscreen.
    it_selscreen-selname = 'KD_FILES'.
    it_selscreen-kind = 'S'.
    MOVE-CORRESPONDING kd_files TO it_selscreen.
    APPEND it_selscreen.
    ENDLOOP.
    endif.
    CLEAR it_selscreen.
    it_selscreen-selname = 'KD_MEMOR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = kd_memor.
    APPEND it_selscreen.
    clear it_selscreen.
    it_selscreen-selname = 'KD_MEMOR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = kd_memor.
    append it_selscreen.


    endform. " KDF_SELSCREEN
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS RFITEMAR
    *& Object header PROG RFITEMAR
    *&---------------------------------------------------------------------*
    *& REPORT RFITEMAR
    *&---------------------------------------------------------------------*
    ...
    report rfitemar message-id msitem no standard page heading.
    * hallo
    *... general data definitions:
    include rfitem_def.
    *... icons and symbols:
    include .

    *>>>> START OF DELETION <<<<<
    tables: kna1, knb1, bsid, bsik.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    tables: kna1, knb1, bsid, bsik, admi_files.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& START-OF-SELECTION
    *&---------------------------------------------------------------------*
    ...
    start-of-selection.
    ***

    clear: x_stop.
    *>>>> START OF DELETION <<<<<
    * number of archived items as i-message:
    dd_iarch = 'X'.
    * set parameters:
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * set parameters:
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& GET BSID
    *&---------------------------------------------------------------------*
    ...
    get bsid.
    *>>>> START OF DELETION <<<<<
    * line items, basic fields:
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * importing BKPF and BSEG data from archive
    PERFORM import_arch_from_memory.
    * line items, basic fields:
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM MAP_SEL_TO_LDB
    *&---------------------------------------------------------------------*
    ...
    dd_budat[] = so_budat[].
    dd_opopt = 'X'.
    dd_apopt = 'X'.
    endcase.
    pa_stida_default = dd_stida.
    *>>>> START OF DELETION <<<<<
    endform. "map_sel_to_ldb
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * For reading from archives:
    * number of archived items as i-message:
    dd_iarch = 'X'.
    dd_memor = 'X'.

    endform. "map_sel_to_ldb
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SET_PARAMETERS
    *&---------------------------------------------------------------------*
    ...
    if sy-subrc = 0 and so_wlbuk-sign = 'I' and so_wlbuk-option = 'EQ'
    and not so_wlbuk-low is initial.
    set parameter id 'BUK' field so_wlbuk-low.
    endif.
    endif.

    *>>>> START OF DELETION <<<<<
    endform. "set_parameters
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * Set parameters for reading from archiv
    gd_usear = dd_usear.
    gd_usedb = dd_usedb.
    gd_memor = 'X'.

    endform. "set_parameters
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM READ_VENDOR_ITEMS
    *&---------------------------------------------------------------------*
    ...
    call function 'LDB_PROCESS'
    EXPORTING
    ldbname = 'KDF'
    expressions = it_dyn_texpr[]
    TABLES
    callback = it_callback
    selections = it_selscreen
    EXCEPTIONS
    ldb_selections_error = 1
    ldb_selections_not_accepted = 2
    free_selections_error = 3
    callback_no_event = 4
    callback_no_program = 5
    callback_no_cbform = 6
    others = 7.
    if sy-subrc ne 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *>>>> START OF DELETION <<<<<
    endif.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    else.
    PERFORM import_arch_from_memory.
    endif.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM READ_CENTRAL_ITEMS
    *&---------------------------------------------------------------------*
    ...
    call function 'LDB_PROCESS'
    EXPORTING
    ldbname = 'DDF'
    expressions = it_dyn_texpr[]
    TABLES
    callback = it_callback
    selections = it_selscreen
    EXCEPTIONS
    ldb_not_reentrant = 1
    ldb_incorrect = 2
    ldb_already_running = 3
    ldb_error = 4
    ldb_selections_error = 5
    ldb_selections_not_accepted = 6
    free_selections_error = 10
    callback_no_event = 11
    callback_node_duplicate = 12
    callback_no_program = 13
    callback_no_cbform = 14
    others = 17.
    *>>>> START OF DELETION <<<<<
    endloop.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    if sy-subrc = 0 .
    PERFORM import_arch_from_memory.
    endif.
    endloop.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM KDF_SELSCREEN
    *&---------------------------------------------------------------------*
    ...
    append it_selscreen.
    endloop.
    if sy-subrc <> 0.
    sy-subrc = 0.
    endif.
    *>>>> START OF DELETION <<<<<
    endif.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * Parameters and Select Options for Archives
    clear it_selscreen.
    it_selscreen-selname = 'KD_USEDB'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = dd_usedb.
    append it_selscreen.
    clear it_selscreen.
    it_selscreen-selname = 'KD_USEAR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = dd_usear.
    append it_selscreen.
    clear it_selscreen.
    it_selscreen-selname = 'KD_USEAS'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = dd_useas.
    append it_selscreen.
    if not dd_files[] is initial.
    loop at dd_files.
    clear it_selscreen.
    it_selscreen-selname = 'KD_FILES'.
    it_selscreen-kind = 'S'.
    move-corresponding dd_files to it_selscreen.
    append it_selscreen.
    endloop.
    endif.
    clear it_selscreen.
    it_selscreen-selname = 'KD_MEMOR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = dd_memor.
    append it_selscreen.
    clear it_selscreen.
    it_selscreen-selname = 'KD_IARCH'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = dd_iarch.
    append it_selscreen.

    endif.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM DDF_SELSCREEN
    *&---------------------------------------------------------------------*
    ...
    it_selscreen-kind = 'S'.
    move-corresponding dd_budat to it_selscreen.
    append it_selscreen.
    endloop.

    *>>>> START OF DELETION <<<<<
    endform. " DDF_SELSCREEN
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * Parameters and Select Options for Archives
    CLEAR it_selscreen.
    it_selscreen-selname = 'DD_USEDB'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = dd_usedb.
    APPEND it_selscreen.
    CLEAR it_selscreen.
    it_selscreen-selname = 'DD_USEAR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = dd_usear.
    APPEND it_selscreen.
    CLEAR it_selscreen.
    it_selscreen-selname = 'DD_USEAS'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = dd_useas.
    APPEND it_selscreen.
    if not dd_files[] is initial.
    LOOP AT dd_files.
    CLEAR it_selscreen.
    it_selscreen-selname = 'DD_FILES'.
    it_selscreen-kind = 'S'.
    MOVE-CORRESPONDING dd_files TO it_selscreen.
    APPEND it_selscreen.
    ENDLOOP.
    endif.
    CLEAR it_selscreen.
    it_selscreen-selname = 'DD_MEMOR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = dd_memor.
    APPEND it_selscreen.
    clear it_selscreen.
    it_selscreen-selname = 'DD_MEMOR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = dd_memor.
    append it_selscreen.

    endform. " DDF_SELSCREEN
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS RFITEMGL
    *& Object header PROG RFITEMGL
    *&---------------------------------------------------------------------*
    *& REPORT RFITEMGL
    *&---------------------------------------------------------------------*
    ...
    report RFITEMGL message-id MSITEM no standard page heading.

    *... general data definitions:
    include RFITEM_DEF.
    *... icons and symbols:
    include .

    *>>>> START OF DELETION <<<<<
    tables: SKAT, SKB1, BSIS.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    tables: skat, skb1, bsis, admi_files.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& START-OF-SELECTION
    *&---------------------------------------------------------------------*
    ...
    start-of-selection.
    ***

    clear: X_STOP.
    *>>>> START OF DELETION <<<<<
    * number of archived items as i-message:
    SD_IARCH = 'X'.
    * set parameters:
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * set parameters:
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM MAP_SEL_TO_LDB
    *&---------------------------------------------------------------------*
    ...
    SD_BUDAT[] = SO_BUDAT[].
    SD_OPOPT = 'X'.
    SD_APOPT = 'X'.
    endcase.
    PA_STIDA_DEFAULT = SD_STIDA.
    *>>>> START OF DELETION <<<<<
    endform. "map_sel_to_ldb
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * For reading from archives:
    * number of archived items as i-message:
    sd_iarch = 'X'.
    sd_memor = 'X'.

    endform. "map_sel_to_ldb
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SET_PARAMETERS
    *&---------------------------------------------------------------------*
    ...
    if SY-SUBRC = 0 and SO_WLBUK-SIGN = 'I' and SO_WLBUK-OPTION = 'EQ'
    and not SO_WLBUK-LOW is initial.
    set parameter id 'BUK' field SO_WLBUK-LOW.
    endif.
    endif.

    *>>>> START OF DELETION <<<<<
    endform. "set_parameters
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * Set parameters for reading from archiv
    gd_usear = sd_usear.
    gd_usedb = sd_usedb.
    gd_memor = 'X'.

    endform. "set_parameters
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM INCLUDE_PL_ACCOUNTS
    *&---------------------------------------------------------------------*
    ...
    call function 'LDB_PROCESS'
    EXPORTING
    LDBNAME = 'SDF'
    EXPRESSIONS = IT_DYN_TEXPR[]
    TABLES
    CALLBACK = IT_CALLBACK
    SELECTIONS = IT_SELSCREEN
    EXCEPTIONS
    LDB_SELECTIONS_ERROR = 1
    LDB_SELECTIONS_NOT_ACCEPTED = 2
    FREE_SELECTIONS_ERROR = 3
    CALLBACK_NO_EVENT = 4
    CALLBACK_NO_PROGRAM = 5
    CALLBACK_NO_CBFORM = 6
    others = 7.
    if SY-SUBRC ne 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *>>>> START OF DELETION <<<<<
    endif.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    else.
    PERFORM import_arch_from_memory.
    endif.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SDF_SELSCREEN
    *&---------------------------------------------------------------------*
    ...
    IT_SELSCREEN-SELNAME = 'SD_BUDAT'.
    IT_SELSCREEN-KIND = 'S'.
    move-corresponding SD_BUDAT to IT_SELSCREEN.
    append IT_SELSCREEN.
    endloop.
    *>>>> START OF DELETION <<<<<
    * modify SO_YRPER:
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * modify SO_YRPER:
    *>>>> END OF INSERTION <<<<<<
    ...
    move-corresponding GD_YRPER to IT_SELSCREEN.
    append IT_SELSCREEN.
    endloop.
    if SY-SUBRC <> 0.
    SY-SUBRC = 0.
    *>>>> START OF DELETION <<<<<
    endif.

    endform. " SDF_SELSCREEN

    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    endif.

    * Parameters and Select Options for Archives
    CLEAR it_selscreen.
    it_selscreen-selname = 'SD_USEDB'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = sd_usedb.
    APPEND it_selscreen.
    CLEAR it_selscreen.
    it_selscreen-selname = 'SD_USEAR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = sd_usear.
    APPEND it_selscreen.
    CLEAR it_selscreen.
    it_selscreen-selname = 'SD_USEAS'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = sd_useas.
    APPEND it_selscreen.
    if not sd_files[] is initial.
    LOOP AT sd_files.
    CLEAR it_selscreen.
    it_selscreen-selname = 'SD_FILES'.
    it_selscreen-kind = 'S'.
    MOVE-CORRESPONDING sd_files TO it_selscreen.
    APPEND it_selscreen.
    ENDLOOP.
    endif.
    CLEAR it_selscreen.
    it_selscreen-selname = 'SD_MEMOR'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = sd_memor.
    APPEND it_selscreen.
    CLEAR it_selscreen.
    it_selscreen-selname = 'SD_IARCH'.
    it_selscreen-kind = 'P'.
    it_selscreen-sign = 'I'.
    it_selscreen-option = 'EQ'.
    it_selscreen-low = sd_iarch.
    APPEND it_selscreen.


    endform. " SDF_SELSCREEN
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM CB_SDF_GET_BSIS
    *&---------------------------------------------------------------------*
    ...
    form CB_SDF_GET_BSIS using NAME like LDBN-LDBNODE
    LS_BSIS like BSIS
    MODE type C
    SELECTED type C.
    BSIS = LS_BSIS.
    perform POS_TABLE_FILL changing X_STOP.
    endform. "cb_sdf_get_bsis

    *>>>> START OF DELETION <<<<<
    *&---------------------------------------------------------------------*
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    *&---------------------------------------------------------------------*
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS RFITEM_DEF
    *& Object header PROG RFITEM_DEF
    *&---------------------------------------------------------------------*
    ...
    constants:
    c_guicnt like sy-tabix value 100,
    c_repid_ar like sy-repid value 'RFITEMAR',
    c_repid_ap like sy-repid value 'RFITEMAP',
    c_repid_gl like sy-repid value 'RFITEMGL',
    c_koart_ar like bseg-koart value 'D',
    c_koart_ap like bseg-koart value 'K',
    c_koart_gl like bseg-koart value 'S',
    c_true type c value 'X',
    c_false type c value space,
    c_x type c value 'X'.
    *>>>> START OF INSERTION <<<<


    * Tables for reading from archive:
    data: ybseg type bseg occurs 10,
    xbseg type hashed table of bseg
    with unique key bukrs belnr gjahr buzei,
    ybkpf type bkpf occurs 10,
    xbkpf type hashed table of bkpf
    with unique key bukrs belnr gjahr.

    types : begin of gty_pos_reduced,
    bukrs type skb1-bukrs,
    belnr type bseg-belnr,
    gjahr type bseg-gjahr,
    buzei type bseg-buzei,
    budat type bkpf-budat,
    end of gty_pos_reduced.
    data: gt_pos_posted type sorted table of gty_pos_reduced
    with unique key bukrs belnr gjahr buzei budat,
    gt_pos_parked type sorted table of gty_pos_reduced
    with unique key bukrs belnr gjahr buzei budat,
    gt_pos_archived type sorted table of gty_pos_reduced
    with unique key bukrs belnr gjahr buzei budat,
    gd_pos_reduced type gty_pos_reduced.

    field-symbols : type gty_pos_reduced.

    DATA: gd_read_memo_done TYPE c.

    data: gd_usear type boole_d,
    gd_usedb type boole_d,
    gd_memor type c.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS RFITEM_INC
    *& Object header PROG RFITEM_INC
    *&---------------------------------------------------------------------*
    *& FORM GET_INITIAL_FIELDCAT
    *&---------------------------------------------------------------------*
    ...
    ls_variant = rs_variant.

    *... build maximal fieldcat:
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    *>>>> START OF DELETION <<<<<
    i_buffer_active = 'X'
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * i_buffer_active = 'X'
    i_bypassing_buffer = 'X'
    *>>>> END OF INSERTION <<<<<<
    ...
    call function 'REUSE_ALV_VARIANT_SELECT'
    EXPORTING
    i_dialog = ' '
    i_user_specific = 'X'
    it_default_fieldcat = it_max_fieldcat
    i_layout = dummy_layout
    *>>>> START OF DELETION <<<<<
    i_buffer_active = 'X'
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * i_buffer_active = 'X'
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM READ_SPECIAL_TABLES
    *&---------------------------------------------------------------------*
    ...
    data: posindex like sy-tabix.

    *... check item table filled?
    read table it_pos index 1.
    check sy-subrc = 0.
    *... loop over all pending tables:
    loop at it_spectab where tstat = 'P'.
    *>>>> START OF DELETION <<<<<
    case it_spectab-tname.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * building additional help tables for BKPF and BSEG for optimized
    * database selections.
    perform create_performance_tables using it_spectab-tname.
    case it_spectab-tname.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM COMPLETE_BKPF
    *&---------------------------------------------------------------------*
    ...
    call function 'OWN_LOGICAL_SYSTEM_GET'
    IMPORTING
    own_logical_system = sd_logsys
    EXCEPTIONS
    others = 1.
    sd_lsflag = 'X'.
    endif.

    *>>>> START OF DELETION <<<<<
    *... first posted items table:

    if b0sg-xstan = 'X'.
    select (gt_spec_fields)
    from bkpf
    into corresponding fields of wa_bkpf
    for all entries in it_pos
    where bukrs = it_pos-bukrs
    and belnr = it_pos-belnr
    and gjahr = it_pos-gjahr.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * reading special fields from archiv infos.
    if gd_usear = 'X'.
    loop at gt_pos_archived assigning .
    read table xbkpf into wa_bkpf
    with table key bukrs = -bukrs
    belnr = -belnr
    gjahr = -gjahr.
    *>>>> END OF INSERTION <<<<<<
    ...
    wa_bkpf-awsys = sd_logsys.
    endif.
    * expiring currencies:
    if not gd_expcur_flag is initial.
    perform item_curr_convert_bkpf using gd_expcur_proc
    *>>>> START OF DELETION <<<<<
    pa_stida_default
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    pa_stida
    *>>>> END OF INSERTION <<<<<<
    ...
    else.
    exit.
    endif.
    endloop.
    endif.
    *>>>> START OF DELETION <<<<<

    endselect.
    endif.

    *... now parked items table:
    if b0sg-xstav = 'X'.
    clear wa_bkpf.
    ld_tablename = 'VBKPF'.
    PERFORM SPECIAL_FIELDS_MODIFY USING ld_tablename.
    * ...If both, normal and parked items have to be read, there are usually
    * ...only a very few parked items and a lot of normal ones.
    * ...The 'select ...for all enties in ...' statement is typically very
    * ...slow in this situation.
    if b0sg-xstan = 'X'.
    loop at it_pos where bstat ca 'VWZ'.
    ld_indexh = sy-tabix.
    exit.
    endloop.
    if sy-subrc = 0.
    do.
    select single (gt_spec_fields)
    from vbkpf
    into corresponding fields of wa_bkpf
    where bukrs = it_pos-bukrs
    and belnr = it_pos-belnr
    and gjahr = it_pos-gjahr.

    * fill logical system id:
    if wa_bkpf-awsys is initial.
    wa_bkpf-awsys = sd_logsys.
    endif.
    * expiring currencies:
    if not gd_expcur_flag is initial.
    perform item_curr_convert_bkpf using gd_expcur_proc
    pa_stida_default
    changing wa_bkpf.
    endif.

    perform move_special_fields using it_spectab-tname.
    modify it_pos index ld_indexh.

    ld_index = ld_indexh + 1.
    loop at it_pos from ld_index where bstat ca 'VWZ'.
    ld_indexh = sy-tabix.
    if it_pos-bukrs = wa_bkpf-bukrs and
    it_pos-belnr = wa_bkpf-belnr and
    it_pos-gjahr = wa_bkpf-gjahr.
    perform move_special_fields using it_spectab-tname.
    modify it_pos index ld_indexh.
    else.
    exit.
    endif.
    endloop.
    if sy-subrc <> 0.
    exit.
    endif.
    enddo.
    endif.
    * ...handling the case that no normal items are selected.
    else.
    select (gt_spec_fields)
    from vbkpf
    into corresponding fields of wa_bkpf
    for all entries in it_pos
    where bukrs = it_pos-bukrs
    and belnr = it_pos-belnr
    and gjahr = it_pos-gjahr
    and budat = it_pos-budat.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    endloop.
    endif.
    * reading special fields from database
    if gd_usedb = 'X'.
    *... first posted items table:
    if b0sg-xstan = 'X' and not gt_pos_posted[] is initial.
    select (gt_spec_fields)
    from bkpf
    into corresponding fields of wa_bkpf
    for all entries in gt_pos_posted
    where bukrs = gt_pos_posted-bukrs
    and belnr = gt_pos_posted-belnr
    and gjahr = gt_pos_posted-gjahr.
    * fill logical system id:
    if wa_bkpf-awsys is initial.
    wa_bkpf-awsys = sd_logsys.
    endif.
    * expiring currencies:
    if not gd_expcur_flag is initial.
    perform item_curr_convert_bkpf using gd_expcur_proc
    pa_stida
    changing wa_bkpf.
    endif.
    * fill special fields for all lines of document:
    read table it_pos with key bukrs = wa_bkpf-bukrs
    belnr = wa_bkpf-belnr
    gjahr = wa_bkpf-gjahr
    binary search.
    if sy-subrc eq 0.
    perform move_special_fields using it_spectab-tname.
    modify it_pos index sy-tabix.
    ld_index = sy-tabix + 1.
    loop at it_pos from ld_index.
    if it_pos-bukrs = wa_bkpf-bukrs and
    it_pos-belnr = wa_bkpf-belnr and
    it_pos-gjahr = wa_bkpf-gjahr.
    perform move_special_fields using it_spectab-tname.
    modify it_pos.
    else.
    exit.
    endif.
    endloop.
    endif.

    endselect.
    endif.

    *... now parked items table:
    if b0sg-xstav = 'X' and not gt_pos_parked[] is initial.
    clear wa_bkpf.
    ld_tablename = 'VBKPF'.
    PERFORM SPECIAL_FIELDS_MODIFY USING ld_tablename.
    select (gt_spec_fields)
    from vbkpf
    into corresponding fields of wa_bkpf
    for all entries in gt_pos_parked
    where bukrs = gt_pos_parked-bukrs
    and belnr = gt_pos_parked-belnr
    and gjahr = gt_pos_parked-gjahr
    and budat = gt_pos_parked-budat.
    *>>>> END OF INSERTION <<<<<<
    ...
    wa_bkpf-awsys = sd_logsys.
    endif.
    * expiring currencies:
    if not gd_expcur_flag is initial.
    perform item_curr_convert_bkpf using gd_expcur_proc
    *>>>> START OF DELETION <<<<<
    pa_stida_default
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    pa_stida
    *>>>> END OF INSERTION <<<<<<
    ...
    endif.
    endif.

    PERFORM IT_POS_SORT_BACK TABLES IT_POS.

    *>>>> START OF DELETION <<<<<

    endform. " COMPLETE_BKPF
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    endform. " COMPLETE_BKPF

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM COMPLETE_BSEG
    *&---------------------------------------------------------------------*
    ...
    clear: wa_bseg, wa_vbsegd, wa_vbsegk, wa_vbsegs.

    * sort due to binary search
    sort it_pos STABLE by bukrs belnr gjahr buzei.

    *>>>> START OF DELETION <<<<<
    *... first posted items table:
    if b0sg-xstan = 'X'.
    select * from bseg into wa_bseg for all entries in it_pos
    where bukrs = it_pos-bukrs
    and belnr = it_pos-belnr
    and gjahr = it_pos-gjahr
    and buzei = it_pos-buzei.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    if gd_usear = 'X'.
    loop at gt_pos_archived assigning .
    read table xbseg into wa_bseg
    with table key bukrs = -bukrs
    belnr = -belnr
    gjahr = -gjahr
    buzei = -buzei.
    if wa_bseg-shkzg = 'H'.
    wa_bseg-menge = wa_bseg-menge * ( -1 ).
    wa_bseg-nebtr = wa_bseg-nebtr * ( -1 ).
    endif.
    * invoice reference:
    if wa_bseg-rebzg is initial
    and wa_bseg-rebzt is initial.
    wa_bseg-rebzg = wa_bseg-belnr.
    endif.
    * fill special fields:
    read table it_pos with key bukrs = wa_bseg-bukrs
    belnr = wa_bseg-belnr
    gjahr = wa_bseg-gjahr
    buzei = wa_bseg-buzei
    binary search.
    if sy-subrc = 0.
    posindex = sy-tabix.
    * expiring currencies:
    if not gd_expcur_flag is initial
    and not gd_expcur_bseg is initial.
    read table xbkpf into wa_bkpf
    with table key bukrs = wa_bseg-bukrs
    belnr = wa_bseg-belnr
    gjahr = wa_bseg-gjahr.
    ld_waers = wa_bkpf-waers.
    perform item_curr_convert_bseg using gd_expcur_proc
    it_pos-hwaer
    ld_waers
    pa_stida
    changing wa_bseg.
    endif.
    perform move_special_fields using it_spectab-tname.
    modify it_pos index posindex.
    endif.
    endloop.
    endif.
    if gd_usedb = 'X'.
    *... first posted items table:
    if b0sg-xstan = 'X' and not gt_pos_posted[] is initial.
    select * from bseg into wa_bseg for all entries in gt_pos_posted
    where bukrs = gt_pos_posted-bukrs
    and belnr = gt_pos_posted-belnr
    and gjahr = gt_pos_posted-gjahr
    and buzei = gt_pos_posted-buzei.
    *>>>> END OF INSERTION <<<<<<
    ...
    select single waers from bkpf into ld_waers
    where bukrs = wa_bseg-bukrs
    and belnr = wa_bseg-belnr
    and gjahr = wa_bseg-gjahr.
    perform item_curr_convert_bseg using gd_expcur_proc
    it_pos-hwaer
    ld_waers
    *>>>> START OF DELETION <<<<<
    pa_stida_default
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    pa_stida
    *>>>> END OF INSERTION <<<<<<
    ...
    endif.
    endselect.
    endif.

    *... now parked items tables:
    *>>>> START OF DELETION <<<<<
    if b0sg-xstav = 'X'.
    clear wa_bseg.
    case it_pos-koart.
    when c_koart_ar.
    select * from vbsegd into wa_vbsegd for all entries in it_pos
    where ausbk = it_pos-bukrs
    and belnr = it_pos-belnr
    and gjahr = it_pos-gjahr
    and bukrs = it_pos-bukrs
    and buzei = it_pos-buzei.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    if b0sg-xstav = 'X' and not gt_pos_parked[] is initial.
    clear wa_bseg.
    case it_pos-koart.
    when c_koart_ar.
    select * from vbsegd into wa_vbsegd
    for all entries in gt_pos_parked
    where ausbk = gt_pos_parked-bukrs
    and belnr = gt_pos_parked-belnr
    and gjahr = gt_pos_parked-gjahr
    and bukrs = gt_pos_parked-bukrs
    and buzei = gt_pos_parked-buzei.
    *>>>> END OF INSERTION <<<<<<
    ...
    select single waers from vbkpf into ld_waers
    where ausbk = wa_bseg-bukrs
    and bukrs = wa_bseg-bukrs
    and belnr = wa_bseg-belnr
    and gjahr = wa_bseg-gjahr.
    perform item_curr_convert_bseg using gd_expcur_proc
    it_pos-hwaer
    ld_waers
    *>>>> START OF DELETION <<<<<
    pa_stida_default
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    pa_stida
    *>>>> END OF INSERTION <<<<<<
    ...
    perform move_special_fields using it_spectab-tname.
    modify it_pos index posindex.
    endif.
    endselect.
    when c_koart_ap.
    *>>>> START OF DELETION <<<<<
    select * from vbsegk into wa_vbsegk for all entries in it_pos
    where ausbk = it_pos-bukrs
    and belnr = it_pos-belnr
    and gjahr = it_pos-gjahr
    and bukrs = it_pos-bukrs
    and buzei = it_pos-buzei.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    select * from vbsegk into wa_vbsegk
    for all entries in gt_pos_parked
    where ausbk = gt_pos_parked-bukrs
    and belnr = gt_pos_parked-belnr
    and gjahr = gt_pos_parked-gjahr
    and bukrs = gt_pos_parked-bukrs
    and buzei = gt_pos_parked-buzei.
    *>>>> END OF INSERTION <<<<<<
    ...
    select single waers from vbkpf into ld_waers
    where ausbk = wa_bseg-bukrs
    and bukrs = wa_bseg-bukrs
    and belnr = wa_bseg-belnr
    and gjahr = wa_bseg-gjahr.
    perform item_curr_convert_bseg using gd_expcur_proc
    it_pos-hwaer
    ld_waers
    *>>>> START OF DELETION <<<<<
    pa_stida_default
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    pa_stida
    *>>>> END OF INSERTION <<<<<<
    ...
    if not gd_expcur_flag is initial
    and not gd_expcur_bseg is initial.

    perform item_curr_convert_bseg using gd_expcur_proc
    it_pos-hwaer
    wa_vbsegs_ext-waers
    *>>>> START OF DELETION <<<<<
    pa_stida_default
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    pa_stida
    *>>>> END OF INSERTION <<<<<<
    ...
    endif.
    endloop.

    endcase.
    endif.
    *>>>> START OF DELETION <<<<<

    PERFORM IT_POS_SORT_BACK TABLES IT_POS.

    endform. " COMPLETE_BSEG
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    endif.

    PERFORM IT_POS_SORT_BACK TABLES IT_POS.

    endform. " COMPLETE_BSEG

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM CHANGE_STATUS
    *&---------------------------------------------------------------------*
    ...
    append lt_exclude.
    lt_exclude-fcode = 'FC03'.
    append lt_exclude.
    lt_exclude-fcode = 'FC04'.
    append lt_exclude.
    *>>>> START OF DELETION <<<<<
    lt_exclude-fcode = 'FC05'.
    append lt_exclude.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * lt_exclude-fcode = 'FC05'.
    * append lt_exclude.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM MOVE_SPECIAL_FIELDS_BOE
    *&---------------------------------------------------------------------*
    ...
    endif.
    endloop.
    endif.

    endform.
    *>>>> START OF INSERTION <<<<





    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM CREATE_PERFORMANCE_TABLES
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * FORM create_performance_tables *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    * --> id_tablename *
    *---------------------------------------------------------------------*
    form create_performance_tables using id_tablename type dd03p-tabname .

    field-symbols : type rfposxext.
    statics : lst_performance_tables type c.

    if lst_performance_tables is initial.
    if id_tablename eq 'BKPF' or id_tablename eq 'BSEG' .

    * Creating additional tables for speeding up the database selects
    refresh: gt_pos_parked, gt_pos_posted, gt_pos_archived.

    loop at it_pos assigning .
    gd_pos_reduced-bukrs = -bukrs.
    gd_pos_reduced-belnr = -belnr.
    gd_pos_reduced-gjahr = -gjahr.
    gd_pos_reduced-buzei = -buzei.
    gd_pos_reduced-budat = -budat.

    if -bstat ca 'VWZ'.
    insert gd_pos_reduced into table gt_pos_parked.
    elseif -xarch eq 'X' and gd_usear = 'X'.
    insert gd_pos_reduced into table gt_pos_archived.
    else.
    insert gd_pos_reduced into table gt_pos_posted.
    endif.
    endloop.

    lst_performance_tables = 'X'.
    endif.
    endif.

    endform.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM IMPORT_ARCH_FROM_MEMORY
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * FORM import_arch_from_memory *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    FORM import_arch_from_memory.

    FIELD-SYMBOLS: TYPE bkpf,
    TYPE bseg.

    IF gd_usear = 'X' AND gd_memor = 'X'.
    import gd_read_memo_done from memory id 'GD_READ_MEMO_DONE'.
    if gd_read_memo_done eq 'N'.
    IMPORT ybkpf FROM MEMORY ID 'YBKPF'.
    IF xbkpf[] IS INITIAL.
    INSERT LINES OF ybkpf INTO TABLE xbkpf.
    ELSE.
    LOOP AT ybkpf ASSIGNING .
    READ TABLE xbkpf WITH TABLE KEY bukrs = -bukrs
    belnr = -belnr
    gjahr = -gjahr
    TRANSPORTING NO FIELDS.
    IF NOT sy-subrc IS INITIAL.
    INSERT INTO TABLE xbkpf.
    ENDIF.
    ENDLOOP.
    ENDIF.
    IMPORT ybseg FROM MEMORY ID 'YBSEG'.
    IF xbseg[] IS INITIAL.
    INSERT LINES OF ybseg INTO TABLE xbseg.
    ELSE.
    LOOP AT ybseg ASSIGNING .
    READ TABLE xbseg WITH TABLE KEY bukrs = -bukrs
    belnr = -belnr
    gjahr = -gjahr
    buzei = -buzei
    TRANSPORTING NO FIELDS.
    IF NOT sy-subrc IS INITIAL.
    INSERT INTO TABLE xbseg.
    ENDIF.
    ENDLOOP.
    ENDIF.

    * INSERT LINES OF ybseg INTO TABLE xbseg.
    * refresh ybseg.
    * FREE MEMORY ID 'YBSEG'.
    endif.
    ENDIF.

    ENDFORM. " IMPORT_ARCH_FROM_MEMORY
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS SAPDBDDF
    *& Object header LDBA DDF
    *&---------------------------------------------------------------------*
    *& REPORT SAPDBDDF
    *&---------------------------------------------------------------------*
    ...
    report sapdbddf defining database ddf message-id fr.

    *>>>> START OF DELETION <<<<<
    * KNKA wird nicht mehr zum Zeitpunkt KNA1 bereitgestellt,
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * KNKA wird nicht mehr zum Zeitpunkt KNA1 bereitgestellt,
    *>>>> END OF INSERTION <<<<<<
    ...
    tables: kna1,
    knas,
    knka,
    knkk,
    knbk,bnka,
    knb1,
    knb4,
    knb5,
    knc1,
    knc3,
    bsid,bsad,
    *>>>> START OF DELETION <<<<<
    bsidext, "40C
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    admi_files,
    bsidext, "40C
    *>>>> END OF INSERTION <<<<<<
    ...
    data: bsidext_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
    *>>>> START OF DELETION <<<<<

    data: count_arch type i,
    mc_sel.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    DATA: MC_SEL.

    * 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: gt_rng_archiv TYPE TABLE OF ty_rng_archiv.
    TYPES: ty_bsid TYPE bsid OCCURS 10.
    DATA : ybsad TYPE bsad OCCURS 10,
    ybkpf TYPE bkpf OCCURS 10,
    ybseg TYPE bseg OCCURS 10.
    DATA : cursor-ybsad 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 : gl_log_handle TYPE balloghndl.
    data : gd_msg601_done type c.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM INIT
    *&---------------------------------------------------------------------*
    ...
    dd_stida = sy-datum.
    * Test ob Anwendungsreport nur A-Segmente liest
    * IF %_GET+1 NA 'X'.
    * B0SG-XASGL = 'X'.
    * ELSE.
    * B0SG-XASGL = ' '.
    * ENDIF.
    *>>>> START OF DELETION <<<<<
    endform. "INIT
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * Initialization for reading from archives.
    IF dd_objec IS INITIAL.
    dd_objec = 'FI_DOCUMNT'.
    ENDIF.
    IF dd_usedb IS INITIAL AND dd_usear IS INITIAL.
    dd_usedb = 'X'.
    dd_usear = space.
    dd_useas = 'X'.
    PERFORM datasource_init
    CHANGING dd_objec dd_usedb dd_usear dd_useas dd_files[].
    ENDIF.
    sscrfields-functxt_05 = text-src.

    endform. "INIT
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PAI
    *&---------------------------------------------------------------------*
    ...
    *----------------------------------------------------------------------*
    * FORM PAI - Selection Screen: Process after input *
    *----------------------------------------------------------------------*
    form pai using fname mark.
    *>>>> START OF DELETION <<<<<
    * Berechtigungspr�fung Kontoart Debitor.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    DATA: ld_progname TYPE progname,
    lt_objects TYPE as_t_archobj.

    * Berechtigungspr�fung Kontoart Debitor.
    *>>>> END OF INSERTION <<<<<<
    ...
    select single waers from t001 into t001-waers
    where bukrs in dd_bukrs.
    endif.

    check mark = space.
    *>>>> START OF DELETION <<<<<
    check sscrfields-ucomm = 'ONLI' " Online submit
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    IF sscrfields-ucomm = 'ONLI' " Online submit
    *>>>> END OF INSERTION <<<<<<
    ...
    dd_stida = '99991231'.
    endif.

    when others.
    endcase.
    *>>>> START OF DELETION <<<<<
    endform. "PAI
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * 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 = dd_usedb
    c_use_archive = dd_usear
    c_use_infosys = dd_useas
    c_archobj = dd_objec
    ct_arch_sel = dd_files[].

    CLEAR : sscrfields-ucomm.
    ENDIF.

    endform. "PAI
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM LDB_PROCESS_INIT
    *&---------------------------------------------------------------------*
    ...
    refresh: vf_debi_where, kna1_where, knka_where, knkk_where,
    knb1_where, bsid_where, vbsegd_where,
    vf_debi_fields, kna1_fields, knka_fields, knkk_fields,
    knb1_fields, bsid_fields, bsidext_fields, bkpf_fields,
    bseg_fields, gseg_fields.

    *>>>> START OF DELETION <<<<<
    clear: count_arch.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * For reading from an archiv:
    CLEAR: gd_count_arch.
    * clear: gd_msg601_done.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM BEFORE_EVENT
    *&---------------------------------------------------------------------*
    ...
    call function 'CA_WRITE_LOG' "#EC EXISTS
    exporting
    i_program = sy-cprog
    exceptions
    write_error = 1
    others = 2.
    if sy-subrc <> 0.
    *>>>> START OF DELETION <<<<<
    message e006(ca_check_date).
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    message e006(ca_check_date). "#EC *
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_KNA1
    *&---------------------------------------------------------------------*
    ...
    *----------------------------------------------------------------------*
    form put_kna1.

    data: lt_kna1 type standard table of kna1 with header line,
    lt_vf_debi type standard table of vf_debi with header line.
    *>>>> START OF DELETION <<<<<
    data: ld_arch.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    DATA: ld_arch TYPE c.
    DATA: BEGIN OF lt_kna1_key OCCURS 0,
    mandt LIKE kna1-mandt,
    kunnr LIKE kna1-kunnr,
    END OF lt_kna1_key.
    DATA: BEGIN OF lt_vf_debi_key OCCURS 0,
    mandt LIKE kna1-mandt,
    kunnr LIKE kna1-kunnr,
    bukrs LIKE knb1-bukrs,
    END OF lt_vf_debi_key.
    *>>>> END OF INSERTION <<<<<<
    ...
    else.
    subrc = 0.
    endif.

    if subrc eq 0.
    *>>>> START OF DELETION <<<<<
    select (kna1_fields) from kna1 into corresponding fields of xkna1
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    SELECT mandt kunnr FROM kna1 INTO TABLE lt_kna1_key
    *>>>> END OF INSERTION <<<<<<
    ...
    where kunnr in dd_kunnr and
    land1 in dd_land1 and
    konzs in dd_konzs and
    vbund in dd_vbund and
    (kna1_where)
    order by primary key. "MANDT KUNNR
    *>>>> START OF DELETION <<<<<
    append xkna1.
    k_kunnr-low = xkna1-kunnr.
    append k_kunnr.
    count = count + 1.
    if count >= max_count.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    LOOP AT lt_kna1_key.
    SELECT single (kna1_fields) FROM kna1
    INTO CORRESPONDING FIELDS OF xkna1
    WHERE kunnr = lt_kna1_key-kunnr.
    append xkna1.
    k_kunnr-low = lt_kna1_key-kunnr.
    append k_kunnr.
    count = count + 1.
    if count >= max_count.
    * archive has to be read
    gd_arch_done = 'N'.
    *>>>> END OF INSERTION <<<<<<
    ...
    perform process_kna1.
    refresh xkna1.
    refresh k_kunnr.
    count = 0.
    endif.
    *>>>> START OF DELETION <<<<<
    endselect.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDLOOP.
    * archive has to be read
    gd_arch_done = 'N'.
    *>>>> END OF INSERTION <<<<<<
    ...
    append xkna1.
    k_kunnr-low = xkna1-kunnr.
    append k_kunnr.
    count = count + 1.
    if count >= max_count.
    *>>>> START OF DELETION <<<<<
    perform process_kna1.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * archive has to be read
    gd_arch_done = 'N'.
    PERFORM process_kna1.
    *>>>> END OF INSERTION <<<<<<
    ...
    refresh xkna1.
    refresh k_kunnr.
    count = 0.
    endif.
    endloop.
    *>>>> START OF DELETION <<<<<
    perform process_kna1.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * archive has to be read
    gd_arch_done = 'N'.
    PERFORM process_kna1.
    *>>>> END OF INSERTION <<<<<<
    ...
    else.
    subrc = 0.
    endif.

    if subrc eq 0.
    *>>>> START OF DELETION <<<<<
    select (vf_debi_fields) from vf_debi
    into corresponding fields of xvf_debi
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    SELECT mandt kunnr bukrs FROM vf_debi INTO TABLE lt_vf_debi_key
    *>>>> END OF INSERTION <<<<<<
    ...
    where kunnr in dd_kunnr
    and bukrs in dd_bukrs
    and land1 in dd_land1
    and konzs in dd_konzs
    and vbund in dd_vbund
    and akont in dd_akont
    and busab in dd_busab
    and (vf_debi_where)
    order by mandt kunnr bukrs.
    *>>>> START OF DELETION <<<<<
    * order by primary key. "MANDT KUNNR BUKRS

    if xvf_debi-kunnr ne s_kunnr.
    if count >= max_count.
    vf_debi = xvf_debi.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * order by primary key. "MANDT KUNNR BUKRS
    LOOP AT lt_vf_debi_key.
    SELECT single (vf_debi_fields) FROM vf_debi
    INTO CORRESPONDING FIELDS OF xvf_debi
    WHERE kunnr = lt_vf_debi_key-kunnr
    AND bukrs = lt_vf_debi_key-bukrs.

    if xvf_debi-kunnr ne s_kunnr.
    if count >= max_count.
    vf_debi = xvf_debi.
    * archive has to be read again
    gd_arch_done = 'N'.
    *>>>> END OF INSERTION <<<<<<
    ...
    append k_kunnr.
    count = count + 1.
    s_kunnr = xvf_debi-kunnr.
    endif.
    append xvf_debi.
    *>>>> START OF DELETION <<<<<

    endselect.

    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDLOOP.
    * archive has to be read
    gd_arch_done = 'N'.
    *>>>> END OF INSERTION <<<<<<
    ...
    loop at lt_vf_debi.
    xvf_debi = lt_vf_debi.
    if xvf_debi-kunnr ne s_kunnr.
    if count >= max_count.
    vf_debi = xvf_debi.
    *>>>> START OF DELETION <<<<<
    perform process_vf_debi.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * archive has to be read again
    gd_arch_done = 'N'.
    PERFORM process_vf_debi.
    *>>>> END OF INSERTION <<<<<<
    ...
    count = count + 1.
    s_kunnr = xvf_debi-kunnr.
    endif.
    append xvf_debi.
    endloop.
    *>>>> START OF DELETION <<<<<
    perform process_vf_debi.
    endif.
    endif. "B0SG-XAGSL = 'X'

    if count_arch <> 0.
    get parameter id 'LDB_NO_DISPL_ARCH' field ld_arch.
    if ld_arch is initial.
    if dd_iarch is initial.
    uline /(60).
    write: / sy-vline, count_arch, text-013,
    60 sy-vline.
    uline /(60).
    else.
    message i010 with count_arch.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * archive has to be read
    gd_arch_done = 'N'.
    PERFORM process_vf_debi.
    endif.
    endif. "B0SG-XAGSL = 'X'

    IF gd_count_arch <> 0.
    get parameter id 'LDB_NO_DISPL_ARCH' field ld_arch.
    if ld_arch is initial.
    if dd_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.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM INIT_BUFFERS
    *&---------------------------------------------------------------------*
    ...
    *---------------------------------------------------------------------*
    form init_buffers.
    refresh: xbsid, xknka, xknb5, xknc3,
    xbsad, xknkk, xknbk, xknc1,
    xknas, xknb4, xknb1, xaddr1_val.
    *>>>> START OF DELETION <<<<<
    cursor-bsid = cursor-bsad = cursor-knka = 0.
    cursor-knas = cursor-knkk = cursor-knb4 = 0.
    cursor-knb5 = cursor-knbk = cursor-knc1 = 0.
    cursor-knc3 = cursor-knb1 = cursor-addr1_val = 0.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    REFRESH: ybsad, ybkpf, ybseg.
    cursor-bsid = cursor-bsad = cursor-knka = 0.
    cursor-knas = cursor-knkk = cursor-knb4 = 0.
    cursor-knb5 = cursor-knbk = cursor-knc1 = 0.
    cursor-knc3 = cursor-knb1 = cursor-addr1_val = 0.
    cursor-ybsad = 0.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BSID
    *&---------------------------------------------------------------------*
    ...
    * FORM PUT_BSID *
    * Posten Debitor *
    *----------------------------------------------------------------------*
    form put_bsid.

    *>>>> START OF DELETION <<<<<
    * if user is not allowed to see line items or balances
    if f_bkpf_bed_subrc <> 0.
    exit.
    endif.

    if b0sg-xasgl = 'X'.
    exit.
    endif.
    if b0sg-xstan = 'X' or b0sg-xstas = 'X'. ">>>> normal documents >>>>>
    save_bstat = ' '.
    if cursor-bsid = 0.
    perform update_xbsid.
    endif.
    do. "BSID
    read table xbsid index cursor-bsid.
    if sy-subrc ne 0.
    exit.
    endif.
    if save_kunnr < xbsid-kunnr. "Eintrag nicht enthalten
    exit.
    elseif save_kunnr > xbsid-kunnr. "Weiterlesen
    cursor-bsid = cursor-bsid + 1.
    else. "Treffer
    if save_bukrs < xbsid-bukrs.
    exit.
    elseif save_bukrs > xbsid-bukrs.
    cursor-bsid = cursor-bsid + 1.
    else.
    bsid = xbsid.
    save_belnr = bsid-belnr.
    save_buzei = bsid-buzei.
    save_gsber = bsid-gsber.
    save_gjahr = bsid-gjahr.
    * Belegpositionsanhang
    if bsid-zfbdt = '00000000'.
    bsid-zfbdt = bsid-bldat.
    endif.
    * expiring currencies:
    gd_waers_save = bsid-waers.
    if not gd_expcur_flag is initial.
    perform item_curr_convert_bsid using 'SAPDBDDF'
    t001-waers
    gd_expcur_date
    changing bsid.
    endif.
    clear bsegh. "<-- 3.0F
    move-corresponding bsid to bsegh.
    * changes to avoid the problem with the field selection: note 36167
    describe table bsid_fields lines sy-tfill.
    if sy-tfill > 0.
    perform putzen_bsegh tables bsid_fields.
    endif.

    bsegh-koart = 'D'.
    perform got_bsega(sapbsega).

    if alcur eq 'X'. perform convert_alt using 'BSID'. endif. "euro

    if bsid-xarch = 'X'.
    count_arch = count_arch + 1.
    endif.

    put bsid.
    clear bsid.
    cursor-bsid = cursor-bsid + 1.
    endif.
    endif.
    enddo.

    if cursor-bsad = 0.
    perform update_xbsad.
    endif.
    do. "BSAD
    read table xbsad index cursor-bsad.
    if sy-subrc ne 0.
    exit.
    endif.
    if save_kunnr < xbsad-kunnr. "Eintrag nicht enthalten
    exit.
    elseif save_kunnr > xbsad-kunnr. "Weiterlesen
    cursor-bsad = cursor-bsad + 1.
    else. "Treffer
    if save_bukrs < xbsad-bukrs.
    exit.
    elseif save_bukrs > xbsad-bukrs.
    cursor-bsad = cursor-bsad + 1.
    else.
    move-corresponding xbsad to bsid.
    save_belnr = bsid-belnr.
    save_buzei = bsid-buzei.
    save_gsber = bsid-gsber.
    save_gjahr = bsid-gjahr.
    * Belegpositionsanhang
    if bsid-zfbdt = '00000000'.
    bsid-zfbdt = bsid-bldat.
    endif.
    * expiring currencies:
    gd_waers_save = bsid-waers.
    if not gd_expcur_flag is initial.
    perform item_curr_convert_bsid using 'SAPDBDDF'
    t001-waers
    gd_expcur_date
    changing bsid.
    endif.
    clear bsegh. "<-- 3.0F
    move-corresponding bsid to bsegh.
    * changes to avoid the problem with the field selection
    describe table bsid_fields lines sy-tfill.
    if sy-tfill > 0.
    perform putzen_bsegh tables bsid_fields.
    endif.

    bsegh-koart = 'D'.
    perform got_bsega(sapbsega).
    if alcur eq 'X'. perform convert_alt using 'BSID'. endif. "euro

    if bsid-xarch = 'X'.
    count_arch = count_arch + 1.
    endif.

    put bsid.
    clear bsid.
    cursor-bsad = cursor-bsad + 1.
    endif.
    endif.
    enddo.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    DATA : ld_arch LIKE dd_usear.

    * if user is not allowed to see line items or balances
    if f_bkpf_bed_subrc <> 0.
    exit.
    endif.
    IF b0sg-xasgl = 'X'.
    exit.
    endif.

    * if archived items are to be read
    IF dd_usear = 'X'.
    IF gd_arch_done eq 'N'.
    PERFORM read_archive.
    gd_arch_done = 'Y'.
    gd_read_memo_done = 'N'.
    ENDIF.
    ld_arch = 'X'.
    PERFORM write_into_bsid TABLES ybsad
    USING cursor-ybsad ld_arch. "#EC ENHOK

    ENDIF.

    * if items from database are to be read
    IF NOT dd_usedb IS INITIAL.
    IF b0sg-xstan = 'X' OR b0sg-xstas = 'X'. ">>>> normal documents >>>>>
    IF cursor-bsid = 0.
    PERFORM update_xbsid.
    endif.
    CLEAR ld_arch.
    PERFORM write_into_bsid TABLES xbsid USING cursor-bsid ld_arch.

    if cursor-bsad = 0.
    perform update_xbsad.
    endif.
    CLEAR ld_arch.
    PERFORM write_into_bsid TABLES xbsad
    USING cursor-bsad ld_arch. "#EC ENHOK

    *>>>> END OF INSERTION <<<<<<
    ...
    perform build_vbseg_where(fi_ldb_util) tables vbsegd_where
    using 'PROJK'.
    perform build_vbseg_where(fi_ldb_util) tables vbsegd_where
    using 'PRCTR'.
    PERFORM BUILD_VBSEG_WHERE(FI_LDB_UTIL) TABLES VBSEGD_WHERE
    USING 'KOSTL'.
    *>>>> START OF DELETION <<<<<


    * BSTAT W oder Z sind nicht im VBKPF
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * BSTAT W oder Z sind nicht im VBKPF
    *>>>> END OF INSERTION <<<<<<
    ...
    clear bsid.
    endselect.

    endif.

    *>>>> START OF DELETION <<<<<
    endform. "PUT_BSID
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDIF. "if dd_usedb active

    endform. "PUT_BSID

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BSIDEXT
    *&---------------------------------------------------------------------*
    ...
    ***********************************************************************
    * put_bsidext *
    * Erweiterungsteil *
    ***********************************************************************
    form put_bsidext.
    *>>>> START OF DELETION <<<<<
    move-corresponding bsid to bsidext.
    move-corresponding bsega to bsidext.
    put bsidext.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    move-corresponding bsid to bsidext.
    move-corresponding bsega to bsidext.
    put bsidext.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BKPF
    *&---------------------------------------------------------------------*
    ...
    *----------------------------------------------------------------------*
    * FORM PUT_BKPF *
    * Belegkopf *
    *----------------------------------------------------------------------*
    form put_bkpf.
    *>>>> START OF DELETION <<<<<
    if bsid-xarch = 'X'.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    IF dd_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 'SAPDBDDF'
    gd_expcur_date
    CHANGING bkpf.
    ENDIF.

    PUT bkpf.
    ELSE.
    * MESSAGE I803 WITH SAVE_BUKRS SAVE_BELNR.
    WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
    ENDIF.
    ENDIF.

    IF dd_usedb = 'X'.
    IF bsid-xarch = 'X'.
    *>>>> END OF INSERTION <<<<<<
    ...
    perform item_curr_convert_bkpf using 'SAPDBDDF'
    gd_expcur_date
    changing bkpf.
    endif.

    put bkpf.
    endif.
    *>>>> START OF DELETION <<<<<
    endform. "PUT_BKPF
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDIF. "dd_usedb

    endform. "PUT_BKPF
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BSEG
    *&---------------------------------------------------------------------*
    ...
    *----------------------------------------------------------------------*
    * FORM PUT_BSEG *
    * Belegposition *
    *----------------------------------------------------------------------*
    form put_bseg.
    *>>>> START OF DELETION <<<<<
    if save_bstat <> 'V'.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    IF dd_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.
    WRITE: text-004, save_belnr, text-005, save_bukrs, text-006.
    ENDIF.

    * Belegpositionsanhang
    IF bseg-koart = 'D' OR bseg-koart = 'K'.
    IF bseg-zfbdt = '00000000'.
    bseg-zfbdt = bkpf-bldat.
    ENDIF.
    ENDIF.

    * expiring currencies:
    IF NOT gd_expcur_flag IS INITIAL.
    PERFORM item_curr_convert_bseg USING 'SAPDBDDF'
    t001-waers
    gd_waers_save
    gd_expcur_date
    CHANGING bseg.
    ENDIF.
    MOVE-CORRESPONDING bseg TO bsegh.

    * clear the fields not used in field selection: note 36167
    DESCRIBE TABLE bseg_fields LINES sy-tfill. "<-- 3.0F
    IF sy-tfill > 0.
    PERFORM putzen_bsegh TABLES bseg_fields.
    ENDIF. "<-- 3.0F
    PERFORM got_bsega(sapbsega).

    * Euro
    IF alcur EQ 'X'.
    PERFORM convert_alt USING 'BSEG'.
    ENDIF.

    PUT bseg.

    CLEAR bseg.
    ENDIF. "dd_usear


    IF dd_usedb = 'X'.
    IF save_bstat <> 'V'.
    *>>>> END OF INSERTION <<<<<<
    ...
    if alcur eq 'X'. perform convert_alt using 'BSEG'. endif. "euro

    put bseg.

    endif.
    *>>>> START OF DELETION <<<<<

    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDIF. "dd_usedb

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_DDF_SP
    *&---------------------------------------------------------------------*
    ...
    dd_bukrs[] = xx_bukrs[].
    *** put:
    put kna1.
    endselect.

    *>>>> START OF DELETION <<<<<
    if count_arch <> 0.
    if dd_iarch is initial.
    uline /(60).
    write: / sy-vline, count_arch, text-013,
    60 sy-vline.
    uline /(60).
    else.
    message i010 with count_arch.
    endif.
    endif.

    endform. "PUT_DDF_SP
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    IF gd_count_arch <> 0.
    IF dd_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.

    endform. "PUT_DDF_SP

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM CHECK_DATE
    *&---------------------------------------------------------------------*
    ...
    endif.

    endform. " check_date



    *>>>> START OF DELETION <<<<<
    **********************************************************************
    * !!! PLEASE DO NOT CHANGE MANUALLY (BEGIN OF BLOCK) !!!!!!!!!!!!!!! *
    *----------------------------------------------------------------------*
    * Data structures for search pattern selection *
    *----------------------------------------------------------------------*
    * DDF_SP : Search pattern values. *
    * After START-OF-SELECTION table DDF_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 DDF_SP will be used in subroutine PUT_DDF_SP. *
    *----------------------------------------------------------------------*
    * DATA: BEGIN OF DDF_SP OCCURS 1000, *
    * KUNNR LIKE KNA1-KUNNR, *
    * BUKRS LIKE KNB1-BUKRS, *
    * END OF DDF_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 DDF_SP, e.g. DDF_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) !!!!!!!!!!!!!!!!! *
    **********************************************************************
    *>>>> END OF DELETION <<<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_ADMI_FILES
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * FORM put_admi_files *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    FORM put_admi_files.
    ENDFORM.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM DATASOURCE_INIT
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * 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.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM READ_ARCHIVE
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * FORM read_archive *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    FORM read_archive.

    DATA : ld_errors TYPE boole,
    ld_progress TYPE boole,
    ld_convert_currency TYPE boole.

    * 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 dd_useas IS INITIAL.
    REFRESH dd_files.
    ENDIF.

    CALL FUNCTION 'FI_DOCUMENT_ARCH_AS_ITEMS_READ'
    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_bsad = ybsad
    i_arch_sel = dd_files[]
    EXCEPTIONS
    no_infostruc_found = 1
    SELECTIONS_ERROR = 2
    CONVERSION_ERROR = 3.
    case sy-subrc.
    when '0'.
    SORT ybsad BY mandt kunnr bukrs.
    when '1'.
    if gd_msg601_done is initial.
    message i601.
    gd_msg601_done = 'X'.
    endif.
    refresh: ybkpf, ybseg, ybsad.
    when '2'.
    message i602.
    refresh: ybkpf, ybseg, ybsad.
    when '3'.
    message i603.
    refresh: ybkpf, ybseg, ybsad.
    when others.
    message i604.
    refresh: ybkpf, ybseg, ybsad.
    endcase.
    cursor-ybsad = 1.
    IF dd_memor = 'X'.
    EXPORT ybkpf TO MEMORY ID 'YBKPF'.
    EXPORT ybseg TO MEMORY ID 'YBSEG'.
    ENDIF.


    ENDFORM.


    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SELTAB_FROM_REGULAR_SEL
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * 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.


    REFRESH:lt_frange.
    ld_trange-tablename = 'BKPF'.

    IF NOT dd_bukrs[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'BUKRS'.
    LOOP AT dd_bukrs.
    MOVE-CORRESPONDING dd_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 dd_budat[] IS INITIAL.
    REFRESH: lt_selopt.
    ld_frange-fieldname = 'BUDAT'.
    LOOP AT dd_budat.
    MOVE-CORRESPONDING dd_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 ( dd_opopt = 'X' AND dd_apopt = 'X' )
    OR ( dd_opopt = 'X' AND dd_apopt IS INITIAL ) .
    REFRESH: lt_selopt.
    ld_frange-fieldname = 'BUDAT'.
    ld_selopt-sign = 'I'.
    ld_selopt-option = 'BT'.
    ld_selopt-low = '00010101'.
    ld_selopt-high = dd_stida.
    APPEND ld_selopt TO lt_selopt.
    ld_frange-selopt_t = lt_selopt[].
    APPEND ld_frange TO lt_frange.
    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_kunnr[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'KUNNR'.
    LOOP AT k_kunnr.
    MOVE-CORRESPONDING k_kunnr 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 dd_augdt[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'AUGDT'.
    LOOP AT dd_augdt.
    MOVE-CORRESPONDING dd_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 ( dd_opopt IS INITIAL AND dd_apopt IS INITIAL )
    OR ( dd_opopt = 'X' AND dd_apopt IS INITIAL ) .
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'AUGDT'.
    ld_selopt-sign = 'I'.
    ld_selopt-option = 'BT'.
    ld_selopt-low = dd_stida.
    ld_selopt-high = '99991231'.
    APPEND ld_selopt TO lt_selopt.
    ld_frange-selopt_t = lt_selopt[].
    APPEND ld_frange TO lt_frange.
    ENDIF.

    IF NOT dd_zuonr[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'ZUONR'.
    LOOP AT dd_zuonr.
    MOVE-CORRESPONDING dd_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 dd_shkzg[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'SHKZG'.
    LOOP AT dd_shkzg.
    MOVE-CORRESPONDING dd_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 dd_umskz[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'UMSKZ'.
    LOOP AT dd_umskz.
    MOVE-CORRESPONDING dd_umskz 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 dd_bschl[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'BSCHL'.
    LOOP AT dd_bschl.
    MOVE-CORRESPONDING dd_bschl TO ld_selopt.
    APPEND ld_selopt TO lt_selopt.
    ENDLOOP.
    ld_frange-selopt_t = lt_selopt[].
    APPEND ld_frange TO lt_frange.
    ENDIF.

    REFRESH:lt_selopt.
    ld_frange-fieldname = 'KOART'.
    ld_selopt-sign = 'I'.
    ld_selopt-option = 'EQ'.
    ld_selopt-low = 'D'.
    APPEND ld_selopt TO lt_selopt.
    ld_frange-selopt_t = lt_selopt[].
    APPEND ld_frange TO lt_frange.


    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.


    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SELTAB_FROM_DYN_SEL
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * 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 bsid-where into ranges format
    ld_where-tablename = 'BSID'.
    ld_where-where_tab = bsid_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 BSID into ranges for BKPF and BSEG
    CLEAR : ld_trange , lt_frange , ld_frange .
    REFRESH : lt_frange .

    ld_tablename = 'BSID'.

    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.


    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM WRITE_INTO_BSID
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * FORM write_into_bsid *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    * --> i_bsid *
    * --> i_cursor *
    * --> i_arch *
    *---------------------------------------------------------------------*
    FORM write_into_bsid TABLES i_bsid TYPE ty_bsid
    USING i_cursor type sy-index
    i_arch type boole_d.

    save_bstat = ' '.
    DO.
    READ TABLE i_bsid INDEX i_cursor.
    IF sy-subrc NE 0.
    EXIT.
    ENDIF.
    IF save_kunnr < i_bsid-kunnr. "Eintrag nicht enthalten
    EXIT.
    ELSEIF save_kunnr > i_bsid-kunnr. "Weiterlesen
    i_cursor = i_cursor + 1.
    ELSE. "Treffer
    IF save_bukrs < i_bsid-bukrs.
    EXIT.
    ELSEIF save_bukrs > i_bsid-bukrs.
    i_cursor = i_cursor + 1.
    ELSE.
    IF i_bsid-xarch = 'X'
    AND i_arch IS INITIAL
    AND dd_usear = 'X'.
    READ TABLE ybsad WITH KEY bukrs = i_bsid-bukrs
    belnr = i_bsid-belnr
    gjahr = i_bsid-gjahr
    buzei = i_bsid-buzei
    TRANSPORTING NO FIELDS.
    * TRANSPORTING NO FIELDS BINARY SEARCH.
    IF sy-subrc = 0.
    i_cursor = i_cursor + 1.
    CONTINUE.
    ENDIF.
    ENDIF.
    bsid = i_bsid.
    save_belnr = bsid-belnr.
    save_buzei = bsid-buzei.
    save_gsber = bsid-gsber.
    save_gjahr = bsid-gjahr.
    * Belegpositionsanhang
    IF bsid-zfbdt = '00000000'.
    bsid-zfbdt = bsid-bldat.
    ENDIF.
    * expiring currencies:
    gd_waers_save = bsid-waers.
    IF NOT gd_expcur_flag IS INITIAL.
    PERFORM item_curr_convert_bsid USING 'SAPDBDDF'
    t001-waers
    gd_expcur_date
    CHANGING bsid.
    ENDIF.
    CLEAR bsegh. "<-- 3.0F
    MOVE-CORRESPONDING bsid TO bsegh.
    * changes to avoid the problem with the field selection: note 36167
    DESCRIBE TABLE bsid_fields LINES sy-tfill.
    IF sy-tfill > 0.
    PERFORM putzen_bsegh TABLES bsid_fields.
    ENDIF.

    bsegh-koart = 'D'.
    PERFORM got_bsega(sapbsega).

    *Euro
    IF alcur EQ 'X'.
    PERFORM convert_alt USING 'BSID'.
    ENDIF.


    IF bsid-xarch = 'X'.
    gd_count_arch = gd_count_arch + 1.
    ENDIF.

    if i_arch = 'X'
    AND dd_usear = 'X'.
    export gd_read_memo_done to memory id 'GD_READ_MEMO_DONE'.
    gd_read_memo_done = 'Y'.
    endif.

    PUT bsid.
    CLEAR bsid.
    i_cursor = i_cursor + 1.
    ENDIF.
    ENDIF.
    ENDDO.

    ENDFORM.




    **********************************************************************
    * !!! PLEASE DO NOT CHANGE MANUALLY (BEGIN OF BLOCK) !!!!!!!!!!!!!!! *
    *----------------------------------------------------------------------*
    * Data structures for search pattern selection *
    *----------------------------------------------------------------------*
    * DDF_SP : Search pattern values. *
    * After START-OF-SELECTION table DDF_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 DDF_SP will be used in subroutine PUT_DDF_SP. *
    *----------------------------------------------------------------------*
    * DATA: BEGIN OF DDF_SP OCCURS 1000, *
    * KUNNR LIKE KNA1-KUNNR, *
    * BUKRS LIKE KNB1-BUKRS, *
    * END OF DDF_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 DDF_SP, e.g. DDF_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) !!!!!!!!!!!!!!!!! *
    **********************************************************************
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS SAPDBKDF
    *& Object header LDBA KDF
    *&---------------------------------------------------------------------*
    *& REPORT SAPDBKDF
    *&---------------------------------------------------------------------*
    ...
    report sapdbkdf defining database kdf message-id fr.

    *>>>> START OF DELETION <<<<<
    * Wenn XASGL nicht gesetzt ist, werden nur A-Segmente gelesen,
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * Wenn XASGL nicht gesetzt ist, werden nur A-Segmente gelesen,
    *>>>> END OF INSERTION <<<<<<
    ...
    tables: lfa1,
    lfas,
    lfbk, bnka,
    lfb1,
    lfb5,
    lfc1,
    lfc3,
    bsik,bsak,
    *>>>> START OF DELETION <<<<<
    bsikext,
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    admi_files,
    bsikext,
    *>>>> END OF INSERTION <<<<<<
    ...
    data: bsikext_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
    *>>>> START OF DELETION <<<<<

    data: count_arch type i,
    mc_sel.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    DATA: MC_SEL.

    * 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: gt_rng_archiv TYPE TABLE OF ty_rng_archiv.
    TYPES: ty_bsik TYPE bsik OCCURS 10.
    DATA : ybsak TYPE bsak OCCURS 10,
    ybkpf TYPE bkpf OCCURS 10,
    ybseg TYPE bseg OCCURS 10.
    DATA : cursor-ybsak 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 : gl_log_handle TYPE balloghndl.
    data : gd_msg601_done type c.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM INIT
    *&---------------------------------------------------------------------*
    ...
    kd_stida = sy-datum.
    * Test ob Anwendungsreport nur A-Segmente liest
    * IF %_GET+1 NA 'X'.
    * B0SG-XASGL = 'X'.
    * ELSE.
    * B0SG-XASGL = ' '.
    * ENDIF.
    *>>>> START OF DELETION <<<<<
    endform. "INIT
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * Initialization for reading from archives.
    IF kd_objec IS INITIAL.
    kd_objec = 'FI_DOCUMNT'.
    ENDIF.
    IF kd_usedb IS INITIAL AND kd_usear IS INITIAL.
    kd_usedb = 'X'.
    kd_usear = space.
    kd_useas = 'X'.
    PERFORM datasource_init
    CHANGING kd_objec kd_usedb kd_usear kd_useas kd_files[].
    ENDIF.
    sscrfields-functxt_05 = text-src.

    endform. "INIT
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PAI
    *&---------------------------------------------------------------------*
    ...
    * --> MARK *
    *---------------------------------------------------------------------*
    form pai using fname mark.
    * Selection Screen: Process after input

    *>>>> START OF DELETION <<<<<
    * Berechtigungspr�fung Kontoart Kreditor.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    DATA: ld_progname TYPE progname,
    lt_objects TYPE as_t_archobj.

    * Berechtigungspr�fung Kontoart Kreditor.
    *>>>> END OF INSERTION <<<<<<
    ...
    select single waers from t001 into t001-waers
    where bukrs in kd_bukrs.
    endif.

    check mark = space.
    *>>>> START OF DELETION <<<<<
    check sscrfields-ucomm = 'ONLI' " Online submit
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    IF sscrfields-ucomm = 'ONLI' " Online submit
    *>>>> END OF INSERTION <<<<<<
    ...
    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
    *>>>> START OF DELETION <<<<<

    case fname.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<


    CASE FNAME.
    *>>>> END OF INSERTION <<<<<<
    ...
    kd_apopt = 'X'.

    kd_stida = '99991231'.
    endif.

    endcase.
    *>>>> START OF DELETION <<<<<

    endform. "PAI
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * Selection of datasources.
    ELSEIF sscrfields-ucomm = 'FC05'.

    ld_progname = sy-repid.
    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 = kd_usedb
    c_use_archive = kd_usear
    c_use_infosys = kd_useas
    c_archobj = kd_objec
    ct_arch_sel = kd_files[].

    CLEAR : sscrfields-ucomm.
    ENDIF.

    endform. "PAI
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM LDB_PROCESS_INIT
    *&---------------------------------------------------------------------*
    ...
    refresh: vf_kred_where, lfa1_where, lfb1_where, bsik_where,
    vbsegk_where,
    vf_kred_fields, lfa1_fields, lfb1_fields, bsik_fields,
    bsikext_fields, bkpf_fields, bseg_fields, gseg_fields.

    *>>>> START OF DELETION <<<<<
    clear: count_arch.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * For reading from an archiv:
    CLEAR: gd_count_arch.
    * clear: gd_msg601_done.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM BEFORE_EVENT
    *&---------------------------------------------------------------------*
    ...
    call function 'CA_WRITE_LOG' "#EC EXISTS
    exporting
    i_program = sy-cprog
    exceptions
    write_error = 1
    others = 2.
    if sy-subrc <> 0.
    *>>>> START OF DELETION <<<<<
    message e006(ca_check_date).
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    message e006(ca_check_date). "#EC *
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_LFA1
    *&---------------------------------------------------------------------*
    ...
    form put_lfa1.


    data: lt_lfa1 type standard table of lfa1 with header line,
    lt_vf_kred type standard table of vf_kred with header line..
    data: ld_arch type c.
    *>>>> START OF DELETION <<<<<

    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    DATA: BEGIN OF lt_lfa1_key OCCURS 0,
    mandt LIKE lfa1-mandt,
    lifnr LIKE lfa1-lifnr,
    END OF lt_lfa1_key.
    DATA: BEGIN OF lt_vf_kred_key OCCURS 0,
    mandt LIKE lfa1-mandt,
    lifnr LIKE lfa1-lifnr,
    bukrs LIKE lfb1-bukrs,
    END OF lt_vf_kred_key.

    *>>>> END OF INSERTION <<<<<<
    ...
    else.
    subrc = 0.
    endif.

    if subrc eq 0.
    *>>>> START OF DELETION <<<<<
    select (lfa1_fields) from lfa1 into corresponding fields of xlfa1
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    SELECT mandt lifnr FROM lfa1 INTO TABLE lt_lfa1_key
    *>>>> END OF INSERTION <<<<<<
    ...
    where lifnr in kd_lifnr and
    land1 in kd_land1 and
    konzs in kd_konzs and
    vbund in kd_vbund and
    (lfa1_where)
    order by primary key. "MANDT LIFNR
    *>>>> START OF DELETION <<<<<
    append xlfa1.
    k_lifnr-low = xlfa1-lifnr.
    append k_lifnr.
    count = count + 1.
    if count >= max_count.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    LOOP AT lt_lfa1_key.
    SELECT single (lfa1_fields) FROM lfa1
    INTO CORRESPONDING FIELDS OF xlfa1
    WHERE lifnr = lt_lfa1_key-lifnr.
    append xlfa1.
    k_lifnr-low = lt_lfa1_key-lifnr.
    append k_lifnr.
    count = count + 1.
    if count >= max_count.
    * archive has to be read
    gd_arch_done = 'N'.
    *>>>> END OF INSERTION <<<<<<
    ...
    perform process_lfa1.
    refresh xlfa1.
    refresh k_lifnr.
    count = 0.
    endif.
    *>>>> START OF DELETION <<<<<
    endselect.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDLOOP.
    * archive has to be read
    gd_arch_done = 'N'.
    *>>>> END OF INSERTION <<<<<<
    ...
    append xlfa1.
    k_lifnr-low = xlfa1-lifnr.
    append k_lifnr.
    count = count + 1.
    if count >= max_count.
    *>>>> START OF DELETION <<<<<
    perform process_lfa1.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * archive has to be read
    gd_arch_done = 'N'.
    perform process_lfa1.
    *>>>> END OF INSERTION <<<<<<
    ...
    refresh xlfa1.
    refresh k_lifnr.
    count = 0.
    endif.
    endloop.
    *>>>> START OF DELETION <<<<<
    perform process_lfa1.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * archive has to be read
    gd_arch_done = 'N'.
    perform process_lfa1.
    *>>>> END OF INSERTION <<<<<<
    ...
    else.
    subrc = 0.
    endif.

    if subrc eq 0.
    *>>>> START OF DELETION <<<<<
    select (vf_kred_fields) from vf_kred
    into corresponding fields of xvf_kred
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    SELECT mandt lifnr bukrs
    FROM vf_kred INTO TABLE lt_vf_kred_key
    *>>>> END OF INSERTION <<<<<<
    ...
    where lifnr in kd_lifnr
    and bukrs in kd_bukrs
    and land1 in kd_land1
    and konzs in kd_konzs
    and vbund in kd_vbund
    and akont in kd_akont
    and busab in kd_busab
    and (vf_kred_where)
    order by mandt lifnr bukrs.
    *>>>> START OF DELETION <<<<<
    * order by primary key. "MANDT LIFNR BUKRS
    if xvf_kred-lifnr ne s_lifnr.
    if count >= max_count.
    vf_kred = xvf_kred.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * order by primary key. "MANDT LIFNR BUKRS
    LOOP AT lt_vf_kred_key.
    SELECT single (vf_kred_fields) FROM vf_kred
    INTO CORRESPONDING FIELDS OF xvf_kred
    WHERE lifnr = lt_vf_kred_key-lifnr
    AND bukrs = lt_vf_kred_key-bukrs.

    IF xvf_kred-lifnr NE s_lifnr.
    IF count >= max_count.
    vf_kred = xvf_kred.
    * archive has to be read again
    gd_arch_done = 'N'.
    *>>>> END OF INSERTION <<<<<<
    ...
    append k_lifnr.
    count = count + 1.
    s_lifnr = xvf_kred-lifnr.
    endif.
    append xvf_kred.
    *>>>> START OF DELETION <<<<<
    endselect.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDLOOP.
    * archive has to be read
    gd_arch_done = 'N'.
    *>>>> END OF INSERTION <<<<<<
    ...
    loop at lt_vf_kred.
    xvf_kred = lt_vf_kred.
    if xvf_kred-lifnr ne s_lifnr.
    if count >= max_count.
    vf_kred = xvf_kred.
    *>>>> START OF DELETION <<<<<
    perform process_vf_kred.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * archive has to be read again
    gd_arch_done = 'N'.
    perform process_vf_kred.
    *>>>> END OF INSERTION <<<<<<
    ...
    s_lifnr = xvf_kred-lifnr.
    endif.
    append xvf_kred.

    endloop.
    *>>>> START OF DELETION <<<<<
    perform process_vf_kred.
    endif.
    endif. "B0SG-XAGSL = 'X'

    if count_arch <> 0.
    get parameter id 'LDB_NO_DISPL_ARCH' field ld_arch.
    if ld_arch is initial.
    if kd_iarch is initial.
    uline /(60).
    write: / sy-vline, count_arch, text-013,
    60 sy-vline.
    uline /(60).
    else.
    message i010 with count_arch.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * archive has to be read again
    gd_arch_done = 'N'.
    perform process_vf_kred.
    endif.
    endif. "B0SG-XAGSL = 'X'

    IF gd_count_arch <> 0.
    get parameter id 'LDB_NO_DISPL_ARCH' field ld_arch.
    if ld_arch is initial.
    if kd_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.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM INIT_BUFFERS
    *&---------------------------------------------------------------------*
    ...
    *---------------------------------------------------------------------*
    form init_buffers.
    refresh: xbsik, xlfb5, xlfc3,
    xbsak, xlfbk, xlfc1,
    xlfas, xlfb1, xaddr1_val.
    *>>>> START OF DELETION <<<<<
    cursor-bsik = cursor-bsak = 0.
    cursor-lfas = cursor-lfc1 = 0.
    cursor-lfb5 = cursor-lfbk = 0.
    cursor-lfc3 = cursor-lfb1 = cursor-addr1_val = 0.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    REFRESH: ybsak, ybkpf, ybseg.
    cursor-bsik = cursor-bsak = 0.
    cursor-lfas = cursor-lfc1 = 0.
    cursor-lfb5 = cursor-lfbk = 0.
    cursor-lfc3 = cursor-lfb1 = cursor-addr1_val = 0.
    cursor-ybsak = 0.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BSIK
    *&---------------------------------------------------------------------*
    ...
    * FORM PUT_BSIK *
    * Posten Kreditor *
    *----------------------------------------------------------------------*
    form put_bsik.

    *>>>> START OF DELETION <<<<<
    * if user is not allowed to see line items or balances
    if f_bkpf_bek_subrc <> 0.
    exit.
    endif.

    if b0sg-xasgl = 'X'.
    exit.
    endif.
    if b0sg-xstan = 'X' or b0sg-xstas = 'X'. ">>>> normal documents >>>>>
    save_bstat = ' '.
    if cursor-bsik = 0.
    perform update_xbsik.
    endif.
    do. "BSIK
    read table xbsik index cursor-bsik.
    if sy-subrc <> 0.
    exit.
    endif.
    if save_lifnr < xbsik-lifnr. "Eintrag nicht enthalten
    exit.
    elseif save_lifnr > xbsik-lifnr. "Weiterlesen
    cursor-bsik = cursor-bsik + 1.
    else. "Treffer
    if save_bukrs < xbsik-bukrs.
    exit.
    elseif save_bukrs > xbsik-bukrs.
    cursor-bsik = cursor-bsik + 1.
    else.
    bsik = xbsik.
    save_belnr = bsik-belnr.
    save_buzei = bsik-buzei.
    save_gsber = bsik-gsber.
    save_gjahr = bsik-gjahr.
    * Belegpositionsanhang
    if bsik-zfbdt = '00000000'.
    bsik-zfbdt = bsik-bldat.
    endif.
    * expiring currencies:
    gd_waers_save = bsik-waers.
    if not gd_expcur_flag is initial.
    perform item_curr_convert_bsik using 'SAPDBKDF'
    t001-waers
    gd_expcur_date
    changing bsik.
    endif.
    clear bsegh. "<-- 3.0F
    move-corresponding bsik to bsegh.
    * clear fields not used by the field selection: note 36167
    describe table bsik_fields lines sy-tfill.
    if sy-tfill > 0.
    perform putzen_bsegh tables bsik_fields.
    endif.

    bsegh-koart = 'K'.
    perform got_bsega(sapbsega).
    if alcur eq 'X'. perform convert_alt using 'BSIK'. endif. "euro

    if bsik-xarch = 'X'.
    count_arch = count_arch + 1.
    endif.

    put bsik.
    clear bsik.
    cursor-bsik = cursor-bsik + 1.
    endif.
    endif.
    enddo.
    if cursor-bsak = 0.
    perform update_xbsak.
    endif.
    do. "BSAK
    read table xbsak index cursor-bsak.
    if sy-subrc ne 0.
    exit.
    endif.
    if save_lifnr < xbsak-lifnr. "Eintrag nicht enthalten
    exit.
    elseif save_lifnr > xbsak-lifnr. "Weiterlesen
    cursor-bsak = cursor-bsak + 1.
    else. "Treffer
    if save_bukrs < xbsak-bukrs.
    exit.
    elseif save_bukrs > xbsak-bukrs.
    cursor-bsak = cursor-bsak + 1.
    else.
    move-corresponding xbsak to bsik.
    save_belnr = bsik-belnr.
    save_buzei = bsik-buzei.
    save_gsber = bsik-gsber.
    save_gjahr = bsik-gjahr.
    * Belegpositionsanhang
    if bsik-zfbdt = '00000000'.
    bsik-zfbdt = bsik-bldat.
    endif.
    * expiring currencies:
    gd_waers_save = bsik-waers.
    if not gd_expcur_flag is initial.
    perform item_curr_convert_bsik using 'SAPDBKDF'
    t001-waers
    gd_expcur_date
    changing bsik.
    endif.
    clear bsegh. "<-- 3.0F
    move-corresponding bsik to bsegh.
    * clear fields not used by the field selection: note 36167
    describe table bsik_fields lines sy-tfill.
    if sy-tfill > 0.
    perform putzen_bsegh tables bsik_fields.
    endif.

    bsegh-koart = 'K'.
    perform got_bsega(sapbsega).
    if alcur eq 'X'. perform convert_alt using 'BSIK'. endif. "euro

    if bsik-xarch = 'X'.
    count_arch = count_arch + 1.
    endif.

    put bsik.
    clear bsik.
    cursor-bsak = cursor-bsak + 1.
    endif.
    endif.
    enddo.
    endif. "<<<<<<<<<<<<<<<<<<<<<<<<<<< normal documents <<<<<<<<<<<<<<<<<

    if b0sg-xstav = 'X'.
    * vorerfasste Belege ueber DB-Index nach LIFNR
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    DATA : ld_arch LIKE kd_usear.

    * if user is not allowed to see line items or balances
    if f_bkpf_bek_subrc <> 0.
    exit.
    endif.
    IF b0sg-xasgl = 'X'.
    exit.
    endif.

    * if archived items are to be read
    IF kd_usear = 'X'.
    IF gd_arch_done eq 'N'.
    PERFORM read_archive.
    gd_arch_done = 'Y'.
    gd_read_memo_done = 'N'.
    ENDIF.
    ld_arch = 'X'.
    PERFORM write_into_bsik TABLES ybsak
    USING cursor-ybsak ld_arch. "#EC ENHOK
    ENDIF.

    * if items from database are to be read
    IF NOT kd_usedb IS INITIAL.
    IF b0sg-xstan = 'X' OR b0sg-xstas = 'X'. ">>>> normal documents >>>>>
    IF cursor-bsik = 0.
    PERFORM update_xbsik.
    endif.
    CLEAR ld_arch.
    PERFORM write_into_bsik TABLES xbsik USING cursor-bsik ld_arch.

    if cursor-bsak = 0.
    perform update_xbsak.
    endif.
    CLEAR ld_arch.
    PERFORM write_into_bsik TABLES xbsak
    USING cursor-bsak ld_arch. "#EC ENHOK

    endif. "<<<<<<<<<<<<<<<<<<<<<<<<<<< normal documents <<<<<<<<<<<<<<<<<

    if b0sg-xstav = 'X'.
    * vorerfasste Belege ueber DB-Index nach lifnr
    *>>>> END OF INSERTION <<<<<<
    ...
    select * from v_vbsegk where lifnr = save_lifnr
    and bukrs = save_bukrs
    and gjahr between '0001' and '9999'
    and budat in kd_budat
    and budat le kd_stida
    and zuonr in kd_zuonr
    and umskz in kd_umskz
    and hkont in kd_hkont
    and gsber in kd_gsber
    and blart in kd_blart
    and bldat in kd_bldat
    and bschl in kd_bschl
    * AND BSTAT IN KD_BSTAT
    and waers in kd_waers
    and zlspr in kd_zlspr
    and zlsch in kd_zlsch
    and (vbsegk_where).
    *>>>> START OF DELETION <<<<<

    clear bsik.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<


    CLEAR bsik.
    *>>>> END OF INSERTION <<<<<<
    ...
    move-corresponding v_vbsegk to bsik.

    save_belnr = bsik-belnr.
    save_buzei = bsik-buzei.
    save_gsber = bsik-gsber.
    save_gjahr = bsik-gjahr.
    *>>>> START OF DELETION <<<<<

    * expiring currencies:
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * expiring currencies:
    *>>>> END OF INSERTION <<<<<<
    ...
    perform item_curr_convert_bsik using 'SAPDBKDF'
    t001-waers
    gd_expcur_date
    changing bsik.
    endif.
    clear bsegh. "<-- 3.0F
    move-corresponding bsik to bsegh.
    *>>>> START OF DELETION <<<<<
    bsegh-koart = 'K'.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    bsegh-koart = 'D'.
    *>>>> END OF INSERTION <<<<<<
    ...
    perform got_bsega(sapbsega).
    if alcur eq 'X'. perform convert_alt using 'BSIK'. endif. "euro

    put bsik.
    clear bsik.
    *>>>> START OF DELETION <<<<<

    endselect.

    endif.

    endform. "PUT_BSIK
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDSELECT.

    endif.

    ENDIF. "if kd_usedb active

    endform. "PUT_BSIK

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BSIKEXT
    *&---------------------------------------------------------------------*
    ...
    * FORM PUT_BSIKEXT *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    form put_bsikext.
    *>>>> START OF DELETION <<<<<
    move-corresponding bsik to bsikext.
    move-corresponding bsega to bsikext.
    put bsikext.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    move-corresponding bsik to bsikext.
    move-corresponding bsega to bsikext.
    put bsikext.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BKPF
    *&---------------------------------------------------------------------*
    ...
    * FORM PUT_BKPF *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    form put_bkpf.
    *>>>> START OF DELETION <<<<<
    if bsik-xarch = 'X'.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    IF kd_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 'SAPDBKDF'
    gd_expcur_date
    CHANGING bkpf.
    ENDIF.

    PUT bkpf.
    ELSE.
    * MESSAGE I803 WITH SAVE_BUKRS SAVE_BELNR.
    WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
    ENDIF.
    ENDIF.

    IF kd_usedb = 'X'.
    IF BSIK-XARCH = 'X'.
    *>>>> END OF INSERTION <<<<<<
    ...
    perform item_curr_convert_bkpf using 'SAPDBKDF'
    gd_expcur_date
    changing bkpf.
    endif.

    put bkpf.
    endif.
    *>>>> START OF DELETION <<<<<
    endform. "PUT_BKPF
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    endif.

    endform. "PUT_BKPF
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BSEG
    *&---------------------------------------------------------------------*
    ...
    *----------------------------------------------------------------------*
    * FORM PUT_BSEG *
    * Belegposition *
    *----------------------------------------------------------------------*
    form put_bseg.
    *>>>> START OF DELETION <<<<<
    if save_bstat <> 'V'.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    IF kd_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.
    WRITE: text-004, save_belnr, text-005, save_bukrs, text-006.
    ENDIF.

    * Belegpositionsanhang
    IF bseg-koart = 'D' OR bseg-koart = 'K'.
    IF bseg-zfbdt = '00000000'.
    bseg-zfbdt = bkpf-bldat.
    ENDIF.
    ENDIF.

    * expiring currencies:
    IF NOT gd_expcur_flag IS INITIAL.
    PERFORM item_curr_convert_bseg USING 'SAPDBKDF'
    t001-waers
    gd_waers_save
    gd_expcur_date
    CHANGING bseg.
    ENDIF.
    MOVE-CORRESPONDING bseg TO bsegh.

    * clear the fields not used in field selection: note 36167
    DESCRIBE TABLE bseg_fields LINES sy-tfill. "<-- 3.0F
    IF sy-tfill > 0.
    PERFORM putzen_bsegh TABLES bseg_fields.
    ENDIF. "<-- 3.0F
    PERFORM got_bsega(sapbsega).

    * Euro
    IF alcur EQ 'X'.
    PERFORM convert_alt USING 'BSEG'.
    ENDIF.

    PUT bseg.

    CLEAR bseg.
    ENDIF. "kd_usear

    IF kd_usedb = 'X'.
    IF SAVE_BSTAT <> 'V'.
    *>>>> END OF INSERTION <<<<<<
    ...
    endif.
    endif.
    if alcur eq 'X'. perform convert_alt using 'BSEG'. endif. "euro

    put bseg.

    *>>>> START OF DELETION <<<<<
    endif.

    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDIF.
    endif.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_KDF_SP
    *&---------------------------------------------------------------------*
    ...
    kd_bukrs[] = xx_bukrs[].
    *** put:
    put lfa1.
    endselect.

    *>>>> START OF DELETION <<<<<
    if count_arch <> 0.
    if kd_iarch is initial.
    uline /(60).
    write: / sy-vline, count_arch, text-013,
    60 sy-vline.
    uline /(60).
    else.
    message i010 with count_arch.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    IF gd_COUNT_ARCH <> 0.
    if kd_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.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM CHECK_DATE
    *&---------------------------------------------------------------------*
    ...
    endloop.
    endif.

    endform. " check_date

    *>>>> START OF DELETION <<<<<
    **********************************************************************
    * !!! PLEASE DO NOT CHANGE MANUALLY (BEGIN OF BLOCK) !!!!!!!!!!!!!!! *
    *----------------------------------------------------------------------*
    * Data structures for search pattern selection *
    *----------------------------------------------------------------------*
    * KDF_SP : Search pattern values. *
    * After START-OF-SELECTION table KDF_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 KDF_SP will be used in subroutine PUT_KDF_SP. *
    *----------------------------------------------------------------------*
    * DATA: BEGIN OF KDF_SP OCCURS 1000, *
    * LIFNR LIKE LFA1-LIFNR, *
    * BUKRS LIKE LFB1-BUKRS, *
    * END OF KDF_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 KDF_SP, e.g. KDF_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) !!!!!!!!!!!!!!!!! *
    **********************************************************************
    *>>>> END OF DELETION <<<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_ADMI_FILES
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * FORM put_admi_files *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    FORM put_admi_files.
    ENDFORM.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM DATASOURCE_INIT
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * 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.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM READ_ARCHIVE
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * FORM read_archive *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    FORM read_archive.

    DATA : ld_errors TYPE boole,
    ld_progress TYPE boole,
    ld_convert_currency TYPE boole.

    * 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 kd_useas IS INITIAL.
    REFRESH kd_files.
    ENDIF.

    CALL FUNCTION 'FI_DOCUMENT_ARCH_AS_ITEMS_READ'
    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_bsak = ybsak
    i_arch_sel = kd_files[]
    EXCEPTIONS
    no_infostruc_found = 1
    SELECTIONS_ERROR = 2
    CONVERSION_ERROR = 3.
    case sy-subrc.
    when '0'.
    SORT ybsak BY mandt lifnr bukrs.
    when '1'.
    if gd_msg601_done is initial.
    message i601.
    gd_msg601_done = 'X'.
    endif.
    refresh: ybkpf, ybseg, ybsak.
    when '2'.
    message i602.
    refresh: ybkpf, ybseg, ybsak.
    when '3'.
    message i603.
    refresh: ybkpf, ybseg, ybsak.
    when others.
    message i604.
    refresh: ybkpf, ybseg, ybsak.
    endcase.
    cursor-ybsak = 1.
    IF kd_memor = 'X'.
    EXPORT ybkpf TO MEMORY ID 'YBKPF'.
    EXPORT ybseg TO MEMORY ID 'YBSEG'.
    ENDIF.

    ENDFORM.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SELTAB_FROM_REGULAR_SEL
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * 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.


    REFRESH:lt_frange.
    ld_trange-tablename = 'BKPF'.

    IF NOT kd_bukrs[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'BUKRS'.
    LOOP AT kd_bukrs.
    MOVE-CORRESPONDING kd_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 kd_budat[] IS INITIAL.
    REFRESH: lt_selopt.
    ld_frange-fieldname = 'BUDAT'.
    LOOP AT kd_budat.
    MOVE-CORRESPONDING kd_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 ( kd_opopt = 'X' AND kd_apopt = 'X' )
    OR ( kd_opopt = 'X' AND kd_apopt IS INITIAL ) .
    REFRESH: lt_selopt.
    ld_frange-fieldname = 'BUDAT'.
    ld_selopt-sign = 'I'.
    ld_selopt-option = 'BT'.
    ld_selopt-low = '00010101'.
    ld_selopt-high = kd_stida.
    APPEND ld_selopt TO lt_selopt.
    ld_frange-selopt_t = lt_selopt[].
    APPEND ld_frange TO lt_frange.
    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_lifnr[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'LIFNR'.
    LOOP AT k_lifnr.
    MOVE-CORRESPONDING k_lifnr 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 kd_augdt[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'AUGDT'.
    LOOP AT kd_augdt.
    MOVE-CORRESPONDING kd_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 ( kd_opopt IS INITIAL AND kd_apopt IS INITIAL )
    OR ( kd_opopt = 'X' AND kd_apopt IS INITIAL ) .
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'AUGDT'.
    ld_selopt-sign = 'I'.
    ld_selopt-option = 'BT'.
    ld_selopt-low = kd_stida.
    ld_selopt-high = '99991231'.
    APPEND ld_selopt TO lt_selopt.
    ld_frange-selopt_t = lt_selopt[].
    APPEND ld_frange TO lt_frange.
    ENDIF.

    IF NOT kd_zuonr[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'ZUONR'.
    LOOP AT kd_zuonr.
    MOVE-CORRESPONDING kd_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 kd_shkzg[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'SHKZG'.
    LOOP AT kd_shkzg.
    MOVE-CORRESPONDING kd_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 kd_umskz[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'UMSKZ'.
    LOOP AT kd_umskz.
    MOVE-CORRESPONDING kd_umskz 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 kd_bschl[] IS INITIAL.
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'BSCHL'.
    LOOP AT kd_bschl.
    MOVE-CORRESPONDING kd_bschl TO ld_selopt.
    APPEND ld_selopt TO lt_selopt.
    ENDLOOP.
    ld_frange-selopt_t = lt_selopt[].
    APPEND ld_frange TO lt_frange.
    ENDIF.

    REFRESH:lt_selopt.
    ld_frange-fieldname = 'KOART'.
    ld_selopt-sign = 'I'.
    ld_selopt-option = 'EQ'.
    ld_selopt-low = 'K'.
    APPEND ld_selopt TO lt_selopt.
    ld_frange-selopt_t = lt_selopt[].
    APPEND ld_frange TO lt_frange.


    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.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SELTAB_FROM_DYN_SEL
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * 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 bsik-where into ranges format
    ld_where-tablename = 'BSIK'.
    ld_where-where_tab = bsik_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 bsik into ranges for BKPF and BSEG
    CLEAR : ld_trange , lt_frange , ld_frange .
    REFRESH : lt_frange .

    ld_tablename = 'BSIK'.

    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.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM WRITE_INTO_BSIK
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * FORM write_into_bsik *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    * --> i_bsik *
    * --> i_cursor *
    * --> i_arch *
    *---------------------------------------------------------------------*
    FORM write_into_bsik TABLES i_bsik TYPE ty_bsik
    USING i_cursor type sy-index
    i_arch type boole_d .

    save_bstat = ' '.
    DO.
    READ TABLE i_bsik INDEX i_cursor.
    IF sy-subrc NE 0.
    EXIT.
    ENDIF.
    IF save_lifnr < i_bsik-lifnr. "Eintrag nicht enthalten
    EXIT.
    ELSEIF save_lifnr > i_bsik-lifnr. "Weiterlesen
    i_cursor = i_cursor + 1.
    ELSE. "Treffer
    IF save_bukrs < i_bsik-bukrs.
    EXIT.
    ELSEIF save_bukrs > i_bsik-bukrs.
    i_cursor = i_cursor + 1.
    ELSE.
    IF i_bsik-xarch = 'X'
    AND i_arch IS INITIAL
    AND kd_usear = 'X'.
    READ TABLE ybsak WITH KEY bukrs = i_bsik-bukrs
    belnr = i_bsik-belnr
    gjahr = i_bsik-gjahr
    buzei = i_bsik-buzei
    TRANSPORTING NO FIELDS.
    * TRANSPORTING NO FIELDS BINARY SEARCH.
    IF sy-subrc = 0.
    i_cursor = i_cursor + 1.
    CONTINUE.
    ENDIF.
    ENDIF.
    bsik = i_bsik.
    save_belnr = bsik-belnr.
    save_buzei = bsik-buzei.
    save_gsber = bsik-gsber.
    save_gjahr = bsik-gjahr.
    * Belegpositionsanhang
    IF bsik-zfbdt = '00000000'.
    bsik-zfbdt = bsik-bldat.
    ENDIF.
    * expiring currencies:
    gd_waers_save = bsik-waers.
    IF NOT gd_expcur_flag IS INITIAL.
    PERFORM item_curr_convert_bsik USING 'SAPDBDDF'
    t001-waers
    gd_expcur_date
    CHANGING bsik.
    ENDIF.
    CLEAR bsegh. "<-- 3.0F
    MOVE-CORRESPONDING bsik TO bsegh.
    * changes to avoid the problem with the field selection: note 36167
    DESCRIBE TABLE bsik_fields LINES sy-tfill.
    IF sy-tfill > 0.
    PERFORM putzen_bsegh TABLES bsik_fields.
    ENDIF.

    bsegh-koart = 'K'.
    PERFORM got_bsega(sapbsega).

    *Euro
    IF alcur EQ 'X'.
    PERFORM convert_alt USING 'BSIK'.
    ENDIF.


    IF bsik-xarch = 'X'.
    gd_count_arch = gd_count_arch + 1.
    ENDIF.

    if i_arch = 'X'
    AND kd_usear = 'X'.
    export gd_read_memo_done to memory id 'GD_READ_MEMO_DONE'.
    gd_read_memo_done = 'Y'.
    endif.

    PUT bsik.
    CLEAR bsik.
    i_cursor = i_cursor + 1.
    ENDIF.
    ENDIF.
    ENDDO.

    ENDFORM.


    **********************************************************************
    * !!! PLEASE DO NOT CHANGE MANUALLY (BEGIN OF BLOCK) !!!!!!!!!!!!!!! *
    *----------------------------------------------------------------------*
    * Data structures for search pattern selection *
    *----------------------------------------------------------------------*
    * KDF_SP : Search pattern values. *
    * After START-OF-SELECTION table KDF_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 KDF_SP will be used in subroutine PUT_KDF_SP. *
    *----------------------------------------------------------------------*
    * DATA: BEGIN OF KDF_SP OCCURS 1000, *
    * LIFNR LIKE LFA1-LIFNR, *
    * BUKRS LIKE LFB1-BUKRS, *
    * END OF KDF_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 KDF_SP, e.g. KDF_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) !!!!!!!!!!!!!!!!! *
    **********************************************************************
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *&---------------------------------------------------------------------*
    *& Object REPS SAPDBSDF
    *& Object header LDBA SDF
    *&---------------------------------------------------------------------*
    *& REPORT SAPDBSDF
    *&---------------------------------------------------------------------*
    ...
    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
    *>>>> START OF DELETION <<<<<
    BSISEXT, "40C
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    admi_files,
    bsisext, "40C
    *>>>> END OF INSERTION <<<<<<
    ...
    data: CHAR130(130) type C.
    * SD_OPOPT(1) TYPE C,
    * SD_APOPT(1) TYPE C.
    data: DATABASE(1) type C value 'S'.

    *>>>> START OF DELETION <<<<<
    data: COUNT_ARCH type I.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * 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: gt_rng_archiv TYPE TABLE OF ty_rng_archiv.
    TYPES: ty_bsis TYPE bsis OCCURS 10.
    DATA : ybsas TYPE bsas OCCURS 10,
    ybsis TYPE bsas OCCURS 10,
    ybkpf TYPE bkpf OCCURS 10,
    ybseg TYPE bseg OCCURS 10.
    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 : gl_log_handle TYPE balloghndl.
    DATA : gd_msg601_done TYPE c.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM INIT
    *&---------------------------------------------------------------------*
    ...
    endif.
    else.
    GD_TPC_CHECK = SPACE.
    endif.

    *>>>> START OF DELETION <<<<<
    endform. "INIT
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * Initialization for reading from archives.
    IF sd_objec IS INITIAL.
    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.


    ENDFORM. "INIT
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PAI
    *&---------------------------------------------------------------------*
    ...
    form PAI using FNAME MARK.
    data: GET1, GET2, GET3,
    RC like SY-SUBRC,
    MSG1 like SYMSG.
    data: L_CC_AT_SCREEN like SY-SUBRC.
    *>>>> START OF INSERTION <<<<
    DATA: ld_progname TYPE progname,
    lt_objects TYPE as_t_archobj.

    *>>>> END OF INSERTION <<<<<<
    ...
    select single WAERS from T001 into T001-WAERS
    where BUKRS in SD_BUKRS.
    endif.

    check MARK = SPACE.
    *>>>> START OF DELETION <<<<<
    check SSCRFIELDS-UCOMM = 'ONLI' " Online submit
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    IF sscrfields-ucomm = 'ONLI' " Online submit
    *>>>> END OF INSERTION <<<<<<
    ...
    endloop.

    *---------------------------------------------------------------------*
    when others.
    endcase.
    *>>>> START OF DELETION <<<<<
    endform. "PAI
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    * 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.
    ENDIF.

    ENDFORM. "PAI
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM LDB_PROCESS_INIT
    *&---------------------------------------------------------------------*
    ...
    refresh: SKA1_WHERE, SKA1_FIELDS,
    SKB1_WHERE, SKB1_FIELDS,
    BSIS_WHERE, BSIS_FIELDS,
    BSISEXT_FIELDS, BKPF_FIELDS,
    BSEG_FIELDS, GSEG_FIELDS,
    TEST_FIELDS.

    clear: KTOPL_ENTRY, BUKRS_ENTRY, CHAR130,
    *>>>> START OF DELETION <<<<<
    SD_OPOPT, SD_APOPT, COUNT_ARCH.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    sd_opopt, sd_apopt.
    *>>>> END OF INSERTION <<<<<<
    ...
    DATABASE = 'S'.

    refresh: LEDTAB, F4TAB, C001, XY_BUKRS, ZZ_BUKRS.
    clear: G_FLG_XX_CURTP.

    *>>>> START OF DELETION <<<<<
    clear: COUNT_ARCH.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * For reading from an archiv:
    CLEAR: gd_count_arch.
    * clear: gd_msg601_done.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_SKA1
    *&---------------------------------------------------------------------*
    ...
    * FORM PUT_SKA1 *
    *--------------------------------------------------------------------*
    form PUT_SKA1.

    data: LD_ARCH type C.
    *>>>> START OF DELETION <<<<<
    data: LT_SKA1 type standard table of SKA1 with header line.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    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.
    *>>>> END OF INSERTION <<<<<<
    ...
    GD_EXPCUR_DATE = SY-DATLO.
    else.
    GD_EXPCUR_DATE = SD_STIDA.
    endif.

    *>>>> START OF DELETION <<<<<
    loop at SD_SAKNR transporting no fields
    where OPTION ne 'EQ' or
    SIGN ne 'I'.
    exit.
    endloop.

    if SY-SUBRC = 0.
    select (SKA1_FIELDS) from SKA1 into corresponding fields of XSKA1
    where KTOPL in XX_KTOPL
    and SAKNR in SD_SAKNR
    and (SKA1_WHERE)
    order by primary key. "MANDT KTOPL SAKNR.

    append XSKA1.
    K_SAKNR-LOW = XSKA1-SAKNR.
    append K_SAKNR.
    COUNT = COUNT + 1.
    if COUNT >= MAX_COUNT.
    perform PROCESS_SKA1.
    refresh XSKA1.
    refresh K_SAKNR.
    COUNT = 0.
    endif.

    endselect.
    else. " worklist
    select (SKA1_FIELDS) from SKA1
    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.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * check if sd_saknr contains a worklist. if yes, make sure that
    * WHERE statement doesn't get too long

    LOOP AT sd_saknr TRANSPORTING NO FIELDS
    WHERE option NE 'EQ' OR
    sign NE 'I'.
    EXIT.
    ENDLOOP.
    IF sy-subrc = 0. " no worklist
    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.
    ELSE.
    SELECT mandt ktopl saknr FROM ska1 INTO lt_ska1_key
    FOR ALL ENTRIES IN sd_saknr
    WHERE ktopl IN xx_ktopl
    AND saknr = sd_saknr-low
    AND (ska1_where).
    APPEND lt_ska1_key.
    ENDSELECT.
    SORT lt_ska1_key BY mandt ktopl saknr.
    ENDIF.

    LOOP AT lt_ska1_key.
    SELECT SINGLE (ska1_fields) FROM ska1
    INTO CORRESPONDING FIELDS OF xska1
    WHERE ktopl = lt_ska1_key-ktopl
    AND saknr = lt_ska1_key-saknr.

    *>>>> END OF INSERTION <<<<<<
    ...
    append XSKA1.
    K_SAKNR-LOW = XSKA1-SAKNR.
    append K_SAKNR.
    COUNT = COUNT + 1.
    if COUNT >= MAX_COUNT.
    *>>>> START OF DELETION <<<<<
    perform PROCESS_SKA1.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * archive has to be read
    gd_arch_done = 'N'.
    PERFORM process_ska1.
    *>>>> END OF INSERTION <<<<<<
    ...
    refresh XSKA1.
    refresh K_SAKNR.
    COUNT = 0.
    endif.
    endloop.
    *>>>> START OF DELETION <<<<<

    endif.
    perform PROCESS_SKA1.

    if COUNT_ARCH <> 0.
    get parameter id 'LDB_NO_DISPL_ARCH' field LD_ARCH.
    if LD_ARCH is initial.
    if SD_IARCH is initial.
    uline /(60).
    write: / SY-VLINE, COUNT_ARCH, TEXT-013,
    60 SY-VLINE.
    uline /(60).
    else.
    message I010 with COUNT_ARCH.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    * 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 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.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM INIT_BUFFERS
    *&---------------------------------------------------------------------*
    ...
    *--------------------------------------------------------------------*
    * FORM INIT_BUFFERS *
    *--------------------------------------------------------------------*
    form INIT_BUFFERS.
    refresh: XSKB1, XSKC1A, XSKC1C, YSKC1A, YSKC1C.
    *>>>> START OF DELETION <<<<<
    CURSOR-SKB1 = CURSOR-SKC1A = CURSOR-SKC1C = 0.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    REFRESH: ybsis, ybsas, ybkpf, ybseg.
    cursor-skb1 = cursor-skc1a = cursor-skc1c = 0.
    cursor-ybsas = 0.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BSIS
    *&---------------------------------------------------------------------*
    ...
    * FORM PUT_BSIS *
    *--------------------------------------------------------------------*

    form PUT_BSIS.

    *>>>> START OF DELETION <<<<<
    * if user is not allowed to see line items or balances
    if F_BKPF_BES_SUBRC <> 0.
    exit.
    endif.

    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    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 = '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.
    *>>>> END OF INSERTION <<<<<<
    ...
    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).
    *>>>> START OF DELETION <<<<<

    * 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'.
    continue.
    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'.
    continue.
    endif.
    endif.


    SAVE_BELNR = BSIS-BELNR.
    SAVE_BUZEI = BSIS-BUZEI.
    SAVE_GSBER = BSIS-GSBER.
    SAVE_GJAHR = BSIS-GJAHR.

    * Belegpositionsanhang
    * --------------------
    * PERFORM AUTHORITYCHECK_BSIS.
    * 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 BSIS-XARCH = 'X'.
    COUNT_ARCH = COUNT_ARCH + 1.
    endif.
    if ALCUR eq 'X'. perform CONVERT_ALT using 'BSIS'. endif. "euro

    put BSIS.
    clear BSIS.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    CLEAR ld_arch.
    PERFORM process_bsis USING ld_arch.

    *>>>> END OF INSERTION <<<<<<
    ...
    endselect.

    if B0SG-XNOPL = 'X'.
    exit.
    endif.
    *>>>> START OF DELETION <<<<<

    select (BSIS_FIELDS) from BSAS into corresponding fields of BSIS
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<


    SELECT (bsis_fields) FROM bsas INTO CORRESPONDING FIELDS OF bsis
    *>>>> END OF INSERTION <<<<<<
    ...
    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).
    *>>>> START OF DELETION <<<<<

    * 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'.
    continue.
    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'.
    continue.
    endif.
    endif.


    SAVE_BELNR = BSIS-BELNR.
    SAVE_BUZEI = BSIS-BUZEI.
    SAVE_GSBER = BSIS-GSBER.
    SAVE_GJAHR = BSIS-GJAHR.

    * Belegpositonsanhang
    * -------------------
    * PERFORM AUTHORITYCHECK_BSIS.
    * 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'. perform CONVERT_ALT using 'BSIS'. endif. "euro
    if BSAS-XARCH = 'X'.
    COUNT_ARCH = COUNT_ARCH + 1.
    endif.

    put BSIS.
    clear BSIS.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    CLEAR ld_arch.
    PERFORM process_bsis USING ld_arch.

    *>>>> END OF INSERTION <<<<<<
    ...
    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).
    *>>>> START OF DELETION <<<<<

    * 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'.
    continue.
    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'.
    continue.
    endif.
    endif.

    SAVE_BELNR = BSIS-BELNR.
    SAVE_BUZEI = BSIS-BUZEI.
    SAVE_GSBER = BSIS-GSBER.
    SAVE_GJAHR = BSIS-GJAHR.

    * Belegpositonsanhang
    * -------------------
    * PERFORM AUTHORITYCHECK_BSIS.
    * 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 BSAS-XARCH = 'X'.
    COUNT_ARCH = COUNT_ARCH + 1.
    endif.
    if ALCUR eq 'X'. perform CONVERT_ALT using 'BSIS'. endif. "euro

    put BSIS.
    clear BSIS.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    CLEAR ld_arch.
    PERFORM process_bsis USING ld_arch.

    *>>>> END OF INSERTION <<<<<<
    ...
    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).
    *>>>> START OF DELETION <<<<<

    * 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'.
    continue.
    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'.
    continue.
    endif.
    endif.


    SAVE_BELNR = BSIS-BELNR.
    SAVE_BUZEI = BSIS-BUZEI.
    SAVE_GSBER = BSIS-GSBER.
    SAVE_GJAHR = BSIS-GJAHR.
    * Belegpositionsanhang
    * --------------------
    * PERFORM AUTHORITYCHECK_BSIS.
    * 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'. perform CONVERT_ALT using 'BSIS'. endif. "euro
    if BSIS-XARCH = 'X'.
    COUNT_ARCH = COUNT_ARCH + 1.
    endif.

    put BSIS.
    clear BSIS.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    CLEAR ld_arch.
    PERFORM process_bsis USING ld_arch.

    *>>>> END OF INSERTION <<<<<<
    ...
    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.
    *>>>> START OF DELETION <<<<<

    * 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'.
    continue.
    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'.
    continue.
    endif.
    endif.


    SAVE_BELNR = BSIS-BELNR.
    SAVE_BUZEI = BSIS-BUZEI.
    SAVE_GSBER = BSIS-GSBER.
    SAVE_GJAHR = BSIS-GJAHR.

    * Belegpositonsanhang
    * -------------------
    * PERFORM AUTHORITYCHECK_BSIS.
    * 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'. perform CONVERT_ALT using 'BSIS'. endif. "euro
    if BSAS-XARCH = 'X'.
    COUNT_ARCH = COUNT_ARCH + 1.
    endif.

    put BSIS.
    clear BSIS.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    CLEAR ld_arch.
    PERFORM process_bsis USING ld_arch.

    *>>>> END OF INSERTION <<<<<<
    ...
    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).

    *>>>> START OF DELETION <<<<<
    * 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'.
    continue.
    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'.
    continue.
    endif.
    endif.


    SAVE_BELNR = BSIS-BELNR.
    SAVE_BUZEI = BSIS-BUZEI.
    SAVE_GSBER = BSIS-GSBER.
    SAVE_GJAHR = BSIS-GJAHR.
    * Belegpositionsanhang
    * --------------------
    * PERFORM AUTHORITYCHECK_BSIS.
    * 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'. perform CONVERT_ALT using 'BSIS'. endif. "euro
    if BSIS-XARCH = 'X'.
    COUNT_ARCH = COUNT_ARCH + 1.
    endif.

    put BSIS.
    clear BSIS.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    CLEAR ld_arch.
    PERFORM process_bsis USING ld_arch.

    *>>>> END OF INSERTION <<<<<<
    ...
    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).

    *>>>> START OF DELETION <<<<<
    * check imkey range
    if IMKEY_ELIMINATED eq 'X'.
    perform CHECK_INT_EXT(FI_LDB_UTIL) tables IMKEY_TAB
    using V_VBSEGS-IMKEY
    'IMKEY'
    changing CHECK_OK.
    if CHECK_OK = 'N'.
    continue.
    endif.
    endif.

    if PROJK_ELIMINATED eq 'X'.
    perform CHECK_INT_EXT(FI_LDB_UTIL) tables PROJK_TAB
    using V_VBSEGS-PS_PSP_PNR
    'KONPR'
    changing CHECK_OK.
    if CHECK_OK = 'N'.
    continue.
    endif.
    endif.


    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    *>>>> END OF INSERTION <<<<<<
    ...
    clear BSIS.

    move-corresponding V_VBSEGS to BSIS.
    BSIS-PROJK = V_VBSEGS-PS_PSP_PNR.
    BSIS-HKONT = V_VBSEGS-SAKNR.
    *>>>> START OF DELETION <<<<<

    SAVE_BELNR = BSIS-BELNR.
    SAVE_BUZEI = BSIS-BUZEI.
    SAVE_GSBER = BSIS-GSBER.
    SAVE_GJAHR = BSIS-GJAHR.

    * 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'. perform CONVERT_ALT using 'BSIS'. endif. "euro

    put BSIS.
    clear BSIS.
    endselect.
    endif.

    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    CLEAR ld_arch.
    PERFORM process_bsis USING ld_arch.

    endselect.
    endif.

    ENDIF. " sd_usedb
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BSISEXT
    *&---------------------------------------------------------------------*
    ...
    ***********************************************************************
    * put_bsisext *
    * Erweiterungsteil *
    ***********************************************************************
    form PUT_BSISEXT.
    *>>>> START OF DELETION <<<<<
    move-corresponding BSIS to BSISEXT.
    move-corresponding BSEGA to BSISEXT.
    put BSISEXT.
    endform. "PUT_BSISEXT
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    MOVE-CORRESPONDING bsis TO bsisext.
    MOVE-CORRESPONDING bsega TO bsisext.
    PUT bsisext.

    ENDFORM. "PUT_BSISEXT

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BKPF
    *&---------------------------------------------------------------------*
    ...
    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)

    *>>>> START OF DELETION <<<<<
    if BSIS-XARCH = 'X'.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<

    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.
    * MESSAGE I803 WITH SAVE_BUKRS SAVE_BELNR.
    WRITE: text-007, save_bukrs, text-002, save_belnr, text-003.
    ENDIF.
    ENDIF.

    IF sd_usedb = 'X'.
    IF bsis-xarch = 'X'.
    *>>>> END OF INSERTION <<<<<<
    ...
    perform ITEM_CURR_CONVERT_BKPF using 'SAPDBSDF'
    GD_EXPCUR_DATE
    changing BKPF.
    endif.

    put BKPF.
    *>>>> START OF DELETION <<<<<
    endif.
    endform. "PUT_BKPF
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDIF.
    endif.
    ENDFORM. "PUT_BKPF
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_BSEG
    *&---------------------------------------------------------------------*
    ...
    *--------------------------------------------------------------------*
    * FORM PUT_BSEG *
    *--------------------------------------------------------------------*
    form PUT_BSEG.
    *>>>> START OF DELETION <<<<<
    if SAVE_BSTAT <> 'V'.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<


    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.
    WRITE: text-004, save_belnr, text-005, save_bukrs, text-006.
    ENDIF.

    * 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. "sd_usear

    IF sd_usedb = 'X'.
    IF save_bstat <> 'V'.
    *>>>> END OF INSERTION <<<<<<
    ...
    endif.
    endif.
    if ALCUR eq 'X'. perform CONVERT_ALT using 'BSEG'. endif. "euro

    put BSEG.

    *>>>> START OF DELETION <<<<<
    endif.

    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    ENDIF.
    endif.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_SDF_SP
    *&---------------------------------------------------------------------*
    ...
    COUNT = 0.
    endif.
    endloop.
    perform PROCESS_SKA1.

    *>>>> START OF DELETION <<<<<
    if COUNT_ARCH <> 0.
    if SD_IARCH is initial.
    uline /(60).
    write: / SY-VLINE, COUNT_ARCH, TEXT-013,
    60 SY-VLINE.
    uline /(60).
    else.
    message I010 with COUNT_ARCH.
    *>>>> END OF DELETION <<<<<<<
    *>>>> START OF INSERTION <<<<
    IF gd_count_arch <> 0.
    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.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PUT_ADMI_FILES
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    **********************************************************************
    * !!! 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.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM DATASOURCE_INIT
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * 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.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM READ_ARCHIVE
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * FORM read_archive *
    *---------------------------------------------------------------------*
    * ........ *
    *---------------------------------------------------------------------*
    FORM read_archive.

    DATA : ld_errors TYPE boole,
    ld_progress TYPE boole,
    ld_convert_currency TYPE boole.

    * 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
    conversion_error = 3.
    CASE sy-subrc.
    WHEN '0'.
    APPEND LINES OF ybsis TO ybsas. "#EC ENHOK
    SORT ybsas BY mandt hkont bukrs.
    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 '3'.
    MESSAGE i603.
    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.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SELTAB_FROM_REGULAR_SEL
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * 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.


    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 ) .
    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.

    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 ) .
    REFRESH:lt_selopt.
    ld_frange-fieldname = 'AUGDT'.
    ld_selopt-sign = 'I'.
    ld_selopt-option = 'BT'.
    ld_selopt-low = sd_stida.
    ld_selopt-high = '99991231'.
    APPEND ld_selopt TO lt_selopt.
    ld_frange-selopt_t = lt_selopt[].
    APPEND ld_frange TO lt_frange.
    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_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.

    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.
    ld_frange-selopt_t = lt_selopt[].
    APPEND ld_frange TO lt_frange.


    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.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM SELTAB_FROM_DYN_SEL
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * 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.

    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*
    *& FORM PROCESS_BSIS
    *&---------------------------------------------------------------------*
    *>>>> START OF INSERTION <<<<
    *---------------------------------------------------------------------*
    * 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 ybsas WITH KEY bukrs = bsis-bukrs
    belnr = bsis-belnr
    gjahr = bsis-gjahr
    buzei = bsis-buzei
    TRANSPORTING NO FIELDS.
    * TRANSPORTING NO FIELDS BINARY SEARCH.
    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.

    *
    PUT bsis.

    CLEAR bsis.


    ENDFORM.
    *>>>> END OF INSERTION <<<<<<
    ...
    *&---------------------------------------------------------------------*

    Effected Objects:


    (FUNC) - FI_DOCUMENT_ARCH_AS_ITEMS_READ
    (REPS) - DBDDFSEL
    (REPS) - DBKDFSEL
    (REPS) - DBSDFSEL
    (REPS) - LFAR1F05
    (REPS) - LFAR1IDX
    (REPS) - LFAR1TOP
    (REPS) - RFITEMAP
    (REPS) - RFITEMAR
    (REPS) - RFITEMGL
    (REPS) - RFITEM_DEF
    (REPS) - RFITEM_INC
    (REPS) - SAPDBDDF
    (REPS) - SAPDBKDF
    (REPS) - SAPDBSDF
    (REPS) - SAPLFAR1

    (FUNC) - FI_DOCUMENT_ARCH_AS_ITEMS_READ
    (REPS) - DBDDFSEL
    (REPS) - DBKDFSEL
    (REPS) - DBSDFSEL
    (REPS) - LFAR1F05
    (REPS) - LFAR1IDX
    (REPS) - LFAR1TOP
    (REPS) - RFITEMAP
    (REPS) - RFITEMAR
    (REPS) - RFITEMGL
    (REPS) - RFITEM_DEF
    (REPS) - RFITEM_INC
    (REPS) - SAPDBDDF
    (REPS) - SAPDBKDF
    (REPS) - SAPDBSDF
    (REPS) - SAPLFAR1

    (FUNC) - FI_DOCUMENT_ARCH_AS_ITEMS_READ
    (REPS) - DBDDFSEL
    (REPS) - DBKDFSEL
    (REPS) - DBSDFSEL
    (REPS) - LFAR1F05
    (REPS) - LFAR1IDX
    (REPS) - RFITEMAP
    (REPS) - RFITEMAR
    (REPS) - RFITEMGL
    (REPS) - RFITEM_DEF
    (REPS) - RFITEM_INC
    (REPS) - SAPDBDDF
    (REPS) - SAPDBKDF
    (REPS) - SAPDBSDF

    Solution instructions


    Please import the corrections attached to this OSS note into your SAP system using SNOTE.

    You can also view the full details of this OSS note and download it to your SAP system ready for implementation using transaction code SNOTE. Once it has been downloaded you can read the full details, check out any installation instructions including manual changes and see if there are any pre-requisites.

    You can also check if a new version of note 596865 has been released as well as see if the note is valid for your current SAP system landscape.

    Check if SAP OSS note 596865 has already been downloaded and is valid


    To check if this note has already been download, what status it has and if it is valid for your system first execute t-code SNOTE and click on the SAP Note Browser icon
    Icon used to execute SAP Note Browser report within SNOTE

    From here you can just enter the note number 596865 and press execute. If the note already exists it's details will be displayed. See here for full step by step instructions on how to check if an SAP note has been downloaded and is valid for your system.



    If note 596865 does not exist on your system you will receive the message "Unable to find SAP Note that meets specified criteria"
    Icon used to execute SAP Note Browser report within SNOTE

    If this is the case you will need to download the note to you SAP system also using transaction SNOTE. For further details see Download note using SNOTE. Even if it does exist you may still want to check if you have downloaded the latest version of the note.

    Alternatively you can find full details of this note on the SAP service market place(SNumber / Service market place login will be required)