2014 Feb 21 4:55 AM
Hi Genius,
I need to develop a mailer program for 2 y-axis for single X-axis.
The first one is need a bar chat and second one line chart. ( for example refer my chart image given below ).
2014 Feb 21 5:04 AM
Hi Subramani,
You can use the Function Module GFW_PRES_SHOW_MULT to generate Graphs.
You can also use OLE coding.
-Sowmya
2014 Feb 21 5:06 AM
2014 Feb 21 5:11 AM
Here's the sample Program that I have developed using the above document created by Kartik.
This Program displays the Graph in the Spreadsheet.
ABAP Program to display the Graph in Spreadsheet.
*&---------------------------------------------------------------------*
*& Report YGRAPHEXCEL
*&
*&---------------------------------------------------------------------*
*& *& Graph to be displayed in Excel File directly
*&---------------------------------------------------------------------*
REPORT ygraphexcel.
INCLUDE ole2incl.
FIELD-SYMBOLS: <fs> .
CONSTANTS: co_09(2) TYPE n VALUE 09. “Constant value used for Tab Delimiter
DATA: lv_space(1) TYPE c.
TYPES: ty_data1(15000) TYPE c,
ty_data TYPE TABLE OF ty_data1.
DATA:
gt_output TYPE ty_data,
wa_output LIKE LINE OF gt_output,
lv_active TYPE i,
lv_inactive TYPE i.
DATA:
h_excel TYPE ole2_object, " Excel object
h_mapl TYPE ole2_object, " list of workbooks
worksheet TYPE ole2_object, " list of workbooks
workbook TYPE ole2_object,
range TYPE ole2_object,
h_map TYPE ole2_object,
gs_cell1 TYPE ole2_object,
gs_cell2 TYPE ole2_object,
h_chart1 TYPE ole2_object,
ch_title TYPE ole2_object,
gs_font TYPE obj_record,
gs_colour TYPE obj_record,
h_chart TYPE ole2_object, " workbook
h_chart2 TYPE ole2_object,
h_chart_obj TYPE ole2_object,
h_chart_shape TYPE ole2_object,
ch_font TYPE ole2_object,
h_chart3 TYPE ole2_object,
file_name TYPE string.
DATA:
BEGIN OF wa,
object_type(50) TYPE c,
count(50) TYPE c,
END OF wa,
it_report LIKE STANDARD TABLE OF wa.
DATA: lin1 TYPE i.
DATA l_rc TYPE i.
ASSIGN lv_space TO <fs> TYPE 'X'.
<fs> = co_09.
wa-object_type = 'material'.
wa-count = 'count'.
APPEND wa TO it_report.
wa-object_type = 'mobile'.
wa-count = '20'.
APPEND wa TO it_report.
wa-object_type = 'pda'.
wa-count = '30'.
APPEND wa TO it_report.
wa-object_type = 'laptops'.
wa-count = '50'.
APPEND wa TO it_report.
LOOP AT it_report INTO wa.
CONCATENATE wa-object_type
wa-count
INTO wa_output
SEPARATED BY lv_space.
APPEND wa_output TO gt_output.
CLEAR wa_output.
ENDLOOP.
***************** creates an excel application
CREATE OBJECT h_excel 'EXCEL.APPLICATION'.
*Sheet1
CALL METHOD OF
h_excel
'Workbooks' = h_mapl.
SET PROPERTY OF h_excel 'Visible' = 1.
*************** opens a work book
CALL METHOD OF
h_mapl
'Add' = h_map.
*************** gets the current worksheet
GET PROPERTY OF h_excel 'activesheet' = worksheet.
*************** sets the name of the worksheet
SET PROPERTY OF worksheet 'Name' = 'sheetnew'.
*********** pass data to sheet
CALL METHOD OF
worksheet
'Cells' = gs_cell1
EXPORTING
#1 = 1 " starting row of selection
#2 = 1. " starting column of selection
CALL METHOD OF
worksheet
'Cells' = gs_cell2
EXPORTING
#1 = 1 " ending row of selection
#2 = 1. " ending column of selection
CALL METHOD OF
worksheet
'Range' = range
EXPORTING
#1 = gs_cell1
#2 = gs_cell2.
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = gt_output[]
CHANGING
rc = l_rc.
CALL METHOD OF
range
'Select'.
CALL METHOD OF
worksheet
'Paste'.
**************************************
*************** create a chart sheet
CALL METHOD OF
h_excel
'charts' = h_chart.
*************** add a chart of variable h_chart1
*************** opens the initially created sheet
CALL METHOD OF
worksheet
'Select'.
CALL METHOD OF
h_excel
'Cells' = gs_cell1
EXPORTING
#1 = 1 " starting row of selection
#2 = 1. " starting column of selection
CALL METHOD OF
h_excel
'Cells' = gs_cell2
EXPORTING
#1 = 4 " ending row of selection
#2 = 2. " ending column of selection
*************** combine cells to form the range
CALL METHOD OF
h_excel
'Range' = range
EXPORTING
#1 = gs_cell1
#2 = gs_cell2.
*************** sets the chart type
CALL METHOD OF
h_excel
'charts' = h_chart2.
CALL METHOD OF
h_chart2
'add' = h_chart3.
SET PROPERTY OF h_chart3 'charttype' = '65'.
********************************************** title for chart
SET PROPERTY OF h_chart3 'HasTitle' = 1.
GET PROPERTY OF h_chart3 'ChartTitle' = ch_title.
GET PROPERTY OF ch_title 'Characters' = ch_title.
SET PROPERTY OF ch_title 'text' = 'inventory comparison'.
CALL METHOD OF
h_chart3
'ApplyDataLabels'
EXPORTING
#1 = '5'.
****** selects worksheet
CALL METHOD OF
worksheet
'Select'.
CALL METHOD OF
h_excel
'Cells' = gs_cell1
EXPORTING
#1 = 1 " starting row of selection
#2 = 1. " starting column of selection
CALL METHOD OF
h_excel
'Cells' = gs_cell2
EXPORTING
#1 = 1 " ending row of selection
#2 = 2. " ending column of selection
CALL METHOD OF
h_excel
'Range' = range
EXPORTING
#1 = gs_cell1
#2 = gs_cell2.
*********** sets the bold for the header
GET PROPERTY OF range 'Font' = gs_font .
SET PROPERTY OF gs_font 'Bold' = 1 .
FREE OBJECT h_excel.
Regards,
Sowmya
2014 Feb 21 5:13 AM
i have to use below coding...
lo_ixml = cl_ixml=>create( ).
DATA: l_simplechartdata TYPE REF TO if_ixml_element,
l_categories TYPE REF TO if_ixml_element,
l_series TYPE REF TO if_ixml_element,
l_element TYPE REF TO if_ixml_element,
l_encoding TYPE REF TO if_ixml_encoding,
l_globalsettings TYPE REF TO if_ixml_element.
p_ixml_doc = lo_ixml->create_document( ).
l_encoding = lo_ixml->create_encoding(
byte_order = if_ixml_encoding=>co_little_endian
character_set = 'utf-8' ).
p_ixml_doc->set_encoding( l_encoding ).
l_simplechartdata = p_ixml_doc->create_simple_element(
name = 'SimpleChartData' parent = p_ixml_doc ).
l_categories = p_ixml_doc->create_simple_element(
name = 'Categories' parent = l_simplechartdata ).
*Inserting Year text as X-axis ( 01-2012)
DATA: lv_value TYPE string.
LOOP AT gt_tab INTO gs_tab.
lv_value = gs_tab-monyr.
l_element = p_ixml_doc->create_simple_element(
name = 'C' parent = l_categories ). " C means Category " S means Series
l_element->if_ixml_node~set_value( lv_value ).
ENDLOOP.
lv_value1 = 'Expenses'.
l_series = p_ixml_doc->create_simple_element(
name = 'Series' parent = l_simplechartdata ).
l_series->set_attribute( name = 'label' value = lv_value1 ).
LOOP AT gt_final INTO gs_final. " Y Axis values for using graph axis.
CLEAR: lv_value, lv_no.
lv_no = gs_final-valoc.
lv_value = lv_no.
l_element = p_ixml_doc->create_simple_element(
name = 'S' parent = l_series ).
l_element->if_ixml_node~set_value( lv_value ).
CLEAR gs_final.
ENDLOOP.
l_element = p_ixml_doc->create_simple_element(
name = 'ChartType' parent = l_globalsettings value = 'BARS' ).
lv_value1 = 'No of Chassis'.
l_series = p_ixml_doc->create_simple_element(
name = 'Series' parent = l_simplechartdata ).
l_series->set_attribute( name = 'label' value = lv_value1 ).
LOOP AT gt_final INTO gs_final. " Y Axis values for using graph axis.
CLEAR: lv_value, lv_no.
lv_no = gs_final-valoc.
lv_value = lv_no.
l_element = p_ixml_doc->create_simple_element(
name = 'S' parent = l_series ).
l_element->if_ixml_node~set_value( lv_value ).
CLEAR gs_final.
ENDLOOP.
l_element = p_ixml_doc->create_simple_element(
name = 'ChartType' parent = l_globalsettings value = 'Lines' ).
but my output is like this
2014 Feb 21 5:32 AM
Hi sowmy..
ur program creating Excel sheet. then how to develop further..