cancel
Showing results for 
Search instead for 
Did you mean: 

query on designing part

Former Member
0 Kudos

Hi,

In my scenario,my IDOC is having several segments.Each segment is having same fields,say FieldA,FieldB.

I want to do in mapping in such a way that whenever the value of FieldA is 'Customer',I want to retrieve the corresponding value of FieldB and pass it to the target .

Similarly,when the Value of fieldA is 'Vendor',I want to retrieve the corresponding value of FieldB and pass it to the target .

Here,the IDOC may have 7-8 segments and each segment will have two fields and these fields may contain any value.But,I would like to pass the corresponding values of only those segments which contain 'Customer' and 'Vendor' which is coming as first instance to my target.

My required value 'Customer' and 'vendor' may occur in any of the segements.

Please give your ideas on how to do designing of this scenario.it would be great if I can get some screenshots .

Regards,

Alex.

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Alex,

In addition to Swarup's reply, plz see the below logic.

Create Advanced UDF with 3 Input Parameters(Type:Queue Arguments:fieldA,fieldB,constant)

UDF


for(int j=0;j<fieldA.length;j++)
{
if(constant[0].equals(fieldA[j]))
{
result.addValue(fieldB[j]);
break;
}
}

Mapping logic.

For Customer

fieldA, fieldB,CONSTANT(Customer)->UDF->Target

For Vendor

fieldA, fieldB,CONSTANT(Vendor)->UDF->Target

Former Member
0 Kudos

HI Raj,

You have given really good idea to reduce few lines of code, also that could improve the UDF coding with avoiding the Constant element in the coding. It have created more compact coding format.

Thanks a lot, I also got better idea from this.

Here I would like to repeat the last point of my previous posting for mapping of fieldA as it needs to be replaced the above UDF code with result.addValue(fieldA<i>);.

Thus you need two different UDFs for FieldA(result.addValue(fieldA<i>);)

and fieldB (result.addValue(fieldB<i>);.)

OR better idea will be to pass input parameters as below, it will allow you to use one UDF for mapping of fieldA and fieldB

For mapping of FieldA

Here you will be passing fieldA, fieldA and Constant ("Customer"/"Vendor") ---pass fieldA two times it will treat the fieldA to add in resultlist.

For mapping of FieldB

Here you will be passing fieldA, fieldB and Constant ("Customer"/"Vendor")

Thanks

Swarup

justin_santhanam
Active Contributor
0 Kudos

Thnxs swarup! Just thought of avoiding two UDF's that's the reason I introduced the constant.

Good job! Keep on going!

raj.

Former Member
0 Kudos

Hi Swarup,

Thanks for your quick responses.

My scenario is IDOC to file scenario.In sending IDOC ,I have many segments and each segment have same two fields (FIELDA,FIELDB) and contain any value.

Here,I have to fetch values of FIELDB

where FIELDA value = 'Customer' and

FIELDB Value = 'Vendor'.

When an IDOC is fired from SAP R/3,it will defintely have 'Customer' and 'Vendor'.But,it may be available in any IDOC segment.

How to achieve this through Graphical mapping?

Can I accomodate both the conditions in Graphical mapping?

Could you please provide some screenshots/references to achieve this?

Do we need BPM to handle this case?

Regards,

Alex.

Former Member
0 Kudos

Hi Alex,

Thanks for your responses.

I would like to achieve this through graphical mapping as I am not used to Java coding.

Do I need looping with BPM?

Regards,

Alex.

justin_santhanam
Active Contributor
0 Kudos

Alex,

Why u need BPM? U can use the above code is graphical mapping. It's simple user defined function. Do u want to know how to create UDF?

raj.

Former Member
0 Kudos

Hi Raj,

I am interested to know UDF.

Thanks a lot .

Regards,

Alex.

Former Member
0 Kudos

HI Alex,

First thing that you could do this with Graphical mapping No Need of BPM the given UDF will 100% fulfiill your requirment.

In Graphical mapping at left most-bottom corner you will get an icon to create the UDF.

Click on it and give some name to it as TestUdf with proper description.

Then click on add button to add import fields and give the name as filedA, filedB.

Select the check box for cache parameter as "Queue" and save it.

It will open one editor to write Java code.

Copy the code mentioned in my above post and then in Graphical mapping API List select User Defined function as you did for other APIs such as Text, Date etc.

You will get the API TestUdf and drag it for mapping.

It will ask for the input parameters which you need to map it fieldA and fieldB,

Then map response with target element.

For Target end if you are expecting the value from FiledA then pass FieldA two times or else FieldA and FieldB as import parameters

refer below link to create UDFs

http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm

Thanks

Swarup

Edited by: Swarup Sawant on Feb 9, 2008 7:59 PM

justin_santhanam
Active Contributor
0 Kudos

Alex,

You need to create smething like below mentioned in the URL

http://flickr.com/photos/8764045@N06/2229466820/sizes/o/

in the argument as mentioned earlier give fieldA,fieldB,constant. and write the code provided. See the above URL is just a sample..

raj.

Former Member
0 Kudos

Hi Swarup,

Your steps are very easy to follow.

Could you please give me the exact code,I have to put in UDF?

Regards,

Alex.

Former Member
0 Kudos

Please find here with you excat code

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

{

if( A == "Customer" )

result.addValue(B);

elseif( A == "Vendor" )

result.addValue(B);

}

Thanks

Swarup

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Alex,

This is possible to achieve the values based on "Customers" or "Vendors" with below solution,

As per my understanding there will be multiple segments avaialble on Sender side but on receiver side only two fileds with single segment with 0-Unbounded Occurance.

You could create the UDF to verify the values of Filed A for Customer and Vendor and corresponding value of Field B is to be passed.

Probably below code will help you (I have created it without Java editor so rectify the syntax errors if any)

Input fields -- A , B (FieldA for A and FieldB for B),

Cache parameter -- Queue

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

{

if( A<i> == "Customer" )

result.addValue(B<i>);

elseif( A<i> == "Vendor" )

result.addValue(B<i>);

}

Similar way you need one more UDF for field A just pass result.addValue(A<i>); instead of B<i> in above code

Thanks

Swarup

Edited by: Swarup Sawant on Feb 9, 2008 3:16 PM