cancel
Showing results for 
Search instead for 
Did you mean: 

Coding in Update Rules

i807185
Associate
Associate
0 Kudos

Hello,

I have a customer who does forecasting in APO. Every Month the customer does a rolling forecast for the following 12 months.

Example:

In 04/06: Planning for 05/06 -05/07

In 05/06: Planning for 06/06 - 06/07

etc

I want to <b>store these monthly Planning Versions in a Cube</b> in BW.

I have created a <b>Characteristic ZVERSION</b> and at <b>the end of a month when the forecasting data are loaded from APO</b> <b>I would like to fill this Characteristic with the Year and Month for the Version information</b>or just the Month information:

e.g.

The 04/06 Version of the Planning Data (containing 05/06 -05/07) should be stored as "200604"

The 05/06 Version of the Planning Data (containing 06/06 - 06/07) should be stored as "200605"

<b>What would the coding in the update rules of ZVERSION look like???</b>

Thanks a lot

Christian

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

We do something similar. If you can figure out what the version is based on the dates in the data, what the others have suggested will be fine.

But if you need to assign the version, you could maintain

the master data for for ZVERSION. Then in your update rule, you read the master data to get the value from it.

It's Saturday evening here, but I'll post the code Monday when I get back in the office. I actually have a start routine that reads the master data record into an internal table, then the update rule reads the internal table. An internal table is held in memory, so rather than running a separate SQL query for each record in the request, you just read the internal table which is faster.

Former Member
0 Kudos

Here's the code - some for the Start Routine and an Update Rule. I have simplified this a bit from what we use as we have some validation checks on the Version number. This assumes only one active record in the master data table. You would need to add additional criteria to the WHERE clause in the SELECT if you have multiple records in the table and only want to read a one record.

  • The Global Declarations

TABLES: /BIC/MZVERSION.

DATA: G_ZBUD_VERS(3) TYPE C.

-


  • Start Routine

  • This reads Budget Version from the Master Data table

  • ZVERSION and loads it to memory, so we only need to

  • read the database one time, instead of once per

  • transaction.

select single /BIC/ZBUD_VERS from /BIC/MZVERSION

into (G_ZBUD_VERS)

where OBJVERS = 'A'.

  • If a record is not found, abort the load.

if sy-subrc = 0.

ABORT = 0.

else.

ABORT = 1.

exit.

endif.

-


  • Update Rule

RESULT = G_ZBUD_VERS.

Former Member
0 Kudos

Hi Christian,

If the loading of the forecast from APO to BW is always done at the end of the month, then you can code the update rules so that for ZVERSION it stores the 0calmonth of the current server date/time. You can do this using a formula or abap rountine. The formula for this DATE_MONTH(Current Date) which was already given above in another post. Note that "Current Date" can be chosen from the list of fields in the left half of the formula editor. The field name is SYST-DATUM.

You can also code the following abap routine:

  • result value of the routine

RESULT = sy-datum+0(6). "gets YYYYMM from current date.

  • if the returncode is not equal zero, the result will not be updated

RETURNCODE = 0.

  • if abort is not equal zero, the update process will be canceled

ABORT = 0.

Former Member
0 Kudos

Hello Christian,

Are you always going to store current year and moth in the characteristic zversion? What I mean to say is it possible that you are loading vesion 04/06 data in any othwr month that 04, 2006?

If you want to store current year and month, then in the update rule create a new formula and inside that write this

DATE_MONTH( Current Date )

This will store current year and month (in YYYYMM format) when data is being loaded.

Hope it help.

Regards,

Praveen