cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle the source text length exceed more than target text length size in Message mapping PI 7.31

Former Member
0 Kudos

I have a File to IDOC Message Mapping Scenario:

Source Field                         Targefield

Communiication Address-(Email ID)                                    E1EDK2 - TDLINE

Source Field length: 1/80                                                                               target Field length: Char\70

Mapping Condition:

Note: TDFORMAT =  ‘=’ (Long Line), may need to create 2 TDLINE fields depending on length of text

So give the Solution for handling text Length exceed than target field lenght Using TDLNE and TDFORMAT......

Guide me  and give Suggestions to achive this.

Accepted Solutions (1)

Accepted Solutions (1)

former_member192343
Active Contributor
0 Kudos

Hi,

in graphic mapping it is possible by duplicating TDLINE node in target structure. For first TDLINE item make condition: if email length < 70 map it to tdline directly, else substring first 70 characters and map it to first tdline item.

for second tdline item make condition, if email length > 70, substring all characters from 70 to end and map it to second tdline item.

and test result is

You can also use UDF for your task

Regards,

Mikhail

Former Member
0 Kudos

Hi Mikhail,

     Thanking you. I got the Exact Output. I raised the another Query like this  Only the Mapping Condition Differenciated. So help me to get.

Provide Example mappng Like this with Snaps.

Answers (2)

Answers (2)

naveen_chichili
Active Contributor
0 Kudos

Hi Jeevitha,

In your case if the length exceeds you need to have a condition that if length is > (value) pass partial information usiing substring to TDLINE.

and second half tothe next field using substring.

similar logic as Mikhail said but you need to have a substring.

Thanks and Regards,

Naveen

Former Member
0 Kudos

Thanking you. It s helpful answer for me.

former_member184789
Active Contributor
0 Kudos

Hi,

In our project we had a similar requirement, where we had to first concatenate all occurrences of source field into a single string & once the length increased 70, it should be populated in next occurrence of the target field. However, there should not be more than 5 occurrences of the target field & if total length increased 350 i.e 70*5, the remaining characters had to be ignored. Here is the UDF code:

    try

{

String St = "";

int div,rem = 0;

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

            {           

            St = St +var1[i];

            }

       

        div = St.length()/TextLength;

        rem = St.length()%TextLength;   

        int u = Math.min(div,NoOfText);   

        for(int j =0;j<u;j++)

        {   

result.addValue(St.substring(TextLength*j, TextLength*(j+1)));

        }

        if(rem !=0 && div<NoOfText)

        {

           

result.addValue(St.substring(St.length()-rem, St.length()));

        }

}

catch (StringIndexOutOfBoundsException e)

{

result.addSuppress();

}

The max length of each i.e 70 & max no of occurrences i.e 5 were provided as parameters as TextLength & NoOfText respectively.

Former Member
0 Kudos

Thanking you. It s helpful answer for me.

This is "  File to IDOC Senario  ".

I have Doubt on  this: ( In Message Mapping)

Source field : MSG

Length : 1/264

Taget field : E1EDKT2 - TDLINE

Legth : CHAR/70

Mapping Condition :

Note: TDFORMAT =  ‘=’ (Long Line), until next line of MSG. When new line occurs in MSG, then use TDFORMAT = ‘/’

How to Write UDF for this......?

How to Make the Mapping for this?

help me to get it Quickly.

give your Suggestions and Show some Example Mappings.......

Former Member
0 Kudos

Hi ,

Below is the generic sol for your problem .Graphical mappings wont workout for your problem while using sub string .


Input -->Input string

Length -->length of TDLINE

MESSAGE_V1,V2,V3,V4....depends on how many TDLINES you expect .Here I have taken 4 .

public void SplitbyLength(String[] Input, String[] Length, ResultList MESSAGE_V1, ResultList MESSAGE_V2, ResultList MESSAGE_V3, ResultList MESSAGE_V4, Container container) throws StreamTransformationException{

int lengthVal = Integer.parseInt(Length[0]);

int InpLenVal ;

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

{

InpLenVal  =Input[i].length() ;

if (InpLenVal<=lengthVal)

{

MESSAGE_V1.addValue(Input[i].substring(0));

MESSAGE_V2.addValue(ResultList.SUPPRESS);  

MESSAGE_V3.addValue(ResultList.SUPPRESS);  

MESSAGE_V4.addValue(ResultList.SUPPRESS);  

}

else if ((InpLenVal>lengthVal) && (InpLenVal <= (lengthVal*2)))

{

MESSAGE_V1.addValue(Input[i].substring(0,lengthVal));

MESSAGE_V2.addValue(Input[i].substring(lengthVal,InpLenVal));

MESSAGE_V3.addValue(ResultList.SUPPRESS);  

MESSAGE_V4.addValue(ResultList.SUPPRESS);  

}

else if ((InpLenVal>(lengthVal*2)) && (InpLenVal <= (lengthVal*3)))

{

MESSAGE_V1.addValue(Input[i].substring(0,lengthVal));

MESSAGE_V2.addValue(Input[i].substring(lengthVal,(lengthVal*2)));

MESSAGE_V3.addValue(Input[i].substring((lengthVal*2),InpLenVal));

MESSAGE_V4.addValue(ResultList.SUPPRESS);  

}

else if (Input[i].length()>(lengthVal*3)  && (InpLenVal <= (lengthVal*4)))

{

MESSAGE_V1.addValue(Input[i].substring(0,lengthVal));

MESSAGE_V2.addValue(Input[i].substring(lengthVal,(lengthVal*2)));

MESSAGE_V3.addValue(Input[i].substring((lengthVal*2),(lengthVal*3)));

MESSAGE_V4.addValue(Input[i].substring((lengthVal*3),InpLenVal));

}

else if (Input[i].length()>(lengthVal*4) )

{

MESSAGE_V1.addValue(Input[i].substring(0,lengthVal));

MESSAGE_V2.addValue(Input[i].substring(lengthVal,(lengthVal*2)));

MESSAGE_V3.addValue(Input[i].substring((lengthVal*2),(lengthVal*3)));

MESSAGE_V4.addValue(Input[i].substring((lengthVal*3),(lengthVal*4)));

}

}

}

Regards

Venkat

Former Member
0 Kudos

Hi Venkat,

In File to IDOC senario,

I have a Mapping Condition like this:

IF A02 = 'X' map 'VER ' + A05 + '- ACCEPTED'
IF A02 = 'Y' map 'REJECTED'
IF A02 = 'Z' map 'VER ' + A05 + ' -  EXCEPTIONS'
IF A02 = 'A' map 'VER ' + A05 + ' -  HOLD'
IF A02 = '' map 'VER ' + A05 + ' -  ACK'

Note: Trim any leading zeros in A05 while forming string. If A05 is not available, then use prefix 'VER UNK - '.

Sourcefield : A02

Target field : E1EDK02 - BELNR

                     QUALF = 002

I am unable to map it correctly.

Give some mapping example and Tips.

Please Anyone can give quick reply Now.