Skip to Content
avatar image
Former Member

Posting hard coded member value in target model using script logic

Hello, Experts, I have a requirement to copy data from one model to another model with in the same environment, while copying I need to pass the hard coded value like Company code as 'CC_UNASSGINED' if the source odel doesn't have any value for company code.

I am copying properties data from source to dimensions in destination model.We are in BPC NW 10.0

Any Ideas?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    Aug 03, 2017 at 04:40 PM

    The correct code with RUNLOGIC_PH:

    //Clear data in target for CATEGORY=$DEST_CAT$
    *START_BADI RUNLOGIC_PH
    QUERY=OFF 
    WRITE=ON
    APPSET=ENABLE //It's better to remove this line - then current environment will be used
    APP=PROJECTREPORTING
    LOGIC=CLEAR.LGF //will clear data in PROJECTREPORTING for the scope below
    //CLEAR.LGF text:
    //*WHEN CATEGORY
    //*IS *
    //*REC(EXPRESSION=0)
    //*ENDWHEN
    DIMENSION ACCCLASS=<ALL>
    DIMENSION ANALYST=<ALL> 
    DIMENSION COCODE=<ALL>
    DIMENSION COMMAREA=<ALL>
    DIMENSION EXPTYPE=<ALL>
    DIMENSION PROJTYPE=<ALL>
    DIMENSION RESPCC=<ALL>
    DIMENSION PROJMGR=<ALL>
    DIMENSION CATEGORY = $DEST_CAT$
    *END_BADI
    
    //Copy data to target based on PROJECT properties
    *XDIM_MEMBERSET CATEGORY = $DEST_CAT$ 
    *DESTINATION_APP = PROJECTREPORTING
    *ADD_DIM ACCCLASS = PROJECT:ACCCLASS
    *ADD_DIM ANALYST = PROJECT:ANALYST
    *ADD_DIM COCODE = PROJECT:COCODE
    *ADD_DIM COMMAREA = PROJECT:COMMAREA
    *ADD_DIM EXPTYPE = PROJECT:EXPTYPE
    *ADD_DIM PROJTYPE = PROJECT:PROJTYPE
    *ADD_DIM RESPCC = PROJECT:RESPCC
    *ADD_DIM PROJMGR = PROJECT:PROJMGR
    
    *WHEN CATEGORY
    *IS *
    *REC(EXPRESSION=%VALUE%)
    *ENDWHEN
    

    Please read RUNLOGIC_PH documentation:

    https://www.sap.com/documents/2015/08/de470383-547c-0010-82c7-eda71af511fa.html

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 27, 2017 at 02:38 PM

    With ADD_DIM with property you have to use 2 WHEN/ENDWHEN loops:

    *SELECT(%WITHCOCODE%,ID,PROJECT,"[COCODE]<>''")
    *SELECT(%WITHOUTCOCODE%,ID,PROJECT,"[COCODE]=''")
    *XDIM_MEMBERSET CATEGORY = $DEST_CAT$
    
    *XDIM_MEMBERSET PROJECT = %WITHCOCODE%
    
    *DESTINATION_APP =PROJECTREPORTING
    *ADD_DIM COCODE = PROJECT:COCODE //for projects with something in COCODE
    
    *WHEN CATEGORY
    *IS *
    *REC(EXPRESSION=%VALUE%)
    *ENDWHEN 
    
    *XDIM_MEMBERSET PROJECT = %WITHOUTCOCODE%
    
    *DESTINATION_APP =PROJECTREPORTING
    *ADD_DIM COCODE = UN_ASSGINED //for projects with empty COCODE
    
    *WHEN CATEGORY
    *IS *
    *REC(EXPRESSION=%VALUE%)
    *ENDWHEN 

    It's possible to use single loop if you can implement RENAME_DIM, but not sure about your case.

    P.S. I also removed a lot of useless statements from your code.

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 27, 2017 at 05:18 AM

    Sorry but absolutely not clear what do you want to achieve! Please show detailed examples.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 27, 2017 at 02:11 PM

    Hi Vadim, I have an input model with some dimensions and many properties for one of the dimension, for the reporting purpose we are moving these properties data into reporting model, all these properties we have created as dimensions in the reporting model.

    Ex:- I have a dimension 'Project' in input model and 'Company code' as a property to that, in the reporting model my dimensions are 'Project' and 'Company code', I am copying data from input model to Reporting model and loading 'Company code' property data to Company code dimension in reporting model, but we have some blank values coming for 'Company code', since it is a dimension in reporting model my data copy is failing, I would like to pass hard coded value 'CC_UNASSGINED' when there is a blank value for 'Company code' property coming from Input model.

    *SELECT(%CC%,COCODE,PROJECT,"[COCODE]=''")

    *XDIM_MEMBERSET CATEGORY = $DEST_CAT$

    *DESTINATION_APP =PROJECTREPORTING

    *ADD_DIM COCODE = PROJECT:COCODE

    *WHEN CATEGORY

    *IS $DEST_CAT$

    *WHEN PROJECT.COCODE

    *IS %CC%

    *REC(EXPRESSION=%VALUE%,CATEGORY=$DEST_CAT$,COCODE='UN_ASSGINED')

    *ENDWHEN

    The error I am getting as Unknown Dimension Name in Keyword:"COCODE:

    Looks like the error at line *REC( and it is not recognizing COCODE Dimension in reporting model, even I tried with PROJECT:COCODE and PROJECT.COCODE but same error.

    Hope this is clear, thank you for your help.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 27, 2017 at 03:59 PM

    Hi, Vadim, thank you for the logic and cleaning the code, I tried this but this time I am getting error Member "UN_ASSGINED" not exist.

    Thank you.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 03, 2017 at 06:37 PM

    Thank you Vadim, this is working perfectly.

    Add comment
    10|10000 characters needed characters exceeded