cancel
Showing results for 
Search instead for 
Did you mean: 

IDOC to File Mapping conditions

Former Member
0 Kudos

Hi,

Please helpme out to write an UDF here.

The line item in the IDOC segment called Z1DISPLY having 2 fields GROUPID and ITEMID

Here i need to maintain a mapping based on the following conditions

if the field ITEMID has a value X then add B infront of the value of GROUPID and map to target field.

if the field ITEMID has not a value X

Check if this value is the first one that appears in the list then map the value of GROUPID to the target field.

Also check If this value appears the second time in the list (without ITEMID= X) then add D in front of the value of GROUPID and map this to target field.

Thanks & Regards,

Y.Raj

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hello Yeshwantraj,

If I understood your problem properly here is a UDF that will do the whole thing for you.

public void myUDF(String[] ITEMID,String[] GROUPID,ResultList result,Container container){
	int i,j,flgtest;
// Consider both ITEMID and GROUPID exists same no of time.
// Then loop for all values of ITEMID
	for (i=0;i<ITEMID.length;i++){
// if the field ITEMID has a value X then add B infront of the value of GROUPID and map to target field.
			if (ITEMID<i>.equals("X"){
				result.addValue("B"+GROUPID<i>);
			}
			else{
				flgtst = 0;
// Test how many times ITEMID has existed earlier.
				for(j=0;j<i;j++){
					if (ITEMID<i>.equals(ITEMID[j]))
					{
						flgtst++
					}
				}
// Check if this value is the first one that appears in the list
// then map the value of GROUPID to the target field.
				if (flgtst == 0){
					result.addValue(GROUPID<i>);
				}
// Also check If this value appears the second time in the list (without ITEMID= X)
// then add D in front of the value of GROUPID and map this to target field.
				if (flgtst == 0){
					result.addValue("D"+GROUPID<i>);
				}
			}
		}

Let me know if this is working fine

Former Member
0 Kudos

Please give me the solutions ....as how can i do this above conditions..

Thanks for your valuable suggestions.

kind Regards,

Y.Raj