cancel
Showing results for 
Search instead for 
Did you mean: 

IDOC-File - records in Idoc to file based on some condition

Former Member
0 Kudos

Hello experts,

I have a idoc to file scenario. the incoming Idoc can have multiple records in it and i have to map these records to a csv file. Now the problem is not all records has to be mapped to the file. Based on the value of a perticular file (which is not root), i need to decide if the entire record has to be processed or not. Like the idoc structure is say:

IDOC

E1WPA01 0....9999

E1WPA04 0...99

KONDART 0..1

Now for all valid E1WPA01 where the value of KONDART equals to some spacified value (known) , there has to be one record in the target csv file.

How can this be done at the root level?

One way of doing is we give empty values in the target file where the condition of KONDART is not fulfilled. Say if there are 10 records of E1WPA01 and only 4 satisfies the condition, we will ahve 10 records in the output file but only 4 records will have value and the rest 6 will be blank like (,,,,,,,). But I dont want this. I want only 4 records in the output file.

I tried mapping like this:

E1WPA01----


>Advanced -


> Root

E1WPA04-KONDART---->UDF

The problem i am facing here is if 4 records fulfill the condition, the first 4 are taken and the revelent 4.

Please help.

Regards,

Yash

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

HI,

U can do one thing:

Input a=KONDART take into one context.

write this UDF and map it to the root node of target file.

for(i=0;i<a.length;i++)

{

if(a{i}.equals("Specified Values"))

{

result.addValue("a{i}");

}

else

{

result.addValue("SUPPRESS");

}

}

Thanks and Regards,

Chiarg

Former Member
0 Kudos

Hi Chirag,

Root is not the place where I need to put the value of KONDART.

Root is the root of the target file and it has only to be created if that condition meet. There are other mappings to under the root node and all those mappings has to execute only on that condition.

The way which you have suggested gives me the same problem which i get with my UDF explained earlier. If condition is met 4 times, it will creat 4 root nodes irrestive of the record which fulfils the condition.

Help.

Yash

Former Member
0 Kudos

HI,

I have put the output just for generating the root node based on that condition u can try to pass the constant value as well.

I dont think it will create any problem in generating the output based on the satisfied condition.

Ur output will be for example:

Constant value

SUPPRESS

SUPPRESS

COnstant value

and the target node will be created twice.

During the mapping of

KONDART those value will be mapped whose condition is satisfied.

Can u please let me know the output of UDF.

Thnx

Chirag

Former Member
0 Kudos

Hi Chirag,

I wrote the following code in UDF:

for(i=0;i<a.length;i++)

{

if(a{i}.equals("Specified Values"))

{

result.addValue("a{i}");

}

else

{

result.addValue(ResuktList.SUPPRESS);

}

}

And its working partially. I mean the queue of the UDF looks like

1. AAAA SUPPRESS

2. <Specified value> <Specified value>

3. AAA SUPPRESS

4. AAA SUPPRESS

5. AAA SUPPRESS

6. AAA SUPPRESS

7. <Specified value> <Specified value>

8. AAA SUPPRESS

9. AAA SUPPRESS

and it creates 2 ROOT nodes. But the root nodes are created for line 2 and line 8 insteed of 7.

What can be problem??

Yash

Former Member
0 Kudos

HI,

Just check the child mapping whether it is generating the value for the line 2 nd Line 7.

What AAA stands for.

U will get only two root node thats what u wanted to achieve.

Thnx

Chriag

Former Member
0 Kudos

Hi Chirag,

Even in child nodes i am getting for 2 and 8 as only those nodes are getting created. 2 is correct but note 8. AAA is any value which i dont need to be mapped.

Also i checked by giving the value of 3 input records to fulfil the condition and its giving me 3 output records where the first one is correct, in teh 2nd one its giving the next record (like 8th instead of 7th) and in the 3rd its giving the second next (like 10th instead of 8th).

Dont know where the problem is. But its following some sequence.

The exact code i wrote is (for root):

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

{

if (KONDART<i>.equals("ZKA2") || KONDART<i>.equals("ZKA3") || KONDART<i>.equals("ZKA4") || KONDART<i>.equals("ZKA5"))

{

result.addValue(KONDART<i>);

}

else

{

result.addValue(ResultList.SUPPRESS);

}

}

Yash

Former Member
0 Kudos

HI,

I hope u have taken the KONDART value as KONDART in the array. Can u pls try to write it in a proper manner. if ((KONDART.equals("ZKA2")) || (KONDART..equals("ZKA3")) || (KONDART..equals("ZKA4")) || (KONDART..equals("ZKA5")))

Try this.

Chirag

Former Member
0 Kudos

Not KONDART way but using the first bracket "[" one.

I guess this is correct. That bracket didnt show up in the thread as it makes teh sentence in italics.

Any other mistake you can see or any other way.

Yash

Former Member
0 Kudos

One more thing,,,,just wanted to confirm whether u have a problem with one condition or with all the condition...can u please test the code with only one condition and check the output in display queue.

Have made the changes which I have suggested...also send me the output of the same.

Waiting for both the results.

Thnx

Chirag

Former Member
0 Kudos

By only one condition you mean only one correct condition in the input records or only one codition like ZKA2??

Also if you can give me you mail id i can mail you teh screen grabs of the queue and the code. Cant give the screen grabs here.

Yash

Former Member
0 Kudos

HI,

Yes with only one condition means ZKA2. My mail id is mentioned in my business card.

Thnx

Chirag

Former Member
0 Kudos

Hi chirag,

Have mailed you with screen grabs in detials.

Please check and respond.

Thanks,

Yash

Former Member
0 Kudos

Hi,

Still not got the mail.

thnx

chirag

Former Member
0 Kudos

Hi,

Have mailed you in your official id (CG id) from my gmail id. Just see in you bulk or junk mails. It might have been blocked by your server. Or else you can give me your personal id if u dont mind.

Thanks,

Yash

Former Member
0 Kudos

initial is same only the change is @gmail.com

Thnx

Chirag

Former Member
0 Kudos

Done.

Please acknowledge.

Thanks,

Yash

Former Member
0 Kudos

HI,

I dont see any problem in code. It should work fine. Have u check the occurance of the field whose value needs to be mapped based on condition.

Can u please just put the three or four input values from the test message tab and test it.. not using the payload.

Thnx

Chirag.

Former Member
0 Kudos

Hi Chirag,

Ok that sounds good to me. Let me complete the entire scenario and test it end to end and see what the result is.

I have another question, if you can please help me answer that:

I have 1 idoc and i have to send 2 files out of this 1 idoc, both compeletely independent of each other. What I have done is created two message mapping and everything else in IR. But when I create Receiver determination in ID for the second one and give the same sender interface (as the idoc inteface), it says the object already exists. How can i overcome this??

thanks,

Yash

Former Member
0 Kudos

HI,

use conditional receiver for sending the output to two different reciever.

Thnx

Chirag

Former Member
0 Kudos

Hi,

Its not only 2 different receivers but 2 different mappings too. Like1:n mapping. The sender interface is the same (same IDOC). So i cant have muliple receiver determination or interface detyermination in ID.

I didnt think in this much and did seperate mapping for both. One solution is to do 1:N mapping in message mapping (give both the message types in target message). But that will make me do all the mappings all over again. Lot of manual work. Is there any other better way??

Yash

Former Member
0 Kudos

HI,

If u r using two mapping then ur scenario become independet of each other but if u wnated to use only one mapping then u need to go for 1:N mapping and use conditional receiver.

I dont think there is any workarround for the same.

Have ur previous problem solved. if yes then please close the thread and let me know the result as well.

Thnx

Chirag

Reward points to helpful answers.

Former Member
0 Kudos

Hi chirag,

I was using 2 different mappings and I wanted it to be independent of each other but the problem which i faced was will creating receiver determination. When I gave the same sender interface (same idoc), it said, object already exist.

i have created a new communication channel as well as receiver agreement. Can i now use the same interface determination and receiver detmination for this 2 diffenet message or the only way i ahve in 1:N mapping?

I am asking you this in this thread ebcause unless i complete the full scenario i cannot test it and and close the issue.

Thanks,

Yash

Former Member
0 Kudos

Hi Chirag,

got this 1:N mapping problem sorted out by adding one moe condition in the interface determination.

Thats a big relief.

Will test the entire scenario on wednesday and update you on the thread.

thanks for your help.

Yash

Former Member
0 Kudos

Hi chirag,

Both the issues are solved now and i am abale to get the desired result. Thanks for your support.

Regading breaking information from 1 idoc to 2 files, i used two independent mappings and used 2 rows in interface determination.

Regarding the main problem, well the coding for the ROOT as i showed you last week was correct. The problem was in the handelling of context in one of the other field in the file. Actually one segment in the incoming idoc can appear mutiple times (which is dymanic). I have to write another advanced UDF to handle this and now its working perfect for all scenarios.

Thnaks once again. I hae awarded points to you.

If i have any other doubt, i hope i can get in touch with you.

Regards,

Yash