xtt->MERGE( IV_BLOCK_NAME = ‘R’ IS_BLOCK =
{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"BERLIN", "LANDXTO"=>"Germany", "CARRNAME"=>"Lufthansa", "CONNID"=>"2402", "FLDATE"=>"2023-11-03", "DEPTIME"=>"10:30:00", "ARRTIME"=>"11:35:00", "PRICE"=>242.0, "CURRENCY"=>"EUR", "SEATSMAX"=>475, "SEATSOCC"=>451, "_GROUP1"=>"FRANKFURT-Germany-BERLIN-Germany", "T_COLOR"=>[]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"BERLIN", "LANDXTO"=>"Germany", "CARRNAME"=>"Lufthansa", "CONNID"=>"2402", "FLDATE"=>"2024-01-22", "DEPTIME"=>"10:30:00", "ARRTIME"=>"11:35:00", "PRICE"=>242.0, "CURRENCY"=>"EUR", "SEATSMAX"=>475, "SEATSOCC"=>452, "_GROUP1"=>"FRANKFURT-Germany-BERLIN-Germany", "T_COLOR"=>[]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"BERLIN", "LANDXTO"=>"Germany", "CARRNAME"=>"Lufthansa", "CONNID"=>"2402", "FLDATE"=>"2024-04-11", "DEPTIME"=>"10:30:00", "ARRTIME"=>"11:35:00", "PRICE"=>242.0, "CURRENCY"=>"EUR", "SEATSMAX"=>475, "SEATSOCC"=>461, "_GROUP1"=>"FRANKFURT-Germany-BERLIN-Germany", "T_COLOR"=>[{"FNAME"=>"PRICE", "COLOR"=>{"COL"=>5, "INT"=>"0 ", "INV"=>0}, "NOKEYCOL"=>""}]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"BERLIN", "LANDXTO"=>"Germany", "CARRNAME"=>"Lufthansa", "CONNID"=>"2402", "FLDATE"=>"2024-04-28", "DEPTIME"=>"10:30:00", "ARRTIME"=>"11:35:00", "PRICE"=>242.0, "CURRENCY"=>"EUR", "SEATSMAX"=>475, "SEATSOCC"=>461, "_GROUP1"=>"FRANKFURT-Germany-BERLIN-Germany", "T_COLOR"=>[]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"BERLIN", "LANDXTO"=>"Germany", "CARRNAME"=>"Lufthansa", "CONNID"=>"2402", "FLDATE"=>"2024-05-28", "DEPTIME"=>"10:30:00", "ARRTIME"=>"11:35:00", "PRICE"=>242.0, "CURRENCY"=>"EUR", "SEATSMAX"=>475, "SEATSOCC"=>460, "_GROUP1"=>"FRANKFURT-Germany-BERLIN-Germany", "T_COLOR"=>[{"FNAME"=>"SEATSMAX", "COLOR"=>{"COL"=>6, "INT"=>"0 ", "INV"=>0}, "NOKEYCOL"=>""}]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"BERLIN", "LANDXTO"=>"Germany", "CARRNAME"=>"Lufthansa", "CONNID"=>"2402", "FLDATE"=>"2024-06-30", "DEPTIME"=>"10:30:00", "ARRTIME"=>"11:35:00", "PRICE"=>242.0, "CURRENCY"=>"EUR", "SEATSMAX"=>475, "SEATSOCC"=>459, "_GROUP1"=>"FRANKFURT-Germany-BERLIN-Germany", "T_COLOR"=>[{"FNAME"=>"PRICE", "COLOR"=>{"COL"=>5, "INT"=>"0 ", "INV"=>0}, "NOKEYCOL"=>""}]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"BERLIN", "LANDXTO"=>"Germany", "CARRNAME"=>"Lufthansa", "CONNID"=>"2402", "FLDATE"=>"2024-09-18", "DEPTIME"=>"10:30:00", "ARRTIME"=>"11:35:00", "PRICE"=>242.0, "CURRENCY"=>"EUR", "SEATSMAX"=>475, "SEATSOCC"=>189, "_GROUP1"=>"FRANKFURT-Germany-BERLIN-Germany", "T_COLOR"=>[{"FNAME"=>"SEATSMAX", "COLOR"=>{"COL"=>3, "INT"=>"0 ", "INV"=>0}, "NOKEYCOL"=>""}]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"BERLIN", "LANDXTO"=>"Germany", "CARRNAME"=>"Lufthansa", "CONNID"=>"2402", "FLDATE"=>"2024-12-07", "DEPTIME"=>"10:30:00", "ARRTIME"=>"11:35:00", "PRICE"=>242.0, "CURRENCY"=>"EUR", "SEATSMAX"=>475, "SEATSOCC"=>32, "_GROUP1"=>"FRANKFURT-Germany-BERLIN-Germany", "T_COLOR"=>[]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"TOKYO", "LANDXTO"=>"Japan", "CARRNAME"=>"Japan Airlines", "CONNID"=>"0408", "FLDATE"=>"2023-11-03", "DEPTIME"=>"20:25:00", "ARRTIME"=>"15:40:00", "PRICE"=>1061.36, "CURRENCY"=>"JPY", "SEATSMAX"=>385, "SEATSOCC"=>367, "_GROUP1"=>"FRANKFURT-Germany-TOKYO-Japan", "T_COLOR"=>[{"FNAME"=>"PRICE", "COLOR"=>{"COL"=>5, "INT"=>"0 ", "INV"=>0}, "NOKEYCOL"=>""}]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"TOKYO", "LANDXTO"=>"Japan", "CARRNAME"=>"Japan Airlines", "CONNID"=>"0408", "FLDATE"=>"2024-01-22", "DEPTIME"=>"20:25:00", "ARRTIME"=>"15:40:00", "PRICE"=>1061.36, "CURRENCY"=>"JPY", "SEATSMAX"=>385, "SEATSOCC"=>373, "_GROUP1"=>"FRANKFURT-Germany-TOKYO-Japan", "T_COLOR"=>[{"FNAME"=>"SEATSMAX", "COLOR"=>{"COL"=>6, "INT"=>"0 ", "INV"=>0}, "NOKEYCOL"=>""}]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"TOKYO", "LANDXTO"=>"Japan", "CARRNAME"=>"Japan Airlines", "CONNID"=>"0408", "FLDATE"=>"2024-04-11", "DEPTIME"=>"20:25:00", "ARRTIME"=>"15:40:00", "PRICE"=>1061.36, "CURRENCY"=>"JPY", "SEATSMAX"=>385, "SEATSOCC"=>373, "_GROUP1"=>"FRANKFURT-Germany-TOKYO-Japan", "T_COLOR"=>[]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"TOKYO", "LANDXTO"=>"Japan", "CARRNAME"=>"Japan Airlines", "CONNID"=>"0408", "FLDATE"=>"2024-06-30", "DEPTIME"=>"20:25:00", "ARRTIME"=>"15:40:00", "PRICE"=>1061.36, "CURRENCY"=>"JPY", "SEATSMAX"=>385, "SEATSOCC"=>364, "_GROUP1"=>"FRANKFURT-Germany-TOKYO-Japan", "T_COLOR"=>[{"FNAME"=>"PRICE", "COLOR"=>{"COL"=>5, "INT"=>"0 ", "INV"=>0}, "NOKEYCOL"=>""}]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"TOKYO", "LANDXTO"=>"Japan", "CARRNAME"=>"Japan Airlines", "CONNID"=>"0408", "FLDATE"=>"2024-09-18", "DEPTIME"=>"20:25:00", "ARRTIME"=>"15:40:00", "PRICE"=>1061.36, "CURRENCY"=>"JPY", "SEATSMAX"=>385, "SEATSOCC"=>51, "_GROUP1"=>"FRANKFURT-Germany-TOKYO-Japan", "T_COLOR"=>[]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"TOKYO", "LANDXTO"=>"Japan", "CARRNAME"=>"Japan Airlines", "CONNID"=>"0408", "FLDATE"=>"2024-12-07", "DEPTIME"=>"20:25:00", "ARRTIME"=>"15:40:00", "PRICE"=>1061.36, "CURRENCY"=>"JPY", "SEATSMAX"=>385, "SEATSOCC"=>15, "_GROUP1"=>"FRANKFURT-Germany-TOKYO-Japan", "T_COLOR"=>[{"FNAME"=>"SEATSMAX", "COLOR"=>{"COL"=>3, "INT"=>"0 ", "INV"=>0}, "NOKEYCOL"=>""}]}{"CITYFROM"=>"FRANKFURT", "LANDXFROM"=>"Germany", "CITYTO"=>"NEW YORK", "LANDXTO"=>"USA", "CARRNAME"=>"Lufthansa", "CONNID"=>"0400", "FLDATE"=>"2023-11-03", "DEPTIME"=>"10:10:00", "ARRTIME"=>"11:34:00", "PRICE"=>666.0, "CURRENCY"=>"EUR", "SEATSMAX"=>330, "SEATSOCC"=>321, "_GROUP1"=>"FRANKFURT-Germany-NEW YORK-USA", "T_COLOR"=>[{"FNAME"=>"PRICE", "COLOR"=>{"COL"=>5, "INT"=>"0 ", "INV"=>0}, "NOKEYCOL"=>""}, {"FNAME"=>"SEATSMAX", "COLOR"=>{"COL"=>6, "INT"=>"0 ", "INV"=>0}, "NOKEYCOL"=>""}]}
).
Классы для хранения шаблонов
Ранее для выгрузки отчета нужно было выбрать один из имеющихся классов
А именно:
- ZCL_XTT_FILE_SMW0 Для шаблонов tr. SMW0 (самый распространённый вариант)
- ZCL_XTT_FILE_OAOR tr. OAOR удобен тем что есть встроенная версионность BDS для шаблонов
- ZCL_XTT_FILE_RAW В основном используется для шаблонов на основе String (реже xString) и класса ZCL_XTT_HTML. Который в свою очередь используется чаще всего для отправки писем
Табличные отчёты
Если вы часто создаете отчеты на основе CL_SALV_TABLE или CL_GUI_ALV_GRID используя подытоги и группировку данных, и при этом не хотите создавать Excel шаблон который в точности просто повторяет ALV вывод данный класс вам поможет вам в этом.
Данный класс ZCL_XTT_FILE_GRID создает пустой шаблон для ZCL_XTT_EXCEL_XLSX и обладает рядом преимуществ по сравнению со стандартной выгрузкой в Excel
Разные цвета для подытогов (строка 20) и современный шрифт Calibri
Если подытоги сгруппированы
В итоговом отчете данные также будут сгруппированы
Раскраска ALV
Также в ALV вы можете использовать 3 цвета col_positive (зеленый), col_negative (красный) и col_total (желтый).
Технически эта функция реализована условным форматированием.
PS:
Если у вас отчет построен на основе класса CL_SALV_TABLE и вам нужен класс CL_GUI_ALV_GRID для передачи в конструктор ZCL_XTT_FILE_GRID.
Вы можете воспользоваться методом ZCL_EUI_CONV=>GET_GRID_FROM_SALV( ) для преобразования