Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Abap command meaning

ronaldo_aparecido
Contributor
0 Kudos
433

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.

5 REPLIES 5

FredericGirod
Active Contributor

0 Kudos
267

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 =?

LaurensDeprost
Contributor
267

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.

Matija_Liber
Explorer
267

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.htm
Best regards,

0 Kudos
267

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