cancel
Showing results for 
Search instead for 
Did you mean: 

mapping problem

Former Member
0 Kudos

Hi everybody,

I have a problem when I map an IDOC to a target structure.

The target structure is going to be converted by File content conversion.

I need that in the final flat file a tab occurs everytime a field is empty or full so I type

field.fielSeparator = '0x09'. Until here everything goes ok.

The problem cames when some field of the ZIDOC is empty and the xml tag is not generated.

Consequently, the tag in the target structre is not generated and finally a tab doesn't occur as there is no field.

Every field in the IDOC is 0..1.

I have tried to set the ocurrence in the target field to 1 with a default value but it doesn't work. It gives

a mapping error.

I have managed to solve the problem by implementing a graphical mapping functions (exists, if,...),

something like that:

ZIDOC/Target Structure

A -- Graphical mapping -


> B

Graphical mapping:

IF (EXISTS (A))

THEN A

ELSE CONSTANT=""

Just I need to generate the target field when the source field doesn`t exists.

HOW can I simulate this graphical mapping with a user function as I need to use this function in every field of the IDOC?

Maybe, is there any other way to solve this?

Thanks

Regardas

Carlos

Accepted Solutions (1)

Accepted Solutions (1)

former_member206604
Active Contributor
0 Kudos

Hi,

You can do this manyways in UDF.

in the UDF you can just check

if(input==null)

return = " ";

else

return input;

Thanks,

Prakash

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Use MAPWITHDEFAULT available I think under Node Functions and use it by providing the default value.

SOURCE FIELD -->MAPWITHDEFAULT --> TARGET FIELD

If the source field is not available in the source, then Target field is filled with the default value provided.

Should do the trick I guess.

Regards,

Bhavesh

Former Member
0 Kudos

Hi Prakash,

this solution gives the following error:

/usr/sap/DXI/DVEBMGS50/j2ee/cluster/server0/./temp/classpath_resolver/Map1cde3e403cd111dba6e9000f203c1245/source/com/sap/xi/tf/_MM_MAESTROS_DELEGACIONES_HH_.java:339: cannot resolve symbol symbol : variable input location: class com.sap.xi.tf._MM_MAESTROS_DELEGACIONES_HH_ if(input==null) ^ 1 error

former_member206604
Active Contributor
0 Kudos

Hi,

When you are defining the UDF what is the variable name that is passed in... is it "input" or "a". If it is "a"

please make it as

if(a == null)

Thanks,

Prakash

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Think it is ,

<b>if(a.equals(null))</b> in the solution by prakash~~..

You can avoid the UDF by using MAPWITHDEFAULT

Regards,

Bhavesh

former_member206604
Active Contributor
0 Kudos

Hi,

Also try with MAPWITHDEFAULT as Bhavesh said..I never tried it.. Thats was a real gud info Bhavesh thanks.

Thanks,

Prakash

Former Member
0 Kudos

Hi Bhavesh,

I have tried with MAPWITHDEFAULT and it works.

Thank you very much

Regards

Carlos

Answers (0)