xtt->MERGE( IV_BLOCK_NAME = ‘R’ IS_BLOCK =
{"A"=>{"LEVEL"=>0, "SUB_NODES"=>[{"NAME"=>"GRP A", "ATTR"=>{"LEVEL"=>1, "SUB_NODES"=>[{"NAME"=>"0 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP A", "CAPTION"=>"<Caption 1 />", "DATE"=>"2020-10-21", "SUM1"=>5971.44, "SUM2"=>5021.46}}}, {"NAME"=>"1 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP A", "CAPTION"=>"<Caption 4 />", "DATE"=>"2020-10-21", "SUM1"=>9476.79, "SUM2"=>3683.27}}}, {"NAME"=>"2 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP A", "CAPTION"=>"<Caption 5 />", "DATE"=>"2020-10-21", "SUM1"=>4604.0, "SUM2"=>5525.85}}}, {"NAME"=>"3 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP A", "CAPTION"=>"<Caption 8 />", "DATE"=>"2020-10-21", "SUM1"=>5476.81, "SUM2"=>406.18}}}], "DATA"=>{"GROUP"=>"GRP A", "CAPTION"=>"", "DATE"=>"0000-00-00", "SUM1"=>51058.08, "SUM2"=>29273.52}}}, {"NAME"=>"GRP C", "ATTR"=>{"LEVEL"=>1, "SUB_NODES"=>[{"NAME"=>"0 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP C", "CAPTION"=>"<Caption 2 />", "DATE"=>"2020-10-19", "SUM1"=>2276.75, "SUM2"=>7717.2}}}, {"NAME"=>"1 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP C", "CAPTION"=>"<Caption 6 />", "DATE"=>"2020-10-19", "SUM1"=>2159.71, "SUM2"=>2260.94}}}, {"NAME"=>"2 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP C", "CAPTION"=>"<Caption 10 />", "DATE"=>"2020-10-19", "SUM1"=>5451.87, "SUM2"=>4061.85}}}, {"NAME"=>"3 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP C", "CAPTION"=>"<Caption 12 />", "DATE"=>"2020-10-19", "SUM1"=>1196.35, "SUM2"=>522.46}}}, {"NAME"=>"4 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP C", "CAPTION"=>"<Caption 13 />", "DATE"=>"2020-10-19", "SUM1"=>7686.95, "SUM2"=>2727.98}}}], "DATA"=>{"GROUP"=>"GRP C", "CAPTION"=>"", "DATE"=>"0000-00-00", "SUM1"=>37543.26, "SUM2"=>34580.86}}}, {"NAME"=>"GRP B", "ATTR"=>{"LEVEL"=>1, "SUB_NODES"=>[{"NAME"=>"0 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP B", "CAPTION"=>"<Caption 3 />", "DATE"=>"2020-10-20", "SUM1"=>3031.38, "SUM2"=>445.22}}}, {"NAME"=>"1 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP B", "CAPTION"=>"<Caption 7 />", "DATE"=>"2020-10-20", "SUM1"=>2490.3, "SUM2"=>6388.81}}}], "DATA"=>{"GROUP"=>"GRP B", "CAPTION"=>"", "DATE"=>"0000-00-00", "SUM1"=>11043.36, "SUM2"=>13668.06}}}, {"NAME"=>"GRP D", "ATTR"=>{"LEVEL"=>1, "SUB_NODES"=>[{"NAME"=>"0 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP D", "CAPTION"=>"<Caption 9 />", "DATE"=>"2020-10-18", "SUM1"=>689.66, "SUM2"=>518.6}}}, {"NAME"=>"1 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP D", "CAPTION"=>"<Caption 11 />", "DATE"=>"2020-10-18", "SUM1"=>4573.55, "SUM2"=>5436.0}}}, {"NAME"=>"2 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP D", "CAPTION"=>"<Caption 14 />", "DATE"=>"2020-10-18", "SUM1"=>978.18, "SUM2"=>295.55}}}, {"NAME"=>"3 ", "ATTR"=>{"LEVEL"=>2, "SUB_NODES"=>[], "DATA"=>{"GROUP"=>"GRP D", "CAPTION"=>"<Caption 15 />", "DATE"=>"2020-10-18", "SUM1"=>71.12, "SUM2"=>8878.56}}}], "DATA"=>{"GROUP"=>"GRP D", "CAPTION"=>"", "DATE"=>"0000-00-00", "SUM1"=>12625.02, "SUM2"=>30257.42}}}], "DATA"=>{"GROUP"=>"GRP A", "CAPTION"=>"", "DATE"=>"0000-00-00", "SUM1"=>168404.58, "SUM2"=>161669.79}}, "T"=>[{"GROUP"=>"GRP A", "CAPTION"=>"<Caption 1 />", "DATE"=>"2020-10-21", "SUM1"=>5971.44, "SUM2"=>5021.46}, {"GROUP"=>"GRP C", "CAPTION"=>"<Caption 2 />", "DATE"=>"2020-10-19", "SUM1"=>2276.75, "SUM2"=>7717.2}, {"GROUP"=>"GRP B", "CAPTION"=>"<Caption 3 />", "DATE"=>"2020-10-20", "SUM1"=>3031.38, "SUM2"=>445.22}, {"GROUP"=>"GRP A", "CAPTION"=>"<Caption 4 />", "DATE"=>"2020-10-21", "SUM1"=>9476.79, "SUM2"=>3683.27}, {"GROUP"=>"GRP A", "CAPTION"=>"<Caption 5 />", "DATE"=>"2020-10-21", "SUM1"=>4604.0, "SUM2"=>5525.85}, {"GROUP"=>"GRP C", "CAPTION"=>"<Caption 6 />", "DATE"=>"2020-10-19", "SUM1"=>2159.71, "SUM2"=>2260.94}, {"GROUP"=>"GRP B", "CAPTION"=>"<Caption 7 />", "DATE"=>"2020-10-20", "SUM1"=>2490.3, "SUM2"=>6388.81}, {"GROUP"=>"GRP A", "CAPTION"=>"<Caption 8 />", "DATE"=>"2020-10-21", "SUM1"=>5476.81, "SUM2"=>406.18}, {"GROUP"=>"GRP D", "CAPTION"=>"<Caption 9 />", "DATE"=>"2020-10-18", "SUM1"=>689.66, "SUM2"=>518.6}, {"GROUP"=>"GRP C", "CAPTION"=>"<Caption 10 />", "DATE"=>"2020-10-19", "SUM1"=>5451.87, "SUM2"=>4061.85}, {"GROUP"=>"GRP D", "CAPTION"=>"<Caption 11 />", "DATE"=>"2020-10-18", "SUM1"=>4573.55, "SUM2"=>5436.0}, {"GROUP"=>"GRP C", "CAPTION"=>"<Caption 12 />", "DATE"=>"2020-10-19", "SUM1"=>1196.35, "SUM2"=>522.46}, {"GROUP"=>"GRP C", "CAPTION"=>"<Caption 13 />", "DATE"=>"2020-10-19", "SUM1"=>7686.95, "SUM2"=>2727.98}, {"GROUP"=>"GRP D", "CAPTION"=>"<Caption 14 />", "DATE"=>"2020-10-18", "SUM1"=>978.18, "SUM2"=>295.55}, {"GROUP"=>"GRP D", "CAPTION"=>"<Caption 15 />", "DATE"=>"2020-10-18", "SUM1"=>71.12, "SUM2"=>8878.56}]}
).
Все таблицы и деревья в вашем шаблоне могут быть реплицированы как по строкам так и столбцам.
Данная возможность работает только для класса ZCL_XTT_EXCEL_XLSX
и 2 типов файлов (xlsx и xlsm).
Для этого в любом месте вашего шаблона просто добавьте специальный маркер {;direction=column} для таблицы или дерева.
Код ABAP аналогичен Пример №05
SET HANDLER on_prepare_tree_05 ACTIVATION abap_true.
GET REFERENCE OF lt_rows INTO lr_table.
ls_root-a = zcl_xtt_replace_block=>tree_create(
it_table = lr_table " from 7.5 REF #(lt_rows)
iv_fields = 'GROUP' ). " Name of the fields delimited by ;
SET HANDLER on_prepare_tree_05 ACTIVATION abap_false.
Основное отличие в самом шаблоне.
- Таблица
- Дерево
Результат будет выглядеть следующим образом:
- Таблица
- Дерево
Смещение данных
Если результат в отчете съехал вниз добавьте непустые ячейки слева от столбца с шаблоном.
Обратите внимание на I stay here