cancel
Showing results for 
Search instead for 
Did you mean: 

want to get empty field in out file for the empty value in source IDOC

Former Member
0 Kudos

Hi,

I am doing IDOC to file scenario,my scenarion running good but I am not getting empty spaces in the output file with || (pipe delimiter).

basically,I wan to get empty space if I dont get any value in the IDOC which I get from SAP.

even I am not getting xml payload (SXMB_MONI)tags with empty value

I want to see payload like this

<1> xyz X 1234</1>

<2> </2>

<3>abcd</3>

If I get payload like above I would get similar to that in flatfile.

out flat file like this

XYZ X 1234|| ||abcd||

how can I achieve this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Babu !

Use occurance 1..1 (or minimum occurance = 1) in target data type definition on each field you need to obtain regardless it has no data. Also use mapWithDefault standard mapping function to assign value to those fields that doesn't have target value to avoid error for no assigning value to the mandatory fields (1..1)

Regards,

Matias.

Former Member
0 Kudos

Hi matias,

thank you,I was searching how to do this and come to know that by using the withDefaultValue function ,we can get empty field in the target structure if dont get any source value.

and I have another question about using this function?

lets say I say I have more than one field in in a node in my source IDOC and I wan to apply this function on all fields,how can I do this?

<b>Source:</b>

IDOC seg1

fd1

Fd2

Seg2

fd3

fd4

<b>Target:</b>

MT_target

recset

recstruc

tgfd1

tgfd2

tgfd3

can you explain little with above example?

thank you.

regards,

Babu

Former Member
0 Kudos

Hi Babu !

I don't understand exactly what you mean, saying that you want to apply this to all fields..first of all, take in account that this function (mapWithDefault) is mainly for the target fields..that is: every target field that should appear on target structure regardless if its empty or not, it should be mapped as the output of a mapWithDefault function, I mean, one mapWithDefault function for each target field that could have no value and should appear on target.

The input of the mapWithDefault function could be whatever composition of UDFs or standard mapping functions you need to get the logic.

If your question is if you can mass apply the function to avoid the point and click with the mouse a lot of times...I'm sorry but with graphical mapping you just have to do that way, as far as I know.

In the example of your post..this the expected target or the actually returned one?

If in source you have "fd4" and in target is defined with does not appear, you have to use the mapWithDefault function.

Please clarify your question.

Thanks,

Regards,

Matias.

Former Member
0 Kudos

Matias,

I was trying to get the structure in my previous post but I cant get it the way I wanted to explain.

yes,my question is how we need to use mapWithDefault,l have like 37 fields in the target side,do I need to use 37 times?and I have like 7 fields under one segment in the sending IDOC so is there anyway I can apply once for that segment and can get effected for all fields under that segment?

but my understanding from you reply ,we need to use 37 times if I have to effect all 37 fields.

hope made my question clearer now,

thank you.

Former Member
0 Kudos

Babu,

Yes we need to 37 times in our case their is no other option. we dont have luxury to map to root element and refelect it in it subelements yet.

Regards

Sreeram.G.Reddy

Former Member
0 Kudos

Hi Babu !

Yes, there is no mass mapping when using functions in between..there is a mass mapping that only works, selecting source and target fields that have the exactly same name. The only way: field by field.

Regards,

Matias.

Former Member
0 Kudos

ok,I got it now.

thank you both for your help.

Answers (2)

Answers (2)

Former Member
0 Kudos

Babu,

You cannot see spaces in sxmb_moni. Take the payload of the message and test it in message mapping. Once you test then take the reciever payload and copy it in a notepad and see whether you have spaces or not. There you will see the spaces. If you see the spaces then you will see it in the ouput file also.

Regards,

---Satish

turmoll
Active Contributor
0 Kudos

Hi,

The occurance of tag <2> in definition of data tape should be equal "1".

Regards,

Jakub