[ABAP] Transportauftrag prüfen

* Siehe Typgruppe SCTSC (Konstanten CTS)

SELECTION-SCREEN BEGIN OF LINE.
  SELECTION-SCREEN COMMENT (20) lbl1 FOR FIELD p_trkorr.
  PARAMETERS: p_trkorr LIKE e070-trkorr OBLIGATORY.
SELECTION-SCREEN END OF LINE.

INITIALIZATION.
  lbl1 = 'Transport-Auftrag:'.

START-OF-SELECTION.

  DATA: lv_req TYPE trwbo_request.

* (Nach-)Lesen von Einzelbestandteilen eines Auftrags
  CALL FUNCTION 'TR_READ_REQUEST'
    EXPORTING
      iv_read_e070     = abap_true
      iv_read_e07t     = abap_true
      iv_trkorr        = p_trkorr
    CHANGING
      cs_request       = lv_req
    EXCEPTIONS
      error_occured    = 1
      no_authorization = 2
      OTHERS           = 3.

  IF sy-subrc = 0.

    DATA: lv_messages TYPE ctsgerrmsgs.

* Prüfe kompletten Auftrag
    CALL FUNCTION 'TR_CHECK_REQUEST'
      EXPORTING
        is_request           = lv_req
        iv_check_lockability = abap_true
        iv_collect_mode      = abap_true
      IMPORTING
        et_messages          = lv_messages
      EXCEPTIONS
        header_error         = 1
        attribute_error      = 2
        obj_or_key_error     = 3
        OTHERS               = 4.

    IF sy-subrc = 0.
      cl_demo_output=>write_data( lv_messages ).
      cl_demo_output=>display( ).
    ENDIF.
  ENDIF.