Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to create a spool requset for 'z program'.

Former Member
0 Likes
3,161

Hi,

Could anybody please tell me how to generate a spool request for a Z program. and how to check the spool request.

Regards

sathish

Hi,

Could anybody please tell me how to generate a spool request for a Z program. and how to check the spool request.

Regards

sathish

3 REPLIES 3
Read only

Former Member
0 Likes
1,587

Spool request is automatically created when a background job is executed and list is generated. For manually doing it via program check this sample code:

DATA: pripar TYPE pri_params,
      arcpar TYPE arc_params,
      lay TYPE pri_params-paart,
      lines TYPE pri_params-linct,
      rows TYPE pri_params-linsz.
DATA: val(1), val1(1).
DATA: dest TYPE pri_params-pdest VALUE 'NHREMOTE'.
DATA: name TYPE pri_params-plist VALUE 'Testing'.
DATA: i_pdf TYPE STANDARD TABLE OF tline.
DATA: spono TYPE tsp01-rqident.
 
CALL FUNCTION 'GET_PRINT_PARAMETERS'
  EXPORTING
    destination            = dest
    no_dialog              = 'X'
    immediately            = ' '
  IMPORTING
    out_archive_parameters = arcpar
    out_parameters         = pripar
    valid                  = val
    valid_for_spool_creation = val1
  EXCEPTIONS
    archive_info_not_found = 1
    invalid_print_params   = 2
    invalid_archive_params = 3
    OTHERS                 = 4.
IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
 
pripar-prdsn = 'DSN'.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
  EXPORTING
    in_archive_parameters    = arcpar
    in_parameters            = pripar
    no_dialog                = 'X'
    list_name                = name
  IMPORTING
    out_archive_parameters   = arcpar
    out_parameters           = pripar
    valid                    = val
    valid_for_spool_creation = val1
  EXCEPTIONS
    archive_info_not_found   = 1
    invalid_print_params     = 2
    invalid_archive_params   = 3
    OTHERS                   = 4.
 
IF sy-subrc EQ 0.
  NEW-PAGE PRINT ON
  NEW-SECTION
  PARAMETERS pripar
  ARCHIVE PARAMETERS arcpar
  NO DIALOG.
ELSE.
  WRITE:/ 'Unable to create spool'.
   EXIT.
ENDIF.
 
WRITE:/ 'First Line'.
WRITE:/ 'Second Line'.
 
NEW-PAGE PRINT OFF.
 
spono = sy-spono.
System Variable SPONO holds the spool number. Now you can use the spool number for further processing like downloading to PC later or send a mail with the data in spool.

Read only

Former Member
0 Likes
1,587

Hi ,

You can check the following code for reference

FORM get_job_details.

  • Get current job details

CALL FUNCTION 'GET_JOB_RUNTIME_INFO'

IMPORTING

eventid = gd_eventid

eventparm = gd_eventparm

external_program_active = gd_external_program_active

jobcount = gd_jobcount

jobname = gd_jobname

stepcount = gd_stepcount

EXCEPTIONS

no_runtime_info = 1

OTHERS = 2.

ENDFORM. " get_job_details

&----


*& Form obtain_spool_id

&----


  • To obtain the spool ID generated

FORM obtain_spool_id.

CHECK NOT ( gd_jobname IS INITIAL ).

CHECK NOT ( gd_jobcount IS INITIAL ).

SELECT * FROM tbtcp

INTO TABLE it_tbtcp

WHERE jobname = gd_jobname

AND jobcount = gd_jobcount

AND stepcount = gd_stepcount

AND listident <> '0000000000'

ORDER BY jobname

jobcount

stepcount.

READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.

IF sy-subrc = 0.

gd_spool_nr = wa_tbtcp-listident.

MESSAGE s004 WITH gd_spool_nr.

ELSE.

MESSAGE s005.

ENDIF.

ENDFORM. " obtain_spool_id

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,587

This is automaticaly done in batch, so i suppose you ask in interactive mode.

The ways to produce a spool while being created are

- Execute a report using the Execute and print function

- Switch on printing in a report using the ABAP statement NEW-PAGE PRINT ON.

- Call a report using the statement SUBMIT rep TO SAP-SPOOL

- Schedule a report as a background job using the statement SUBMIT rep USER user VIA JOB job NUMBER n TO SAP-SPOOL. When the report runs, the system writes the output to the spool system.

- Schedule a report as a background job using the function module JOB_SUBMIT. When the report runs, the sytsem writes the output to the spool system.

You could also use "tips" like the following code to force printing :

TABLES sscrfields.

AT SELECTION-SCREEN.
IF sscrfields-ucomm = 'ONLI'.
  sscrfields-ucomm = 'PRIN'.
ENDIF.

Regards