cancel
Showing results for 
Search instead for 
Did you mean: 

Hard coding required to be done

Former Member
0 Kudos

Hi All,

I have created simple Web Dynpro program. In this Web Dynpro program, I have imported Model and provided connectivity with R/3 using RFC. For some testing purpose, I have to do some hard coding for some of the fields of Web Dynpro form. For example there is one field in form called Emp No. I have to pass Emp No as 1001. Can you please let me know in order to do so where we have to write the code. I believe it will be in the "wdDoInit" of implementation tab of View. Pls let me know if it is correct. Also what should be the code. I have created context nodes, component controller as per the standard procedure and binded them.

Regards,

Ravindra

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member189631
Active Contributor
0 Kudos

Hi,

You can hardcode the value for employee number in Your Component Controller,

Init method of your View,The place where you bind your model node or in the Execute Method.

Regards,

Ramganesan K.

Former Member
0 Kudos

just pass 1.544

not as a string, as a bigdecimal

AM

Former Member
0 Kudos

Hi Anoop,

Thanks for the help. I tried like that. However it is not working.

Regards,

Ravindra

Former Member
0 Kudos

Hi Anoop,

Following code is working fine:

wdContext.currentPritemElement().setPreq_Price( new BigDecimal (1.98));

Regards,

Gaurav

Former Member
0 Kudos

Hai,

wdContext.currentPritemElement().setPreq_Price(new BigDecimal("1.544"));

regards,

Naga

Former Member
0 Kudos

Thanks Naga,

This is the solution.

Regards,

Ravindra

Former Member
0 Kudos

hi,

if you want to set the input form with 1001, then ,

lets say you bind the input field with the context attribute EmpNo,

then wdContext.currentContextelement().setEmpNo("1001");

or if you want to execute the RFC then put 1001 as the import parameter of the RFC

AM

Former Member
0 Kudos

Hi Ravindra,

You can hard code those values in the init() of Component Controlelr or in your execute method. The code looks something like this:

wdContext.current<Bapiname_Input>Element.setEmpNo("1001");

Regards,

Jhansi

Former Member
0 Kudos

Hi Jhansi,

Thanks for prompt reply. I have one question. Can we do the same coding viz wdContext.current<Bapiname_Input>Element.setEmpNo("1001");

in the view and NOT in the component controller.

My point is that in ideal case data flows from view to controller (may be custom controller or component controller) and then to model. So instead of passing value in controller, can't we pass it from view directly. If you can pls clarify then it will be great.

Regards,

Ravindra

Former Member
0 Kudos

Hi Ravindra,

View init() will be invoked for the first time when u launch the application, it is not invoked when u come back from other views or when you do some operations in the view. Component Controlelr init() is invoked everytime when u perform any operation in view and also when you navigate to other views.

For that reason you have to write that code in Component Controlelr inti().

You can write that line of code in the ExecuteRFC method as that is only required at time of RFC execution.

Jhansi

Former Member
0 Kudos

Hi Jhansi,

Thanks for the help.

There is another problem. In the process of execution of the process, I have to write one line like this:

wdContext.currentPritemElement().setPreq_Price("1.544");

This is not getting compiled. The error is "The method setPreq_Price(BigDecimal) in the type IPrivateMyView.IPritemElement not applicable for arguments(string)".

It looks like there is datatype mismatch and due to this we are getting above error. We Can we do some like typecasting etc to sort out the issue. If yes, how we can do so.

Regards,

Ravindra

Former Member
0 Kudos

Hi Ravindra,

Try removing the quotes. You are passing a string and it is expecting the BigDecimal.

Like this:

wdContext.currentPritemElement().setPreq_Price(<b>1.544</b>);

Regards,

Jhansi

Former Member
0 Kudos

Hi Jhansi,

Thanks for the help. I tried like that. However it is not working.

Regards,

Ravindra

Former Member
0 Kudos

Hi Jhansi,

The following code is working fine:

wdContext.currentPritemElement().setPreq_Price( new BigDecimal (1.98));

Regards,

Ravindra