on 05-09-2008 5:59 AM
Hi all,
I have an Adaptive RFC application which fetches the data from the R/3 and displays the Employee's Personal Data.
I am using a ZFM which is customised as per the requirement from the Standard BAPI_EMPLOYEE_GETDATA.
Now the Problem i am facing is Date is default and Optional Parameter in RFC.
If i execute the RFC in R/3 without Date it is not filling the Internal Tables. And if i pass the Date it is filling the Internal Table and fetches the Records.
So in WD application i am inputing Employee FirstName, LastName or the Employee ID.
User can give any of the above input or combination of FirstName and LastName Or only the Employee ID.
Now the Main Problem is of Date which is of type Date.
I have also tried the SimpleDateFormat Class, but i am not able to achieve the result.
I have also seen the Links and threads on SDN, but unable to solve the problem.
So pls help me out asap.
Thanks & Regards,
Dhruv Shah
Hi,
Can anybody help me out?
Thanks & Regards,
Dhruv Shah
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
By default , RFC accept date format of SQL date (yyyy-mm-dd) . If you are using a date picker from WD, it directly set the date in SQL date format. Incase if you are trying to pass date to RFC in some other way you have to convert that into SQL date format before passing.
if you are passing String date of format dd-mm-yyyy , you try this method to convert that to SQL date and pass to your RFC.
**************************************************************************************************************
public java.sql.Date sqlDateConvert( String date) {
//@@begin sqlDateConvert()
java.sql.Date dateObj=null;
try{
StringTokenizer tempStringTokenizer = new StringTokenizer(""+date,"-"); int dd=Integer.parseInt(tempStringTokenizer.nextToken().trim());
int mm=Integer.parseInt(tempStringTokenizer.nextToken().trim());
mm=mm-1;
int yyyy=Integer.parseInt(tempStringTokenizer.nextToken().trim());
Calendar cal =Calendar.getInstance();
cal.set(yyyy,mm,dd);
dateObj = new java.sql.Date( cal.getTime().getTime());
}catch(Exception e)
{
}
return dateObj;
}
****************************************************************************************************************
Hope this will help you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Go to Dictionary, find the date in the model dictionary and make an attribute of that type.
nikhiL
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dhruv,
did you tried sql.date...?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI,
I am using the context variable of type type
com.ani.wd.model.types.Datum
and in RFC its Date.
My code is :
Date currdate = new Date(System.currentTimeMillis());
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
String out_date = formatter.format(currdate);
Zbapi_Employee_Getdata_Com_New_Input inp = new Zbapi_Employee_Getdata_Com_New_Input();
wdContext.nodeZbapi_Employee_Getdata_Com_New_Input().bind(inp);
inp.setFstname_M(wdContext.currentZbapi_Employee_Getdata_Com_New_InputElement().getFstname_M());
inp.setLastname_M(wdContext.currentZbapi_Employee_Getdata_Com_New_InputElement().getLastname_M());
inp.setEmployee_Id(wdContext.currentZbapi_Employee_Getdata_Com_New_InputElement().getEmployee_Id());
inp.setDate(out_date);
but now i amgetting error cannot convert String to Date.
Thanks & Regards,
Dhruv Shah
Hi Manoj,
Following is my code:
Also in R/3 the date format is dd.MM.yyyy
Date currdate = new Date(System.currentTimeMillis());
SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy");
String out_date = formatter.format(currdate);
Zbapi_Employee_Getdata_Com_New_Input inp = new Zbapi_Employee_Getdata_Com_New_Input();
wdContext.nodeZbapi_Employee_Getdata_Com_New_Input().bind(inp);
inp.setFstname_M(wdContext.currentZbapi_Employee_Getdata_Com_New_InputElement().getFstname_M());
inp.setLastname_M(wdContext.currentZbapi_Employee_Getdata_Com_New_InputElement().getLastname_M());
inp.setEmployee_Id(wdContext.currentZbapi_Employee_Getdata_Com_New_InputElement().getEmployee_Id());
// inp.setDate(out_date);
wdContext.currentContextElement().setIn_Date(out_date);
Thanks & Regards,
Dhruv Shah
Hi,
Ok. Now what is the problem. What i mean to say in my previous reply is that the variable out_date is a String and as you said that the attribute in RFC accepts Date.
Then how can you set the attribute which accepts Date with a String.
What type of parameter does inp.setDate() takes?
thanks & regards,
Manoj
Hi Dhruv,
Try this ways:
Create a context attribute say "JoiningDate" of type "com.ani.wd.model.types.Datum" and bind it to the input field.
While passing the date to back end get the value from input field and set it to the input field.
Zbapi_Employee_Getdata_Com_New_Input inp = new Zbapi_Employee_Getdata_Com_New_Input();
inp.setEmployee_Id(wdContext.currentContextElement().getJoiningDate());
Thanks n Regards,
Jhansi Miryala
Hi,
There is something seriously wrong somewhere. As you said that In_Date is a value attribute of type Date. And out_date is a String then if you use the code:
wdContext.currentContextElement().setIn_Date(out_date);
it will give the error at the compile time only. No idea how you are getting through this line.
thanks & regards,
Manoj
Hi Dhruv,
Try following:
Date currdate = new Date(System.currentTimeMillis());
Zbapi_Employee_Getdata_Com_New_Input inp = new Zbapi_Employee_Getdata_Com_New_Input();
wdContext.nodeZbapi_Employee_Getdata_Com_New_Input().bind(inp);
inp.setFstname_M(wdContext.currentZbapi_Employee_Getdata_Com_New_InputElement().getFstname_M());
inp.setLastname_M(wdContext.currentZbapi_Employee_Getdata_Com_New_InputElement().getLastname_M());
inp.setEmployee_Id(wdContext.currentZbapi_Employee_Getdata_Com_New_InputElement().getEmployee_Id());
inp.setDate(currdate);
Regards,
Gopal
HI Gopal,
As you said:
you don't have to care any thing about the formatting of the date. Automatically you will see in ABAP table date values in dd.mm.yyyy format.
My problem is that in WD its returning as String but i want it as Date.
Also if i am taking as Date then i have then again prblem for the Format.
I want dd.MM.yyyy format.
Thanks & REgards,
Dhruv Shah
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.