0

Hi I made my first Hello World in BTP and it didn't show my user alias...

Why?

ABAP code

CLASS zpo_hello_world DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC.

  PUBLIC SECTION.
  INTERFACES if_oo_adt_classrun.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.


CLASS zpo_hello_world IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
  out->write( |Hello World ! ({ cl_abap_context_info=>get_user_alias( ) })| ).

  ENDMETHOD.

ENDCLASS.
3
  • 2
    do your user have an alias? have a look in su01 Commented Aug 24, 2022 at 11:34
  • There should be a fiori application maintain business users for maintaining users in an ABAP cloud system, including setting the users alias. Commented Aug 27, 2022 at 10:22
  • do you run your console app in the productive BTP? Trial one does not support SU01 fiori tile
    – Suncatcher
    Commented Oct 9, 2022 at 21:33

1 Answer 1

1

Some of the methods in cl_abap_context_info can only be used in a cloud environment.

cl_abap_context_info=>
New Method Old Environemnt
ET_SYSTEM_DATE SYST-DATUM
GET_SYSTEM_TIME SYST-UZEIT
GET_USER_TECHNICAL_NAME SYST-UNAME
GET_USER_LANGUAGE_ABAP_FORMAT SYST-LANGU
GET_USER_LANGUAGE_ISO_FORMAT ISO format for language
GET_USER_TIME_ZONE SYST-TZONE
GET_USER_ALIAS Alias of user master data (Cloud)
GET_SYSTEM_URL URL of the system (Cloud)
GET_USER_FORMATTED_NAME BAPI_USER_GET_DETAIL
GET_USER_DESCRIPTION BAPI_USER_GET_DETAIL
GET_USER_BUSINESS_PARTNER_ID Business-Partner-ID of the user (Cloud)

(see here)

Thus means if you run On-Premise those methods will not return any value as far as I know.

But I just saw that you are using the BTP abap cloud example. I've also tested it here it seems that there no alias is set for the users.

You can verify your user with the get_user_business_partner_id-method which is only valid in cloud.

  METHOD if_oo_adt_classrun~main.
    TRY.
        out->write( |Hello World { cl_abap_context_info=>get_user_business_partner_id( ) }| ).
      CATCH cx_abap_context_info_error.
    ENDTRY.
  ENDMETHOD.

I'm not sure weather you can set a user alias with transaction SU1 due there is no SAP Gui support I guess.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.