Application Development 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: 

how to avoid Wait upto 5 seconds

Former Member
0 Kudos

Dear Friends,

I have used the below code for generating the spool by submitting the standard program.

CALL FUNCTION 'JOB_OPEN'
EXPORTING
jobname = lv_job_name
IMPORTING
jobcount = lv_job_nr
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc EQ 0.
SUBMIT RPCEDTX0 
TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS mstr_print_parms
USING SELECTION-SET 'ZPDF'
VIA JOB lv_job_name NUMBER lv_job_nr
AND RETURN.
IF sy-subrc = 0.
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
jobcount = lv_job_nr
jobname = lv_job_name
strtimmed = 'X'
IMPORTING
job_was_released = lv_job_released
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 syst-subrc NE 0.
MESSAGE i162(00) WITH
'An error occured while closing the background job.'.
STOP.
ENDIF.
ENDIF.

   WAIT UP TO 5 SECONDS .

 *get job details
    CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
    IMPORTING
*eventid = gd_eventid
*eventparm = gd_eventparm
*external_program_active = gd_external_program_active
    jobcount =  lv_job_nr  " gd_jobcount
    jobname =  lv_job_name  "gd_jobname
*stepcount = gd_stepcount
    EXCEPTIONS
    no_runtime_info = 1
    OTHERS = 2.
* Get the spool number
    SELECT * FROM tbtcp
    INTO TABLE it_tbtcp
    WHERE jobname = lv_job_name   " gd_jobname
    AND jobcount = lv_job_nr    "gd_jobcount
*   AND stepcount = gd_stepcount
*   AND listident '0000000000'
    ORDER BY jobname
    jobcount.
*stepcount.
    IF sy-subrc = 0.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
      IF sy-subrc = 0.
        gd_spool_nr = wa_tbtcp-listident. "gd_spool_nr --> contains spool no.
      ENDIF.
    ENDIF.
    mi_rqident = gd_spool_nr .
*-- Convert Spool to PDF
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
      EXPORTING
        src_spoolid              = mi_rqident
        no_dialog                = space
        dst_device               = mstr_print_parms-pdest
      IMPORTING
        pdf_bytecount            = mi_bytecount
      TABLES
        pdf                      = mtab_pdf
      EXCEPTIONS
        err_no_abap_spooljob     = 1
        err_no_spooljob          = 2
        err_no_permission        = 3
        err_conv_not_possible    = 4
        err_bad_destdevice       = 5
        user_cancelled           = 6
        err_spoolerror           = 7
        err_temseerror           = 8
        err_btcjob_open_failed   = 9
        err_btcjob_submit_failed = 10
        err_btcjob_close_failed  = 11
        OTHERS                   = 12.

Iam using in my program as WAIT UP TO 5 SECONDS , i dont want to use this option as i wanted to use a better way other than this way to increase the performance , please could anyone let me know what i can do.

If iam not using the WAIT UP TO 5 SECONDS then i found the spool no is not getting generated and there by iam getting an error as spool no found .

Please help me what is the better way of doing .

regards

divya

Formatted by: Vijay Babu Dudla on Apr 27, 2009 9:56 AM

1 ACCEPTED SOLUTION

ThomasZloch
Active Contributor
0 Kudos

Please use tags around source code in future postings.

Since you are using SUBMIT ... VIA JOB, control comes right back to your program and you don't know when the asynchronous job is finished and the spool data is available.

Do you need to schedule this as a job at all? If you use SUBMIT without VIA JOB, then control comes back when the called program is finished and you can read TSP01 right away (instead of TBTCP) to get the spool ID RQIDENT, using a unique RQ2NAME that you set in the SUBMIT ... LIST NAME ... addition.

Works for me

Thomas

4 REPLIES 4

Peter_Lintner
Participant
0 Kudos

Hi!

Use COMMIT WORK AND WAIT instead of the WAIT UP TO ...!

Kind regards

Peter

Edited by: Peter Lintner on Apr 27, 2009 1:48 PM

Former Member
0 Kudos

Hi Divya,

Use Function module BAPI_TRANSACTION_COMMIT this will COMMIT all the entries in current Logical Unit of Work LUW so that you can take forward further processing.

If you are calling this Function module I dont think you will require WAIT.

Regards

Shital

ThomasZloch
Active Contributor
0 Kudos

Please use tags around source code in future postings.

Since you are using SUBMIT ... VIA JOB, control comes right back to your program and you don't know when the asynchronous job is finished and the spool data is available.

Do you need to schedule this as a job at all? If you use SUBMIT without VIA JOB, then control comes back when the called program is finished and you can read TSP01 right away (instead of TBTCP) to get the spool ID RQIDENT, using a unique RQ2NAME that you set in the SUBMIT ... LIST NAME ... addition.

Works for me

Thomas

Former Member
0 Kudos

Hi ,

To avoid wait upto 5 mins, you can simply use the below written code.

*---commit

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'.

Regards,

Ashish