cancel
Showing results for 
Search instead for 
Did you mean: 

Copy Reference material into plan cube using FOX formula

Anand71
Active Contributor
0 Kudos

Hello Gurus,

Please can any one give idea how to solve the following scenario. I have tired all options and lost.

I have plan cube and reference cube. In Plan cube I have 0material and key_figure and in reference cube I have Omaterial and Zmaterial, Key_figure. My requirement is I want to copy all 0Material which is present in reference cube in plan cube with reference to the Zmaterial.I have to loop through the reference cube and copy 0Material in plan cube and take corresponding Zmaterial and search this Zmaterial in plan cube and copy the keyfigure (Which present in Plan cube) of Zmaterial into Omaterial in plan cube.

Here is the explanation.



Plan Cube
Omaterial     Key_Figure
1                   10
2                   50
3                   40

Reference cube
Omaterial    Zmaterial        Key_Figire
15               2                  1
16               1                  1
17               2                  1

Final Plan cube should look like 

Plan Cube
Omaterial     Key_Figure
1                   10
2                   50
3                   40
15                  50
16                  10
17                  50


Hope I have explain clearly.

Thanks.

With regards,

Anand Kumar

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try this.

suppose fields to changed are{KF,0MATERIAL,ZMATERIAL,0INFOPROVIDER}


DATA LV_ZMAT TYPE ZMATERIAL.
DATA LV_MAT   TYPE 0MATERIAL.
DATA LV_T_MAT TYPE 0MATERIAL.
DATA DUMMY TYPE F.


****---- THIS IS A SIMPLE DUMMY LINE TO GET THE FOX GET REFRENCE DATA FROM REF CUBE
DUMMY = {Key_Figure,#,#,REF_CUBE}

****---- LOOP OVER THE MATERIALS EXISTS IN REFERENCE DATA
FOREACH LV_MAT,LV_ZMAT IN REFDATA.

****-----CHECK IF A RECORD ALREADY EXISTS IN PLAN CUBE IF NOT THEN CREATE IT WITH THE VALUE FROM PLAN CUBE
   IF {Key_Figure,LV_MAT,#,PLAN_CUBE} = 0.

****---- LOOK HOW KV_ZMAT AND LV_MAT EXCHANGED IN EACH SIDE OF THE EQUIVELANCE
          LV_T_MAT = LV_ZMAT.
         {Key_Figure,LV_MAT,#,PLAN_CUBE}  =  {Key_Figure,LV_T_MAT,#,PLAN_CUBE}.

   ENDIF.

ENDFOR.

Regards,

Eitan.

Anand71
Active Contributor
0 Kudos

Thanks Eitan.

Answers (0)