[ABAP] Transportaufträge: Kommandodatei (Cofile) laden

Variante 1 (TR_READ_GLOBAL_INFO_OF_REQUEST)

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_cofile TYPE ctslg_cofile.
  DATA: lv_user TYPE e070-as4user.
  DATA: lv_project TYPE trkorr.

* Kommandodatei lesen und abhängig vom Aufruf aufbereiten
  CALL FUNCTION 'TR_READ_GLOBAL_INFO_OF_REQUEST'
    EXPORTING
      iv_trkorr   = p_trkorr
      iv_dir_type = 'T'          " Typ Directory: T(ransport), P(ut)
    IMPORTING
      es_cofile   = lv_cofile
      ev_user     = lv_user
      ev_project  = lv_project.

  cl_demo_output=>write_data( lv_cofile ).
  cl_demo_output=>write_data( lv_user ).
  cl_demo_output=>write_data( lv_project ).
* html-code holen
data(lv_html) = cl_demo_output=>get( ).
* Daten im Inline-Browser im SAP-Fenster anzeigen
  cl_abap_browser=>show_html( EXPORTING title       = 'Transportauftrag Cofile'
                                        html_string = lv_html
                                        container   = cl_gui_container=>default_screen ).
* cl_gui_container=>default_screen erzwingen
  WRITE: space.

Variante 2 (STRF_READ_COFILE)

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_ev_cofi_header TYPE tstrfcofih.
  DATA: lv_ev_project TYPE trkorr_p.
  DATA: lv_et_predecessors TYPE tms_trkorrs.

  DATA: it_tt_cofi_lines TYPE STANDARD TABLE OF tstrfcofil WITH DEFAULT KEY.

* SL-intern: Lesen und Interpretieren Inhalt von cofiles-Dateien
  CALL FUNCTION 'STRF_READ_COFILE'
    EXPORTING
      iv_dirtype             = 'T'         " Typ Directory: T(ransport), P(ut)
      iv_trkorr              = p_trkorr
      iv_read_header         = 'X'
      iv_transport_directory = ' '
    IMPORTING
      ev_cofi_header         = lv_ev_cofi_header
      ev_project             = lv_ev_project
      et_predecessors        = lv_et_predecessors
    TABLES
      tt_cofi_lines          = it_tt_cofi_lines
    EXCEPTIONS
      wrong_call             = 1
      no_info_found          = 2
      OTHERS                 = 3.

  IF sy-subrc = 0.

    cl_demo_output=>write_data( lv_ev_cofi_header ).
    cl_demo_output=>write_data( lv_ev_project ).
    cl_demo_output=>write_data( lv_et_predecessors ).
    cl_demo_output=>write_data( it_tt_cofi_lines ).

* html-code holen
    DATA(lv_html) = cl_demo_output=>get( ).
* Daten im Inline-Browser im SAP-Fenster anzeigen
    cl_abap_browser=>show_html( EXPORTING title       = 'Transportauftrag Cofile'
                                          html_string = lv_html
                                          container   = cl_gui_container=>default_screen ).
* cl_gui_container=>default_screen erzwingen
    WRITE: space.
  ENDIF.