cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping issue in Date Format

Former Member
0 Kudos

Hi Experts,

I have a mapping problem in my object.

I have two filelds coming from the Control record of an IDoc CREDAT and CRETIM. Now, I need to concate them and put them in a target field DateandTimeCreated in the format: YYYYMMDDHHMMSS

Is their an UDF or message mapping for this. Messge mapping will be better for me.DateTrans will work over here??

Please reply.

Thanks and regards,

Aniruddha

Accepted Solutions (1)

Accepted Solutions (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

If Doc fields CREDAT and CRETIM gives output in this format respectively YYYYMMDD and HHMMSS, then use concat to concatenate the string as below.

map CREDAT and CRETIM fields to concat -> concatenated output

otherwise we have to convert CREDAT data to YYYYMMDD and cretim data to HHMMSS first, and then use concat function.

Note: To convert date and time to the required pattern we have to use UDF.

Answers (4)

Answers (4)

Former Member
0 Kudos

ok

Former Member
0 Kudos

Aniruddha,

This is a very easy requirement. just use the standard function "CreateDate" if you need to send the system generated date.

you can select both day and time formats by double clicking the "createDate".

If you need to send data from the IDOC (creation time and date idoc created) then use the concat function followed by DateTrans standard functions to manipulate the Date format.

Regards,

Pavan

baskar_gopalakrishnan2
Active Contributor
0 Kudos

@pawan: Do you mean currentDate standard mapping function?

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Sample UDF code:

Execution Type: Single Values

Date UDF

a)if your input date field declared as string then,

public String dateValue(String value, Container container) throws StreamTransformationException{

String input =value;

String strDate ="";

if (input !=null)

{

Date date1 = new java.util.Date(Long.parseLong(input));

SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");

strDate = formatter.format(date1);

}

return strDate;

}

Time UDF

a) if your input time field declared as string then,

public String timeValue(String value, Container container) throws StreamTransformationException{

String input = value;

String strTime="";

if (input !=null)

{

Date date = new java.util.Date(Long.parseLong(input));

SimpleDateFormat formatter = new SimpleDateFormat("HHmmss");

strDate = formatter.format(date);

}

return strTime;

}

Note: include import statement

import java.text.*

If you have question, let us know. This code will work for sure.

Former Member
0 Kudos

Hi,

Thanks a lot for you reply, can I have a sample UDF for this which I may require for this mapping. I am new to Java.

Regards,

Aniruddha

former_member200962
Active Contributor
0 Kudos

Why do you need JAVA...dont you think this can be achieved by standard mapping functions?

baskar_gopalakrishnan2
Active Contributor
0 Kudos

If your requirement is minimal and it would accomodate your requirement with standard mapping function then use DateTrans function itself

use input format and output format options according to your requirement in DateTrans function.