SUBMIT program and spool number

How to get a spool number (SY-SPONO or any other number) of the list created by a SUBMIT command, when using
SUBMIT.. TO SAP-SPOOL
Also note that the SUBMIT is executed with in a batch / background job
Helpful answers will be definitely rewarded

I tried using SY-SPONO, the problem is SY-SPONO is not set after the SUBMIT command both in foreground and background modes.
I want to access the spool created by a SUBMIT command in the calling program.
I think, I have found out a way to do this, will have to test.. but if there is any better way...
  submit (p_repid) to sap-spool without spool dynpro
                   spool parameters mstr_print_parms
                   via selection-screen
                   and return.
*-- Find out what the spool number is that was just created
  perform get_spool_number using sy-repid
             sy-uname
    changing mi_rqident.
  form get_spool_number using f_repid
     f_uname
                changing f_rqident.
  data:
    lc_rq2name like tsp01-rq2name.
  concatenate f_repid+0(8)
              f_uname+0(3)
    into lc_rq2name separated by '_'.
  select * from tsp01 where  rq2name = lc_rq2name
  order by rqcretime descending.
    f_rqident = tsp01-rqident.
    exit.
  endselect.
  if sy-subrc ne 0.
    clear f_rqident.
  endif.
endform." get_spool_number
<a href="http://abap4.tripod.com/Save_Report_Output_to_a_PDF_File.html">Credits</a>

Similar Messages

  • How to find out spool number from a jobname.

    Hi,
    If I know the jobname and jobcount how to find the spool number of it. Jobname and Jobcount are in table TBTCO and spool number is in TSP01. Is there any link between these tables.
    Your help will be appreciated.
    Thanks & Regards,
    Soumya.

    Hi,
    Check the below link
    [Re:Spool request;
    Regards,
    Surinder

  • Call program and return with data

    Hi, Experts,
    I have called a program from my main program using SUBMIT
    and return.
    I need to get data back from called program in table format.
    Is there any way to fullfill such requirement.
    Regards
    Rajiv singh.

    if the program is custom , then you can use import and export  option. you can export the data to memory in the submit program, and import from memory after submit call.
    if it Standard program , in some standard programs also will export data to memory , so check in inside the program.

  • How to get Spool Number after submtting the program and return

    Hi All,
    Could you please assist me on this issue. I have ABAP program which will create a spool number and this spool number is generated by submitting the same report. Now when try to retrive the spool number from sy-spono it is displaying as 000000 but it suppose to be the spool which is created during submit program. COuld you please assist me on this issue. I have added the part of code for your reference,
    DATA: l_params TYPE pri_params,
    l_valid TYPE string,
    w_spool_nr like sy-spono,
    p_m_werks like marc-werks.
    export p_werks to memory id 'P_WERKS'.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
    IMPORTING
    out_parameters = l_params
    valid = l_valid
    IF sy-subrc <> 0.
    ENDIF.
    import p_werks from memory id 'P_WERKS'.
    p_m_werks = p_werks.
    SUBMIT zmmlist01 with p_werks eq p_m_werks
    to SAP-SPOOL
    spool parameters l_params
    without spool dynpro and return.
    write: sy-SPOno.
    Thanks & Regards,
    Nagaraj Kalbavi

    Hi,
    You can use the code snippet as below :
    SELECT MAX( RQIDENT ) INTO G_SPOOL_NUM
    FROM TSP01
    WHERE RQCLIENT = SY-MANDT AND
    RQOWNER = SY-UNAME.
    Also you can use the FM RSPO_FIND_SPOOL_REQUESTS' and pass the relevant parameters to this FM. This should get you the desired results.
    Hope this would be of some help!!
    Regards,
    Lalit Kabra

  • Spool number and program name

    Hi All,
    Im trying to fetch spool number based on object name(program name).
    The table TSP01 has the field RQ2NAME has the program name in it, with some additional characters.
    For example, if the program name is ZQRR1234 , its showing it as ZQRR1234_ABC.
    Is there any other way to fetch spool numbers other than this? Please let me know.
    The other issue is, Spool created for ReportWriter reports, are having a different name in the RQ2NAME field(Totally different from the above case). For example if the report name is Z31L, its showing as GP3ITN115113. Im not sure whether this name will be same in Quality and production system.
    Finally please let me know how to fetch spool numbers based on program name in either case.

    Hello Saravanan,
    Please use FM RSPO_OUTPUT_SPOOL_REQUEST to display your spool.
    Have a Nice Day,
    Regards,
    Sujeet

  • How to get spool number when using SUBMIT job

    Hi All,
    I am calling standard program using SUBMIT through JOB as below. Now I need spool number for this job to covert the output to PDF and send to mail. See the below code and guide me.
    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.
      data: Zscreen type table of RSPARAMS with header line.
       Zscreen-selname = 'PM_AENNR'.
       Zscreen-kind = 'P'.
       ZSCREEN-LOW = '500000000125'.
       APPEND ZSCREEN.
    SUBMIT RCC00130 WITH selection-table Zscreen TO SAP-SPOOL
                        SPOOL PARAMETERS print_parameters
                       WITHOUT SPOOL DYNPRO
                        VIA JOB name NUMBER number
                        AND RETURN.
      IF sy-subrc = 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

    Hi,
    Do this way, first get print parameters by using function module 'GET_PRINT_PARAMETERS'
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
        EXPORTING
          destination    = 'LP01'
          list_name      = 'TEST'
          list_text      = 'SUBMIT ... TO SAP-SPOOL'
          immediately    = ' '
          line_size      = '1023'
          no_dialog      = 'X'
        IMPORTING
          out_parameters = wa_pri_params
          valid          = w_valid.
    If it returns success then
        IF w_valid EQ 'X'.
          CONCATENATE 'R'                                   
                       w_tabix                                
                       sy-datum+4(4)
                       sy-uzeit INTO
                       wa_pri_params-plist.
        ENDIF.
        SUBMIT rprccc00
               WITH firmennr = w_cid
               WITH bel_clus = 'X'
               WITH testlauf = ' '
               WITH not_lokl = 'X'
               WITH file_in  = w_arc_out
               TO SAP-SPOOL WITHOUT SPOOL DYNPRO
               SPOOL PARAMETERS wa_pri_params AND RETURN.
        COMMIT WORK AND WAIT.
    SELECT rqident
             FROM tsp01
             INTO w_rqident
             UP TO 1 ROWS
             WHERE rq2name = wa_pri_params-plist.
      ENDSELECT.
    CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
        EXPORTING
          src_spoolid     = w_rqident
          no_dialog       = 'X'
          dst_device      = 'LP01'
          pdf_destination = 'X'
        TABLES
          pdf             = t_pdf.
    Hope it solves your problem
    Regards
    Krishna

  • Getting spool number after SUBMIT report statement

    Hello Everyone,
    Suppose there is a scenario, when 3 users are sharing same session and executing a program simultaneously.
    In the program, the users are submitting a program to sap spool such that a spool no is generated.
    and based on that spool no, the users read its log...
    How will we identify that which spool no belongs to which particular session so that the the user will read its own loag and not the other person/'s log...

    Hi,
    The program can be submitted as a job which has a unique job number and accordingly spool number will be generated which can read.
    See code e.g below:
    DATA: number TYPE tbtcjob-jobcount,
          name TYPE tbtcjob-jobname VALUE 'JOB_TEST',
          print_parameters TYPE pri_params.
    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 submitable TO SAP-SPOOL
                        SPOOL PARAMETERS print_parameters
                        WITHOUT SPOOL DYNPRO
                        VIA JOB name NUMBER number
                        AND RETURN.
      IF sy-subrc = 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.
        ENDIF.
      ENDIF.
    ENDIF.
    Hope it helps.
    Regards,
    Mansi.

  • SUBMIT program VIA JOB and SET/GET parameter

    Hi All
    I need to pass the content of a variable from the program 'A' to program 'B'.
    Program A uses JOB_OPEN , SUBMIT program VIA JOB jobname NUMBER jobnumber AND return, JOB_CLOSE.
    I tried to use import/export memory but it didn't work. Then I am trying to use set/get parameters but it also did not work.
    Program A is going to run in any server and program B will run in the central instance (it is determined in the FM JOB_CLOSE, parameter target_server).
    Program does not have selection-screen.
    Is it possible use set/get parameter with submit via job?
    Could you please advise?
    Thanks in advance.
    João Gaia

    Here a simple code
    *Submit report as job(i.e. in background)
    data: jobname like tbtcjob-jobname value
                                 'TRANSFER DATA'.
    data: jobcount like tbtcjob-jobcount,
          host like msxxlist-host.
    data: begin of starttime.
            include structure tbtcstrt.
    data: end of starttime.
    data: starttimeimmediate like btch0000-char1 value 'X'.
    * Job open
      call function 'JOB_OPEN'
           exporting
                delanfrep        = ' '
                jobgroup         = ' '
                jobname          = jobname
                sdlstrtdt        = sy-datum
                sdlstrttm        = sy-uzeit
           importing
                jobcount         = jobcount
           exceptions
                cant_create_job  = 01
                invalid_job_data = 02
                jobname_missing  = 03.
      if sy-subrc ne 0.
                                           "error processing
      endif.
    * Insert process into job
    SUBMIT zreport and return
                    with p_param1 = 'value'
                    with p_param2 = 'value'
                    user sy-uname
                    via job jobname
                    number jobcount.
      if sy-subrc > 0.
                                           "error processing
      endif.
    * Close job
      starttime-sdlstrtdt = sy-datum + 1.
      starttime-sdlstrttm = '220000'.
      call function 'JOB_CLOSE'
           exporting
    "            event_id             = starttime-eventid
    "            event_param          = starttime-eventparm
    "            event_periodic       = starttime-periodic
                jobcount             = jobcount
                jobname              = jobname
    "            laststrtdt           = starttime-laststrtdt
    "            laststrttm           = starttime-laststrttm
    "            prddays              = 1
    "            prdhours             = 0
    "            prdmins              = 0
    "            prdmonths            = 0
    "            prdweeks             = 0
    "            sdlstrtdt            = starttime-sdlstrtdt
    "            sdlstrttm            = starttime-sdlstrttm
                strtimmed            = starttimeimmediate
    "            targetsystem         = host
           exceptions
                cant_start_immediate = 01
                invalid_startdate    = 02
                jobname_missing      = 03
                job_close_failed     = 04
                job_nosteps          = 05
                job_notex            = 06
                lock_failed          = 07
                others               = 99.
      if sy-subrc eq 0.
                                           "error processing
      endif.
    Then... for import/export of a variable, you can use Import Memory and Export Memory function.
    Like this:
    REPORT A:
      IF NOT it_dlist_out IS INITIAL.
        EXPORT it_dlist_out TO MEMORY ID 'TEST1234'.
      ELSE.
    * Clearing memory
        FREE MEMORY ID 'TEST1234'.
      ENDIF.
    REPORT B:
    IMPORT it_dlist_out TO lt_dlist_out FROM MEMORY ID 'TEST1234'.
    Edited by: spantaleoni on Jan 11, 2011 3:21 PM
    Edited by: spantaleoni on Jan 11, 2011 3:23 PM

  • Spool number of sumitted program

    Hello,
    does somebody know, how I can get the generated spool number of a submitted program?
    Unfortunately, the system variables sy-spono or sy-sponr will be deleted, when the submitted program will be left.
    Is it possibly feasible to get the spool number between the function modules 'JOB_OPEN' and 'JOB_CLOSE'?
    Thanks a lot and regards.
    Sergej

    Hello Sergej,
    Yes, you can get the Spool Number from the Job created.
    1. Use the FM: 'GET_JOB_RUNTIME_INFO' to get the Background Job Runtime Data.
    2. Then use the table TBTCP to get the Spool Number.
    * get the 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.
    * Get the spool number
    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.
    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.
    Hope this helps.
    BR,
    Suhas

  • SUBMIT 'program'TO SAP-SPOOL LAYOUT

    Hi all.,
    The problem is i call a transaction from my program ,And the output of the tansaction should not be displayed.. but should be saved in spool and return to the
    called report..(i have acheived this ) but i get a warning message.. how to correct it..
    code used:
    SUBMIT ppio_entry TO SAP-SPOOL LAYOUT 'zlayout'
       VIA SELECTION-SCREEN
       KEEP IN SPOOL 'X'
       WITHOUT SPOOL DYNPRO
       AND RETURN.
    warning:
    The "SUBMIT ... TO SAP-SPOOL WITHOUT SPOOL DYNPRO" statement produces          
    unexpected results without the essential ("DESTINATION", "IMMEDIATELY",          
    "KEEP IN SPOOL") print parameters.          
    thanx in advance.

    Hi ,
    When you add   "WITHOUT SPOOL DYNPRO"  , the standard pop up which tells the details like
    DESTINATION  of the print spool
    and when to print ( IMMEDIATELY ) is suppressed
    Kindly pass these too
    SUBMIT ppio_entry  TO SAP-SPOOL LAYOUT 'zlayout'
    VIA SELECTION-SCREEN
    DESTINATION 'locl'
    KEEP IN SPOOL 'X'
    IMMEDIATELY 'X'
    WITHOUT SPOOL DYNPRO
    AND RETURN.
    Thanks
    Soumyadip

  • Capturing spool number while submit report

    Hi all,
    Thanx for ur replies. I'm trying submit to spool. This wud suffice my req. But how to capture the spool number other than going to tsp01 as everythng happens in background. Ineed to further process the spool number. My code is
    SUBMIT rkpep005 USING SELECTION-SET 'TEST1'
    TO SAP-SPOOL
    WITHOUT SPOOL DYNPRO
    AND RETURN.

    hi,
    There are some system parameters which captures the spool number.
    sy-spono -> Contains the name of the spool number during printing.
    SY-PRDSN -> Contains the name of the spool file during printing.
    Rgds,
    Jothi.P
    *Ps close the thread once you got the answer.
    Those don't work with submits.
    Regards,
    John
    Edited by: John Smith on Nov 30, 2010 3:40 PM

  • Problem with submit for spool number generation

    Hi All,
    I have a ALV report which downloads the output to pdf . I have a footer data in the END_OF_PAGE event which should be displayed for each page. It works fine if I take a  printout using the print option in the report output screen and generate a spool number the footer is getting printed.
    But when I use a submit to sap-spool....statement to generate the spool number the footer is not displayed.
    Any suggestions??

    Hi RAkesh,
    Are you using the FM 'REUSE_ALV_COMMENTARY_WRITE' for footer text or simple using the write statements.
    try with the both options, still problem provide the complete code.
    Regards,
    Satya.

  • How to find the number of Z or Y programs and amount of code lines?

    hi all, I'm trying to find the number of programs on user namespace (Z* or Y*) and the number of coded lines in them. something like report Z_MY_REPORT, lines 582; Include Z_MY_INCLUDE, lines 135.
    Exist any standard report to do it or do I have to develop it by myself?
    thanks for any suggestion.

    If you have to do in urself
    DATA: i_reptx TYPE STANDARD TABLE OF textpool WITH HEADER LINE.
    READ TEXTPOOL 'ZJ_ALV' INTO i_reptx.
    and describe the itab.. and get  the lines.
    In conjunction with TADIR table to get the program repository.

  • Create spool in a program and read spool in same program

    hi all,
    i have a requirement like i have to create a spool in a program and should read that spool and send a email in same program.
    i m done with creating spool and sending email but the problem is when i execute a program the spool is created only after total program execution, is there a way to create a compleate spool before finishing the report execution.
    thanks,

    Solution:
    call function 'GET_PRINT_PARAMETERS'
          exporting
            destination    = 'LP01'
            copies         = count
            list_name      = 'ZTEST'
            list_text      = 'ZTESTSPOOL'
            immediately    = ' '
            release        = 'X'
            new_list_id    = 'X'
            expiration     = days
            line_size      = 90
            line_count     = 65
            layout         = 'X_PAPER'
            sap_cover_page = 'X'
            receiver       = 'SAP*'
            department     = 'System'
            no_dialog      = 'X'
          importing
            out_parameters = params
            valid          = valid.
        new-page print on parameters params no dialog.
    write : hi this is the test for spool.
    new-page print off.
        commit work.
    write : / sy-spono.   "system variable for spool no
    solved thanks
    anupama.

  • Submit program exporting list to memory and return in background

    Dear Experts,
    I am using the following code in one of my program to get opening and closing stock of a material.
    SUBMIT RM07MLBD
             WITH MATNR IN LOC_R_MATNR
             WITH WERKS IN LOC_R_WERKS
             WITH DATUM IN LOC_R_DATE
             WITH PA_SUMFL = WL_X
             AND RETURN
             EXPORTING LIST TO MEMORY.
    The program is working fine when executed in foreground. however when executed in background the job is cancelled. I tried to debug in background through SM50 and found that the program is terminated(No short dump but debug screen is closed and i dont see this program running in SM50) when the above code is executed.
    I found in the forum that when an ALV report is submitted in background it does not work. In my case the standard program is producing an ALV list (not ALV grid though).
    How would i avoid this situation because the program i am submitting is a standard program.
    What is the best solution to avoid from background jobs being cancelled when the above code is executed. Is there an alternate way that i can use to submit the program  and get data.
    Thanks in advance.
    Rajesh.

    Hi Rajesh,
    Just excute your standard program with the same input in back ground mode and check
    out put is coming or not .
    If output is not coming search by sy-batch and make the break points there and Ideantify
    the problem.
    When you execute the standard program  in back ground mode If the output is come it should in your Zreport also.
    I tried in my system in background mode also the output is coming for me.
    Thnx,
    Sam.

Maybe you are looking for