cancel
Showing results for 
Search instead for 
Did you mean: 

Date format

Former Member
0 Kudos

Hi,

I have an application which makes a call to a BAPI.

The input parameter for this BAPI is date.

The date in Webdynpro is of the format MM/dd/yyyy,

whereas in ABAP it is yyyymmdd.

Due to this my application is unable to make the right call.

Can anyone tell me how I can change the format from MM/dd/yyyy to yyyymmdd?

I have tried using Simpledateformat. But this returns a a value of type String, while I need to pass the value of type Date only.

Can anyone help me out?

(I have browsed through the other posts but in vain)

Thanks and Regards

Reena

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Reena,

As per my experience, there is NO need to convert the format of the date from mm/dd/yyyy to yyyy,mm,dd while passing it to a BAPI. Web dynpro takes care of automatically converting the value into the required fromat.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Reena,

Can you confirm one thing :

when you import the RFC, what is the data type for that particular entry. What I mean is when you write the code :

<BAPI>_Input input = new <BAPI>_Input();

<b>input.set<date_attribute_name>();</b>

Please check what is the datatype of the parameter that this method is expecting.

I ask this because, normally when you have date at the R/3 side, you can bind that to an attribute of type 'date' in webdynpro. Then when you enter a date in webdynpro and call the BAPI, the conversion is internally handled. And as far as I know, we cannot change the format in which a 'date' attribute stores it's value. We can only extract the value stored in a particular format.

So, if your setter method is expecting a date in webdynpro, you can set it to a any normal date attribute. And if it is expecting a string, you very well know how to handle it

Hope this helps,

Best regards,

Nibu.

Former Member
0 Kudos

Hi Nibu,

Date f_date = wdContext.currentContextElement().getFdate();

Date t_date = wdContext.currentContextElement().getTdate();

input_list.setPo_End_Date(t_date);

input_list.setPo_Start_Date(f_date);

In the backend, the import parameters(Po_Start_Date and Po_End_Date) are of the type 'DATS' (Length = 8).

The Context attributes (Fdate and Tdate) are of the type 'Date'.

Where am I going wrong?

Thanks,

Reena

Former Member
0 Kudos

Hi Reena,

There is absolutely nothing wrong in what you are doing. If the data type in R/3 is 'DATS', it will be converted to 'Date' in webdynpro and you are setting it properly. When you execute this BAPI from WD, the conversion from 'MM/DD/YYYY' to 'YYYYMMDD' takes place internally.

So you can be almost sure that the error is noth with the date format

Best Regards,

Nibu.

Former Member
0 Kudos

Hi,

Please award points if u found my answer as helpful.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I agree with Bala, if your input field is of type "date", then the conversion is taken care of for you. I have done this in a couple of webdynpro applications and it works fine.

Regards,

Rich Heilman

Former Member
0 Kudos

Hi Bala and Rich,

Thanks for the reply.

Currently I am passing the date without any conversion in the format. But I am unable to retrieve the data from the backend.

In order to test this I created a Report program in R/3 and tried calling the BAPI from it. When I passed the date in the 'yyyyMMdd' format (ABAP format) it worked fine.

But when I passed the date in the 'MM/dd/yyyy' format (Web Dynpro)it failed to retrieve any data.

That is why I thought the problem was in my Date format.

What can I do about this?

Thanks and Regards

Reena

Former Member
0 Kudos

Hi Reena,

You can use the SimpleDateFormat class to convert the date format.

Date date = wdContext.<node>Element.getDate();

SimpleDateFormat simpD = new SimpleDateFormat("dd-MM-yyyy");

java.util.Date dt = null;

dt = simpD.parse(date.getDate()"-"(date.getMonth()1)"-"(1900date.getYear()));

Then u can set by

wdContect.<node>Element().setDate(new Date(dt.getTime));

regards

Prakash

Former Member
0 Kudos

hi

use a simple type and set the format as yyyy/MM/DD. use it in a context variable and use that to pass the import parameter value. hope this helps.

regards

vln

Former Member
0 Kudos

Hi Prakash,

dt = simpD.parse(date.getDate()"-"(date.getMonth()1)"-"(1900date.getYear()));

Parse() takes a 'date' type as an argument. But what you have mentioned is in the 'string' format. Also the getDate(), getMonth(), and getYear() methods are deprecated and I cannot use them.

Any other solution?

Thanks in Advance

Reena