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

Relations (Else If) in Repeat Region

SOLVED
Level 12

Relations (Else If) in Repeat Region

Hello,

I am able to set relations in repeat region as below:

if asm_mbr_name == "PRT0001"

CAD_SAP_PLM_IDX = "1000"

else

CAD_SAP_PLM_IDX = RPT_INDEX

endif

I would like to understand how to use else if into relation. My scenario is as below:

  • CAD_SAP_PLM_IDX = "1000" for "PRT0001"
  • CAD_SAP_PLM_IDX = "1001" for "PRT0002"
  • CAD_SAP_PLM_IDX = rpt.index for rest all parts

Thank you in advance.

Regards

Ketan

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Relations (Else If) in Repeat Region

Remember that for every "if" you need and an "endif" at the end.

I have a word doc that I can cut and paste as needed (a sample of that file):

IF asm_mbr_pn == "9594"

NEWQTY = "0.5"

ELSE

IF asm_mbr_pn == "9556"

NEWQTY = "0.5"

ELSE

IF asm_mbr_pn == "9151"

NEWQTY = "0.5"

ELSE

ENDIF

ENDIF

ENDIF

5 REPLIES 5

Re: Relations (Else If) in Repeat Region

By stacking up all the ifs. Each if statement has to end with an endif.

if asm_mbr_name == "PRT0001"

CAD_SAP_PLM_IDX = "1000"

else

if asm_mbr_name == "PRT0002"

CAD_SAP_PLM_IDX = "1001"

else

if asm_mbr_name == "PRT0003"

CAD_SAP_PLM_IDX = "1002"

else

CAD_SAP_PLM_IDX = RPT_INDEX

endif

endif

endif

Re: Relations (Else If) in Repeat Region

Remember that for every "if" you need and an "endif" at the end.

I have a word doc that I can cut and paste as needed (a sample of that file):

IF asm_mbr_pn == "9594"

NEWQTY = "0.5"

ELSE

IF asm_mbr_pn == "9556"

NEWQTY = "0.5"

ELSE

IF asm_mbr_pn == "9151"

NEWQTY = "0.5"

ELSE

ENDIF

ENDIF

ENDIF

Re: Relations (Else If) in Repeat Region

To summarize, there is no built in "ELSE IF" in Creo. You can get the same effect by using "ELSE", then another "IF", then another "ELSE" and so on, but deeply nested "IF" and "ELSE" statements can get tough to follow.

For repeat region relations I prefer to set the default value and then check for the other conditions. (The last one set "wins".)

CAD_SAP_PLM_IDX = RPT_INDEX

IF ASM_MBR_NAME == "PRT0001"

CAD_SAP_PLM_IDX = "1000"

ENDIF

IF ASM_MBR_NAME == "PRT0002"

CAD_SAP_PLM_IDX = "1001"

ENDIF

Re: Relations (Else If) in Repeat Region

For those of us who have trouble keeping track of our if statements, it's really helpful to indent the statements:

if asm_mbr_name == "PRT0001"

CAD_SAP_PLM_IDX = "1000"

else

if asm_mbr_name == "PRT0002"

CAD_SAP_PLM_IDX = "1001"

else

if asm_mbr_name == "PRT0003"

CAD_SAP_PLM_IDX = "1002"

else

CAD_SAP_PLM_IDX = RPT_INDEX

endif

endif

endif

Then it's easy to see if you're missing an "endif", and which "else" goes with which "if". Just remember that Creo doesn't care about whitespace (spaces and tabs), so if you were to write:

if asm_mbr_name == "PRT0001"

CAD_SAP_PLM_IDX = "1000"

else

if asm_mbr_name == "PRT0002"

CAD_SAP_PLM_IDX = "1001"

endif

Creo thinks the "endif" goes with the last "if", not the first "if". When things go wrong in a nested if statement, it's often because we get confused about where we are when writing the statements. Indenting the code helps to get your thinking straight.

Re: Relations (Else If) in Repeat Region

Thank you all for help.