cancel
Showing results for 
Search instead for 
Did you mean: 

How to write a macro to read one CVC's KF value & assign to all other CVCs in the selection?

Former Member
0 Kudos

Hi APO Gurus,

I am looking for a macro to read one CVC's key figure value and assign to rest of all CVCs in the selection as shown below. Any Idea how todo it? This is going to be within SNP time series key figure. And I need to run this in background job and not interactively. The original value is going to be always at ZFAMX22 CVC. 

Before running the macro all the CVCs and key figure value for one CVC ZFAMX22.

NAAPO ProductUnitM 06/2012M 07/2012M 08/2012
NTDMTotalUNT200040001000
NTDMA912340UNT
NTDMA912350UNT
NTDMA912360UNT
NTDMA912370UNT
NTDMZFAMX22UNT200040001000

After running the macro values should be copied to all CVCs

NAAPO ProductUnitM 06/2012M 07/2012M 08/2012
NTDMTotalUNT10000200005000
NTDMA912340UNT200040001000
NTDMA912350UNT200040001000
NTDMA912360UNT200040001000
NTDMA912370UNT200040001000
NTDMZFAMX22UNT200040001000

Thanks and appreciate your time.

Raj

Accepted Solutions (1)

Accepted Solutions (1)

rajkj
Active Contributor
0 Kudos

Raj,

Try using SUM_CALC macro function.  The following pseudo code might work for both interactive and background execution.

Step 1:  1 iteration - Initialize a variable

IF ( LAYOUTVAR_VALUE( 'VAR1' ) = 0 )

     LAYOUTVARIABLE_SET( 'VAR1' ; 1 )

ELSE

    LAYOUTVARIABLE_SET( 'VAR1' ; EVAL( LAYOUTVAR_VALUE( 'VAR1' ) + 1 ) )

ENDIF

Step 2: 1... n iterations

NTDM = EVAL( SUM_CALC( NTDM ) / LAYOUTVAR_VALUE( 'VAR1' )

Thanks,

Rajesh

Former Member
0 Kudos

Hi Rajesh,

Thanks for the helpful information. Yes, your suggestion also should work if it is only one node of hierarchy. I have multiple nodes means many families SKUs and related child SKUs. For my purpose I have used TS_SET and TS_GET macro functions and able to populate required key figure values to required SKUs. This part is done.

However when I use TS_SET to save all ZFAM* CVCs key figure values system is going to save these to a TS DB table /SAPAPO/ADV_SERI as shown below. Few questions on this table:

1. For each CVC I save data using TS_SET it saving as two records. The EXT 001 & 002. The values are only in EXT 001. What is EXT and how 002 being used?

3. What are these 3 parameters we are passing TS_SET & GET: KEY1, KEY2, KEY3 where I am using A, B, C values. What is the purpose these values?

2. Is there any report to manage (delete or purge) when no more required or in case of increased number of CVCs are saved?

Thanks and appreciate your time.

Raj

rajkj
Active Contributor
0 Kudos

Hi Raj,

TS_SET and TS_GET are functions for creating and accessing database time series (different from classical time series key figures) similar to those used in phase in/out, weighting, and trend-dampening profiles as well as time series for MLR variables.

Since the entries do not depend on the CVC values, there might be chances of inappropriate data read if concurrent use is allowed in interactive planning.

1. EXT denotes the iteration or update counter. Somehow, TS_SET was being executed twice in your case. First time with proper CVC and hence, the key figure values were copied correctly.

2. KEY1, KEY2, and KEY3 allow you to distinguish your entry and easy retrieval using TS_GET

3. In the corresponding function modules, I could see delete statement. Probably, your ABAP expert could explain better on deleting the records.

FM: /SAPAPO/TS_SET

      /SAPAPO/TS_GET

Thanks,
Rajesh

Answers (0)