Skip to Content
avatar image
Former Member

Problem with mapping under conditions

Hi experts,

I am designing idoc to jdbc scenario and i am having trouble setting up a mapping rule :

my source is as follow:

IDOC

>E1EDKA1 0..99

>>PARVW

>>NAME1

>E1EDP01 0..9999

>>Z1E1EDP01 0..99

>>>ERNAM

>>E1EDPA1 0..8

>>>PARVW

>>>NAME1

my target is simple : i create as many statement as i have E1EDP01

statement 0..99

>access

>>creator

I have many cases to cover, and i cant manage to cover them all, even with UDF:

there are 4 cases :

1) if PARVW from E1EDKA1 = ZY or ZX then if PARVW from E1EDPA1=ZX or ZY then i have to map NAME1 from E1EDPA1 to creator.

2) if PARVW from E1EDKA1 = ZY or ZX then (if PARVW from E1EDPA1 not equals to ZX or ZY) OR if E1EDPA1 does not exist then i have to map NAME1 from E1EDKA1 to creator.

3) if PARVW from E1EDKA1 not equals to ZY or ZX then if PARVW from E1EDPA1=ZX or ZY then i have to map NAME1 from E1EDPA1 to creator.

4) if PARVW from E1EDKA1 not equals to ZY or ZX then (if PARVW from E1EDPA1 not equals to ZX or ZY) OR if E1EDPA1 does not exist then i have to map ERNAM from Z1E1EDP01 to creator.

To be clearer, here is an example :

IDOC

>E1EDKA1

>>PARVW = AS

>>NAME1 = TOTO

>E1EDKA1

>>PARVW = ZY

>>NAME1 = TETE

>E1EDP01

>>Z1E1EDP01

>>>ERNAM = ERNAM1

>>E1EDPA1

>>>PARVW = AS

>>>NAME1 = TITI

>>E1EDPA1

>>>PARVW = ZY

>>>NAME1 = TATA

>E1EDP01

>>Z1E1EDP01

>>>ERNAM = ERNAM2

>>E1EDPA1

>>>PARVW = HY

>>>NAME1 = TUTU

>>E1EDPA1

>>>PARVW = ZX

>>>NAME1 = TYTY

in this case, as result i should get 2 statements with these values :

statement

>access

>>creator = TATA

statement

>access

>>creator = TYTY

second example : i dont have PARVW = ZY or ZX in the second E1EDP01

IDOC

>E1EDKA1

>>PARVW = AS

>>NAME1 = TOTO

>E1EDKA1

>>PARVW = ZY

>>NAME1 = TETE

>E1EDP01

>>Z1E1EDP01

>>>ERNAM = ERNAM1

>>E1EDPA1

>>>PARVW = AS

>>>NAME1 = TITI

>>E1EDPA1

>>>PARVW = ZY

>>>NAME1 = TATA

>E1EDP01

>>Z1E1EDP01

>>>ERNAM = ERNAM2

>>E1EDPA1

>>>PARVW = HY

>>>NAME1 = TUTU

in this case, as result i should get 2 statements with these values :

statement

>access

>>creator = TATA

statement

>access

>>creator = TETE (from NAME1 of E1EDKA1)

third example : i dont have PARVW = ZY or ZX in E1EDKA1 and E1EDPA1 does not exist in my second E1EDP01:

IDOC

>E1EDKA1

>>PARVW = AS

>>NAME1 = TOTO

>E1EDKA1

>>PARVW = ZC

>>NAME1 = TETE

>E1EDP01

>>Z1E1EDP01

>>>ERNAM = ERNAM1

>>E1EDPA1

>>>PARVW = AS

>>>NAME1 = TITI

>>E1EDPA1

>>>PARVW = ZY

>>>NAME1 = TATA

>E1EDP01

>>Z1E1EDP01

>>>ERNAM = ERNAM2

in this case, as result i should get 2 statements with these values :

statement

>access

>>creator = TATA

statement

>access

>>creator = ERNAM2

my UDF works fine for the first case, but as soon as i try another one, it wont work :

	public static void test(String[] PARVW_E1EDKA1,String[] PARVW_E1EDP01,String[] NAME1_E1EDKA1,String[] NAME1_E1EDP01,String[] ERNAM_Z1E1EDP01,ResultList result,Container container){
		 
		int i = 0;
		int j = 0;
		int k = 0;
		boolean found1 = false;
		boolean found2 = false;
		
		for (; i < PARVW_E1EDKA1.length ; i++) 
		{
			if (("ZY".equals(PARVW_E1EDKA1<i>.trim())) || ("ZX".equals(PARVW_E1EDKA1<i>.trim()) ) )
				{
					found1 = true;
		            break;
		        }
		 }
		 
		if ( found1 )
		{
			for (; j < PARVW_E1EDP01.length ; j++) 
			{
				if (("ZY".equals(PARVW_E1EDP01[j].trim())) || ("ZX".equals(PARVW_E1EDP01[j].trim()) ) )
					{
						found2 = true;
			            break;
			        }
			 }
			if ( found2 )
			{
			  result.addValue(NAME1_E1EDP01[j]);
			}
			else
			{
			  result.addValue(NAME1_E1EDKA1<i>);
			}
		}
		else
		{
			for (; k < PARVW_E1EDP01.length ; k++) 
			{
				if (("ZY".equals(PARVW_E1EDP01[k].trim())) || ("ZX".equals(PARVW_E1EDP01[k].trim()) ) )
					{
						found2 = true;
			            break;
			        }
			 }
			if ( found2 )
			{
			  result.addValue(NAME1_E1EDP01[k]);
			}
			else
			{
			  result.addValue(ERNAM_Z1E1EDP01[k]);
			}
		}
		
	}

hope i ve been clear enough,

any help would be greatly appreciated and rewarded

Kind regards,

Jamal

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 29, 2008 at 06:18 PM
    	result.addValue(NAME1_E1EDP01[j]);
    			}
    			else
    			{
    			  result.addValue(NAME1_E1EDKA1<i>);

    Do you need to use j here instead of i in the above code.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 29, 2008 at 06:56 PM

    Hi Jamal

    Try with this

    public static void test(String[] PARVW_E1EDKA1,String[] PARVW_E1EDP01,String[] NAME1_E1EDKA1,String[] NAME1_E1EDP01,String[] ERNAM_Z1E1EDP01,ResultList result,Container container){
    		 
    		int i = 0;
    		int j = 0;
    		int k = 0;
    		boolean found1 = false;
    		boolean found2 = false;
    		
    		for (; i < PARVW_E1EDKA1.length ; i++) 
    		{
    			if (("ZY".equals(PARVW_E1EDKA1<i>.trim())) || ("ZX".equals(PARVW_E1EDKA1<i>.trim()) ) )
    				{
    					found1 = true;
    		            break;
    		        }
    
    
    			if ( found1 )
    			{
    				for (; j < PARVW_E1EDP01.length ; j++) 
    				{
    					if (("ZY".equals(PARVW_E1EDP01[j].trim())) || ("ZX".equals(PARVW_E1EDP01[j].trim()) ) )
    					{
    						found2 = true;
    			            		break;
    			        	}
    			 	}
    
    				if ( found2 )
    				{
    			  		result.addValue(NAME1_E1EDP01[j]);
    				}
    
    				else
    				{
    			  		result.addValue(NAME1_E1EDKA1<i>);
    				}
    			}
    		
    			else
    			{
    				for (; k < PARVW_E1EDP01.length ; k++) 
    				{
    					if (("ZY".equals(PARVW_E1EDP01[k].trim())) || ("ZX".equals(PARVW_E1EDP01[k].trim()) ) )
    					{
    						found2 = true;
    			            		break;
    			        	}
    			 	}
    				
    				if ( found2 )
    				{
    			  		result.addValue(NAME1_E1EDP01[k]);
    				}
    				else
    				{
    			  		result.addValue(ERNAM_Z1E1EDP01[k]);
    				}
    			}
    		
    
    		 }
    		 
    		
    		
    	}

    Thanks

    Gaurav

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 29, 2008 at 07:17 PM

    Thx for replies,

    Anand, I've put i because I want the value of NAME1 for PARVW = ZY or ZX of E1EDKA1.

    Gaurav, I cant see where is the changes in the UDF you gave me?

    Thanx,

    kind regards

    Jamal

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Jamal

      I made changes that the complete logic is inside first for loop. i is not alive once you left the loop and you are using it in found2 else.

      Thanks

      Gaurav