cancel
Showing results for 
Search instead for 
Did you mean: 

optional segment under ITEM segment

Former Member
0 Kudos

Hello All:

I tried this scenario using node function but not getting desired output in FILE.

This is IDOC to FILE scenario.

IDOC has segments and value of fields as below:

E1_ITEM (1)

E1_ITEM-key_field=KEY1

E1_ITEM-E1_CHILD (1st occurance)

E1_ITEM-E1_CHILD-f1=100

E1_ITEM-E1_CHILD-f2=x

E1_ITEM-E1_CHILD (2)

E1_ITEM-E1_CHILD-f1=100

E1_ITEM-E1_CHILD-f2=y

-


context change E1_ITEM

E1_ITEM (2)

E1_ITEM-key_field=KEY2

E1_ITEM-E1_CHILD (1)

E1_ITEM-E1_CHILD-f1=200 (Note: VALUE OF E1_CHILD-f2 is not there, that makes the result distorted)

-


context change E1_ITEM

E1_ITEM (3)

E1_ITEM-key_field=KEY3

E1_ITEM-E1_CHILD (1)

E1_ITEM-E1_CHILD-f1=100

E1_ITEM-E1_CHILD-f2=z

REQUIRED FILE output:- ( 2 fields, Please suggest how to get this result)

KEY1,x

KEY2,blank

KEY3,z

Logic:

1) Number of records in file equals number of E1_ITEM occurance.There are 3 E1_ITEM segments so 3 records in FILE

2) 1st field in flat file = E1_ITEM-key_field

3) 2nd field in flat file =

a) Read all E1_CHILD segments under E1_ITEM for that specific E1_ITEM context where E1_CHILD-f1 = 100

b) Read E1_CHILD-f2 for that E1_ITEM context (AFTER applying condition 'a' above)

For 1st E1_ITEM context E1_CHILD-f2=x and y. Pick first f2 value which is x

For 2nd E2_ITEM context there are no values as E1_CHILD-f1 NOT equals 100 (here value is 200)

For 3rd E2_ITEM context E1_CHILD-f2=z.

I tried graphical mapping using node function, but getting result in FILE as:

KEY1,x

KEY2,z

KEY3,

I tried increasing the context of E1_CHILD-f1, E1_CHILD-f2 to E1_ITEM that did not help.

Please provide pointers. Help much appreciated.

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

Did you try using mapWithDefault under node functions?

E1_ITEM-E1_CHILD-f2 --> mapWithDefault --> targetnode

Please let me know if this works,

Regards

Former Member
0 Kudos

I used formatByExample to change the context back to original (after using splitByvalue, collapsecontext) and that got the results aligned to original context. Thanks for the help.

Answers (0)