cancel
Showing results for 
Search instead for 
Did you mean: 

Passing Current Date and Time to BAPI

Former Member
0 Kudos

HI,

I have developed a web dynpro java application. I will have to pass Current date and time to BAPI from web dynpro application.

In the BAPI date field is stored as DATS data type with length 8 and time field is stored as TIMS data type with length 6.

please let me know how to get current date and time in the above format and how to pass it to BAPI.

Regards,

Madhu.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

Passing date field will always put you in trouble, so better you can have a look at this solution,

Create one function module, which accepts import export params as like as BAPI and there you send Sy-Datum with other parameter to BAPI.

Else, Check the data type of BAPI parameters in WD Java then let me know whats the data type used for those params?, also let me know what is the date & time format that BAPI accepts import parameter.

Regards!

Sheik

Former Member
0 Kudos

Hi Madhu,

Try this.

1. Create an Input field in the View under a Transparent Container.

2. Navigate to Dictionaries>Simple Type>right-click "Create new Simple Type"

3. Enter the name and package for the simple type & select the bulit in type as "Date"

4. Switch to "Representation" tab and enter the format as dd.MM.yyyy

5. In the Context Tab, right-click create context attribute

6. Select type as the simple tyoe created in step 3.

7. Bind the Input field's "Vaue" property to the context attribute.

In the wdDoInit() write the following code:

wdContext.currentContextElement().set<contextattributename>(new java.sql.Date(System.currentTimeMillis());

Or

import java.util.Calendar;

...

Calendar currCal = Calendar.getInstance();

currCal.add(Calendar.DATE,-2);

Date date = new Date(currCal.getTimeInMillis());// Set this date to your From date field attribute.

...

Or

long twoDay = 2L * 24L * 60L * 60L * 1000L;

java.util.Date d = new java.util.Date();

d.setTime(d.getTime() - twoDay);

I hope above code will help.

Regards

Vijay Kalluri

gill367
Active Contributor
0 Kudos

Hi

In the BAPI what is format in which the date is expected. and find out the format for time field also .

then you can fetch the curret time and date in web dynpro using the following code and pass it to BAPI.

String str = Calendar.getInstance().getTime().toString();

and then from this string you can get the date and time in whatever format you want to pass.

Thanks

Sarbjeet Singh

Former Member
0 Kudos

Hi ,

To get Time

Calendar cal = new GregorianCalendar();

int intHour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..23

int intMin = cal.get(Calendar.MINUTE); // 0..59

int intSec = cal.get(Calendar.SECOND); // 0..59

String strTime = intHour24":"intMin":"intSec;

input.set<time>(strTime)

To Get Date

input.set<date>(new Date(System.currentTimeMillis()) ,

Sunitha

Former Member
0 Kudos

Hi Sunitha,

I am able to get the date and time as a string. But the backend table has data type as DATS and TIMS.

So i will not be able to pass string value to the BAPI. Data type has to DATE and TIME.

Regards,

Madhu.

former_member185879
Active Contributor
0 Kudos

Hello Madhu,

wdContext.currentInputElement().setDate(new Date(System.currentTimeMillis()));

wdContext.currentInputElement().setTime(new Time(System.currentTimeMillis()));

I hope above code will help.

Regards

Nizamudeen SM