Cursor memory use in a background job

I am researching a solution for a client, and need help as I'm admittedly an Oracle greenhorn. They run 10g Enterprise Edition.
{color:navy}*The problem*{color}: create a low-priority background process that uses DB inactivity windows to read through a large table (over 25 million records) a row at a time, and perform some simple operations with a few fields from each row. The process needs to be running 24x7 by default, although able to be administratively paused/restarted at any time. It also needs to pause itself M hours after last row read, and restart after a subsequent N hours.
h3.
Oracle Jobs
First, I'm wondering whether this sounds like a task suitable for a "job" managed by the Scheduler (<tt>DBMS_SCHEDULER</tt>), which could be enabled or disabled to mimic pausing/restarting functionality.
h3.
Cursors and memory usage
My second, main question lies with memory usage. One of their main concerns is that the background process not occupy much memory on the server. The general flow I've worked up:
<li> Function1: declare and open a cursor for the main SELECT. This would be run once only. Call Function2.
<li> Function2: the second, main function would perform a fetch of one row on the cursor, and make a call to an auxiliary function to operate on the data. Function2 would be executed constantly as the main process.
<li> Function3: close the cursor. Would be executed upon reaching the last row of the table, or if for some reason the admin. should decide to abort the process prematurely.
<li> If the client decides such, this process may be constant, so it would be restarted automatically with a call back to Function1.
However, I don't understand cursors enough to know if that would occupy a lot of memory on the server throughout the life-cycle of the master process, knowing ahead of time that the resultset the cursor identifies is very large. I've attempted to research this both in manuals (the DB Administrator, SQL Reference, Application Developer's Guide) and these forums, but not able to track down a clear answer -- I got lost somewhere between PGA and SGA memory. The furthest I've gotten in understanding cursors is that they're a mere instruction set, not a copy of the resultset, and therefore don't occupy a substantial amount of resident memory. I would very much appreciate some verification about whether this is accurate or not.
I'm wide open to suggestions -- thanks in advance for the help!

Wow, so many good questions make me only think of more questions! Part of the problem is I don't get to talk directly to the client -- any questions I have (such as statistical data about the main_table) must be formed to my manager, who relays them to the client and then we wait for an answer.
Toine wrote:
Are these 'DB inactivity windows' predictable time windows or do you mean that the process should only eat up resources when activity on the database server is low?Not predictable timeframes, but rather the process should take advantage of database server inactivity.
acadet wrote:
For the large table, how does it get its data and what happens to a row once it has been processed? Is the data static or constantly changing and if it does change, does it happen in a batch or in a series of small update/inserts etc.To my best knowledge, and without compromising the client's security: _the main table represent debts_. This is a financial institution, and it is their primary table. Each record contains about 100 fields which include various dates, amounts, rates, etc. Unfortunately, as I commented before, this table does not have a numeric primary key, but rather the 2 fields (one numeric and one varchar2) which serve together as unique identifiers. It's not a static table, as new debts are added a bit at a time for new clients, etc. Also, the existing debts are updated when rates change, etc. I've requested statistical information on the extent to which the data is updated.
Billy Verreynne wrote:
All SQLs that are parsed and executed in Oracle, is done as cursors. Do not confuse that with how the client deals with that cursor, explicitly, implicitly, via a cursor or ref cursor handle, etc. SQL = cursor.
Andre raised an important point - it sounds like what should be business/functional specifications having technical detail included that needs to be part of the solution. Been in a few boardroom brawls myself over that - telling clients that they must state WHAT needs to be done, and not technically HOW it will be done. Worse offenders usually are senior or executive management that used to be techies decades ago and still think that they are somehow still technically competent at a software engineering level.Of course I was referring to an explicit cursor when I asked about disabling consistent read. I'm very doubtful that this is a good idea any more.
Another challenge I have with this client is that since they are a large company and actually have their own development team, the requirements come from different members of that team. Depending who wrote them, they are better or more poorly stated, and often mix in detailed technical requirements framing a boxed solution. You would expect the management to revise these requirements and weed out the nonessentials that we should be able to propose ourselves... go figure. <steps down from soapbox>
I know it's hard for everyone to understand the main requirements when I've piece-mealed the problem description together. I'm just concerned about not revealing too much information that might even possibly compromise the client.
How does the following solution sound:
I've discarded the "explicit big-momma cursor that does it all ;)" possibility, as it presents way too many issues. Instead, we can propose to the client that we add a column to the debts_table which tracks processing status, 0 or 1. 0 if it hasn't been processed yet or errors occur in processing, and 1 once it's processed successfully. 0 would be the default for all existing records and on addition of new debts. In this way, all I would have to do is select one row at a time, possibly in order of the debt's addition date, and if its processing status is 0 then process it. If it completes successfully, update the status to 1. Flow would return back to the select statement, which would select the next row with status=0, and so on.
Edited by: CrackerJackhammer on Aug 5, 2009 2:43 AM

Similar Messages

  • Actual Varaint Name used in the Background Job

    Hi,
    When a program is executed in Background made the selection screen variant selected is not the one that is shown in the Background Job Step information. There we see variant as &0000000000044.
    I want to find the actual variant that was selected at the time of running the program in background mode.
    Thanks.

    Hi,
    I also faced the same issue and after my R&D i found a workaround for this. Check this out.
    Create a selection screen parameter and hide it.
    PARAMETERS: po_varnt TYPE sy-slset NO-DISPLAY.
    Now place below code in AT SELECTIO-SCREEN OUTPUT event.
    AT SELECTION-SCREEN OUTPUT.
        CHECK sy-batch IS INITIAL.
        CLEAR po_varnt.
        MOVE sy-slset TO po_varnt.
    If you are running in background by pressing F9 from selection screen, Use your hided parameter po_varnt for the variant name instead of sy-slset.
    If you are running the report in foreground or through SM36 then you can use sy-slset to know the variant name.
    Thanks,
    Vinod.

  • How to use function inside background job?

    I try to call function inside job. It does not work. Is it possible to use function inside job or not. I hope you can help me. Here is my example code.
    Start-Job -Name ForestJob {param($v01,$v02)
      $line = @()
      function test {
        return "testvalue"
      $t = test
      $line += $t
    } -ArgumentList $var01, $var02

    Hi,
    Just checking in to see if the suggestions were helpful. Please let us know if you would like further assistance.
    TechNet Subscriber Support
    If you are
    TechNet Subscription
    user and have any feedback on our support quality, please send your feedback
    here.
    Regards, Yan Li

  • Find out particular printers that are being used by background jobs.

    Find out particular printers that are being used by background jobs..
    Hi Gurus,
    I have to remove some printers from SPAD, but before removing those printers I have to make sure that those are not being used by any background jobs.   The table TBTCP can be used to identify which jobs are still using those printers, but this is a tedious process. 
    Any input would be highly appreciated.
    Thank you
    Adil

    Hi Adil,
    I'm lazy so I'd just run this SQL
    select distinct(jobname), pdest from SAPSR3.TBTCP where PDEST in ('LP01', 'LOCL') ;
    Just put the printers you want as shown above and just perform a little manual cross check by checking the job in SM37.
    And that's it .....
    Cheers,
    Amerjit

  • Background job failing

    Experts,
    We have background job running as part of the daily load. The user who created and scheduled the job, his account diabled recently and that makes job failing. I need to keep that job running but can not figure out how to change the user name in the job. For example, 0EMPLOYEE_CHANGE_RUN job based on event  'zemployee' triggers at the end of employee data load. Can you please provide any hint what should I do to change user name or take the ownership to keep this job running. Thanks.
    Regards,
    Nimesh

    Hello,
    Go to SM37--> put job name "0EMPLOYEE_CHANGE_RUN"  and user as "*" to get all users.
    Now select the job with released status>(Menu)Job>change->Steps-> select 1st row > change(pencil icon)>now you see the user name here.
    Change the user name to the user name used for all background job and save.
    Done.
    Happy Tony

  • Schedule Background Jobs

    Hi
    Gurus
    What is Schedule Background Jobs and whatu2019s the use of Schedule Background Jobs
    How it will worku2019s
    Please give me detail Information about Schedule Background Jobs
    Many Thanks
    Mahi

    Hello Mahi,
    The BackGround job - "Program" thats runs in SAP Server and not depend any user interface.
    like Antivirus program on your local station that runs (scaning your computer all the time)  without any user interface (becide tray Icon) and unless you going to Running Proccess on your computer you don't know that it working.
    Schedule BackGround Job its any backGround Job that you schedule to run any time you want and you can make it run recursivly.
    you can go to Transaction SM36 to schedule your Programs.
    Good Luck
    Eli Steklov
    Please Reward Points if it Helped

  • Workprocess for Infinite background job in ABAP

    Dear all,
    I have a background job which has an infinite loop i.e. WITHOUT any exit condition. The loop contains WAIT UPTO x mins statement.
    So my query is if I run this program in background then will the Background Work process which executes this job, always be occupied and cant be used for other background jobs ?  In other words,  will I be wasting 1 BG workprocess for this job since it will never be freed to be used for other background jobs?
    LOOP AT ITAB
    WAIT UP TO x MINS.
    ENDLOOP.
    Requesting your expert insights .
    Thanks in advance.
    BR
    Nilesh

    I am not so sure if this is correct. To my knowledge, BTC processes, as opposed to DIA, never perform "roll out" (e.g. during an RFC call) but just wait until processing continues. I just made a quick test in NW 740 release, there the BTC process remains occupied by my job when it does WAIT UP TO xxx SECONDS. So you occupy one BTC process as long as your job runs.
    Please try out yourself and then award points to whoever is right, please.
    Regards,
      Alex

  • E-Mail for background Job

    Hi All,
    We need to schedule a Job in background in every 30 min or 1 hr, which will monitor all the other Jobs running in background.
    If any job is running more than 30000 sec, it should trigger an email.
    Please guide me how to achieve this( i'm ABAPer).
    Regards
    VEnk@

    see the following t.code may be it will use
    SWWCLEAR_INSERT
    Workflow: Background Job 'SWWCLEAR';
    Workflow: Hintergrundjob 'SWWCLEAR';
    Workflow : job arr.-plan 'SWWCLEAR';
    Workflow: achtergrondjob 'SWWCLEAR'
    Workflow: Background Job 'SWWCLEAR'
    SWWCOND_INSERT
    Workflow: Background Job 'SWWCOND';
    Workflow: Batchjob 'SWWCOND';
    Workflow : job batch 'SWWCOND';
    Workflow: achtergrondjob 'SWWCOND'
    Workflow: Background Job 'SWWCOND'
    SWWD
    Maintain Work Item Error Monitoring;
    Workitem-Fehlerüberwachung pflegen;
    Gérer surveillance erreurs WI;
    Workitem-foutbewaking verzorgen
    Maintain Work Item Error Monitoring
    Edited by: Krupaji on Feb 17, 2010 12:45 PM

  • Trigger a background job after executing tcode MMPV

    Hi All,
    I would like to trigger a background job after executing tcode MMPV. In MMPV, after closing a particular period and entering
    new period, the transaction will be saved. After saving, the background job should be triggered. How to do it?
    Regards,
    Vinod

    Depending what system you are on your best bet would be to create an enhancement point inside a form, that is called after the save has been performed, and raise an event within that form.
    Events can be used to trigger background jobs are maintained in transaction SM62.
    Cheers.

  • Variants for background jobs

    You need to schedule and automate batch jobs in an organisation. There will be multiple variants and multiple steps within same batch jobs. The variants are date dependent and needs to change every day. You need to automatically change the variants every day and schedule the jobs. Also check for the failures in the jobs. Apart from that Once the jobs in one server example : R/3 server ends the jobs in BW servers should be triggered automatically. Explain all steps with proper T codes and also provide a dry run example. Also provide all the table used for the variants purpose.
    Please help on this,thanks
    Narendra

    Hi Narendra,
    The background jobs are scheduled depending on the requirement with specific variants which are both date specific and even specific sometimes. These variants are created for the programs or reports which are run in the background job ,These variants are stored in VARID table for client specific variants and
    VARID_CI for client independent. For most of the times all these jobs are maintained in some job scheduling tools so that they automatically inform about job failures and processes can be automated.In our organisation we use UC4 for background job schedulign and it controls the process as you are looking for.
    Please award points accordingly
    With Regards,
    Junaid
    Message was edited by:
            muhammed junaid

  • Program for background jobs...

    Hi
    I know that when i create any info structure; a program is also created in background viz used while creating background jobs...<b>but i dont know where can i view them</b>? This program is used while creating a background jobs in SM36.......Please correct me if i am wrong
    Suppose i have created info structure S999; then in that case from where to locate that program which must have been created in background?
    Rgds

    Hi,
    While executing the info structure, in the initial screen, click <b>system</b> in the menu bar and click <b>status</b>. in the popping menu you can find the program associated with the info structure.

  • Execution of Macro in Background job

    We have created a macro in APO DP that uses 4 characteristics and a key figure. As part of the macro we are executing a Z-function that we have created. The problem occurs when executing the macro in a background job. When the background job is executed the macro processes correctly (performs the correct calculations) for the first CVC that is processes, but it is not able to process the rest of the CVCs.
    <b>ERROR: "There are no plannable characteristic combinations",</b>
    The function copies data from the CVC that is being processed (source CVC) to another CVC (target CVC). The values for the target CVC to which the data has to be copied for a particular key figure are determined from the paramaters that are given to the function in the macro.
    The steps followed in the function are the following:
    1- Determine the relation between source and target CVC, ie, from the source CVC that is being processes in the macro, the function determines the target CVC to which the data has to be copied.
    2- Call BAPI "BAPI_PBSRVAPS_GETDETAIL2" to retrieve the valuesthat are in the Planning Book for the source CVC.
    3- Perform the addition of data (value retrieved from the source CVC is added to the target CVC).
    4- Write value to the target CVC using BAPI "BAPI_PBSRVAPS_CHANGEKEYFIGVAL2".
    When using the BAPIs the aggregation level used is the same aggregation as the one specified in the Background job used for the execution of the macro.
    This macro is executed in a background job, and the copy/calculation is performed correctly for the first CVC (first CVC contained in the data selection used in the background job) processed, but then it does not do anything else for the rest of CVC's. The error message given by the log of the background job is <b>"There are no plannable characteristic combinations",</b> when in fact, the characteristic combinations do exist in the Planning Object Structure.

    Hi Ian
    There are not any other macros in the planning book.
    In addition, if we execute the macro in interactive mode we have another error at the end of the execution (after doing all the combinations):
    <b>Invalid data status</b>.
    and we don't know why.
    Regards

  • Scheduling a background job using Job_Submit and Job_Close FM

    Hi Guys,
                  I am calling a report in background using Job_Submit and Job_Close FM's.
    I am not providing start time and date in the Job_close FM, in this case, when the job will be scheduled to start.
    Even after an hour, job status is still scheduled.
    I am not exporting variant, since I am using memory ID.
    Thanks
    Edited by: sapgeek007 on May 11, 2009 4:11 AM

    In Job_close fm use the parameter 'STRTIMMED'
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount                          = LV_NUMBER
        jobname                           = LV_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
       INVALID_TARGET                    = 8
       OTHERS                            = 9
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    That would start the background job immediately.
    Regards,
    Deepak

  • How to schedule a background job using the Event concept..?

    Hi Folks,
    I have a requirement that, I need a schedule a background job.
    Once after the previous job successful only, new job should get triggered. How to go ahead with this..?
    For Eg, I am scheduling a job called ZTEST periodically for 1 minute. If the job is not get completing with in 1 minute, I dont want to start my new job. Only after the success of my old job, I want my new job to run.
    Waiting for ur replies.
    Regards,
    Savi.

    Hi,
    You can use events that have already been defined, or you can create new events for scheduling background jobs.
    If you wish to use new events, do the following to implement the event scheduling:
    Define and transport the event as a user event with transaction SM62.
    You must define only event IDs; event arguments are not defined in the R/3 System. Instead, you specify event arguments when you schedule a job to wait for an event and when you trigger the event.
    If you define a new event, you must also transport it to your production systems. The event transaction does not have a connection to the transport system. Instead, you must create a transport request for the event yourself.
    Do this to transport an event:
    Create a transport request.
    Start the editor in the transport request and enter the following:
    R3TR TABU <table name> where table name is BTCSEV for a system event ID, BTCUEV for a user event ID.
    Press F2 with the cursor on the table name to call up the screen for specifying the table entries to transport. In this screen, enter the event ID’s that you have created.
    Save and release the transport request. Ensure that it is imported into your production system(s).
    To trigger an event, add:
    – the function module BP_EVENT_RAISE to your ABAP program, or
    – the program SAPEVT to your external script, batch file, or program.
    When your programs execute these keywords, an event will be triggered in the R/3 background processing system. The event-based scheduler is started immediately. It in turn starts all jobs that were waiting upon the event, subject to normal background processing restrictions, such as the requirement that the job has been released to start.
    Schedule the jobs that are to run when your events are triggered.
    You can schedule jobs for one-time start or to be started whenever an event is triggered.
    Regards,
    Raj.

  • Parallel (same) background jobs:  Memory and locking issues

    <b>Scenerio:</b>  Multiple concurrent inbound asynchronous XI messages need to be processed in SAP.  We have the XI proxy initiating an RFC. This RFC exports internal tables (essentially the XI payload) to a unique shared memory ID (for each XI message). RFC then submits an abap (submit..and return)  in a background job. This abap reads (via IMPORT) the shared memory ID to get the data then process it.
    <b>Problem:</b>  : When multiple concurrent jobs/abap are running, often, but not always, one of the submitted abaps either gets a non-zero return code from the IMPORT, or the IMPORT from shared memory seems to work fine, but the table contents contains data from the other (parallel) run, even though the memory ID used is correct and unique.
    I have attempted to resolve this by using various methods (memory IDs, SPA/GPA parameter, ENQUEUE) of locking in the RFC (unlocking at end of abap), so that only one background job is executed at a time.  However, the best I can do is having two or three running in parallel.
    So I'm wondering how to solve this memory issue and/or how to make the abap processing synchronous?  Any help appreciated. Thanks.

    There is a limitation on Amt of data you can store in ABAP Memory and SAP Memory .. check those limitation ..per user ..
    also check for Number of external session granted by urr basis ppl...
    it may be possible that only 3-4 session are allowed coz each background process create and external session ..

Maybe you are looking for

  • Best practice when using auto complete in view layer

    Hello I have a question regarding best way to store/cash data when using auto complete function in view layer. I know that there will be a lot of visitors that will use this function and I dont want to kill the application server so I need some advic

  • Fire wire question

    I just purchased a new mac book pro and I want to sync it up with my old mac book pro, but I don't know what kind of fire wire cable to buy. The old mac book pro was purchased in 2006-I have no clue waht the correct size cable is for that specific po

  • Dynamic field in where clause

    Hi all, I have a requirement to dynamically select some data into an internal table using table name,table field as parameter and a select option for that field.I am using field symbols for this. Now , i am not able to formulate my select query based

  • When the Adobe Application Manager will open the following message: Download error. What should I do

    When the Adobe Application Manager will open the following message: Download error. What should I do

  • Restricting Authorisations for different controlling areas

    Hi SAP Gurus, I am facing a problem in restricting authorisations for CO Transactions in different controlling ares. We have a new controlling area started recently. But the CO user in this new controlling area is able to create master data in a diff