on 03-09-2010 7:14 AM
Hello,
Plzz help me how do i map if below condition arise.
REFAJ123
REFCD432
here REF is Record with 2 fields 1)REF01 2)REF02
I want to mapping this REF record to output side record.
Query is: If REF01 field is AJ then i need to map REF02 field(123) is to be map output side field. else ignore that record.
Output,
I need only value of 123 beacause( REF01 has value AJ) i dont want below REF data in Output.
Thanks,
Singh.
Hi,
write a UDF like this,
Input:REF01,REF02
Output:result,container
Mode: All values of Context
-
if(REF01[0].equals("AJ"))
result.addValue(REF02[0])
else
{
//nothing.....
}
-
Try with this one..
If still prblm.. pl do post
Babu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the input and output has been mentioned by Babu in his post....maintain some names for input parameters in your UDF and say create....then paste the code and save.....you will have a UDF tab created....click on it and the UDF will be visible in the Mapping Editor section as we see the standard functions.....now here point the arrow from the source fields to UDF and then from UDF to Target....you may have to modify the code given by babu before using it.
Hi,
1. In graphical mapping u have Functions...
2.Functions->User Defined Functions.(or u have a button to create a new function)
3.now give the input parameters as REF01 and REF02.
4.Choose all values of context(this will also gives u container and result as input)
Input:REF01,REF02(container and result will come by default.. so dnt give)
Execution Type: All values of Context
Now a window is opened..
in it put this code...
-
if(REF01[0].equals("AJ"))
result.addValue(REF02[0])
else
{
//nothing.....
}
-
Now use this UDF in mapping.
U map the REF01 and REF02 as input to the UDF.
and output of UDF will be mapped to the target field.
If still any prblm... pl do post
Babu
Babu i followed below procedure.
Click on UDF.
Provided name and title.
Excution type: All values of context .
Category: USer- defined.
Signature variables;
TYPE Name Java Type
Argument ref01 string
Argument ref02 string
Here i written code has
if(REF01[0].equals("AJ"))
result.addValue(REF02[0])
else
{
//nothing.....
}
Is it right Procedure.
how i would check syntax
Thanks,
Singh.
Edited by: vcpsingh on Mar 9, 2010 3:18 PM
Edited by: vcpsingh on Mar 9, 2010 3:21 PM
Hi,
Yes it's correct.
To check ur mapping syntax..
1.When u activate the mapping it will throw exception if any..(error also).
2.When u try to test it using test tab.. u wil get the error or warning if any.
Also now make sure that the input and output for the UDF are given properly..
i mean here in mapping of source fields to UDF and output of UDF to Target node
If still any prblm pl do post
Babu
Plzz find below Situation that occurs for me.
In input file i am getting REF record 3 times.
i.e. REFCR!23
REFAJ234
REFDF345
IN output side Record has 2 field REC1 and REC2
I need output in Record REC1 has value = AJ
REC2 has value = 234.
I dont want to display 1 and 3 REF records in output.
SO like u said i created UDF.
and Mapped REF01 and REF02 are source fields to that UDF to map REC1 Target fields.
and
REF01 and REF02 tosource fields that UDF to REC2 Target Fields.
Is it correct.
Query: U have given REF[0] = "AJ" here it will take first occurence of REF.is it right. But if I get REF AJ value in 4 line of REF Record how would i used that code.like I mentioned my problem.
Thanks,
SIngh.
Edited by: vcpsingh on Mar 9, 2010 3:34 PM
Ok fine,
Spend 5 more minutes for this.
In input file i am getting REF record 3 times.
i.e. REFCR!23
REFAJ234
REFDF345
IN output side Record has 2 field REC1 and REC2
I need output in Record REC1 has value = AJ
REC2 has value = 234.
I dont want to display 1 and 3 REF records in output.
Now in the same UDF do these things.
1. Change the code in UDF as
-
for(int i=0;i<REF01.length;i++)
{
if(REF01<i>.equals("AJ"))
result.addValue(REF02<i>);
}
-
2.in mapping change the context of REF01 and REF02 to message type.(top of records)
Right click on the REF01 and change the context on editor... same for REF02.
3.Now when mapping to Record, i.e
IN output side Record has 2 field REC1 and REC2
take REF01 and REF02 as input to UDF and out put of UDF to the Record(Target node)
Note:change context of REF01 and REF02 to message type.
2.When map to REC2...
take REF01 and REF02 as input to UDF and out put of UDF to the REC1(Target Element)
Note:Change the context here also as above.
3.When map to REC1
take REF01 and a REF01 as input to UDF and out put of UDF to the REC2(Target Element)
Note:Change the context here also as above.
Yes u r correct: when u r mapping to REC2.. u r giving REF01 as both inputs... it's just a work around.
Now Test the mapping..
This should work....
If still prblm do post..
Babu
Hi,
As u did in step1, u just change the context for all mapping.
When u r mapping.. as told above ..
for inputs i.e. REF01 and REF02.. u just right click on the REF01 and REF02 and u wil see the conext level.
U just change this context level to topmost in the editor.
If i didnt get ur question properly.. please make me clear the question
Babu
Babu,
In mapping change the context of REF01 and REF02 to message type.(top of records) for this where i need to change.
If i Select REF01 in input side and righ click i am getting options as
1.Where used
2. Copy Path
3.Dependices
how would i change this Context of REF01 and REF02 to Message type.
Is my Question is clear.
Thanks,
Singh.
Hi,
Yes i gt now.
U r trying to do this from the mapping schema.
When u r mapping i hope u will be doing like this..
1.double click on the target node u want to map to.
2.Now this element will appear in bottom or down with yellow colour..(Graphical editor...)
3.Now u will be choosing from which u want to choose..
u will double click the source also.... it will also now appear in the bottom.. graphical editor.
Now here,i.e in graphical editor u right click.. u will get the option Context.
Change the context to top level.
For all the mapping u follow the same thing.
When u want to map the REF01 to udf means u will drag the connection from REF01 and point it to 1st input of UDF.
If still any prblm .. do post
Babu
Hi,
Exactly...
But please re read my post earlier...
For REC2 u have to map from REF01 and REF01(yes u r repeating the same) also change the context for these also to message type.(It's just work around)
Now also do the same thing for Record of target as explained in previous post.
Still problem.. pl do post
Babu
Babu
here is my input file.
- <G_SPO1>
- <S_PO1>
<D_350>0001</D_350>
<D_330>6</D_330>
<D_355>EA</D_355>
<D_212>151</D_212>
<D_235>VC</D_235>
<D_234>40421-821/1920-02</D_234>
<D_235_2>SK</D_235_2>
<D_234_2>427Y73226</D_234_2>
- <S_REF>
<D_128>SU</D_128>
<D_127>0060325940</D_127>
</S_REF>
- <S_REF>
<D_128>SU</D_128>
<D_127>0060325957</D_127>
</S_REF>
- <S_REF>
<D_128>SU</D_128>
<D_127>0060325964</D_127>
</S_REF>
- <S_REF>
<D_128>SU</D_128>
<D_127>0060325971</D_127>
</S_REF>
- <S_REF>
<D_128>SU</D_128>
<D_127>0060325988</D_127>
</S_REF>
- <S_REF>
<D_128>SU</D_128>
<D_127>0060325995</D_127>
</S_REF>
- <S_REF>
<D_128>CR</D_128>
<D_127>WHITEHOUSE,RYAN</D_127>
</S_REF>
</S_PO1>
</G_SPO1>
- <G_SPO1>
- <S_PO1>
<D_350>0002</D_350>
<D_330>6</D_330>
<D_355>EA</D_355>
<D_212>151</D_212>
<D_235>VC</D_235>
<D_234>40421-821/1920-02</D_234>
<D_235_2>SK</D_235_2>
<D_234_2>427Y73228</D_234_2>
- <S_REF>
<D_128>SU</D_128>
<D_127>0060325950</D_127>
</S_REF>
- <S_REF>
<D_128>SU</D_128>
<D_127>0060325967</D_127>
- </S_REF>
</S_PO1>
</G_SPO1>
for this i need to check to conditions.
IF D_128 = "SU" then i need to map D_127 to Target field. dor this i need to check PO1 1st field ="0001" also.
If PO1 = "002" again i need to check D_128 = "SU" then i need to map D_127 to target field.
Plzz help me on this.
This is for EDI to IDOC Scenario.
In IDOC Target field is E1EDPT2 Segment TDLNR field.
Plzz help me.
Thanks,
Singh.
Hi Singh,
As discussed in this blog, the same UDF will sufice for ur requirements.
The only thing u need to do is, change the inputs to UDF accordingly, based on diffferent conditions.
Go through the posts clearly once more.
If u still feel its very complex..
The best idea is to go for the java mapping.
In java mapping u have a lot of control on data, so u can map as u require.
Babu
USE Standard Function
if without else
if REF01 --> Equals S
Constant(AJ)
Than REF02 --> Target
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks,
For ur reply.
Here i have one doubt.
in output side i have to fieds field 1 is mapped from REF01.
Field2 is mapped from above condition u have mentioned.
If Ref 01 not equals to AJ then i want to ignore that record data.
i.e. i dont want to print ref01 CR value in output.
Thanks,
Singh.
Edited by: vcpsingh on Mar 9, 2010 1:19 PM
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.