Open navigation

Period handling using an SAP program

Modified on Tue, 28 May at 5:33 PM

Info: Please note we are not SAP specialists. The examples given are from our SAP environment, but yours might differ. If you have any questions relating to your SAP environment, please contact your SAP Support Team.

This article shows how to use an SAP program to open and close FI periods. 

Note that Aico has its own basic period handling function, but we are seeing the use of the RFPERIOD_OPEN and REPERIOD_CLOSE SAP programs as a more commonly used approach to period handling.



What is the SAP "Posting period variant"?


This article will start by explaining the SAP concept of a "Posting period variant" to help you understand SAP terminology.  

Normally, we associate the term "variant" with a stored set of parameters for a program. However, for period handling, SAP uses an additional concept of a Posting period variant which can be thought of as an ordinary program parameter.

A “Posting period variant” specifies which posting periods are opened or closed for each company code.

Note: One posting period variant can be assigned to one or more company codes and the posting periods are then opened or closed simultaneously for all company codes linked to that posting period variant. It is not an uncommon set-up to configure a unique posting period variant for each company code but this is a customer decision set up in SAP.

This can become confusing because when we set up the SAP program through Aico to automate period opening and closing we also use the normal "variant" concept to set all the program parameters including the posting period variant. 

In addition, in SAP, the REPERIOD_OPEN and RFPERIOD_CLOSE programs refer to a Company Code variant which is the same as the Posting period variant.

Setting up a posting period variant in SAP

To set up a new posting period variant, follow the steps below, using SAP T-code OBBP.

In our example below, the Posting period variant "1000" is used by many company codes including Company code 1000.

It could be that the posting period variant is shared between all company codes in a country or region.

Note that, in SAP, you can assign a posting period variant at a ledger level. This means there could be a posting period variant for the leading ledger, and a separate posting period variant for the local ledger in a company code. This underscores the importance of understanding how the posting period is set up in your SAP before you are able to automate this in Aico. 

Once you understand the relationship between a company code and posting period variant in your SAP, we recommend you set this up as an Automation manager Company Code attribute. 

This step is not necessary if you have a very simple set-up, such as one posting period variant for all companies, as this can be set directly in the Task template (see step 5 in the Creating the task template in Aico section below). You can also use this approach if the posting period variant is shared by assigning it only to one of the companies that uses the shared posting period. You then set up the Task to only be run from Aico for that one company and this will open the period for all company codes using that posting period variant.

Info: There is no way to get around the posting period variant concept. Aico cannot open only one of the companies that uses a shared posting period variant. You are limited to your own SAP set-up in this area.

To set this up as an Automation manager Company Code attribute, do the following:

1 Go to System settings

2. Expand the Company attribute names field

3. Select an available attribute and name it Posting period variant. You could use two attributes if you have different local and leading posting period variants.

4. Save

Now you will need to set your posting period variant against each company code in Automation manager. 

Go to Automation manager:

Click Manage

1. Choose Companies and open the company for which you want to set the posting period variant. In the details view (2) you will see the Attributes including the one you just named above (3). Set the variant there.

Note: It is common to use the company code as the posting period variant (as we have in our demo system) but you must look up the posting period variant used in your own SAP system for each company code as it can be shared.

Next, we need to set up the program in SAP itself in preparation for calling it from Aico. This is where we need to save a traditional variant.

In SAP, go to T-Code SE38.

In the program dialog set RFPERIOD_OPEN (or RFPERIOD_CLOSE) and execute.

Set the base program parameters (including a posting period variant) for a single company and fiscal year/period combination and save these in a program variant (such as AICORFOPEN or AICORFCLOSE) that we can then call from Aico. 

Warning! Remember many of these parameters will be overridden using smart tags in Aico.

1. Once your parameters are set then save these in a program variant.

2. This is the Posting period variant.

3. Note the account type values as we will set these directly in the Automation manager task.

Creating the task template in Aico

Create the task template in Aico using the SAP transaction or program task type.

Go to Automation manager -> New -> Task template.

1. Set a Name etc. in the normal way and select the SAP program task type.

2. Enter the program name 

3. Enter the variant name that you saved in SAP


Set the program parameters using smart tags as appropriate.

4. Set the account type depending on which ledger you are opening/closing. The suggestion here is to set this directly in the task template to override the SAP variant default value rather than setting up many different SAP variants. You can also set a CSV list of values here, for example, "+,S,A" would open All account types, G/L Accounts and Assets.

5. The Company code variant is, in fact, the posting period variant which will now appear in the smart tags list based on the company attribute name you gave it, described above. This will then change the posting period variant based on the attribute you gave to each company, when the task is generated for that company code. 

Note: If you have a simpler posting period variant set up then you can simply enter a value in this parameter instead of a smart tag.

Time Frame 1 is for the normal periods 1-12.

Time Frame 2 is for the special periods 13-16.

The From and To Fiscal Year and Period parameters need some thought depending on what you are trying to open/close. You will use a combination of standard smart tags and formulas to achieve the desired results.

The example explains how you would open the next period whilst still keeping the current period open, which would be the most common set-up in SAP during month-end closing which you might run on Workday -4. If we are running this task as part of our 2022-04 closing then this task will open 2022-05 but also leave open 2022-04. You would then have another task to close 2022-04 which you might run around Workday +5.

Warning! Think through carefully the Period 12 opening and closing tasks as these will take you into the next fiscal year and formulas are needed to cater for these as explained below.

6. In the From Fiscal Year box we set our smart tag as Period Year. This will then set the year of the period we want to affect as the from year. Remember we are keeping open the current period as well as opening the next period which is why the From Fiscal Year (in this example) is Period Year.

7. In the To Fiscal Year box, we use a formula as we are going to be opening the next period and if we are in Period 12 then the fiscal year will be next year as we are opening Period 1. For example, in 2022-12, we are opening 2023-01.
The smart tag formula used here is = IF ( {periodNumber} = 12, {nextPeriodYear}, {periodYear})

8. In the From Period we are setting the Period number which will set the period number from the period we are closing. This is correct in that this task is opening the next period whist also leaving the current period open.

9. In the To Period box, we are setting the Next Period Number smart tag. This smart tag was introduced in 22.1 and understands that the period after 12 is again Period 1. Note you must use the actual numbers 13-16 if you are setting Timeframe 2. If you are on a version earlier than 22.1 then you must use a formula instead of the Next Period Number smart tag. = IF ( {periodNumber} = 12,1, ( {periodNumber} +1))

Connect the task to either purpose-built schedule groups or , if you have a lot of different dates/times you want to run these tasks, then simply set a custom schedule on each task.

Tip: Remember the earlier advice is that posting period variants can be shared between company codes and you only need to run the task for ONE of the company codes that has the posting period variant.This will then open/close the period for ALL other company codes sharing that posting period variant.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article