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 statement not generating SPOOL

premal_mistry2
Active Participant
0 Likes
4,185

Hi,

I am using SUBMIT statement to call a Z program. I am using the code specified below :



      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          JOBNAME          = NAME
        IMPORTING
          JOBCOUNT         = NUMBER
        EXCEPTIONS
          CANT_CREATE_JOB  = 1
          INVALID_JOB_DATA = 2
          JOBNAME_MISSING  = 3
          OTHERS           = 4.

      IF SY-SUBRC = 0.
        SUBMIT <Z-PROG> TO SAP-SPOOL
        SPOOL PARAMETERS MSTR_PRINT_PARMS
        WITHOUT SPOOL DYNPRO
        VIA JOB NAME NUMBER NUMBER
        WITH PLNT = PLANT
        WITH QUOT IN QUOT
        WITH MAT IN V_MATNR
        WITH LIF IN V_LIFNR AND RETURN.

        IF SY-SUBRC EQ 0.
          CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              JOBCOUNT             = NUMBER
              JOBNAME              = NAME
              STRTIMMED            = '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.
            WAIT UP TO 2 SECONDS.

            CLEAR WA_TBTCP.
            SELECT SINGLE * FROM TBTCP INTO WA_TBTCP WHERE JOBCOUNT = NUMBER.
          ENDIF.
        ENDIF.
      ENDIF.

The problem is WA_TBTCP contains spool number as zero (0000).

Regards,

Premal

1 ACCEPTED SOLUTION
Read only

former_member212005
Active Contributor
0 Likes
2,277

Use the submit statement in the below format...

DATA: v_user_print_params LIKE pri_params.

v_user_print_params-primm = space.

SUBMIT <Z-PROG> TO SAP-SPOOL

SPOOL PARAMETERS v_user_print_params

WITHOUT SPOOL DYNPRO

VIA JOB NAME NUMBER NUMBER

WITH PLNT = PLANT

WITH QUOT IN QUOT

WITH MAT IN V_MATNR

WITH LIF IN V_LIFNR AND RETURN.

Hope it helps!

8 REPLIES 8
Read only

Former Member
0 Likes
2,277

Hi,

I guess the session is created in SM35, and you need to manually reprocess the session to complete the execution, then only it will be executed completely and spool will be created.

First check in SM35. Also check any spool is created in the table TSP01.

Also check SM37.

Also check the standard program RSBDCBTC_SUB for processing the SM35 session immediately.

Regards,

Santhosh.

Read only

0 Likes
2,277

Hi Santosh,

I checked in SM35 there was no session created pertaining to my program and in SM37, the JOB that I was creating in my program was successfully completed.

Read only

former_member212005
Active Contributor
0 Likes
2,278

Use the submit statement in the below format...

DATA: v_user_print_params LIKE pri_params.

v_user_print_params-primm = space.

SUBMIT <Z-PROG> TO SAP-SPOOL

SPOOL PARAMETERS v_user_print_params

WITHOUT SPOOL DYNPRO

VIA JOB NAME NUMBER NUMBER

WITH PLNT = PLANT

WITH QUOT IN QUOT

WITH MAT IN V_MATNR

WITH LIF IN V_LIFNR AND RETURN.

Hope it helps!

Read only

0 Likes
2,277

Hi Vin,

Tried in the format that you specified bu t still the spool number is ZERO ...

Read only

0 Likes
2,277

Hi,

The values passed during SUBMIT are not taken over until the event INITIALIZATION has been processed, i.e. default values set at INITIALIZATION are overwritten if values are passed for the PARAMETER or SELECT-OPTION during SUBMIT .

Thanks!

Prashant

Read only

0 Likes
2,277

Hi Prashant,

I have not used INITILIZATION section in my code. .. How ever my queries are written under STAR-OF-SELECTION. Can you please elaborate you reply.

Regards,

Premal

Read only

premal_mistry2
Active Participant
0 Likes
2,277

Still facing the problem .... the SUBMIT statement is not generating the SPOOL Number.

Read only

2,277

Thanks to all for replying ... the problem was solved. I used another method which I have shown below for those seeking solution like me.

*-- Setup the Print Parmaters

  CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
      COPIES                 = '1'
      NO_DIALOG              = 'X'
      USER                   = SY-UNAME
      ABAP_LIST              = 'X'
      NEW_LIST_ID            = 'X'
      EXPIRATION             = '9'
      PRIORITY               = '1'
    IMPORTING
      OUT_PARAMETERS         = MSTR_PRINT_PARMS
      VALID                  = MC_VALID
    EXCEPTIONS
      ARCHIVE_INFO_NOT_FOUND = 1
      INVALID_PRINT_PARAMS   = 2
      INVALID_ARCHIVE_PARAMS = 3
      OTHERS                 = 4.


*-- Make sure that a printer destination has been set up
*-- If this is not done the PDF function module ABENDS
      IF MSTR_PRINT_PARMS-PDEST = SPACE.
        MSTR_PRINT_PARMS-PDEST = 'LP01'.
      ENDIF.

*-- Explicitly set line width, and output format so that
*-- the PDF conversion comes out OK
      MSTR_PRINT_PARMS-LINSZ = '255'.
      MSTR_PRINT_PARMS-PAART = 'X_65_255'.

* Store the current selection screen details
      CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
        EXPORTING
          CURR_REPORT     = SY-REPID
        TABLES
          SELECTION_TABLE = I_RSPARAMS
        EXCEPTIONS
          NOT_FOUND       = 1
          NO_REPORT       = 2
          OTHERS          = 3.

* SUBMIT TO GET THE SPOOL NUMBER
      SUBMIT <Z-PROGRAM> WITH SELECTION-TABLE I_RSPARAMS
      TO SAP-SPOOL
      SPOOL PARAMETERS MSTR_PRINT_PARMS
      WITHOUT SPOOL DYNPRO
      AND RETURN.

      WAIT UP TO 2 SECONDS.

* SELECT THE RECENTLY CREATED SPOOL
      SELECT MAX( RQIDENT ) INTO MI_RQIDENT FROM TSP01
      WHERE RQCLIENT = SY-MANDT
      AND RQOWNER = SY-UNAME.

*REPORT TO GENERATE SPOOL NUMBER FOR PDF CONVERT
      SUBMIT RSTXPDF5 WITH SPOOLNO = MI_RQIDENT
      WITH DSTDEVIC = 'LP01' AND RETURN .

      IF SY-SUBRC EQ 0.
        CLEAR MI_RQIDENT.

* SELECT THE RECENTLY CREATED SPOOL FOR PDF
        SELECT MAX( RQIDENT ) INTO MI_RQIDENT FROM TSP01
        WHERE RQCLIENT = SY-MANDT
        AND RQOWNER = SY-UNAME.

*REPORT TO DOWNLOAD PDF SPOOL TO GUI

        SUBMIT RSTXPDFT5 WITH SPOOLID = MI_RQIDENT
        AND RETURN.
      ENDIF.

This is the link which helped to get the solution.

[http://sapprograms.blogspot.com/2008/11/create-pdf-from-abap.html]