2023 Nov 01 12:07 PM
IF sy-subrc = 0.
if gwa_invdata-werks = '4200' OR '4210'
gwa_output-add_tracking_number_req_mt-tracking-carrier_code = 'MOL'.
ELSE.
gwa_output-add_tracking_number_req_mt-tracking-carrier_code =
gwa_scaccode-scac_code.
Relational operator "GWA_OUTPUT-ADD_TRACKING_NUMBER_REQ_MT-TRACKING-CARRIER_CODE" is not supported.
2023 Nov 01 12:42 PM
Hello,
1) comparing a field to more than 1 value in ABAP is not possible as short as you tried it
2) the error message comes up because of the missing . at the end of the if clause.
IF sy-subrc = 0.
if gwa_invdata-werks = '4200' or gwa_invdata-werks = '4210'.
gwa_output-add_tracking_number_req_mt-tracking-carrier_code = 'MOL'.
ELSE.
gwa_output-add_tracking_number_req_mt-tracking-carrier_code = gwa_scaccode-scac_code.
endif.
endif.
Kind regards
Jan
PS: please use the 'Code' button when using code in your postings.
2023 Nov 01 12:42 PM
Hello,
1) comparing a field to more than 1 value in ABAP is not possible as short as you tried it
2) the error message comes up because of the missing . at the end of the if clause.
IF sy-subrc = 0.
if gwa_invdata-werks = '4200' or gwa_invdata-werks = '4210'.
gwa_output-add_tracking_number_req_mt-tracking-carrier_code = 'MOL'.
ELSE.
gwa_output-add_tracking_number_req_mt-tracking-carrier_code = gwa_scaccode-scac_code.
endif.
endif.
Kind regards
Jan
PS: please use the 'Code' button when using code in your postings.
2023 Nov 01 12:53 PM
2023 Nov 01 1:01 PM
Please edit your question (Actions>Edit), select your code and press the button [CODE], which makes the code appear colored/indented, it'll be easier for people to look at it. Thanks!
2023 Nov 01 1:05 PM
If you want to do the same code for several values of one variable, I'd recommend using either CASE:
CASE gwa_invdata-werks.
WHEN '4200' OR '4210'.
gwa_output-add_tracking_number_req_mt-tracking-carrier_code = 'MOL'.
WHEN OTHERS.
gwa_output-add_tracking_number_req_mt-tracking-carrier_code = gwa_scaccode-scac_code.
ENDCASE.
Or SWITCH if the same target variable is to be initialized:
gwa_output-add_tracking_number_req_mt-tracking-carrier_code
= SWITCH #( gwa_invdata-werks
WHEN '4200' OR '4210' THEN
'MOL'
ELSE
gwa_scaccode-scac_code ).