xtt->MERGE( IV_BLOCK_NAME = ‘R’ IS_BLOCK =
{"FIRST_NAME"=>"FirstName", "LAST_NAME"=>"LastName", "MIDDLE_NAME"=>"MiddleName", "T"=>[{"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"=>[]}, {"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"=>[]}, {"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"=>[]}, {"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"=>[]}, {"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"=>[]}, {"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"=>[]}, {"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"=>[]}, {"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"=>[]}, {"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"=>[]}]}
).
Background
Previously, absolutely all transmitted data had to be formed in advance and passed to the xtt-> merge( ) method. And sometimes there is quite a lot of such data. In order to reduce the amount of data transferred in example №130, the addition ;cond= is introduced, which allows you to write simple ABAP COND #( ) expressions. For example, if you need to display the maximum of the fields A
and B
in the R
structure, you can write in the template{R;cond=WHEN value-A gt value-B THEN value-A ELSE value-B }
without creating a 3rd field in R
. For brevity, the expression can be written like this {R:WHEN v-A gt value-B THEN v-A ELSE v-B}
.
But what if the expression contains a lot of WHEN-THEN pairs, or is it problematic to write it on one line? To improve the reading of the template, the ability to call a method with passing parameters to it has been introduced.
Implicit parameter passing
To call a method in a template, you can use the addition ;call =, the object itself whose methods will be called is passed in the merge method
There is no need to specify the transfer of the structure R
in the template
It is passed implicitly, by the name IS_ROOT
get_fullname
IMPORTING
is_root TYPE ts_root "<--- is passed implicitly
RETURNING VALUE (rv_text) TYPE string,
...
METHOD get_fullname.
rv_text = to_upper (| {is_root-first_name} {is_root-last_name} {is_root-middle_name} |).
ENDMETHOD.
Short form
So that, as in the case of replacing ;cond =
with :
, you can replace;call=
with one symbol @
Passing parameters explicitly
If you don’t need to pass the entire structure, you can pass the parameter explicitly via value-FIELD
(for ;call=) or v-FIELD
(for @)
The method has the following signature
date_text
IMPORTING
"is_root TYPE ts_flight_info <- no need. Pass v-FLDATE explicitly
iv_date TYPE d
iv_lang TYPE sylangu DEFAULT sy-langu
RETURNING VALUE (rv_text) TYPE string.
Note that the type (by default STRING) as opposed to;cond=
in the cell {R-T:sy-tabix;type=integer}
is not required. Since the type for rv_text
is determined dynamically
Result in two languages:
PS
Displaying dates through a function is demonstrative in nature. When using Excel, it is better to use the ABAP D
date type, and set the format in the cell itself (Ctrl + 1)
For universal display of dates in Pdf & Word, often you can use ;cond=
with COUNTRY
addition