cancel
Showing results for 
Search instead for 
Did you mean: 

bar chart in abap web dynpro

Former Member
0 Kudos

Hi,

I have some data which i need to show in bar chart when I click a button.

So, can you guide me the procedure to do so.

Thanks and Regards

Tenzin

Accepted Solutions (1)

Accepted Solutions (1)

saket_abhyankar
Active Participant
0 Kudos

To display graph in popup -

1) Embed 'BusinessGraphicsUIElement' in the view

2) Embed this view in a window

3) Write logic to fetch data for graph in this view

4) Write following code to open this window in the event of button click

data: l_window_manager type ref to if_wd_window_manager,

window type ref to if_wd_window,

api_component type ref to if_wd_component.

api_component = wd_comp_controller->wd_get_api( ).

l_window_manager = api_component->get_window_manager( ).

  • Create window and pass parameters

call method l_window_manager->create_window

exporting

modal = abap_true

window_name = 'W_ABC'

title = 'ABC'

close_button = abap_true

receiving

window = wd_comp_controller->z_window.

wd_comp_controller->z_window->open( ).

*z_window is an public attribute of type IF_WD_WINDOW declared in Componentcontroller

Former Member
0 Kudos

Hi,

I created z_window but its telling data unknown in the code. though i have already activated the component controller.. and can you tell me how do i pass the values to that view... can i pass the data context from one view?

Regards

Tenzin

arjun_thakur
Active Contributor
0 Kudos

Tenzin,

You can pass data in the context from one view to another via component controller. Just map that node to component controller and then map it to the pop up view.

Regards

Arjun

saket_abhyankar
Active Participant
0 Kudos

Declare 'z_window' as publicin componentcontroller (tick both checkboxes).

To pass the data,

1) create a node in componentcontroller

2) map it with both the views

3) collect data in the internal table

4) using bind_table( ) method, bind data to the node

5) map this node Graph UI element

step 3 & 4 can be implemented in any view (i.e. either main view or popup view)

Former Member
0 Kudos

Hi Arjun,

From view can we map the context node to the component controller ?

Regards

Tenzin

arjun_thakur
Active Contributor
0 Kudos

Tenzin,

No, we can't do that. You have two ways two ways to do it.

- Create a node in your component controller and drag and drop it over the context of view controller. This way both the nodes will be mapped

or

- Create a node in component controller and then go the view controller, create a similar node with similar attributes (same as in component controller). Right click on it, select 'define mapping' and then select the node in the component controller. This will map the two node.

Regards

Arjun

Former Member
0 Kudos

Hi,

I have created the node in component controller and mapped to both the views. then i am passing the data to the context node of the view which is calling the chart view. to the chart view i have created the business graphics element and binded with the context node, but i am not getting the chart...

1) is it necessary to bind only to table or wat.

2) while refering to the context node in the view, how do i refer it, as the current node which is mapped to the current node or do i need to refer to the componenent controller? can u give me a demo code as to how to refer to the component controller so that data is reflected from both the views.

thanks and regards

Tenzin

arjun_thakur
Active Contributor
0 Kudos

Hi Tenzin,

while refering to the context node in the view, how do i refer it, as the current node which is mapped to the current node or do i need to refer to the componenent controller? can u give me a demo code as to how to refer to the component controller so that data is reflected from both the views.

I am not sure what exactly you are trying to ask here, but if you want to refer a node in any view which is mapped to component controller, simply read that node with the help of code wizard. If both the nodes are mapped then they'll contain same data at all time. You cannot refer to any node present in the component controller from view controller without mapping them. If you want to refer to any node in component controller, simply map it in the view and then just read it.

I hope it helps.

Regards,

Arjun

arjun_thakur
Active Contributor
0 Kudos

Tenzin,

Put a break poiint on the supply function used for getting the chart data and check if the internal table (which is binded to the node) contain any data.

Regards

Arjun

saket_abhyankar
Active Participant
0 Kudos

Hi Tenzin,

If you create node in component controller, map it with view controllers (suppose there are 2 views in the application) in the application & binds data in any of the view to the context of that view, then that data becomes available everywhere i.e. 2 view controllers & 1 componentcontrollers.

steps:

1) create node cn_abc in component controller

2) map it with contexts of the 2 views

3) collect data in the internal table of type context node

4) using following code in method of any view, bind the data to the context of that view. Then the collected data will be available in all the 3 contexts

DATA lo_nd_cn_abc TYPE REF TO if_wd_context_node.

DATA lo_el_cn_abc TYPE REF TO if_wd_context_element.

DATA ls_cn_alv TYPE wd_this->element_cn_alv.

  • navigate from <CONTEXT> to <CN_ALV> via lead selection

lo_nd_cn_abc = wd_context->get_child_node( name = wd_this->wdctx_cn_abc ).

  • collect data in t_abc table

lo_nd_cn_abc->bind_table( t_abc ).

Convert the data in string format,

I hope you have followed all the remianing steps correctly.

Regards,

Saket.

Former Member
0 Kudos

Hi,

I got the chart now, My doubt at present is i need one static line of text to be displayed below the chart,

ie.. 'all cost are in $'

how do i do it ?

Regards

Tenzin

arjun_thakur
Active Contributor
0 Kudos

Tenzin,

Right click on the business graphics UI element and go to edit customizing. then from the overview list select title or sub-title. Set its postion as bottom and give text in the caption field.

Regards

Arjun

saket_abhyankar
Active Participant
0 Kudos

Hi Tenzin,

If you doesnt find any solution, simple option is to use a textview ui element at the bottom of graph & put text value as per your requirement

Regards,

Saket.

kai_gutenkunst
Active Contributor
0 Kudos

Hi,

If you want to have this text displayed as part of the image then simply enter it as the Caption of the Title (or Subtitle).

I.e. when editing the chart in the chart designer click on the Title node, enter the text in the Caption property and set the Alignment propery to South for changing its position.

Regards, Kai

Answers (1)

Answers (1)

arjun_thakur
Active Contributor
0 Kudos

Hi Tenzin,

You can use business graphics UI element. Refer this article for for help: https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/ca932ebc-0901-0010-68a0-b4dd81a4...

Regards

Arjun

Former Member
0 Kudos

Hi Arjun,

I tried the link which you gave, but I am not able to open it... and one more doubt is how do i create the bar charts graphics in a different popup when i will press the button.

Thanks and Regards

Tenzin

arjun_thakur
Active Contributor
0 Kudos

Hi Tenzin,

Try searching 'How to Create Business Graphics in Web Dynpro for ABAP' in SDN, you'll get the required document.

how do i create the bar charts graphics in a different popup when i will press the button

In the pop up view, insert the business graphics UI element, write the code for it. On action of the button, generate the pop up window with the help of code wizard.

Regards

Arjun