on 02-18-2009 4:46 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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
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.
> 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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raghu,
Hope the below works in your scenario.
E1EDP01segment ->Index(std function)->TargetField.
Regards,
Swetha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raghu,
the name of the standard function is counter
Regards,
Udo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use "Count" standard XI function for the source segement.
Regards,
Naresh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.