cancel
Showing results for 
Search instead for 
Did you mean: 

To create a line item in the file only if one of the condition from source idoc is true.

Former Member
0 Kudos

Hi All,

I have a Idoc to csv file scenario.

In my idoc  have a segment E1WXX01(it can occur n number of times) where it contains the fields FLDGRP, FLDNAME and FLDVALUE.

If FLDGRP = "MARA" and FLDNAME = "TRUE" and FLDVAL  =  "Y" then only that line item should come or else it should not come. Not all the E1WXX01 segment contains exactly these values, it varies so if any of the E1WXX01 segment contains these values then the line item should populate.

My source structure:

Idoc:

EDI_DC40--->E1WPA01(1:1)---->E1WXX01(1:unbounded)

CSV file format:

Data1

Item,3154,1,TRUE,1,0

Item,2674,1,FALSE,1,0

Item,8908,1,TRUE,1,0

so, in my case now only first and third line items should come second should not populate at all. I am unable to use create if function due to context changes. How can I get the target file as expected?

Thanks in Advance.

Accepted Solutions (1)

Accepted Solutions (1)

manoj_khavatkopp
Active Contributor
0 Kudos

Just change the context of fields FLDGRP , FLDNAME and FLDVAL  to E1WPA01 in your mapping.

Br,

Manoj

former_member186851
Active Contributor
0 Kudos

yes..Manoj idea should work.

If not let us know I will check trying in my system.

former_member190293
Active Contributor
0 Kudos

Hi Raghuraman!

Yes, you're right, it should work. But it's worth mention that if any of FLDGRP, FLDNAME or FLDVAL is missing for E1WXX01 segment than moving these elements to E1WPA01 in some cases might lead to wrong count and order of elements in respective queues.

So, if the FLDGRP, FLDNAME and FLDVAL elements are always obligatory for a E1WXX01 segement we can follow Manoj's above suggestion, otherwise, we might consider using MapWithDefault[]->RemoveContexts for each of these fields with its initial context.

Regards, Evgeniy.

former_member186851
Active Contributor
0 Kudos

yes Eve,

Thanks again .:)..I didn't simulate that..:)

Let us wait for her reply.

Former Member
0 Kudos

Hi All,

Thanks for all your suggestions.

I applied Evgeniy logic and now I am able to get the line items. But the problem is in the line items whererver the constant values are mapped only those are shown. I have 2 fields where some mapping is there, those are not appearing in the target nodes.

My mapping at the Data_1 Level:

My target nodes created after applying this:

After first field, there is a field called SKU, it is not appearing in the target node although in display queue I can see the values.

Thanks

former_member190293
Active Contributor
0 Kudos

Hi Richa!

Wouldn't you provide a source tree fragment with field that you need to map to SKU slement of target structure?

Regards, Evgeniy.

Former Member
0 Kudos

Hi Evgeniy,

I did not understand your question correctly.

The ARTIKELNR is the artilcle number and it is present in the E1WPA01(the parent segment) of the idoc. I have to populate this article number in the field SKU of target node.

manoj_khavatkopp
Active Contributor
0 Kudos

Try mapping ARTIKELNR with SKU for target with useOneAsMany with other two input as E1WXX01.

Former Member
0 Kudos

Hi Manoj,

No it is not working if I use OneAsMany.

My field ARTIKELNR  is in E1WPA01 and it is mandatory. so how many E1WPA01 segments are there in idoc those many SKU 's will generate.

Thanks

manoj_khavatkopp
Active Contributor
0 Kudos

Check this:

Former Member
0 Kudos

Hi Manoj,

Thank you very much. It is working as expected. But previously when I applied the same logic, it did not work.

Now I have the final field "seq no" in the target structure. If the line item is more than one than we will put the sequence no according to that. i.e if the line item is 1 then the seq no is 0 and if line item is 2 the seq no is 1.It worked perfectly before applying this Data_1 logic. But now it is generating some random values.

Thanks

manoj_khavatkopp
Active Contributor
0 Kudos

I guess counter and index wont help in this case as there is context change due to false values.

But,Is this how you are expecting ?

Former Member
0 Kudos

Hi Manoj,

The seq no in target structure should generate the same as you have shown above.

So, can we not achieve this using index ?

manoj_khavatkopp
Active Contributor
0 Kudos

Richa,

Using Counter and Index will be bit tricky as we are suppressing node with create if so you can use the GlobalContainer to add the counter value to the field.

      Firstly define the int counter =0;  in   Attributes and Methods

     Add the below UDF no input required


GlobalContainer gc = container.getGlobalContainer();

Object o =gc.getParameter("counter");

Integer i=0;

if(o==null)

i = new Integer(0);

else

i = (Integer)o;

i = new Integer(i.intValue() + 1);

gc.setParameter("counter",i);

return i.toString();

Mapping logic just combine the same logic of create IF with the UDF as below.

Former Member
0 Kudos

Hi Manoj,

I have given int counter =0; in Attributes and Methods.

Then the udf as below:

and mapping as below:

but you can see it is not generating as expected and also we can see the result only in display queue but not in target structure.

Thanks

manoj_khavatkopp
Active Contributor
0 Kudos

SplitbyValue should be used befor IfS check the screenshot which i provided.

Former Member
0 Kudos

Thanks a lot Manoj. It is working as expected. Could not have completed without your help.

Answers (1)

Answers (1)

former_member186851
Active Contributor
0 Kudos

Hello Richa,

Can you post the queue and context ,might be you can use If else and node functions to achieve the same.

Former Member
0 Kudos

Hi,

  This is my mapping:

 

My context is in E1WXX01 the child node of E1WPA01 in the Idoc.

former_member186851
Active Contributor
0 Kudos

Please post how values are coming in the queue and the queue where the extra node is getting created.

Former Member
0 Kudos

Hi Raghuraman,

This is how my data is coming in the idoc:

Thanks,

Richa.

Former Member
0 Kudos

Hi

This is how my source and receiver structure look alike:

source:

Receiver: