14.01.2020 Views

ABAP_to_the_Future

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Enhancing Custom Reports with ABAP2XLSX 11.2

Another object, LO_ELEMENT_2, is going to be a child node of the <conditional_

formatting> node; LO_ELEMENT_2 represents the node that starts and ends with

<cfRule>. This is turn has another child node, the node that starts and ends with

<formula>, and in the code this is represented by LO_ELEMENT_3.

Inside each element, add the values to match the example generated code. For

example, inside the formula node, dynamically add the string that looks like

LEFT(G6LEN("1"))-"1". Likewise, inside the rule node, add the type="begins

with" and text="1" strings by calling the SET_ATTRIBUTE_NS method.

Finally, at the end of Listing 11.18, the child node for the formula is linked to its

parent by calling the APPEND_CHILD method.

*---------------------------------------------------------------*

* Begin of Insertion PDH

*---------------------------------------------------------------*

* -<conditionalFormatting sqref="G6:G12">-

* <cfRule operator="beginsWith" priority="4" dxfId="4"

type="beginsWith" text="1">

* <formula>LEFT(G6,LEN("1"))="1"</formula>

* </cfRule>

* </conditionalFormatting>

*---------------------------------------------------------------*

WHEN zcl_excel_style_conditional=>c_operator_beginswith.

ls_cellis = lo_style_conditional->mode_cellis.

READ TABLE me->styles_cond_mapping INTO ls_style_cond_mapping

WITH KEY guid = ls_cellis-cell_style.

lv_value = ls_style_cond_mapping-dxf.

CONDENSE lv_value.

"Element 2 = <cfRule> node

lo_element_2->set_attribute_ns( name = lc_xml_attr_dxfid

value = lv_value ).

lv_value = ls_cellis-operator.”Begins With

lo_element_2->set_attribute_ns( name = lc_xml_attr_operator

value = lv_value ).

lv_value = ls_cellis-formula.”The number 1

lo_element_2->set_attribute_ns( name = 'text'

value = lv_value ).

"Element 3 = <Formula> Node

lo_element_3 = lo_document->create_simple_element(

name = lc_xml_node_formula

parent = lo_document ).

lv_value = lo_style_conditional->get_dimension_range( ) .

SPLIT lv_value AT ':' INTO ld_first_half ld_second_half.

lv_value = 'LEFT(' && ld_first_half && ',LEN("'

&& ls_cellis-formula && '"))="'

479

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!