cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a UDF in SAP XI

Former Member
0 Kudos

Hi,

I have Idoc to File Mapping in SAP XI, where I need to populate "Spaces" in most of the Target fields Dynamically. I need to create a UDF for this mapping. Since I have n no.of Target fields where I need to populate Sapces and Target fileds has different lengths. As of now I have cretated a simple UDF which is usefull only for one field mapping. Below is the UDF:

String s;

char []c = new char[10];

for(int i=0; i<10; i++)

c<i> = 'S';

s = new String(c);

return s;

2. My source file will be having 1000 records where 999 records will be mapped to Traget sturucture and the end of the Record should be mapped to the other Traget structure(Traget sturcture is same in the both the cases).

Please let me know how can I go about on this.

Thanks in Advance.

Jose

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Jose,

On the target side, do you want as many Spaces in the field as the field length ? Are you looking for a help for creating the UDF in IDOC to file case ?

Thanks,

Pooja

Former Member
0 Kudos

Hi Pooja,

UDF is solved. Can you tell me how to map the End record of the file to the other structure.

Jose

Former Member
0 Kudos

Hi Jose,

If you have two message type at the target end.

You can divide them into 999 and 1 piece using two simple UDFs. One to create 999 nodes, which should be used only once at the node level of the first message type :

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

if(i!=0) result.addValue(node1(i));

//Use the square brackets around i

and

another UDF is needed to fetch the last ( 1000th) record. You have to use the UDF for each and every field (field1 --> UDF ---> field1. .... same for all fields of the second structure

result.addValue(a (a.length-1) );

//Use the square brackets around a.length-1

Let me know if you face any issue in resolving your problem

Thanks,

Pooja

Former Member
0 Kudos

Hi Pooja,

Have look at my target structure :

Messages

Messages1

MT_Insite_Req

DataConversionArea

DataElement

Messages

Messages1

MT_Insite_Req

DataConversionArea

Field1

Field2

DataElement

Field1

Field2

Field3

...

....

Now can you show the UDF?

Thanks in Advance.

Jose

Former Member
0 Kudos

Hi Pooja,

Have look at my target structure :

Messages

Messages1

MT_Insite_Req

DataConversionArea

DataElement

Messages

Messages1

MT_Insite_Req

DataConversionArea

Field1

Field2

DataElement

Field1

Field2

Field3

...

....

Now can you show the UDF?

Thanks in Advance.

Jose

Former Member
0 Kudos

Messages

Messages1

<MT_Insite_Req>-> UDF1->MT_Insite_Req

DataConversionArea

DataElement

Messages

Messages1

<constant>--->MT_Insite_Req

<constant> --->DataConversionArea

<Field1> ---> UDF2 --->Field1

<Field2> ---> UDF2 --->Field2

<constant> ---> UDF2 --->DataElement

<Field1> ---> UDF2 --->Field1

<Field2> ---> UDF2 --->Field2

I have assumed that DataConversionArea and DataElement come only ones under the MT_Insite_Req.

Fields in the angle brackets are the input fields.

UDF1 :

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

if(i!=0) result.addValue(node1(i));

UDF2:

result.addValue(a (a.length-1) );

Let me know if I have confused you. :)Pooja

Former Member
0 Kudos

Messages

.......Messages1

.........MT_Insite_Req

...........DataConversionArea

.................Field1

.................Field2

.............DataElement

.................Field1

.................Field2

.................Field3

.......Messages2

..........MT_Insite_Req

.............DataConversionArea

.................Field1

.................Field2

.............DataElement

.................Field1

.................Field2

.................Field3

Pooja, It will be great if you can give the UDF related to the above structure and explain me in detail.

Once again Thanks for ur help.

Joseph

Former Member
0 Kudos

HI Joseph

Pooja has given UDF to apply like this


Messages
.......Messages1
.......UDF1..MT_Insite_Req (work for 999)
.................DataConversionArea
.................Field1
.................Field2
.............DataElement
.................Field1
.................Field2
.................Field3
.......Messages2
.......Constant...MT_Insite_Req
.......................DataConversionArea
............UDF2...Field1
...........UDF2....Field2
.......Constant...DataElement
........UDF2.......Field1
......UDF2.........Field2
........UDF2.......Field3

Thanks

Gaurav

Former Member
0 Kudos

Hi Pooja,

Continution to the issue.....

E1BP2017_GM_ITEM_CREATE is the SAP segment of the IDoc YWMS_MBGMCR03. The above segment is repeting 0 to unbounded.

Requirment:I need to create a UDF where I need to find the End of data coming from the segment.Once we reach the end of data then I should map the end record(Hardcoded Values). Before we were using 2 message types of sametype at the traget, now we should use only one.

Thanks in Advance.

Best Regards,

Joseph

Former Member
0 Kudos

HI Joseph,

As per my understanding, if the sender sends 200 records, you want to sender 199 into one message and you want to create one last message with some constant.

Did I understand your question correctly ?

thanks,

Pooja

Former Member
0 Kudos

I think , I misconstrued your question.

DO you want to create only one target structure with the last occurence of the segment to be replaced by some constants or rest occurence as it is

or

do you only need the last occurence or the segment in your target?

You can achieve that by writign a small UDF at the segment level.

thanks,

pooja

Edited by: Pooja Pandey on Dec 19, 2008 12:11 PM

Former Member
0 Kudos

Hi Pooja,

I need to send all the item records of the Segment E1BP2017_GM_ITEM_CREATE like we should use the segment counter. And the last record we will be hardcodeing.

We have taken out the concept of using the second Message type, because we have to mapp all the 140 fields again for the end record. What we want to do is, if we have reached the end of the data which is comming from source, we just want have if condition and Hardcord a value LIKE EOD which means end of data.

hope you have got the point.

Jose.

Former Member
0 Kudos

Hi Joseph,

Give a try to use the below UDF for the fields where you want to have some hardcoded values :

a : Field you would like to change

b : New hardcoded value for the field.

for( int i=0; i<a.length; i++)
{
  if (i==(a.length-1))
      result.addValue(b[0]); 
  else
     result.addValue(a<i>); 
}

input_field_1   --------------------
                                       UDF  -------------------- target_field_1
new_constant_EOD  ------------------

Rest all mappings should remain as it is.

Let me know if you face any issue.

Thanks,

Pooja