Print carrier labels

With the document output mode 'RETURN', the carrier labels are provided as a byte stream. One can sent this byte stream to a printer from within SAP.

Please note: Responsibility for printers, their settings and proper handling lies is within your IT operation. AEB just provides the label stream in the appropriate format for the printer. Examples provided here just describe one possible approach, technical availabilities may vary dependend on the infrastructure of your SAP system.

There are different options to print the carrier labels, check this document for an overview: https://rz3.aeb.de/docudata/other/carrier-connect/printing-with-carrier-connect/en-US/index.html

This example outlines the printing when executing an output type for an outbound delivery:

FORM print_single_label USING iv_vbeln TYPE vbeln_vl
                            is_doc   TYPE /aeb/pa_pb_dl_doc_do.

  DATA: lv_spool_handle TYPE syst_tabix,
        lv_spool        TYPE rspoid,
        lv_xstring      TYPE xstring,
        lv_filesize     TYPE i,
        lt_raw_buffer   TYPE solix_tab,
        lv_title        TYPE rspotitle,
        lv_name         TYPE rspo0name,
        lv_suffix1      TYPE rspo1name,
        lv_suffix2      TYPE rspo2name,
        lv_ldest        TYPE ldest.

  " Prepare data for output of the labels
  lv_xstring    = is_doc-content.
  lt_raw_buffer = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_xstring ).
  lv_filesize   = xstrlen( lv_xstring ).

  " Spool-Settings
  CONCATENATE 'AEB-Label' iv_vbeln INTO lv_title SEPARATED BY space.
  lv_name    = 'AEB'.
  lv_suffix2 = iv_vbeln.

  " Determination Printer based on your customer individual logic
  " Printer name equals short name of printer in SPAD
  lv_dest = 'printer_name'.

  " Create Spool Request
  CALL FUNCTION 'RSPO_SR_OPEN'
    EXPORTING
      dest             = lv_ldest
      layout           = 'G_RAW'
      doctype          = 'BIN'
      titleline        = lv_title
      suffix1          = lv_suffix1
      suffix2          = lv_suffix2
      name             = lv_name
      immediate_print  = abap_true       " Direct Print
    IMPORTING
      handle           = lv_spool_handle
      spoolid          = lv_spool
    EXCEPTIONS
      device_missing   = 1
      name_twice       = 2
      no_such_device   = 3
      operation_failed = 4
      OTHERS           = 5.

  IF sy-subrc NE 0.
  " Spool-request could not be created!
  " Create log!!
    RETURN.
  ELSE.
    " Spool-request has been created!
  ENDIF.

  " Add the binary content into Spool Request
  CALL FUNCTION 'RSPO_SR_TABLE_WRITE_BINARY'
    EXPORTING
      handle           = lv_spool_handle
      total            = lv_filesize
    TABLES
      lines            = lt_raw_buffer
    EXCEPTIONS
      handle_not_valid = 1.

  IF sy-subrc NE 0.
  " Create log!!
    RETURN.
  ENDIF.

  " Close Spool Request
  CALL FUNCTION 'RSPO_SR_CLOSE'
    EXPORTING
      handle           = lv_spool_handle
    EXCEPTIONS
      handle_not_valid = 1
      operation_failed = 2
      OTHERS           = 3.

  IF sy-subrc NE 0.
	" Create log!!
    RETURN.
  ENDIF.

ENDFORM.