cancel
Showing results for 
Search instead for 
Did you mean: 

Calculator

Former Member
0 Kudos

Hi Community,

I need the possibility of a calculator while the user works on the site. How can I implement a calculator within a WD ?

Did you ever have such a similar req?

Thx in advance for your efforts

Reagrds

ilhan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

the question is solved for me, because there is no solution existing inside wd to implement a

calculator.

I'd like learn Flash Iceland but unfortunately I am very bussy.

The colleague gets the 10 points because he responded briefly.

Regards

ertas

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> the question is solved for me, because there is no solution existing inside wd to implement a

> calculator.

>

>

> I'd like learn Flash Iceland but unfortunately I am very bussy.

> The colleague gets the 10 points because he responded briefly.

>

> Regards

> ertas

Perhaps you gave up to easily. You say there is no solution within WD to implement a calculator, yet no one said that. We said that there was a solution in classic dynpro. It is used in the travel and expense management transaction. Here is a screen shot:

http://www.flickr.com/photos/tjung/3488066649/

The fact that it exists in classic dynpro seemed to me like you should be able to replicate the same thing in Web Dypnro ABAP. I took a few minutes and was able to recreate the funtionality as a freely programmed value help in WDA:

http://www.flickr.com/photos/tjung/3488066657/in/photostream/

Former Member
0 Kudos

Hi Thomas,

it looks greeat. How can I get more information. I mean in order to replicate the same thing in Web Dypnro ABAP

Regards

ilhan

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

I used a freely programmed value help. You can read more on that topic in general here:

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/9ef8cc9b5e3c5ce10000000a421937/frameset.htm

There are also some samples in the sytem you can study.

Your component that will implement the value help gets an interface and method that gets called by the value help framework on initialization. I wanted to be able to support a variety of source data types so I use this method to inspect the data type of the source attribute and to generate a local attribute matching this. I've got a dummy check for data type as a place holder right now, but it needs to be expanded:

METHOD set_value_help_listener .

  wd_this->value_help_listener = listener.

****Check the data type of the source field - it must be a date data type.
  IF wd_this->value_help_listener->f4_attribute_info-rtti->type_kind NE cl_abap_typedescr=>typekind_numeric.
  ENDIF.

  DATA lo_nd_calculator TYPE REF TO if_wd_context_node.
  DATA lo_el_calculator TYPE REF TO if_wd_context_element.
  data dyn_node_info type ref to if_wd_context_node_info.
* navigate from <CONTEXT> to <CALCULATOR> via lead selection
  lo_nd_calculator = wd_context->get_child_node( name = wd_this->wdctx_calculator ).
  dyn_node_info = lo_nd_calculator->get_node_info( ).
  dyn_node_info->add_attribute( wd_this->value_help_listener->f4_attribute_info ).


ENDMETHOD.

You can then layout the user interface in the view pretty much like normal - expect for the inputField. That I had to dynamically generate because the context attribute was dynamic. You can do that in the WDDOMODIFYVIEW of the view:

method WDDOMODIFYVIEW .
  data lo_tc type ref to cl_wd_transparent_container.
  data lo_inputfield type ref to cl_wd_input_field.
  if first_time = abap_true.
    lo_tc ?= view->get_element( 'TC_INPUTFIELD' ).
    data l_binding_string type string.
    CONCATENATE `CALCULATOR.` WD_COMP_CONTROLLER->value_help_listener->f4_attribute_info-name
      into l_binding_string.
    lo_inputfield = cl_wd_input_field=>new_input_field(
         bind_value             = l_binding_string
         enabled                = abap_true
         id                     = 'VH_INPUT'
*        length                 = '20'
         read_only              = abap_true
         view                   = view
*        visible                = E_VISIBLE-VISIBLE
*        width                  = width
    ).
    data flow type ref to CL_WD_FLOW_DATA.
    flow = CL_WD_FLOW_DATA=>new_flow_data(
*        cell_design = E_CELL_DESIGN-PADLESS    " CELL_DESIGN
        element     = lo_inputfield
        id          = 'FLOW_ID'
*        v_gutter    = E_V_GUTTER-NONE    " V_GUTTER
    ).

    lo_inputfield->set_layout_data( flow ).

    lo_tc->add_child( lo_inputfield ).
  endif.

endmethod.

I map all the buttons to the same event handler. When a numberic button is pressed it has to append the value to the current displayed value. Also this is where you would implement the memory and actual calculation functions. Since I was just prototyping I only implemented one button, but that is enough to prove how it works. Now it just needs some time to expand this logic to support all the buttons:

METHOD onactiononbuttonpress .
  DATA lo_nd_calculator TYPE REF TO if_wd_context_node.
  DATA lo_el_calculator TYPE REF TO if_wd_context_element.
  lo_nd_calculator = wd_context->get_child_node( name = wd_this->wdctx_calculator ).
  lo_el_calculator = lo_nd_calculator->get_element( ).
  data lr_value type ref to data.
  lr_value = lo_el_calculator->get_attribute_ref( WD_COMP_CONTROLLER->value_help_listener->f4_attribute_info-name ).
  FIELD-SYMBOLS <wa_numeric> type numeric.
  ASSIGN lr_value->* to <wa_numeric>.
  data l_string type c LENGTH 60.
  CASE id.
    WHEN 'BTN_7'.
      move <wa_numeric> to l_string.
      CONCATENATE l_string `7` into l_string. CONDENSE l_string NO-GAPS.
      <wa_numeric> = l_string.
      lo_el_calculator->set_attribute(
        EXPORTING
          value = <wa_numeric>
          name  = WD_COMP_CONTROLLER->value_help_listener->f4_attribute_info-name ).

  ENDCASE.
ENDMETHOD.

I tested this with integers, but it might need some additional logic on the concatenation if it supports Float (exponent notation).

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Thomas,

because of this line the program is dumping

CONCATENATE `CALCULATOR.` WD_COMP_CONTROLLER->value_help_listener->f4_attribute_info-name

Furthermore

in your example with the calculator you have the action method

METHOD onactiononbuttonpress

Is it necessary to insert a button in order to pass him this method. If not

how can I assign this method to any button or something like that

Regards

ertas

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Its dumping on the CONCATENATE itself? What exactly is the message of the dump. I don't really see anything there that should cause a dump.

>Is it necessary to insert a button in order to pass him this method. If not

how can I assign this method to any button or something like that

When you define a button in the layout, you have the onAction property. You can choose an existing event handler method or create a new one to assign to the onAction event property.

Former Member
0 Kudos

Hello,

If someone enters a number then klicks the 'plus' button for addition, enters a number again and clicks

the plus button again he gets the result of this addition.

Now it must be possible contining this additon with entering a new number

to get the new result by klicking on the addition button finally.

This works in my coding not properly as well.

Can someone give a hint me a hint how the implement this requirement.


method onactionpress
* * * * ADDITION * * * * * * * * * * * * * * * * * * * * * * * * *

    WHEN 'BTN_PLUS'.
      WD_COMP_CONTROLLER->OPERATION = 'ADDIT'.

      IF WD_COMP_CONTROLLER->merker EQ 'X' AND NOT WD_COMP_CONTROLLER->firstNr IS INITIAL.
        <wa_numeric> = WD_COMP_CONTROLLER->erg + <wa_numeric>.
        lo_el_calculator->set_attribute(
               EXPORTING
                 value = <wa_numeric>
                 name  = WD_COMP_CONTROLLER->value_help_listener->f4_attribute_info-name ).
        WD_COMP_CONTROLLER->COMP = 'X'.
        clear WD_COMP_CONTROLLER->firstNr.

      ENDIF.


      IF WD_COMP_CONTROLLER->firstNr IS INITIAL.
        WD_COMP_CONTROLLER->firstNr =   <wa_numeric>.
      ENDIF.

      IF WD_COMP_CONTROLLER->merker IS INITIAL.
        WD_COMP_CONTROLLER->merker = 'X'.
        CLEAR  l_string .
        CLEAR <wa_numeric>.
        lo_el_calculator->set_attribute(
               EXPORTING
                 value = <wa_numeric>
                 name  = WD_COMP_CONTROLLER->value_help_listener->f4_attribute_info-name ).
      ENDIF.
endmethod.

Former Member
0 Kudos

hi Thomas,

how must the method set_value_help_listener be implemented and where.

When do you call this method ?

I would be glad if you could help me in this matter.

Regards

ertas

Former Member
0 Kudos

hi,

Refer this :

The SET_VALUE_HELP_LISTENER method for the interface controller of IWD_VALUE_HELP can be called only by Web Dynpro Framework. The framework uses this method to pass a callback interface to the input help component. The input help component can use this interface to tell the framework that it is to be closed, for example, if data has been selected, if Cancel has been pressed, or if an error has occurred. This interface contains the two attributes F4_CONTEXT_ELEMENT and F4_ATTRIBUTE_INFO as well.

Above extract is taken from SAP Online help :

http://help.sap.com/saphelp_nw70ehp1/helpdata/en/47/9ef8cc9b5e3c5ce10000000a421937/frameset.htm

I would suggest you to implement Freely programme Value help. That would help you in understanding more clearly the code given by Thomas.

Refer Standard component : Demp_value_help for that.

Thanx.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

As a normal part of building a freely programmed value help, you need add the interface IWD_VALUE_HELP to your component. This will add the method SET_VALUE_HELP_LISTENER to your component controller for you. The method is called by the framework, not by you.

Former Member
0 Kudos

Thomas thank you many times. Indeed I gave up easly.

how did you defined listener ?

METHOD set_value_help_listener .
   wd_this->value_help_listener = listener.

I will spent some time on it before saying anythhing. You will hear very soon a feedback

after having implemented the calulator (hopefully)

Regards

ertas ilhan

Edited by: Ilhan Ertas on Apr 30, 2009 5:01 PM

Former Member
0 Kudos

Hi,

Try to implement standard value help for OVS.

When you use the standard OVS you will get the value help listeners.

Please check out the example - DEMO_VALUE_HELP

Check out this examples -

/people/shruti.rathour/blog/2008/05/05/ovs-help-in-web-dynpro-abap

http://help.sap.com/saphelp_nw04s/helpdata/en/47/9ef8c99b5e3c5ce10000000a421937/frameset.htm

Regards,

Lekha.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

Value help listener is type IF_WD_VALUE_HELP_LISTENER. The data type is shown as an importing parameter of the interface method SET_VALUE_HELP_LISTENER.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hi,

>

> Try to implement standard value help for OVS.

> When you use the standard OVS you will get the value help listeners.

>

>

> Please check out the example - DEMO_VALUE_HELP

> Check out this examples -

> /people/shruti.rathour/blog/2008/05/05/ovs-help-in-web-dynpro-abap

>

> http://help.sap.com/saphelp_nw04s/helpdata/en/47/9ef8c99b5e3c5ce10000000a421937/frameset.htm

>

>

>

>

> Regards,

> Lekha.

I disagree with your assesment that OVS applies here. With the design required to create a calculator and the custom logic needed, OVS simply won't meet those needs. I stand by my recommendation that Freely Programmed Value Help is necessarily in this case.

Former Member
0 Kudos

Hi Thomas,

I have searched and couldn't find the mentioned calculator value help .

Where can I find it ? Please help.

Regards

ertas ilhan

former_member40425
Contributor
0 Kudos

Hi,

It is available in classic dynpro not in webdynpro.

Regards,

Rohit

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You marked the question as solved. Have you actually found a solution? Just curious, which way did you decide to go?

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

There is a calculator value help implemented in classic dynpro. It doesn't seem like it would be that difficult to replicate such a design in Web Dynpro. The drawback would be that you would need a server round trip every time a button is pressed. This wound't make for the most responsive calculator UI. For a more client side calculator, I would agree with the earlier suggestion of using FlashIslands if you are on NetWeaver 7.0 EnhP 1.

Former Member
0 Kudos

has somebody never implemented yet such a req

Former Member
0 Kudos

Hi,

One thing you can do is, if there is any calculatore Application/Exe file you can use it the same in WD.

This you can do rather desiging the calculator in WD.

Regards,

Lekha.

Former Member
0 Kudos

Hi,

This is a peculiar requirement. usually the WDA is not ment for this type of requirement.

It's mainly used for implmenting the business logic for large companies.

You can still achieve this.......using table control with each cell as the Button, but the layout should be well designed.

You can stil acheive this active Xcontrol for this using FlashIslands UI element.

Regards,

Lekha.