cancel
Showing results for 
Search instead for 
Did you mean: 

mapping problem in idoc

Former Member
0 Kudos

Hi

I had a source segment E1EDP20 (0---99 occurences), i need to pass a constant value to target field poitem.

the requirement is

on every occurence of E1EDP20, the constant value should be incremented by 1 and that constant should be passed to target field poitem.

Ex- on first occurence of E1EDP20 the constant value should be 1.

on second occurence of E1EDP20 the constant value should be 2.

on third occurence of E1EDP20 the constant value should be 3.

like this as long as on E1EDP20 occurs the constant value should be incremented by 1.

the constant should be passed to targetfield poitem.

pls suggest what is the logic should i write for the above requirement.

regards

raghu

Accepted Solutions (1)

Accepted Solutions (1)

former_member181955
Contributor
0 Kudos

Hi

You can check it UDF also.

For example if you have the following structure try this UDF.

Source:

E1EDP20(1)

E1EDP20(2)

E1EDP20(3)

Target:

<Item>

<poitem/>

</item>

Mapping:

E1EDP20 ---> item (Context one level high)

E1EDP20 >UDF->poitem (Context is root)

UDF:(Type Context)

String str =null;

for(int i=0;i<=a.length;i)

{

str = Integer.toString(i);

result.addValue(str);

}

Hope it may help you.

Former Member
0 Kudos

Hi Prasad

i tried your udf,but it is throwing exception error.

is it possible to do with graphical mapping.

my requirement is

on every occurence of E1EDP20, the constant value should be incremented by 1 and that constant should be passed to target field poitem.where poitem is a field under segment E1BPEMPOSCHEDULE (0--99999 occurence)

Ex- on first occurence of E1EDP20 the constant value should be 1.

on second occurence of E1EDP20 the constant value should be 2.

on third occurence of E1EDP20 the constant value should be 3.

like this as long as on E1EDP20 occurs the constant value should be incremented by 1.

the constant should be passed to targetfield poitem.

pls suggest what is the logic should i write for the above requirement.

regards

raghu

Edited by: raghu y on Feb 19, 2009 10:19 AM

former_member181955
Contributor
0 Kudos

Hi

Please the same UDF with nodefunction SplitByValue(EachValue).

E1EDP20 --- > E1BPEMPOSCHEDULE

E1EDP20 -


>UDF->SplitByalue->poitem

Thanks

Prasad Nemalikanti

Former Member
0 Kudos

Hi prasad

Your udf is working fine as per the changes u suggest.

I am getting output value as

1 for 1st occurence of E1EDP20

2 for 2nd occurence of E1EDP20

but i require output as

0001 for 1st occurence of E1EDP20.

0002 for 2nd occurence of E1EDP20

.

.

.

0031 for 31st occurence of E1EDP20.

how could i achieve this,though i change i value to 0001 in udf, it is giving output as 1,2,3 as on

but i require as 0001,0002,.....,0031,.....

regards

raghu

former_member181955
Contributor
0 Kudos

Hi

Is the length of the constant is 4 characters ?. I meean the expected constant

0001,0010,0999 is 4 in the lenght.

If it is so use the following UDF.It may require small changes in the loop.

String str =null;

for(int i=1;i<=a.length;i++)

{

str = Integer.toString(i);

if(i>=1 && i<=9)

str = "000".concat(str);

else if(i>=10 && i<=99)

str ="00".concat(str);

else

str = "0".concat(str);

result.addValue(str);

}

Thanks

Prasad Nemalikanti

Former Member
0 Kudos

If your requirement is to make the string length to 4 padding with 0's before, then try the below udf.

public static String Pad(String input, String padChar, int iLength, String sPadDir) {

StringBuffer strBuf = new StringBuffer(input);

String sTemp = "";

int iInputLen = input.length();

if (iInputLen >= iLength)

return input;

if (sPadDir.length() != 0) {

if (sPadDir.equalsIgnoreCase("right")) {

for (int j = 0; j < iLength - iInputLen; j++) {

sTemp = strBuf.append(padChar).toString();

}

} else if (sPadDir.equalsIgnoreCase("left")) {

for (int h = 0; h < iLength - iInputLen; h++) {

sTemp = strBuf.insert(h, padChar).toString();

}

} else {

sTemp = "Pad Direction Incorrect";

}

} else {

sTemp = "Pad Direction Does not exist";

}

return sTemp;

}

constant value->UDF->Target

If you use the above UDF, you would get the output as 0xxx if your input is xxx,00xx for xx input,000x for x input.

Regards,

Swetha.

Former Member
0 Kudos

> but i require as 0001,0002,.....,0031,.....

Since your UDF is giving result as 1, 2, 3..... therefore to achieve the desired result just use the standard function FormatNum just after your udf. eg.

E1EDP20 -


> UDF -


> FormatNum (enter 0000 in the upper box) -


> Poitem.

By this way you dont have to use another udf just for formating.

Regards,

Sarvesh

Former Member
0 Kudos

Hi prasad

my problem is solved with your udf.

regards

raghu

Answers (6)

Answers (6)

Former Member
0 Kudos

To ensure that you have prefixed leading "0", Indeed you need to arrange this in a UDF.

I thought you needed a function which enables you to only give details when the E1EDP20 segments was filled. and the number in the target field would be equal to the E1EDP20 "counter".

So my solution describes the following

seg 1 has E1EDP20 so dyn conf --> 1

seg 2 has E1EDP20 so dyn conf appends and write --> 2

seg 3..10 don't have a E1EDP02 dyn conf appends but no target is written

seg 11 has E1EDP20 so dyn conf requests the created value --> 11

in this case you have 3 output fields with entries 1, 2, 11

If this is not the thing you want then don't use the Dynamic Configuration implementation

greets

And if i'm not mistaking, there is a standard function in the message mapper which arranges the prefixes.

Edited by: Patrick Pot on Feb 19, 2009 2:35 PM

Former Member
0 Kudos

Raghu,

If this is the case then you shoud it different,

Create a UDF which fills a key in the dynamic configuration. Within each loop the number is increased.

But whenever you have the E1EDP20 filled do the dynamicConfiguration.get

you retrieve the value of the given key and include that into the field.

If you need a Code Snipplet let me know ok.

Greets

Former Member
0 Kudos

Hi,

if the provided solutions don't work there is a workaround.

if you use the "ifExist" on the E1EDP20 on beforehand. Then when the result is true use the "add" function to add 1 to the existing number.

so IF (E1EDP20 Exitst)

then

counter = counter + 1;

greets

Former Member
0 Kudos

Hi Raghu,

Hope the below works in your scenario.

E1EDP01segment ->Index(std function)->TargetField.

Regards,

Swetha.

Former Member
0 Kudos

Hi,

We can use the count in the stastic functions.Give the input as E1EDP20. and output to the value to be mapped.It will return the value of no of times this node exist.

Is there any other condition for the occurrence of E1EDP20.

if yes, provide the details

Thanks,

Tiny

udo_martens
Active Contributor
0 Kudos

Hi Raghu,

the name of the standard function is counter

Regards,

Udo

Former Member
0 Kudos

Hi marten

Thanks for your reply, can you pls suggest how should i write the condition using counter

on first occurence of E1EDP01 the constant should be1

on second occurence of E1EDP01 the constant should be2.

how should i start the loop.

regards

raghu

Former Member
0 Kudos

Use "Count" standard XI function for the source segement.

Regards,

Naresh