cancel
Showing results for 
Search instead for 
Did you mean: 

Adding same fields from different segments

Former Member
0 Kudos

Hi everybody!

This is my first post in this forum, and as i could see you're very helpful with many SAP XI topics.

I've a iDoc to file scenario,

My question is the next one:

I would like to add the same field in the different segments that an iDoc could be sent, lets suppose that this is an example of an incoming idoc:

IDOC

|

|------ZPAGOS_CAB

|----


MyField

|------ZPAGOS_CAB

|----


MyField

|------ZPAGOS_CAB

|----


MyField

I would like to sum all the "MyField" instances that come in the different segments, the segments are always the same ones and the field too.

Any suggest?

Thanx in advance.

John

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member182004
Contributor
0 Kudos

Ok, thanx, i'll try making an udf and i'll tell you what happened.

Regards,

John

Former Member
0 Kudos

If I undestand well the structure of the segment of IDoc should be:

ZPAGOS_CAB 0..unbounded (or 1..unbounded)

MyField 1..1

For your problem I suggest you to use a user defined function as this one:

type of function: context

public String concatenateString(String field[], ResultList result){

String resultTmp = new String();

// We concatenate all the value of the field

for (int i = 0; i < field.length; i ++){

resultTmp = resultTmp + field[ i ];

}

result.addValue(resultTmp);

}

Note: you have to use as input "MyField" and set the context one level up context respect to the default choice. (right click of the mouse --> context)

nisarkhan_n
Active Contributor
0 Kudos

Does you want to add all the value of Myfield adn then send to target :

for this you need to write an UDF to add the values

or

You want to create the different segemtn at target for each value of Myfield:

Use the SPLIBYVALUE function in the MM

Myfield->SPLITBYVALUE->taget

correct me if i am wrong

Former Member
0 Kudos

Cho,

Use the standard airthmetic funciton Add (for the first two fields) and the result you once again to the third field. So concatenating two adds should solve your issue.

Regards,

---Satish