on 07-08-2009 3:24 PM
Hi,
I have to map the source tdline field of IDOC segment E1EDPT1 to target IDOC Tdline field. Currently few tdline brings more than 31 chars but target should have only 31 and if it's more than 31 should roll over to next line.
I can able to truncate 31 chars using substring and if coneditions, but chars from 31 to rest couldnt be mapped, I tried a duplicate subtree in target and didnt work, used global variables to store the remainins but still didnt work.
Any suggestion would be greatly appreciated.
Thanks,
Menaga
Menaga,
Create a Context user defined function AddNode. Have one argument input. Add this code:
String str=input[0];
while(str.length()>31)
{
result.addValue(str.substring(0,31));
str=str.substring(31,str.length());
}
result.addValue(str);
So map tdline source --> udf(Addnode) --> tdline target
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks every one , below is my UDF
String str="";
str=var1[0];
while(str.length() >31);{
result.addValue(str.substring(0,30));
str=str.substring(30);
}
result.addValue(str);
mapping
Source tdline -> remove context->udf->target tdline
I get this below exception
untime exception when processing target-field mapping /ORDERSEX/IDOC/E1EDKT1/E1EDKT2/TDLINE; root message: Exception:[java.lang.StringIndexOutOfBoundsException: String index out of range: 30] in class com.sap.xi.tf._MM_ACSI_ORDER_ method Tdlinesplit[[Ljava.lang.String;@2a96d411, com.sap.aii.mappingtool.tf7.rt.ResultListImpl@143cbdef,
Thanks,
Menaga
Hi Menaga,
Your udf should be context only because we are passing as an array in the line String str=input[0];.
Also please dont the substring number. I see you changed from 31 to 30. It should be the same as I have given. I just tested and it is working for me.
If you want to change to 30 change everywhere to 30 in the udf.
Regards,
---Satish
Hi Sathish,
Thanks for your response, I found and did the change already and UDF is working what I want but now the problem is it just only picks up the first line in the context / array and doest loop through the rest.
How the mapping should be?
I have it as
E1EDPT1(source) - UDF - E1EDPT1(target)
Tdline(Source) - Remove context - UDF -Split by value change - tdline target.
Thanks,
Menaga
Hi Amir,
Tdline is 0-1 , I have tried my mapping like this
TDLINE- UDF - E1EDKT2
TDLINE - UDF - TDLINE
it results with 2 E1EDKT2 segment in the target with one first 31 chars string in tdline nad second one blank, in the queue I could able to see 2 lines of text , first one with 31 and next one with the remaining
all other lines where truncated in the target ...
I tried
E1EDKT2 - UDF E1EDKT2
TDLINE - UDF - TDLINE
E1EDKT2 source has 6 lines with few lines more than 31 chars
target provides 2 E1EDKT2 segment with one segment TDLINE present and next one doesnt have.
Thanks
Menaga
Hi Amir,
UDF for string manipulateion
String str="";
str=var1[0];
while(str.length() >31){
result.addValue(str.substring(0,31));
str=str.substring(31, str.length());
}
result.addValue(str);
I have 6 lines of E1EDKT2 with soem more than 31 mapping to target E1EDKT2.
input value as argument and using Execution type "All values of context".
Thanks,
Menaga
Menaga,
You should map like this:
For the segment E1EDPT2:
TDLINE(change the context to E1EDP01) ---> udf --> E1EDPT2
For TDLINE:
TDLINE --> removecontext --> udf --> splitbyvalue --> TDLINE.
Menaga, you should observe one thing. You started your question or thread with E1EDPT2 and now you are using E1EDKT2. These are two different segments. One is in header and one is detail. So please make sure you are doing what you want. I am giving my logic for Item level.
Regards,
---Satish
Menaga,
Create a udf with name addnode and Queue as cache. Have one parameter as input:
Imports: java.;*
Add this code:
for (int i=0; i<input.length; i++)
{
String str=input<i>;
while(str.length()>31)
{
result.addValue(str.substring(0,31));
str=str.substring(31,str.length());
}
result.addValue(str);
}
Now map like this:
For e1edkt2:
tdline(change context to idoc) --> addnode udf --> e1edkt2
For tdline:
tdline --> removecontext --> addnode --> splitbyvalue --> tdline
Regards,
---Satish
Hi Menaga,
fF the field does not support a length greater than 31, you can duplicate the segment(not the element) the times you need to send all the source content, but for that you need to talk to the responsible persons at the backend side.
Other solution, Is truncates it using substring standard function.
I hope this helps you.
Thanks
Ivan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
YOu can use a Java UDF (Chose Context radio button while creating the UDF)
The logic should be something like
for(int i =0;i<str.length();i++)
{
if ( i%31 == 0)
{
v_str = str+i(31);
addResult(v_str);
}
}
Regards,
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
According to my understanding , if the text is more than 31 char it should display in 2 lines right ! ..
So try using UDF , and you can solve it .
Regards,
B.Jude
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey
In a standard IDOC,TDLINE occurs 0-1 so you cant put your logic just there,did you write a UDF to create multiple E1EDPT2 and then populate TDLINE?
Thanks
Aamir
Edited by: Aamir Suhail on Jul 8, 2009 9:38 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
You can Go with a Simple mapping logic..
Use if then ESLE Function:
If Length is greater than 31 Then tdline--> Substring of (0 to 31) and to target
Else Directly map tdline to Target
Regards,
Sainath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.