DATA: lv_service TYPE bapisrv_asmd.
DATA: lv_servicex TYPE bapisrv_asmdx.
DATA: it_bapiret2 TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY.
lv_service-service = '1234567890'. " Leistungsnummer
lv_service-matl_group = '10000000'. " Warengruppe
lv_service-base_uom = 'ST'. " Basismengeneinheit
lv_service-serv_cat = 'SERV'. " Leistungstyp
lv_service-val_class = '1000'. " Bewertungsklasse
lv_service-master_langu = sy-langu. " Sprache
lv_service-master_langu_iso = cl_i18n_languages=>sap1_to_sap2( im_lang_sap1 = lv_service-master_langu ).
lv_servicex-service = lv_service-service.
lv_servicex-matl_group = abap_true.
lv_servicex-base_uom = abap_true.
lv_servicex-serv_cat = abap_true.
lv_servicex-val_class = abap_true.
lv_servicex-master_langu = abap_true.
lv_servicex-master_langu_iso = abap_true.
DATA it_shorttext TYPE STANDARD TABLE OF bapisrv_asmdt WITH DEFAULT KEY.
it_shorttext = VALUE #( ( language = lv_service-master_langu
language_iso = lv_service-master_langu_iso
short_text = 'Kurztext'
change_id = 'I' ) ).
DATA(it_longtext) = VALUE srv_sm_text_tty( ( language = sy-langu
language_iso = cl_i18n_languages=>sap1_to_sap2( im_lang_sap1 = sy-langu )
format = '/'
line = 'Langtext'
change_id = 'I' ) ).
CALL FUNCTION 'BAPI_SERVICE_CREATE'
EXPORTING
im_service_data = lv_service
im_service_datax = lv_servicex
testrun = ''
TABLES
return = it_bapiret2
service_description = it_shorttext
service_long_texts = it_longtext.
TRY.
IF lines( it_bapiret2 ) > 0.
IF it_bapiret2[ 1 ]-type CA 'EAX'.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
ENDIF.
CATCH cx_sy_itab_line_not_found.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDTRY.
cl_demo_output=>write_data( lv_service ).
cl_demo_output=>write_data( lv_servicex ).
cl_demo_output=>write_data( it_shorttext ).
cl_demo_output=>write_data( it_longtext ).
cl_demo_output=>write_data( it_bapiret2 ).
* HTML-Code vom Demo-Output holen
DATA(lv_html) = cl_demo_output=>get( ).
* Daten im Inline-Browser im SAP-Fenster anzeigen
cl_abap_browser=>show_html( EXPORTING
title = 'Leistungsstammsatz'
html_string = lv_html
container = cl_gui_container=>default_screen ).
* cl_gui_container=>default_screen erzwingen
WRITE: space.