Data archiving: Financial documents

This blog will explain how to archive financial documents via object FI_DOCUMNT. Generic technical setup must have been executed already, and is explained in this blog.

Object FI_DOCUMNT

Go to transaction SARA and select object FI_DOCUMNT.

Dependency schedule:

No dependencies.

Main tables that are archived:

  • BKPF (accounting document header)
  • BSAD (accounting document secondary index for customers)
  • BSAK (accounting document secondary index for vendors)
  • BSAS (accounting document secondary index for GL accounts cleared items)
  • BSEG / RFBLG (cluster for accounting document)

Technical programs and OSS notes

Write program: FI_DOCUMNT_WRI

Delete program: FI_DOCUMNT_DEL

Post processing program: FI_DOCUMNT_PST

Read program: read program in SARA refers to FAGL_ACCOUNT_ITEMS_GL. This program you can use with online data and archive files as data source

Reloading of FI_DOCUMNT was supported in the past, but not any more: 2072407 – FI_DOCUMNT: Reloading of archived data.

Relevant OSS notes:

Application specific customizing

In the application specific customizing for FI_DOCUMNT you can maintain the document retention time settings:

Executing the write run and delete run

In transaction SARA, FI_DOCUMNT select the write run:

Select your data, save the variant and start the archiving write run.

Give the archive session a good name that describes the company code and year. This is needed for data retrieval later on.

After the write run is done, check the logs. FI_DOCUMNT archiving has average speed, and high percentage of archiving (up to 90 to 99%). Most of the items that cannot be archived is about open items.

Deletion run is standard by selecting the archive file and starting the deletion run.

Post processing

It is important to run the post processing of FI_DOCUMNT. After the archiving BSAK, BSAS and BSIS secondary table records are still present with the field ARCHIV marked with ‘X’. See notes 2683107 – Archived items still exist in BSAK and 2775018 – Archived items still exist in BSAK.

Standard SAP will deal correctly with this field. But custom made reports and the average BI data analyst will not.

So run post processing directly after the deletion run.

Data retrieval

For FI_DOCUMNT multiple read programs are available. To select them press the F4 search:

Start the program and select the button Data Source, tick the archive as well and select the archive files to read:

Due to data volume the query might run long. Select the archive files with care.

Most finance programs to list data use this Data Source principle.

SARI infostructure issues

If you get issues for sessions which are in error in SARI for infostructure SAP_FI_DOC_002, read the below potential work around.

The reason we see the errors for the archive session when we attempt to refill is that there are a number of documents that already exist in the infostructures, and there cannot be duplicates in the infostructure table.

The most common cause is that the variant for the WRITE program was set so the same document got archived twice into different archive files.

What can be done? If it is OK to have the same document in different files, you can ignore the archive session entries with error in SARI if the case is as above. To avoid having duplicate keys in the infostructure in future, you can add the filename as an extra key field to the infostructure. This can be done as follows:

  • SARI -> Customizing -> SAP_FI_DOC_002 -> Display
  • Technical data
  • Change the field “File Name Processing” from ‘D’ to ‘K’.

This is untested method.

Parallel processing

There is an option to archive Financial documents in parallel processing mode. This is an advanced development option. It uses archiving object FI_DOC_PPA. For more information read OSS note 1779727 – FI_DOCUMNT: Integrating parallel process with archiving.

If your data volume is manageable and you can archive during nights and weekends, keep it simple and use FI_DOCUMNT.

DST daylight saving time

3277061 – ABAP Date/Time Conversion with DST for SELECT_MESSAGES

DST (daylight saving time) starts in the spring (= a loss of one hour) and ends in the fall (= a gain of one hour ). For clock adjustment, one must remember “Spring forward, Fall back”.

Spring forward:

Fall backward:

Method 1: shut down the system

During the switch, simply shutdown the SAP system, for the entire duration of the double hour, and bring it up only after the double hour has passed. Thus, the SAP Kernel software does not have to deal with any possible mismatch of standard time and local time. The big setback off course is that you have work shutting down and starting up the systems in the middle of the night. And the business cannot work during this time. Long running weekend jobs might be interrupted as well and need to be redone.

Method 2: zero downtime by slowing down the time

Slow down the time by half, during the double hour, so that the 2 hour period is treated as one hour.

In SAP, executing this is easier than it appears by setting the parameter zdate/DSTswitch_contloctime = on which is default in the latest kernel release 6.40 and higher, so that you can make your SAP system see a continuous time with a deviation of 30 minutes.

During the conversion from summer time to winter time, there is a “doubled” hour.  In Europe, for example, the summer time is reset to winter time on the last Sunday in October between 2 a.m. and 3 a.m.

1:00    1:30    2:00    2:30    2:00    2:30    3:00 official time

–+——+—–x+xxxxx+xxxxxx+xxxxxx+xxxxxx+x—

How to check the time zone at different levels

  • Run the report from SA38: TZCUSTHELP (trouble shooting time zone)
  • Run the report from SA38: RSDBTIME (time diagnosis)
  • Run this function module in SE37: TZ_SYSTEM_GET_TZONE
  • Run this report fromSA38: TZONECHECK 

DST in non-ABAP systems

For DST in non-ABAP systems check these notes:

References

Excellent blog from SAP: Daylight Saving Time and Slowing Down The Time.

Reference OSS notes:

ABAP programming DST specific notes:

SAP profile parameters

This blog will give tips and tricks for SAP profile parameters.

List of all profile parameters

Program RSPARAM will list all profile parameters:

The system default, the user defined value and the description is listed.

Program RSPFPAR can be used for a selective set of parameters.

Explanation note: 3202666 – The RSPARAM report usage.

Changing profile parameters

Transactions RZ10 and RZ11 can be used to change the profile parameters. If lost after restart, check OSS note 2228845 – RZ10: New or changed value is not active after restart.

Check also OSS note 2789094 – Maintaining ASCS profiles using RZ10.

Checking history of profile parameters

Transaction TU02 will list the profile parameter changes:

A different way to check the history is using SAP Focused Run configuration validation. Read more on this feature in this blog.

Technical tables and routines

Table TPFET contains the current parameters.

Table PAHI is keeping the history of parameter changes (if not updated, read note 3205243 – PAHI Table data is not updated).

RFC enabled function module TH_GET_PARAMETER can be used to read a profile parameter value.

Period end shift

The finance module works with periods. Mostly this is a calendar month, but it can also be a period of 4 or 5 weeks.

In a productive system the business Finance team will take care of month end closing and opening of new financial period.

In a sandbox or development system this might not be done. As a result logistical postings might fail with a message that the financial period must be opened.

Initialization of financial periods: MMPI

To initialize the periods in a newly installed system, start transaction MMPI:

Only run in newly installed systems!

Background and warning notes:

Period shift: MMPV

The shift the period with one month, start transaction MMPV:

MMPV relevant OSS notes:

Test slow network speed for FIORI and web developments

If you are working with users across the globe you will be faced with performance complaints for your FIORI apps and web developments.

To analyze these user complaints you need to throttle you network speed so it is behaving like a far way computer:

  • Lower bandwidth
  • Higher ping response times

The applications you develop close to the server on fast network can become very sluggish when used by distant users. It is your job as developer to analyze this issues and to improve your design to have less roundtrips.

Network throttling in Chrome

The full details of Chrome network throttling can be found here.

Short instruction:

  1. Open the developer tools with F12 and go to the Network settings

2. Select the No throttling and create a new profile:

3. Now select your profile:

Enjoy the new end user experience. Don’t forget to switch back to your normal speed!

Network performance tips & tricks

One of the most irritating and annoying things in the basis area is when the network gives issues. For whatever reason.

This blog will give hints and tips on how to recognize network issues and options to analyze them.

SAP notes on network performance

Main OSS note is: 1100926 – FAQ: Network performance.

Main SAP wiki on network performance can be found via this link.

Detailed analysis notes:

Specific issues with application to database server issues:

Check if database is the issue, or network:

Network issues on Azure:

LAN check

Check by ST06: start the LAN check by Ping:

Or directly via transaction OS01:

SAP GUI network issues

If the user is far away from the server, network issues can be cause of slow transactions for the end user.

SAP GUI slow connection can be set on creation of GUI entry, or by right clicking on the GUI entry and then selecting the network option:

FIORI and web developments

FIORI tiles and web developments might be slow with users further away from the server. If the application has many round trips built in the increase network latency will definitely kill the end user performance.

Read more in this blog on how you can simulate a distant user in Chrome to analyze the issue.

ODATA V4 activation

This blog will explain how to activate ODATA V4.

Questions that will be answered in this blog are:

  • How to activate ODATA V4 on your SAP system?
  • Does SAP support ODATA V3?
  • Do all consuming applications support ODATA V4?
  • What are the differences of ODATA V2 and V4?

ODATA V4

In the typical FIORI use case you will activate ODATA V2. SAP has skipped ODATA V3. ODATA V4 is supported by SAP.

Constraints of SAP ODATA V4 are listed in OSS note 2322624 – SAP Gateway SAP_GWFND OData V4 protocol – Known Constraints.

Filtering is powerful in ODATA V4. Read more on this in OSS note 2305033 – SAP Gateway OData V4 $flter Consulting Note.

Keep in mind not all application fully support all aspects of ODATA V4 or might not be able to consume ODATA V4 at all. Check first with the consumer before publishing an ODATA on V4.

Activation of ODATA V4

First step in activation is to check the virus scan settings for ODATA:

Activation of ODATA V4 messages via service administration:

Or use transaction /iwbep/v4_admin:

And for the front end /iwfnd/v4_admin:

Press button Add service groups:

Push the button Get Service Groups:

And select your entry and press Publish Service Groups:

Which one to publish has to be told to you. The consultant requesting it might link to the API hub.

After activation, you can use the Service Test button to check if the activation is ok:

On the screen hit Execute and the result should be a HTTP 200 success message:

OSS notes and background

Background notes:

Bug fix OSS notes:

Useful background blogs:

Differences between ODATA V2 and V4

For UI consumption differences between ODATA V2 and V4 read this SAP help file.

Generic blog on main differences ODATA V2 and V4: read here.

Or read this SAP blog on differences ODATA V2 and V4 for SAP specific.

Deleting SAP office documents

In your system the amount of SAP office documents is consuming more and more space. You want to clean up these tables: BCST_CAM, BCST_SR, SOC3, SOFFCONT1, SOFM, SOOD, SOOS, SOST. This blog will explain how.

Questions that will be answered are:

  • How to reduce size of tables BCST_CAM, BCST_SR, SOC3, SOFFCONT1, SOFM, SOOD, SOOS, SOST?
  • How to run the clean up programs before running RSBCS_REORG?
  • How to run program RSBCS_REORG?

SAP office documents to content server

If table SOFFCONT1 is growing fast, you can migrate data to the content server. This might be the easiest solution. Read more in this blog.

See also note 1634908 – Reduce the number of entries of table SOFFCONT1.

See OSS note 3225275 – BC-SRV-COM Guided Answer for the guided Q&A.

Preparations before running RSBCS_REORG

SAP office documents are stored in table SOFFCONT1, and can be deleted with program RSBCS_REORG. See note 966854 – Reorganization – new report. Note 988057 – Reorganization – information contained in the past a very useful PDF document that explains what to do in cases that RSBCS_REORG is not directly can delete an SAP office document. This was removed, but you can download it here:

In most cases you have to run a special program that breaks the link between the document and the data. After that is done you can delete the content. Extra explanation is in OSS note 1641830 – Reorganization of Business Communication Services data (RSBCS_REORG).

Set expiration date

Run program RSBCS_SREQ_EXPIRE (see OSS note 1478279 – Deleting send requests that have not expired) to set the expiration date when needed:

This will remove the expiry dates.

Release the send requests

Run program RSBCS_SREQ_RELEASE (see OSS note 1238740 – Deleting unreleased send requests):

Don’t select too much data, otherwise the program will dump (see note 3033843 – Program RSBCS_SREQ_RELEASE failed with dump TSV_TNEW_PAGE_ALLOC_FAILED).

This will release the send requests for deletion.

But it will only do so if a document is attached. Apply OSS note 3256308 – Initial send requests are not released to get new program RSBCS_SREQ_INITIAL_RELEASE:

This will also release the send request for deletion in case there is no document attached.

Unlink document from application

Run program RSBCS_SREQ_UNLINK (see note 1276402 – Send requests cannot be deleted due to links) to unlink the the document from the object:

Document is in SAP connect queue

Documents might still be in the SAP connect queue. Use program RSBCS_DELETE_QUEUE (see OSS note 1244680 – Deleting send requests from the queue) to remove the queue for the documents:

Document is in a folder

If the document is in a folder it might be in different sort of folder:

  • Hidden folder
  • Private folder
  • Document has GOS link
Document is in a hidden folder

Run program RSSODFRE (see OSS note 567975 – Hidden folder: Reorganization) to delete documents from the hidden folders:

Document is in a private folder

Run program RSSO_DELETE_PRIVATE (see OSS note 922671 – Deleting folder entries) to delete from private folder:

Document has GOS link

To be able to delete document with GOS link, run program RSGOSRE01 (see OSS notes 569123 – Reorganizing documents from generic object services, 1641800 – How to delete ‘Has links to GOS/Document not sent’ documents from the Hidden folder and 2016688 – RSGOSRE01: New selection parameters):

Or run program RSGOSRE02 (OSS note 2031234 – RSGOSRE02: Reorganizing documents from generic object services):

Running RSBCS_REORG

Program RSBCS_REORG will not archive, but only delete.

Test this first and check with the data owner that the documents are no longer needed.

Program RSBCS_REORG selection criteria:

Output:

Double clicking on the line will show the details for the issue why you cannot delete.

Bug fix OSS notes for RSBCS_REORG:

ABAP to content server check

A content server can be used to store attachments and other documents. In some cases both the ABAP stack and content server are up and running, but the connection between the two is broken for some reason.

This blog will provide a check program which you can plan in a batch job to check the connection between the ABAP stack content repository and the the content server.

Questions that will be answered in this blog are:

  • How can I automate the content server check?
  • How can I be alerted if the connection between ABAP stack and content server is broken?

The OAC0 connection check

In transaction OAC0 for maintaining the content server link there is a check button:

We will use the function module SCMS_HTTP_PING which is behind this button for our custom code ABAP test program.

Custom code ABAP check program for testing the ABAP to content server connection

Load this ABAP code into your system and create the texts:

*&---------------------------------------------------------------------*
*& Report ZCSCHECK
*&---------------------------------------------------------------------*
REPORT ZCSCHECK.

DATA: z_ok TYPE boolean.
CONSTANTS: c_mesid      TYPE char3 VALUE 'ZZZ', "system log message ID defined in SE92
           c_zero       TYPE string VALUE '0 ',
           c_secirity_n TYPE c VALUE 'N',
           c_secirity_s TYPE c VALUE 'S'.
PARAMETERS p_crep TYPE scms_crep MATCHCODE OBJECT h_crep_http.

* initialize ok code
  z_ok = abap_true.

*Fetch http server details
  SELECT SINGLE crep_id, http_serv, http_port, http_sport, http_scrpt, version
         FROM   crep_http INTO @DATA(ls_crep)
         WHERE  crep_id = @p_crep.
  IF sy-subrc EQ 0.
    IF NOT ls_crep-http_port CO c_zero OR
            ls_crep-http_sport CO c_zero.
      CALL FUNCTION 'SCMS_HTTP_PING'
        EXPORTING
          crep_id    = ls_crep-crep_id
          http_serv  = ls_crep-http_serv
          http_port  = ls_crep-http_port
          http_sport = ls_crep-http_sport
          http_scrpt = ls_crep-http_scrpt
          version    = ls_crep-version
          security   = c_secirity_n"'N'
        EXCEPTIONS
          error_http = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
        z_ok = abap_false. "not ok
      ENDIF.
    ENDIF.
*Check Security with S
    IF z_ok <> abap_false AND NOT ls_crep-http_sport CO c_zero.
      CALL FUNCTION 'SCMS_HTTP_PING'
        EXPORTING
          crep_id    = ls_crep-crep_id
          http_serv  = ls_crep-http_serv
          http_port  = ls_crep-http_port
          http_sport = ls_crep-http_sport
          http_scrpt = ls_crep-http_scrpt
          version    = ls_crep-version
          security   = c_secirity_n"'S'
        EXCEPTIONS
          error_http = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
        z_ok = abap_false. "not ok
      ENDIF.
    ENDIF.

    IF z_ok = abap_false. "not ok
* write to SM21 system log
      WRITE: / TEXT-004. "ping not ok
      CALL FUNCTION 'RSLG_WRITE_SYSLOG_ENTRY'
        EXPORTING
          sl_message_area    = c_mesid(2)
          sl_message_subid   = c_mesid+2
          data_word1         = ls_crep-crep_id
        EXCEPTIONS
          data_missing       = 1
          data_words_problem = 2
          other_problem      = 3
          pre_params_problem = 4
          OTHERS             = 5.

      IF sy-subrc EQ 0.
        WRITE: / TEXT-001  , ls_crep-crep_id. "succes to write to SM21
      ELSE.
        WRITE: / TEXT-002  , ls_crep-crep_id. "fail to write to SM21
      ENDIF.
    ELSE.
      WRITE: / TEXT-003  ,  ls_crep-crep_id. "ping ok
    ENDIF.
  ELSE.
    WRITE: / TEXT-004  ,  ls_crep-crep_id. "Ping to webservice not ok
  ENDIF.

The program uses function module SCMS_HTTP_PING to test the connection. In case of issues it will write an entry to the application log. Use SE92 to create a new system log message. You can choose to replace this code by sending a mail or do anything else.

Running the check program

Running the program is simple:

If the connection fails it writes an entry to SM21.

In case you have multiple content repositories to check: create multiple variants and run the program in background with multiple steps.

Data archiving: CO Order data

This blog will explain how to archive CO Order data via object CO_ORDER. Generic technical setup must have been executed already, and is explained in this blog.

Object CO_ORDER

Go to transaction SARA and select object CO_ORDER.

Dependency schedule:

This means you must first archive relevant purchase requisitions, purchaser orders and financial documents relating to the CO order..

Tables that are archived:

Most important:

  • COEP: CO line items

Technical programs and OSS notes

Pre-processing program: RKOREO01

Write program: RKAARCWR

Delete program: RKAARCD1

Read program: RKAARCS1

Relevant OSS notes:

Application specific customizing

In the application specific customizing for CO_ORDER you have to set two retention periods per CO order type:

Residence time 1 determines the time interval (in calendar months) that must elapse between setting the delete flag (step 1) and setting the deletion indicator (step 2).

Residence time 2 determines the time (in calendar months) that must elapse between setting the deletion indicator (step 2) and reorganizing the object (step 3).

Executing the pre-processing run

The pre-processing run will set the deletion indicator for the CO Orders:

The output is a list of orders that are processed, and if not processed, the reason of blocking is written down.

Executing the write run and delete run

In transaction SARA, CO_ORDER select the write run:

Select your data, save the variant and start the archiving write run.

Give the archive session a good name that describes date range. This is needed for data retrieval later on.

After the write run is done, check the logs. CO_ORDER archiving has average speed, but high percentage of archiving (up to 100%). Reason is that all filtering and checking is already done by the pre-processing program.

Deletion run is standard by selecting the archive file and starting the deletion run.

Data retrieval

Start the data retrieval program and fill selection criteria:

Result is a list. From the list double click on the order. You can see the order now in normal GUI layout.