Eigenen Spool erzeugen

Nützliche Abap Codes und Code Fragmente

Eigenen Spool erzeugen

Postby Tron » Mon Oct 25, 2021 10:38 am

Moin.
Manchmal ist es nötig, einen eigenen Spool zu erzeugen.

e.g.: SP01 / Spool mit 2 Zeilen text erzeugen.
Spool Request.png
Spool Request.png (255.93 KiB) Viewed 86 times


Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. *&---------------------------------------------------------------------*
  2. *& Report ZCREATE_SPOOL
  3. *&---------------------------------------------------------------------*
  4. *&
  5. *&---------------------------------------------------------------------*
  6. REPORT zcreate_spool.
  7. CONSTANTS c_ht(1) VALUE %_horizontal_tab.
  8.  
  9. PERFORM write_spool.
  10.  
  11.  
  12. *&---------------------------------------------------------------------*
  13. *&      Form  WRITE_LOG
  14. *&---------------------------------------------------------------------*
  15. *       text
  16. *----------------------------------------------------------------------*
  17. *  -->  p1        text
  18. *  <--  p2        text
  19. *----------------------------------------------------------------------*
  20. FORM write_spool.
  21.  
  22.   DATA: lv_dest        TYPE tsp01-rqdest,
  23.         lv_handle      TYPE sy-tabix,
  24.         lv_spool_id    TYPE tsp01-rqident,
  25.         lv_name        TYPE tsp01-rq0name,
  26.         lv_titleline   TYPE tsp01-rqtitle,
  27.         lv_receiver    TYPE tsp01-rqreceiver,
  28.         lv_rc          TYPE c,
  29.         lv_errmsg(100) TYPE c,
  30.         lv_text(70)    TYPE c,
  31.         lv_spool_nr    TYPE tsp01-rqident.
  32.  
  33.   DATA lv_row(300) .
  34.   "
  35.  
  36.   CLEAR : lv_name,
  37.           lv_receiver,
  38.           lv_titleline,
  39.           lv_handle,
  40.           lv_spool_nr,
  41.           lv_rc,
  42.           lv_errmsg.
  43.  
  44.  
  45. * Set the name,title,receiver of the spool
  46.   lv_name = 'LIST1S'.
  47.   lv_titleline = 'My own Spool request'.
  48.   lv_receiver = sy-uname.
  49.  
  50. * Open the spool request for an ABAPLIST
  51.   CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'
  52.     EXPORTING
  53.       dest            = 'LP01'
  54.       name            = lv_name
  55.       copies          = 1
  56.       immediate_print = ' '
  57.       titleline       = lv_titleline
  58.       receiver        = lv_receiver
  59.       doctype         = 'LIST'
  60.     IMPORTING
  61.       handle          = lv_handle
  62.       spoolid         = lv_spool_nr
  63.       rc              = lv_rc
  64.       errmessage      = lv_errmsg.
  65.  
  66. * Write One line to the Spool incl. a horizontal Tab
  67. "lv_row = 'Lorem ipsum dolor sit amet, his et malis senserit, '.
  68.  
  69.   'Lorem ipsum dolor sit amet,'
  70.   'his et malis senserit, '
  71.   INTO lv_row SEPARATED BY c_ht.
  72.  
  73.   CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
  74.     EXPORTING
  75.       handle           = lv_handle
  76.       text             = lv_row
  77.       "length           = 3
  78.     IMPORTING
  79.       rc               = lv_rc
  80.       errmessage       = lv_errmsg
  81.     EXCEPTIONS
  82.       handle_not_valid = 1
  83.       OTHERS           = 2.
  84.  
  85. * Write One line to the Spool
  86. lv_row = 'Veri natum voluptua nam cu, quo no tation lobortis tractatos. '.
  87.  
  88.   CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
  89.     EXPORTING
  90.       handle           = lv_handle
  91.       text             = lv_row
  92.       "length           = 3
  93.     IMPORTING
  94.       rc               = lv_rc
  95.       errmessage       = lv_errmsg
  96.     EXCEPTIONS
  97.       handle_not_valid = 1
  98.       OTHERS           = 2.
  99.  
  100.  
  101. * Close the spool request
  102.   CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'
  103.     EXPORTING
  104.       handle           = lv_handle
  105.     IMPORTING
  106.       rc               = lv_rc
  107.       errmessage       = lv_errmsg
  108.     EXCEPTIONS
  109.       handle_not_valid = 1
  110.       OTHERS           = 2.
  111.  
  112.   MESSAGE ID '8I' TYPE 'S' NUMBER '000' WITH
  113.   'File Extraction results sent to spool' lv_spool_nr.
  114.  
GeSHi ©


clipboard.png
clipboard.png (16 KiB) Viewed 86 times


gruß Jens
Tron
.....
.....
 
Posts: 1107
Joined: Sat Aug 04, 2007 10:21 pm

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest

cron