Retrieve cancelled background job and display it user on the selection scre

Hi all,
i am executing a background job and if successful it sends an email to the user .
if the job gets cancelled i want to display the job status to the user or email the user .
can anyone share your experiences on this .
thanks in advance.
regards,
Ry

U can use the FM 'BP_JOBLOG_READ' for the aborted jog to get their  status log..then u can send this log to the user via mail.
pl. check this sample code..
REPORT ZEXAMPLE.
DATA: JOBLIST LIKE TBTCJOB OCCURS 0 WITH HEADER LINE,
      JOBDETS LIKE BTCSELECT,
      JOBLOG  LIKE TBTC5 OCCURS 0 WITH HEADER LINE,
      V_ANS.
PARAMETERS P_UNAME LIKE SY-UNAME DEFAULT SY-UNAME OBLIGATORY.
IF NOT P_UNAME IS INITIAL.
  JOBDETS-JOBNAME     = '*'.
  JOBDETS-USERNAME    = P_UNAME.
  JOBDETS-FROM_DATE   = SY-DATUM.
  JOBDETS-TO_DATE     = SY-DATUM.
  JOBDETS-NO_DATE     = 'X'.
  JOBDETS-WITH_PRED   = 'X'.
  JOBDETS-PRELIM      = 'X'.
  JOBDETS-SCHEDUL     = 'X'.
  JOBDETS-READY       = 'X'.
  JOBDETS-RUNNING     = 'X'.
  JOBDETS-FINISHED    = 'X'.
  JOBDETS-ABORTED     = 'X'.
ENDIF.
CALL FUNCTION 'BP_JOB_SELECT'
     EXPORTING
          JOBSELECT_DIALOG    = 'Y'
          JOBSEL_PARAM_IN     = JOBDETS
     TABLES
          JOBSELECT_JOBLIST   = JOBLIST
     EXCEPTIONS
          INVALID_DIALOG_TYPE = 1
          JOBNAME_MISSING     = 2
          NO_JOBS_FOUND       = 3
          SELECTION_CANCELED  = 4
          USERNAME_MISSING    = 5
          OTHERS              = 6.
IF SY-SUBRC EQ 0.
  IF NOT JOBLIST[] IS INITIAL.
    READ TABLE JOBLIST INDEX 1.
    CALL FUNCTION 'BP_JOBLOG_READ'
         EXPORTING
              JOBCOUNT              = JOBLIST-JOBCOUNT
              JOBNAME               = JOBLIST-JOBNAME
         TABLES
              JOBLOGTBL             = JOBLOG
         EXCEPTIONS
              CANT_READ_JOBLOG      = 1
              JOBCOUNT_MISSING      = 2
              JOBLOG_DOES_NOT_EXIST = 3
              JOBLOG_IS_EMPTY       = 4
              JOBLOG_NAME_MISSING   = 5
              JOBNAME_MISSING       = 6
              JOB_DOES_NOT_EXIST    = 7
              OTHERS                = 8.
    IF JOBLOG[] IS INITIAL.
      WRITE:/ 'NO JOB LOG FOUND'.
    ELSE.
      CALL FUNCTION 'POPUP_TO_CONFIRM'
           EXPORTING
                TITLEBAR      = 'DELETE JOB LOGS'
                TEXT_QUESTION = 'JOB LOGS FOUND. DELETE?'
                POPUP_TYPE    = 'W'
           IMPORTING
                ANSWER        = V_ANS.
    ENDIF.
    IF V_ANS EQ '1'.
      CALL FUNCTION 'BP_JOB_DELETE'
           EXPORTING
                JOBCOUNT                 = JOBLIST-JOBCOUNT
                JOBNAME                  = JOBLIST-JOBNAME
           EXCEPTIONS
                CANT_DELETE_EVENT_ENTRY  = 1
                CANT_DELETE_JOB          = 2
                CANT_DELETE_JOBLOG       = 3
                CANT_DELETE_STEPS        = 4
                CANT_DELETE_TIME_ENTRY   = 5
                CANT_DERELEASE_SUCCESSOR = 6
                CANT_ENQ_PREDECESSOR     = 7
                CANT_ENQ_SUCCESSOR       = 8
                CANT_ENQ_TBTCO_ENTRY     = 9
                CANT_UPDATE_PREDECESSOR  = 10
                CANT_UPDATE_SUCCESSOR    = 11
                COMMIT_FAILED            = 12
                JOBCOUNT_MISSING         = 13
                JOBNAME_MISSING          = 14
                JOB_DOES_NOT_EXIST       = 15
                JOB_IS_ALREADY_RUNNING   = 16
                NO_DELETE_AUTHORITY      = 17
                OTHERS                   = 18.
      IF SY-SUBRC EQ 0.
        WRITE:/ JOBLIST-JOBCOUNT, JOBLIST-JOBNAME, 'LOG DELETED'.
        EXIT.
      ELSE.
        WRITE:/ JOBLIST-JOBCOUNT, JOBLIST-JOBNAME, 'LOG NOT DELETED'.
      ENDIF.
    ELSE.
      CALL FUNCTION 'BP_JOBLOG_SHOW'
           EXPORTING
                JOBCOUNT                  = JOBLIST-JOBCOUNT
                JOBNAME                   = JOBLIST-JOBNAME
           EXCEPTIONS
                ERROR_READING_JOBDATA     = 1
                ERROR_READING_JOBLOG_DATA = 2
                JOBCOUNT_MISSING          = 3
                JOBLOG_DOES_NOT_EXIST     = 4
                JOBLOG_IS_EMPTY           = 5
                JOBLOG_SHOW_CANCELED      = 6
                JOBNAME_MISSING           = 7
                JOB_DOES_NOT_EXIST        = 8
                NO_JOBLOG_THERE_YET       = 9
                NO_SHOW_PRIVILEGE_GIVEN   = 10
                OTHERS                    = 11.
    ENDIF.
  ELSE.
    WRITE:/ 'NO JOBS FOR', P_UNAME.
    EXIT.
  ENDIF.
ENDIF.
Regards,
Joy.

Similar Messages

  • Retain background jobs and its variants before system refresh activity

    Hello All,
    I am going to perform system refresh activity on quaity system on monday. Customer wants to retain the background jobs and its variants in the quality system. Please guide me and let me know the steps to retain the background jobs and its variants before starting the system refresh activity.
    Regards
    Subbu

    Dear Subbu,
    You have to export the TBT* Tables to retain the jobs. You can do this with R3trans:
    1. Make Export file
    2. Make Import file
    3. Make Export in Q System before Systemcopy
    4. Start Database and not SAP
    5. Make Import in Q after Systemcopy
    6. Start sap
    1. Make Export file /tmp/export_cmd
    export
    file='/tmp/export_Q.dmp'
    client=<your client>
    delete from TBTCA               
    delete from TBTCB               
    delete from TBTCCNTXT           
    delete from TBTCCTXTT           
    delete from TBTCCTXTTP          
    delete from TBTCI               
    delete from TBTCJCNTXT          
    delete from TBTCJSTEP           
    delete from TBTCO               
    delete from TBTCO_V01           
    delete from TBTCP               
    delete from TBTCPV              
    delete from TBTCR               
    delete from TBTCS               
    delete from TBTC_SPOOLID        
    delete from BTCEVTJOB
    select * from TBTCA             
    select * from TBTCB             
    select * from TBTCCNTXT         
    select * from TBTCCTXTT         
    select * from TBTCCTXTTP        
    select * from TBTCI             
    select * from TBTCJCNTXT        
    select * from TBTCJSTEP         
    select * from TBTCO             
    select * from TBTCO_V01         
    select * from TBTCP             
    select * from TBTCPV            
    select * from TBTCR             
    select * from TBTCS             
    select * from TBTC_SPOOLID 
    select * from BTCEVTJOB
    2. Make Import file /tmp/import_cmd
    import
    file='/tmp/export_Q.dmp'
    3. Make Export in Q System before Systemcopy
    R3trans -w /tmp/Q_export.log  /tmp/export_cmd
    4. Start Database and not SAP
    sqlplus "/as sysdba"
    SQL> startup
    or
    startsap
    stopsap r3
    5. Make Import in Q after Systemcopy
    R3trans -w /tmp/Q_import.log  /tmp/import_cmd
    If you want to undo this, start the export script in P system and the Import script in Q system.
    Don't be afraid of the delete statement but without delete it doesn't work!
    6. Start sap
    startsap
    Best regards
    Willi Eimler

  • Run the Report as a Background job and Get the Output in Excel in Local PC

    Hello Gurus,
    I have one following requirement.
    One should be able to run the report as a background job and it should be possible to get the report in Excel format, also when running the report in background. The excel report should have the same information and look as the current SAPreport.
    Please provide some solution.
    Any helpful answer get surely awarded.
    Thanks a lot,
    Varlanir

    GUI_* WS_* Function In Background, CSV Upload
    GUI_* and WS_* function modules do not work in background
    When scheduling a job in the background the appropriate statement to read in your file is OPEN DATASET, and the file must be on the file system that the SAP server can see.
    At anytime, a user can switch of the Personal Computers even though the job is still running in the background.  Therefore GUI_* and WS_* function modules are not designed to work in that way, as they need to access your personal computer  file.
    To choose the correct download method to used, you can check the value of SY-BATCH in your code,
    if it is 'X' use OPEN DATASET and if it is ' ' use WS_UPLOAD.
    *-- Open dataset for reading
    DATA:
      dsn(20) VALUE '/usr/test.dat',
      rec(80).
    OPEN DATASET dsn FOR INPUT IN TEXT MODE.
    IF sy-subrc = 0.
      DO.
        READ DATASET dsn INTO rec.
        IF sy-subrc <> 0.
          EXIT.
        ELSE.
          WRITE / rec.
        ENDIF.
      ENDDO.
    ENDIF.
    CLOSE DATASET dsn.
    *-- Open dataset for writing
    DATA rec(80).
    OPEN DATASET dsn FOR OUTPUT IN TEXT MODE.
      TRANSFER rec TO '/usr/test.dat'.
    CLOSE DATASET dsn.
    What is the difference when we use upload, ws_upload, gui_upload function modules?
    UPLOAD, WS_UPLOAD, GUI_UPLOAD, are used in BDC concepts.  ie., Batch Data Communication.
    Batch Data Conversion is a concept where user can transfer the Data from non SAP to SAP R/3.  So , in these various Function Modules are used.
    UPLOAD---  upload a file to the presentation server (PC)
    WS_UPLOAD----    Load Files from the Presentation Server to Internal ABAP Tables.
    WS means Work Station.
    This is used upto SAP 4.6 version.
    GUI_UPLOAD-------    Replaces WS_UPLOAD. Upoad file from presentation server to the app server.  From 4.7 SAP version it is replaced.
    How to Upload csv file to SAP?
    Common File Download Upload Questions:
    How  you upload the data from text file to sap internal table?  From my knowledge its by upload or gui_upload. 
    How you download the data from sap internal table to text file?
    How  you upload the data from xls (excel) file to sap internal table how you download the data from sap internal table to xls(excel) file.
    You can upload data from presentation server to an internal table using gui_upload. Use gui_download to download from internal table to flat file.
    Use fm ALSM_EXCEL_TO_INTERNAL_TABLE to upload data frm excel.
    Use function module GUI_UPLOAD
    The FILETYPE refer to the type of file format you need: For e.g 'WK1' - Excel format , 'ASC' - Text Format etc.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        FILENAME                      = 'C:\test.csv'
       FILETYPE                      = 'ASC'
      TABLES
        DATA_TAB                      = itab
    EXCEPTIONS
       FILE_OPEN_ERROR               = 1
       FILE_READ_ERROR               = 2
       NO_BATCH                      = 3
       GUI_REFUSE_FILETRANSFER       = 4
       INVALID_TYPE                  = 5
       NO_AUTHORITY                  = 6
       UNKNOWN_ERROR                 = 7
       BAD_DATA_FORMAT               = 8
       HEADER_NOT_ALLOWED            = 9
       SEPARATOR_NOT_ALLOWED         = 10
       HEADER_TOO_LONG               = 11
       UNKNOWN_DP_ERROR              = 12
       ACCESS_DENIED                 = 13
       DP_OUT_OF_MEMORY              = 14
       DISK_FULL                     = 15
       DP_TIMEOUT                    = 16
       OTHERS                        = 17.

  • Differences in Background jobs and Dialog jobs

    Hi everyone,
    I am new to SAP and would like a little clarification regarding what is meant by Background jobs and Dialog jobs/processes. We had a situation at our client location where the system got completely bogged down to the point that it almost froze and many of the process chains were failing in BI. As per the basis team, the jobs were triggered as "dialog jobs" instead of "background" jobs which caused a heavy load on the system.
    What is the difference? What happens when the jobs are run in the background or as dialog? Can both be checked in SM37?
    Points will be awarded
    Thanks.

    **Dialog Work process:** The Dialog work process fulfill all requests for the execution of dialog steps triggered by an active user. The dialog work process are not used for request which take long time and which use more cpu. Every dispatcher requires at least two dialog work processes. The dialog work process default time is 300 secs. If the dialog work process does not respond in this time, it will be terminated. Also dialog work process are multiplexed to handle large no of user request.
    **Background Work process:** The background work processes execute programs that run without user interaction. At least two background work processes are required per SAP system. More than one background work processes can be configured per dispatcher. Usually the background work process are used for carrying jobs that take long time to finish, like client copy, client transport etc.., . There are two types of background work process. They are A type and B type. A type background work process are used for mission critical jobs. Background jobs of priority a have high priority than B type back ground jobs.
    you can check your job using tcode SM50.
    Thanks
    Dhiraj

  • Different Subroutines in Background jobs and Dialog jobs

    Hi guys,
    I want to execute some subroutines when the program is running  using a background  job  , and some other subroutines completely different when the user use dialog job ( program -> execute in background ) . I know that sy-batch  = 'X'  in both cases  , but, there is something else to identify them ? , any ideas .
    thank you .

    It will be - he meant that they start the background job from SE38/SA38 not run it online.
    SY-SLSET is a starter point for checking the variant used - dynamic variants are used when you don't pick one from the list.  However, this would not help if the user picked a variant and then scheduled the job dynamically.  Another option is to use function GET_JOB_RUNTIME_INFO in your program.  Assuming your scheduled jobs are named differently, you can check for the condition by checking the name of the running job.  Dynamically created jobs will have the program name as the job name.

  • What is the difference between background job and foreground job

    Hi Experts,
    Could you pls tell me
    What is the difference between background job and foreground job
    and where exactly used background jobs...
    Thanks

    Hello,
    Background jobs - without user interaction, scheduled via SM37.
    Foreground jobs - with user interaction (transactions).
    For more information, please read these: [http://help.sap.com/saphelp_nw04/helpdata/en/e4/2adbda449911d1949c0000e8353423/frameset.htm], [http://help.sap.com/saphelp_nw04/helpdata/en/73/69ef5755bb11d189680000e829fbbd/frameset.htm] and [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/20cb0b44-8f0b-2a10-2381-ca8162bcb5b2].
    Regards,

  • Divide the billing due list into multiple background jobs and start them si

    Hello Gurus,
          How to divide the billing due list into multiple background jobs and start them simultaneously?
    Many thanks,
    Frank

    Hello Frank,
    Check this:
    http://help.sap.com/erp2005ehp_03/helpdata/EN/dd/561076545a11d1a7020000e829fd11/frameset.htm_
    plz assign suitable points, if this helps.
    Rgds,
    Raghu.

  • Triggering a background job of class 'A' from within the ABAP program

    Dear All,
    We are implementing SAP ECC 6.0 on IBM System i, i5/OS V5R4,  SAP kernel 7.00, kernel patch level 173.
    Is there a way to control that when a background job is triggered from within an ABAP program using the : CALL FUNCTION 'JOB_OPEN' statement, the background job is of class A ?
    I know that through transaction SM37, the job class for a background job can be changed manually, but the situation is an outsource company did for us some changes in the native SAP ABAP programs related to some SAP native transactions, and those programs trigger at their end some background jobs, each job running with the name of user running the transaction.
    Through SM37, I can't find a template background job, to be changed to have class 'A'
    The following is an excerpt from the ABAP code, bearing the CALL FUNCTION 'JOB_OPEN' statement :
    FUNCTION z_cs_technical_completion.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(AUFNR) TYPE  VBRP-AUFNR
      DATA jobcount TYPE tbtcjob-jobcount.
      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          jobname                = 'CS_TECH_COMPLETE'
      SDLSTRTDT              = NO_DATE
      SDLSTRTTM              = NO_TIME
      JOBCLASS               =
       IMPORTING
         jobcount               = jobcount
    CHANGING
      RET                    =
       EXCEPTIONS
         cant_create_job        = 1
         invalid_job_data       = 2
         jobname_missing        = 3
         OTHERS                 = 4
      SUBMIT zcs_technical_completion
              WITH p_aufnr EQ aufnr
                AND RETURN
              VIA JOB 'CS_TECH_COMPLETE'
              NUMBER jobcount.
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = jobcount
          jobname              = 'CS_TECH_COMPLETE'
          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
          invalid_target       = 8
          OTHERS               = 9.
    ENDFUNCTION.
    Thank you in advance for your cooperation.
    Best regards.
    Reda Khalifa

    Dear Darren,
    Thank you very much for your cooperation and for your prompt reply.
    Could you please explain to me how to find out the template background job that was first used, or in other words, how things were set up in the first place, i.e. when first the ABAP program was written and executed, there had to be at least one background job created through transaction SM36 ?
    Thank you in advance for your cooperation.
    Best regards.
    Reda Khalifa

  • I am trying to change the color of a background layer and it will not accept the color I want

    I am trying to change the color of a background layer and it will not accept the color I want

    If you want to get help you may have to provide a lot more details about what you are doing (which tools or commands do you use, what exactly happens when it fails, …)?

  • To break out of a non-global zone and become root user in the global zone

    Hi folks
    "to break out of a non-global zone and become root user in the global zone through a kernel bug exploit"
    Is this possible and has SUN allready a fix/workaround/patch for that?
    Cheers

    Is it possible there's a bug in the kernel? Sure.
    Someone would need to find and identify such a bug before it could be fixed. I've not heard of the discovery of a bug like this. You could check the bug database at www.opensolaris.org.
    Darren

  • I am trying to cancel my membership and I can´t find the cancel botton

    I am trying to cancel my membership and I can´t find the cancel botton. Is any other way to cancel it?

    Mariajose_2387 if you have an annual membership please contact our support team directly at Contact Customer Care to cancel your membership.  You can find additional details on how to cancel a membership at Cancel your membership or subscription | Creative Cloud - http://helpx.adobe.com/x-productkb/policy-pricing/cancel-membership-subscription.html.

  • Hide and Display submit button on the Simple search page.

    Heading 1: h1 Hide and Display submit button on the Simple search page.
    I'm trying to set the enabled property of the submit button on the simple search page. The business case is to disable the button if the VO has not returned any rows.
    The Submit button is on the page button bar.
    regards
    Abhi

    Hi,
    I have already added this in my ProcessRequest, the issue I am facing is it the submit button is disabled while I load >the page which is fine. but when I do a search and the query returns rows still the submit button is disabled.---Will nt reuired SPEL here..
    ---On go button click setsession value.
    Follow below steps:
    CO PR:*
    OASubmitButtonBean continueBtn=(OASubmitButtonBean)flowLayout.findChildRecursive("continueBtn");
    if(continueBtn != null && "D".equals(oapagecontext.getSessionValue("Flag"))
    continueBtn.setDisabled(false);
    else if(continueBtn != null )
    continueBtn.setDisabled(true);
    CO PFR:_
    if(pageContext.getParameter("Go") != null)
    oapagecontext.putSessionValue("Flag","D");
    Regards
    Meher Irk
    Edited by: Meher Irk on Mar 22, 2011 7:48 PM
    Edited by: Meher Irk on Mar 22, 2011 7:48 PM

  • I have monthly subscription app how can i know about who cancel subscription ? and how i can calculed the monthly revenue ?

    i have monthly subscription app how can i know about who cancel subscription ? and how i can calculed the monthly revenue ?

    Apple20141 wrote:
    Or open sim tray and find out the carrier ring the carrier and give them numbers on sim
    The carrier will not give out information about the owner of the phone.

  • Unable to remove a host from VMM - Error (2606) Unable to perform the job because one or more of the selected objects are locked by another job.

    I am unable to remove a host from my Virtual Machine Manager 2012 R2. I receive the following error:
    Error (2606)
    Unable to perform the job because one or more of the selected objects are locked by another job.
    Recommended Action
    To find out which job is locking the object, in the Jobs view, group by Status, and find the running or canceling job for the object. When the job is complete, try again.
    I have already tried running the following command in SQL Server Management Studio
    SELECT * FROM [VirtualManagerDB].[dbo].[tbl_VMM_Lock] where TaskID='Task_GUID'
    I received this error back:
    Msg 8169, Level 16, State 2, Line 1
    Conversion failed when converting from a character string to uniqueidentifier.
    I have also tried rebooting both the host and the Virtual Machine Manager Server.  After rebooting them both, I still receive the same error when trying to remove the host.
    Here are my server details
    VMM Server OS = Windows 2012 Standard
    VMM Version = 2012 R2 3.2.7510.0
    Host OS = Windows 2012 R2 Datacenter
    Host Agent Version = 3.2.75.10.0
    SQL Server OS = Windows 2012 Datacenter
    SQL Version = 2012 SP 1 (11.0.3000.0)

    Hi there,
    How many hosts are you managing with your VMM server?
    The locking job might be the background host refresher job. Did you see any jobs in the jobs view, when the host removal job failed?
    If there is no active jobs in the jobs view when this host removal job fails, can you please turn on the VMM tracing, retry the host removal, and paste back the traces for the failed job (search for exception and paste the whole stack)?
    Thanks!
    Cheng

  • Service template problem - Unable to perform the job because one or more of the selected objects are locked by another job - ID 2606

    Hello,
    I’ve finally managed to deploy my first guest cluster with a shared VHDX using a service template. 
    So, I now want to try and update my service template.  However, whenever I try to do anything with it, in the services section, I receive the error:
    Unable to perform the job because one or more of the selected objects are locked by another job.  To find out which job is locking the object, in the jobs view, group by status, and find the running or cancelling job for the object.  ID 2606
    Well I tried that and there doesn’t seem to be a job locking the object.  Both the cluster nodes appear to be up and running, and I can’t see a problem with it at all.  I tried running the following query in SQL:
    SELECT * FROM [VirtualManagerDB].[dbo].[tbl_VMM_Lock] where TaskID='Task_GUID'
    but all this gives me is an error that says - conversion failed when converting from a character string to uniqueidentifier msg 8169, level 16, State 2, Line 1
    I'm no SQL expert as you can probably tell, but I'd prefer not to deploy another service template in case this issue occurs again.
    Can anyone help?

    No one else had this?

Maybe you are looking for

  • How to automatic print to default printer

    now i use this command web.show_document('http://servername:7778/reports/rwservlet?server='|| 'repserver&report='||Para_Repname||'&desformat=pdf&destype=cache&userid='|| Get_Application_Property(USERNAME)||'/'||Get_Application_Property(PASSWORD)||'@'

  • Windows 7 (64) Blue Screen of Death at Start up after installing iTunes 10

    I just got a brand new computer a week ago and decided to install iTunes 10 this evening. The install finished successfully and a message prompted me to restart to complete the installation. So I did. Now my machine will not boot. Each time it does,

  • OT: I am in need of a Emmy membership endorsement

    I am in the process of signing up for my LA Area Associate Membership. I meet all the qualifications, however I need an active member to endorse me. Anyone out there willing to help a fellow FCP user out? I have a pretty extensive background, a resum

  • Button to save as reader enabled

    Good evening! I have a form that I am automatically saving with a button.  However, I will have to go into each form and save as reader-enabled.  It is for evaluation forms--so does not exceed the EULA.  Is there a way to save as reader extended with

  • How can I fix my iphone because no one can hear me.

    How can I fix my iphone4 because no one can hear me.