on 09-22-2010 8:02 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.