LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Can't figure out nested IF bracketing

    Employee
    Posted 11-13-2015 12:13

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Martholomule

    I have a pretty long block of IF's, but I can only get my conditions to fire up until I get to nesting. I have some conditions that don't use the nesting, and if I put those first then they will all fire up until the nested part. I'm sure it's something wrong with my bracket work but I just can't figure out what the problem is. Any insights?

    
    SERVICE = 
    
    if toUpper(substr('1:db_PON',(len(trim('1:db_PON'))-3),3)) <> "FIX" then 
    	{ #open FIX	
    		if strFind('1:db_IDNUMBER', "XXX") >= 0 then 
    			{
    			"THING1"
    			}
    		else if (substr('1:db_PON',4,1) == "V" or substr('1:db_PON',4,1) == "R" or substr('1:db_PON',4,1) == "A") then
    			{ #open subFIX
    			if substr('1:db_PON',4,1) == "V" then 
    				{
    				"THING2"
    				}
    			else if substr('1:db_PON',4,1) == "R" then 
    				{
    				"THING3"
    				}
    			else if substr('1:db_PON',4,1) == "A" then 	 
    				{
    				"THING4"
    				}
    			else if substr('1:db_PON',4,1) == "H" then 
    				{
    				"THING5"
    				}
    			else if '1:wa_SEGMENT' == "CONDITION1" and 
       			    ((substr('1:db_NC',1,1) == "X"
    			   or substr('1:db_PON',4,1) == "L"
    			   or substr('1:db_PON',4,1) == "N"
    			   or substr('1:db_PON',4,1) == "P"
    			   or substr('1:db_PON',4,1) == "T"
    			   or substr('1:db_PON',4,1) == "W")
    			   or '1:db_NC' == "SB" 
    			   or '1:db_NC' == "SD") then 
    				{
    				"THING6"        
    				}
    			 } #close subFIX	
    	} #close FIX
    
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "HC" then "THING7"
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "HF" then "THING8"
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "OG" then "THING9"
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "OF" then "THING10"
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "OD" then "THING11"
    else if '1:wa_SEGMENT' == "CONDITION1" and ('1:db_NC' == "OB" or '1:db_NC' == "JJ") then "THING12"
    else if '1:wa_SEGMENT' == "CONDITION1" and ('1:db_NC'.substr(1) == "K" or '1:db_NC'.substr(1) == "V") then 
    
    	{
    
    	if '1:db_REQTYPE' == "SD" and '1:db_SEI' == "Y" then 
    
    	{
    	"THING13"
    	}
    	
    	 else if '1:db_REQTYPE' == "SD" and '1:db_SEI'.isNull() then 
    
    	{
    	"THING14"
    	}
    
    	else if '1:db_REQTYPE' == "ED" then 
    	
    	{
    	"THING15"
    	}
    
    	else if '1:db_PON'.substr(4,1) == "V" then 
    
    	{
    	"THING16"
    	}
    	
    	else 
    
    	{
    	"THING17"
    	}
    	
    	}
    	 
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "O" then 
    	
    	{
    	"THING18"
    	}
    	
    else if '1:wa_SEGMENT' == "CONDITION1" and ('1:db_NC' == "H-" or '1:db_NC' == "O-") then 
    
    	{
    	"THING19"
    	}
    	
    else if '1:wa_SEGMENT' == "CONDITION2" then 
    
    	{
    
    	if '1:db_NC' == "HC" then 
    
    	{
    	"THING20"
    	}
    				 
    	else if '1:db_NC' == "HF" then 
    
    	{
    	"THING21"
    	}
    
    	else if '1:db_NC' == "OG" then 
    
    	
    	{
    	"THING22"
    	}
    	else if '1:db_NC' == "OF" then 
    	
    	{
    	"THING23"
    	}
    	
    	else if '1:db_NC' == "OD" then 
    
    	{
    	"THING24"
    	}
    
    	else if ('1:db_NC' == "OB" or '1:db_NC' == "JJ") then 
    	
    	{
    	"THING25"
    	}
    
    	else if substr('1:db_SVC_TYPE_CODE',1,1) == "V" then 
    
    	{
    	"THING26"
    	}
    
    	else if '1:db_SVC_TYPE_CODE' == "KF" then 
    
    	{
    	"THING27"
    	}
    	
    	else if '1:db_SVC_TYPE_CODE' == "KG" then 
    
    	{
    	"THING28"
    	}
    	}
    			  
    emit *, SERVICE


  • 2.  RE: Can't figure out nested IF bracketing

    Employee
    Posted 11-13-2015 15:36

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    Could you specify which portion doesn't work outside of the nest? Maybe give a simpler/reduced version of what you're trying to do?


  • 3.  RE: Can't figure out nested IF bracketing

    Employee
    Posted 12-18-2015 07:18

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: mgajdosik

    Your code simplified actually works fine, i think it is the logic that you need alteration for. I have simplified it to this level... Maybe if you can provide some pseudocode behind on defining what you actually want to achieve:

    SERVICE = 
    
    if toUpper(substr('1:db_PON',(len(trim('1:db_PON'))-3),3)) <> "FIX" then { #open FIX	
    	if strFind('1:db_IDNUMBER', "XXX") >= 0 then "THING1"	
    	else if (substr('1:db_PON',4,1) == "V" or substr('1:db_PON',4,1) == "R" or substr('1:db_PON',4,1) == "A") then { #open subFIX
    		if substr('1:db_PON',4,1) == "V" then "THING2"
    		else if substr('1:db_PON',4,1) == "R" then "THING3"
    		else if substr('1:db_PON',4,1) == "A" then "THING4"
    		else if substr('1:db_PON',4,1) == "H" then "THING5"				
    		else if '1:wa_SEGMENT' == "CONDITION1" and 
       			    ((substr('1:db_NC',1,1) == "X"
    			   or substr('1:db_PON',4,1) == "L"
    			   or substr('1:db_PON',4,1) == "N"
    			   or substr('1:db_PON',4,1) == "P"
    			   or substr('1:db_PON',4,1) == "T"
    			   or substr('1:db_PON',4,1) == "W")
    			   or '1:db_NC' == "SB" 
    			   or '1:db_NC' == "SD") then "THING6"        
    				
    	} #close subFIX	
    } #close FIX
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "HC" then "THING7"
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "HF" then "THING8"
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "OG" then "THING9"
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "OF" then "THING10"
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "OD" then "THING11"
    else if '1:wa_SEGMENT' == "CONDITION1" and ('1:db_NC' == "OB" or '1:db_NC' == "JJ") then "THING12"
    else if '1:wa_SEGMENT' == "CONDITION1" and ('1:db_NC'.substr(1) == "K" or '1:db_NC'.substr(1) == "V") then {
    	if '1:db_REQTYPE' == "SD" and '1:db_SEI' == "Y" then "THING13"
    	else if '1:db_REQTYPE' == "SD" and '1:db_SEI'.isNull() then "THING14"
    	else if '1:db_REQTYPE' == "ED" then "THING15"
    	else if '1:db_PON'.substr(4,1) == "V" then "THING16"
    	else "THING17"	
    } 
    else if '1:wa_SEGMENT' == "CONDITION1" and '1:db_NC' == "O" then "THING18"
    else if '1:wa_SEGMENT' == "CONDITION1" and ('1:db_NC' == "H-" or '1:db_NC' == "O-") then "THING19"
    else if '1:wa_SEGMENT' == "CONDITION2" then {
    	if '1:db_NC' == "HC" then "THING20"
    	else if '1:db_NC' == "HF" then "THING21"
    	else if '1:db_NC' == "OG" then "THING22"
    	else if '1:db_NC' == "OF" then "THING23"
    	else if '1:db_NC' == "OD" then "THING24"
    	else if ('1:db_NC' == "OB" or '1:db_NC' == "JJ") then "THING25"
    	else if substr('1:db_SVC_TYPE_CODE',1,1) == "V" then "THING26"
    	else if '1:db_SVC_TYPE_CODE' == "KF" then "THING27"	
    	else if '1:db_SVC_TYPE_CODE' == "KG" then "THING28"
    }
    			  
    emit *, SERVICE