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

SUBMIT Report with Immediate Print

Former Member
0 Likes
7,465

Hello Experts,

Here's my code:

g_print_parameters = p_print. (p_print is the Printer Name)

  CALL FUNCTION 'JOB_OPEN'

    EXPORTING

      jobname          = g_jobname

    IMPORTING

      jobcount         = g_jobcount

    EXCEPTIONS

      cant_create_job  = 1

      invalid_job_data = 2

      jobname_missing  = 3

      OTHERS           = 4.

  IF sy-subrc = 0.

    SUBMIT z_xyz_report TO SAP-SPOOL

                      SPOOL PARAMETERS g_print_parameters

                      WITHOUT SPOOL DYNPRO

                      USER g_user

                      VIA JOB g_jobname NUMBER g_jobcount

                      WITH p_file = p_file

                      AND RETURN.

    IF sy-subrc = 0.

      CALL FUNCTION 'JOB_CLOSE'

        EXPORTING

          jobcount             = g_jobcount

          jobname              = g_jobname

          strtimmed            = c_x

        EXCEPTIONS

          cant_start_immediate = 1

          invalid_startdate    = 2

          jobname_missing      = 3

          job_close_failed     = 4

          job_nosteps          = 5

          job_notex            = 6

          lock_failed          = 7

          OTHERS               = 8.

      IF sy-subrc <> 0.

        MESSAGE e003(zvxyz).

      ENDIF.

      MESSAGE s002(zxyz) WITH g_jobname.

    ENDIF.

  ENDIF.

Job is getting scheduled immediately as well as the Spool is generated successfully. But it is not printing immediately.

How can I print the Spool immediately from the Printer?

Thanks & Regards,

Sowmya

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
6,720

The structure for print parameter, is a little more complex than printer name

Read some documentation like Setting Program-Driven Print Parameters.

For immediate print on a specified printer device :

CALL FUNCTION 'GET_PRINT_PARAMETERS'

  EXPORTING

    destination            = tsp03-padest " p_print

    copies                 = 1

    immediately            = 'X'

    mode                   = 'BATCH'

    no_dialog              = 'X'

    report                 = 'Z_XYZ_REPORT'

  IMPORTING

    out_parameters         = pri_params " g_print_parameters

  EXCEPTIONS

    archive_info_not_found = 1

    invalid_print_params   = 2

    invalid_archive_params = 3

    OTHERS                 = 4.

Regards,

Raymond

13 REPLIES 13
Read only

satyabrata_sahoo3
Contributor
0 Likes
6,720

Hope this helps:

http://help.sap.com/saphelp_45b/helpdata/en/34/8e739c6df74873e10000009b38f9b8/content.htm

Try using the FM GET_PRINT_PARAMETERS and pass it in the print parameters.

Found this useful:

http://www.sapdev.co.uk/reporting/rep_submit.htm

-SS-

Read only

Former Member
0 Likes
6,720

Dear Sowmya.

Try to use the following fields in g_print_parameters (PRI_PARAMS).

PDEST = Printer name

PRIMM = 'X'

PRNEW = 'X'

Regards

Michael

Read only

RaymondGiuseppi
Active Contributor
0 Likes
6,721

The structure for print parameter, is a little more complex than printer name

Read some documentation like Setting Program-Driven Print Parameters.

For immediate print on a specified printer device :

CALL FUNCTION 'GET_PRINT_PARAMETERS'

  EXPORTING

    destination            = tsp03-padest " p_print

    copies                 = 1

    immediately            = 'X'

    mode                   = 'BATCH'

    no_dialog              = 'X'

    report                 = 'Z_XYZ_REPORT'

  IMPORTING

    out_parameters         = pri_params " g_print_parameters

  EXCEPTIONS

    archive_info_not_found = 1

    invalid_print_params   = 2

    invalid_archive_params = 3

    OTHERS                 = 4.

Regards,

Raymond

Read only

0 Likes
6,720

Thanks for the reply Raymond.

How do I check if the Output has been printed in the given Printer? Since I'm in different location, how to track the same?

The Background Job is 'Completed', but there is no Spool in it. How to check the Output?

I'm unable to find in SP01.

Earlier, I could see the Spool list in my job.

Thanks & Regards,

Sowmya

Read only

0 Likes
6,720

There will no longer be a spool via SP01 if you don't also explicitly initialize RELEASE 'Delete after print' parameter of GET_PRINT_PARAMETERS (*) or in user Default values for "Delete after output".

You will be able to see a spool number in SM37 or in table TBTC_SPOOLID even if spool is no longer stored in database/file system.

Regards,

Raymond

(*) Print Parameters

Read only

0 Likes
6,720

Hi Raymond,

Thanks again!

Here's my SM37 list:

Yesterday, it was not printing, but Spool was there.

Today, after I used 'GET_PRINT_PARAMETERS'; there's no SPOOL.

My question is:

1) How do we know whether it has printed or not?

2) Why is it not showing the Spool? How do I display the output in the Job Spool?

Thanks & Regards,
Sowmya

Read only

0 Likes
6,720

Try to display the "steps" of background job. even after its removal, the spool number will be displayed. Also, when displaying the steps, you could  display the actual print parameter used for the execution, click on  "Print specifications".

Regards,

Raymond

Read only

0 Likes
6,720

Hi Raymond,

There's no Spool number

Here's my code:

DATA: g_jobcount     TYPE tbtcjob-jobcount,

      g_jobname          TYPE tbtcjob-jobname

                               VALUE 'JOB XYZ',

      g_user               TYPE sy-uname VALUE 'XYZ',

      g_printname       TYPE rspopshort,      "Printer's Short name

      g_print_parameters     TYPE pri_params.

START-OF-SELECTION .

 

* Getting Short Name for the Printer

  SELECT SINGLE padest

           INTO   g_printname

           FROM   tsp03d

           WHERE  name EQ p_print.

   IF sy-subrc EQ 0.

  ENDIF.

 

*  Job Open

  CALL FUNCTION 'JOB_OPEN'

    EXPORTING

      jobname          = g_jobname

    IMPORTING

      jobcount         = g_jobcount

    EXCEPTIONS

      cant_create_job  = 1

      invalid_job_data = 2

      jobname_missing  = 3

      OTHERS           = 4.

  IF sy-subrc = 0.

    CALL FUNCTION 'GET_PRINT_PARAMETERS'

      EXPORTING

        copies                 = 1

        list_name              = 'ZVXY'

        list_text              = 'SUBMIT FROM Z_XYZ'

        destination            = g_printname

        immediately            = 'X'

        mode                   = 'BATCH'

        no_dialog              = 'X'

        release                = 'X'

        user                   = 'XYZUSR'

      IMPORTING

        out_parameters         = g_print_parameters

        valid                  = g_valid

      EXCEPTIONS

        archive_info_not_found = 1

        invalid_print_params   = 2

        invalid_archive_params = 3

        OTHERS                 = 4.

    IF sy-subrc <> 0.

      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    SUBMIT z_xyz_prog_batch TO SAP-SPOOL

                      SPOOL PARAMETERS g_print_parameters

                      WITHOUT SPOOL DYNPRO

                      USER g_user

                      VIA JOB g_jobname NUMBER g_jobcount

                      WITH p_file = p_file

                      AND RETURN.

    IF sy-subrc = 0.

      CALL FUNCTION 'JOB_CLOSE'

        EXPORTING

          jobcount             = g_jobcount

          jobname              = g_jobname

          strtimmed            = c_x

        EXCEPTIONS

          cant_start_immediate = 1

          invalid_startdate    = 2

          jobname_missing      = 3

          job_close_failed     = 4

          job_nosteps          = 5

          job_notex            = 6

          lock_failed          = 7

          OTHERS               = 8.

      IF sy-subrc <> 0.

        MESSAGE e003(zxy).

      ENDIF.

      MESSAGE s002(zxy) WITH g_jobname.

    ENDIF.

  ENDIF.

Earlier when I was not using the Function Module, I was able to see the Spool. Now, I can't see..

Thanks for your help.

Thanks & Regards,

Sowmya

Read only

0 Likes
6,720

Should not be related, changing the print parameters should not prevent spool generation, only its content if size not correct. (In my sample I used 'BATCH' mode, but for this reason I also passed Report name.)

Double-click on the step and display print parameters actually used to create the step, click on  "Print specifications"

Also if some wrong parameter was passed, you could look to job log.

Regards,

Raymond

Read only

0 Likes
6,720

Thanks so much Raymond. I had missed to give 'Report Name' in the FM.

I'm getting the below Spool Problem now:

What is the reason for this?

Thanks & Regards,

Sowmya

Read only

0 Likes
6,720

No problem, your spool was printed, only one character may not have been converted between character set 1100 of your system and character set 1116 of the printer device.  As both character sets comply to ISO-8859-1 (Latin-1) set that should not matter much.

NB: The report name take line size and count per page from the program.

Regards,

Raymond

Read only

0 Likes
6,720

Thanks so much Raymond...

-Sowmya

Read only

Former Member
0 Likes
6,720