2022 Jan 20 2:16 PM
Hi guys
I'm working with the following code:
DATA:
lo_cmrfw TYPE REF TO /bobf/cm_frw,
lo_message TYPE REF TO /bobf/cl_frw_message,
lo_applog TYPE REF TO /scmtms/cm_applog_msg,
lo_tmrequest TYPE REF TO /scmtms/cl_tm_request.
DATA:
lt_message TYPE /bobf/t_frw_message_k.
DATA:
lv_incomp TYPE boolean VALUE abap_true.
lo_tmrequest ?= lo_request.
lo_message ?= lo_tmrequest->mo_message.
lo_message->/bobf/if_frw_message~get_messages( IMPORTING
et_message = lt_message ).
TRY.
DATA(ls_message) = lt_message[ severity = 'W' ].
lo_cmrfw ?= ls_message-message.
DATA(lv_msgid) = lo_cmrfw->if_t100_message~t100key-msgid.
DATA(lv_msgno) = lo_cmrfw->if_t100_message~t100key-msgno.
IF '/SCMTMS/INCOMP' NS lv_msgid.
SET PARAMETER ID 'MESSA' FIELD lv_incomp. " Export del indicador de imcompatibilidad.
ENDIF.
CATCH cx_sy_itab_line_not_found.
ENDTRY.
What is the meaning of '?=' in the code: lo_tmrequest ?= lo_request.
Do you have a sap help link that talks about this? I looked for it but didn't know how to look for it.
2022 Jan 20 2:38 PM
It is known as the Casting in ABAP Object :
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapmove_cast.htm
2022 Jan 20 2:41 PM
I use this, for example, when you have a Class with several Interfaces. The instance is created using Interface_1, but at a moment you need to manage the instance through interface_2. You use this =?
2022 Jan 20 2:40 PM
Hi Ricardo,
Try putting your cursor on the '?=' and pressing F1 for documenation.
?= is the down casting operator in ABAP.
In your example, the reference in lo_request is being down cast to a reference to one of its subclasses, class '/scmtms/cl_tm_request', contained in variable lo_tmrequest.
2022 Jan 20 2:43 PM
Hi ronaldo.aparecido
this is casting operator, in practice often You will see in downcast, also can be used for upCast. See docu:https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapmove_cast.htm2022 Jan 21 10:49 AM
Hi Ricardo,
1. ?= is the casting operator which is used in both Widening cast as well as Narrowing cast. It's used for assignments between reference variables, whose assignability is checked as early as the runtime starts.
2. Widening cast can be used when we need to access the Specific functionality of the subclass from the Superclass.
Thanks and Regards,
Aditya Mane