cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

script-get property of dm package prompt

sap_user62
Active Participant
0 Kudos
148

Hello Friends,

Env-10.1 on hana.

I have a requirement to move data from one material to another (around 100 materials)

The destination material already has data posted to it. So I need to append the data of source material to the destination without overwriting it and clear the data posted at the source.

Material dimension has a "new_mtrl_code" property which will identify the destination material. For convenience "new_mtrl_code" of destination is the same as the ID.

I plan to pass the materials in a DM package prompt, which would be read by the script.

created a test script

*XDIM_MEMBERSET CATEGORY = %CATEGORY_SET%

*XDIM_MEMBERSET MATERIAL= %MATERIAL_SET%

*SELECT(%NewMATERIAL%,"[NEW_MTRL_CODE]",MATERIAL,"[ID]=%MATERIAL_SET%")

*XDIM_ADDMEMBERSET MATERIAL= %NewMATERIAL%

*WHEN CATEGORY

*IS %CATEGORY_SET%

*REC(EXPRESSION = %VALUE%, MATERIAL= MATERIAL.NEW_MTRL_CODE) *ENDWHEN

*XDIM_MEMBERSET CATEGORY = %CATEGORY_SET% *

*XDIM_MEMBERSET MATERIAL= %MATERIAL_SET%

*WHEN MATERIAL *IS %MATERIAL_SET%

*REC(EXPRESSION = 0)

*ENDWHEN

Tested the script in UJKT, it worked well for one material, however I am not able to pass multiple materials in the data region of ujkt, it keeps throwing an error

UJA_ADMIN_ERROR:Invalid attribute name (XXXX) in dimension (Material). However I can pass multiple categories with a comma. Is it a limitation for user defined dimensions?

if I have to run this script for multiple materials, does it need a for loop or this logic will take care.

Thanks for your time

Ed.

Accepted Solutions (1)

Accepted Solutions (1)

former_member186338
Active Contributor
0 Kudos

Next time, please format your code with a code button, now it's close to unreadable!

The code:

*LOOKUP SameModelName
*DIM NEWMAT:MATERIAL=MATERIAL.NEW_MTRL_CODE //corrected
*ENDLOOKUP

*XDIM_MEMBERSET CATEGORY = %CATEGORY_SET%
*XDIM_MEMBERSET MATERIAL= %MATERIAL_SET%

*WHEN CATEGORY
*IS *
*REC(EXPRESSION = %VALUE%+LOOKUP(NEWMAT), MATERIAL= MATERIAL.NEW_MTRL_CODE)
*REC(EXPRESSION = 0) 
*ENDWHEN

you don't need to maintain same code for new materials...

Answers (1)

Answers (1)

sap_user62
Active Participant
0 Kudos
Thanks Vadim for your reply. I will make sure I will format the code (did not know notice the button)
I have updated the second line and it works well
*DIM NEWMAT:Material=Material.NEW_MTRL_CODE

when I ran your code in UJKT, i was able to pass multiple materials in the prompt using commas, my code above threw errors inUJKT as well as a regular DM package. It did not accept multiple materials to be passed with commas. 
I was looking into this note, 2587285 - Script logic Error "Invalid attribute name() in dimension()"
former_member186338
Active Contributor
0 Kudos

Yes, it was typo error: correct - *DIM NEWMAT:Material=Material.NEW_MTRL_CODE

If my code is working - please accept the correct answer.