cancel
Showing results for 
Search instead for 
Did you mean: 

How to access Target field type, length from DT definition

Former Member
0 Kudos

I have defined the XSD Type (String, Number, Date..) and the length in the DT for the Target message

How do I access this info. in the mapping - so I can fill trailing spaces on String data, and zero-fill on Numeric data on the outbound XML MT ?

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mustafa,

Eventhough you define in xsd in xi it treats them as string. So if for example for a field which is integer of length 10 is there in the target then in your mapping map from source and in the end use FormatNum standard udf with ten zeros in it. So if your source field is 34534 then your output will be 0000034534 and if it character and if you are writing fixed length file then in your output file it will automatically add spaces according to the length. Else you can write a UDF, but the pain here is you have to write for every field.

Regards,

---Satish

Former Member
0 Kudos

Hi Satish,

Thanks for this info.

Exactly - I am trying to avoid Field length maintenance on every field level mapping.

Currently, I have a HashMap defined as follows..

empFieldLengthsMap = new HashMap();

// emp field lengths

empFieldLengthsMap.put("Record_Type","1");

empFieldLengthsMap.put("Movement_Type","1");

empFieldLengthsMap.put("Company_Code","3");

...

and then a UDF that yields me the size as follows from the map

String out = "";

out = (String) empFieldLengthsMap.get( targetField );

if (out == null || out.equals("") ) {

out = "0";

}

return out;

HOWEVER, I cannot get the target field to input into this UDF! Any ideas?

Mustafa

Edited by: Mustafa Dadawalla on Jul 15, 2010 11:44 AM

former_member200962
Active Contributor
0 Kudos
HOWEVER, I cannot get the target field to input into this UDF! Any ideas?

The target field wont come into the UDF.

Former Member
0 Kudos

All,

I mapped to each field individually and was able to complete this....

Thanks for your input. Best regards,

Mustafa

Answers (0)