Schedule a Job with multiple steps via ABAP Program

Hi Friends,
I want to create a report(Ex: ZREP) that will run another program(Ex: ZPGM) in background. What I need to do is, when I execute the report ZREP it should run the ZPGM automatically in background. This background execution should happen through JOB with multiple steps.
Why i am mentioned steps is, i have 1000 records in ZTABLE and need to execute 100 records each in one step and need to proecess in ZPGM with selection parameters. So in my case my job should create with 10 steps and need to execute in sequential manner.
FYI, In the ZREP selection screen i need to enter the records count/ interval to derive the job steps.
Please guide how to go ahead? Thanks in advance for all the help.
Regards,
Raghu.

Hi Raghu,
You can try the following pieces of code:
Loop at gt_table.   "This table contains 100 records previously appended
w_jobname = c_job_emision   "Job Name.
    CALL FUNCTION 'JOB_OPEN'
      EXPORTING
        jobname          = w_jobname
      IMPORTING
        jobcount         = w_jobacount
      EXCEPTIONS
        cant_create_job  = 1
        invalid_job_data = 2
        jobname_missing  = 3
        OTHERS           = 4.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
* Perform or create T_SELTAB with parameters options
PERFORM Create_seltab_table.
*Call second program.
SUBMIT ZREP WITH  SELECTION-TABLE t_seltab AND RETURN.
*Close Job.
    CALL FUNCTION 'JOB_CLOSE'
      EXPORTING
        jobcount             = w_jobacount
        jobname              = w_jobname
        strtimmed            = c_x  "Immediate Start
     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.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
ENDLOOP.
Hope this helps.
Regards
Ernesto
PS: Raymond Giuseppi was faster.
Edited by: Ernesto Caballero on Mar 10, 2010 1:57 PM

Similar Messages

  • Schedule Jobs with multiple steps via ABAP Program

    Hi,
    I need to schedule multiple programs via background jobs on a daily basis. Since all these jobs are to be run as a single job, the various programs have to be run as steps in a major job.
    I am however not very clear on how this can be done via an ABAP program ( the idea of a program is that various parameters to be passed to each program in the step can be entered dynamically rather than via variants).
    I am using the JOB_OPEN and JOB_CLOSE functions and submitting the programs with selection screen parameters dynamically passed to create a job. I need to do this for various programs as a job step (WITHOUT Variants being defined).
    Can anyone suggest any ideas for this? I have tried out JOB_SUBMIT Function but am not very confident I know what exactly it is for as it asks for a variant.
    Thanks very much,
    Preet

    Hi Preet,
    just to be sure: you know, that variants can be dynamical, too?
    It's quite usual to assign dynamical current date, but it's also possible to add / subtract value and even define own functionality.
    Maybe it's easier to implement a dynamical selection and handle static jobs.
    If you try to plan a job (online or with JOB_SUBMIT), you have to use variants - you can create (or change) them dynamical in beforehand. Only SE38, F8, F9 is creating a temporary variant, so that no saved variant is necessary.
    But if you end up creating variants dynamical, you can change one existing variant, too. Then you can use a static job definition (with periodical starting rule).
    So: have a look, if dynamic variants are enough, otherwise change variants per job.
    Regards,
    Christian

  • Defining Job with multiple steps

    This is a general question on SM36.
    I have 4 programs that need to run as part of a job. I do not want this as a periodic job because these 4 steps needs to be done by the user when needed.
    I defined a job and created 4 steps and saved. system showed the job is scheduled and then I released it. All the 4 steps ran successfully.
    Now if I want to run again the same job, system is prompting me to create the steps again. I do not want to do that every time i want to run the job. how can I save this 4 steps under a job and just call the job name to schedule immediately on demand/when needed?

    Swathi,
    Create the job, leave the job with a status of  'scheduled' (no start conditions).
    When the user wishes to run the job:  SM37 > select your job; then Job > repeat scheduling. The user will have to determine the trigger; presumably it will be 'Immediate'; however, any of the normal selections are possible.
    This activity will start a copy of your scheduled job.  Your job remains with a status of scheduled.
    Since it is so easy for a user to make a mistake and inadvertently release your job, you might want to create a backup copy.  SM37 > select your job; then Job > copy.  This will give you a screen where you can create a copy of your job, but with a new name, such as <yourjobname>_BAK.
    Best Regards,
    DB49

  • Scheduling a job with multiple output formats.

    Urgent!!
    Basically while scheduling a job in BI Publisher we specify an output format. It can be PDF, CSV, HTML or so… Is there a way to specify more than one output format while scheduling a job.
    Thanks in advance.
    Ashok

    you have to re-publish them.
    for a run, you can have only one output .

  • Job with multiple event schedules

    Is it possible to create a job with multiple schedules? Can you have multiple schedule names?
    DBMS_SCHEDULER.CREATE_JOB (
    job_name => 'my_new_job2',
    job_type => 'PLSQL_BLOCK',
    job_action => 'BEGIN SALES_PKG.UPDATE_SALES_SUMMARY; END;',
    schedule_name => 'my_saved_schedule, my_saved_schedule2'); <------------------ like this?
    END;
    thanks.

    I am using oracle 10g and have installed the file arrival package. I want my job to run when multiple files arrive. I have created the file arrival event schedules. I know i can create chain event steps to respond, but my chain has to be running for the steps to respond to the events. I want the chain (or rather the job that starts the chain) to kick off when 2 or more files arrive.
    thanks.

  • Scheduled Report - Bug with Multiple Selection LOV parameter

    Problem:
    I have a scheduled report with a parameter that has it's "Multiple Selection" checkbox checked. I schedule the report with multiple values selected. When I receive the report via email, the report ran as if I only selected one LOV value instead of multiple values.
    Facts:
    1) Enterprise version 10.1.3.2.1
    2) When you run the report manually with multiple values selected in the LOV, it runs great with the correct dataset.
    3) This scheduled report does not have a Data Template.
    James
    P.S. - I searched this forum for other treads on this issue. I didn't find any. Sorry if this is a duplicate.

    I have this same problem, too.
    When I select multiple parameters on the "View" screen for a given report, everything works fine.
    When I schedule it, however, only the last parameter I clicked on (regardless of whether a select a range or multiple individual values) is passed to the query. The other selections I make are ignored.
    What gives? Am I doing something wrong? Is this a bug? Is there a workaround?

  • Schedule FTP Job with OEM 9i

    Hi All,
    Does anyone have experience of setting schedule ftp job with OEM and could give me some hints or an example, thank you very much. I am now using Oracle 9i.
    Rds,
    CH

    Lucas,
    Your first issue is regarding the control file not being passed. In order to fix that you have to specify the control file in the mapping configuration. Beware that this control file is being read through utl_file, i.e. you will have to set the utl_file_dir in the init parameters of your database to the correct directory in order for the database to be able to read it. Basically, the control file is being read in order to fill the audit tables with the correct data.
    Your second issue is regarding the type of job. As you may know OWB 'integrates' with Oracle Workflow (OWF) as well. The OWF solution also relies on the use of OEM for job execution. All of that is currently managed by Workflow Queue Listener. In order for Workflow Queue listener to be able to correctly handle the OEM jobs (defined as external functions in OWF) the job has to be defined as is. Besides, with the current way of registering the jobs all jobs (PL/SQL, ABAP or SQL Loader) are registered in the same way and directed by parameters.
    Hope this helps,
    Mark.

  • Schedule a job with email destination in BOXI R2 with email format as html

    Hello Guys, would it to possible to schedule a job with email destination in BOXI R2 with email format as html? we are able to get it running with plain text email format. we use Java SDK to interface with BO Enterprise servers.
    thanks for your thoughts,
    Venkat

    Hi
    your job should SMOF_DOWNLOAD can bring new material master if you set up correctly.
    as a smart method smof_download is the best way.
    doble check your filter condition. it should work as you expected. because we dont involve in  manual pulling...
    check your variant once again. in vari table,
    can you check r3ac1 - filter settings- source seetingsa--> source site nmae --> backendlogical system and filter sync..
    br
    Muthu

  • Job with multiple variant

    Dear Friends,
    I have some jobs which has many variants. So it possible to create a job with multiple variants or only option is to create job chain.
    Please suggest.
    Thanks in advance.
    Regards,
    Jiggi

    Hi,
    You can submit the same job with different variant, but that is your runtime.
    Limitation is that you can't migrate all these runtime jobs.
    It is better you create different jobs with different variants, so that you have frexibility to run them independently, monitor and troubleshoot them, also migrate them to next environment (QA or PRD). And you can still create a job chain using all these independent jobs if require.
    Only creating Job Chain would be useful only if you want to run them in parallel or in sequence. (Not if you want to run them independently).
    Hope this help.
    regards,
    Sunil Rohit

  • Who scheduled a job with service user

    Hi,
    In my one of the system one job is running with service user. As service user cannot log into system. One of the dialog user logged in to system and scheduled one job with service user. this job is running more than 2 months. Now we want to know who is that dialog user scheduled this job with service user.  I have checked in job details it is not showing dialog user who has sheduelded first time.
    Pls someone help me in this case.
    Kind regards,
    Ram
    <subject_modified>
    Use a proper subject
    Read the "Rules of Engagement"
    Edited by: Juan Reyes on Jul 1, 2009 10:25 AM

    Just check the job owner.... If the Owner is the service user then most likely the user was changed to service user after the job creation. Also be aware that some jobs are generated by the system.
    Regards
    Juan

  • Send a mail via ABAP program

    Hello Experts,
    I want to send mail via ABAP program with the following requirements :
    1. Recipient is OUTLOOK email -id
    2. Sender address has to be an external email-id
    3. Send mail as CC and BCC also to other email-id.
    Is there any function module which can satisfy all the above requirements.
    Regards,
    Mansi.

    hi,
    this code will definately help you just go through it:
    firstly  exported the data to memory using the FM LIST_FROM_MEMORY.
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = t_listobject
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    IF sy-subrc 0.
    MESSAGE e000(su) WITH text-001.
    ENDIF.
    then i converted it into ASCII using LIST_TO_ASCI,
    CALL FUNCTION 'LIST_TO_ASCI'
    TABLES
    listasci = t_xlstab
    listobject = t_listobject
    EXCEPTIONS
    empty_list = 1
    list_index_invalid = 2
    OTHERS = 3.
    IF sy-subrc NE 0.
    MESSAGE e003(yuksdbfzs).
    ENDIF.
    This gives the data in ASCII format separated by '|' and the header has '-', dashes. If you use this internal table directly without any proccesing in SO_NEW_DOCUMENT_ATT_SEND_API1, then you will not get a good excel sheet attachment. To overcome this limitation, i used cl_abap_char_utilities=>newline and cl_abap_char_utilities=>horizontal_tab to add horizontal and vertical tabs to the internal table, replacing all occurences of '|' with
    cl_abap_char_utilities=>horizontal_tab.
    Set the doc_type as 'XLS', create the body and header using the packing_list and pass the data to be downloaded to SO_NEW_DOCUMENT_ATT_SEND_API1 as contents_bin.
    This will create an excel attachment.
    Sample code for formatting the data for the attachment in excel format.
    u2022     Format the data for excel file download
    LOOP AT t_xlstab INTO wa_xlstab .
    DESCRIBE TABLE t_xlstab LINES lw_cnt.
    CLEAR lw_sytabix.
    lw_sytabix = sy-tabix.
    u2022     If not new line then replace '|' by tabs
    IF NOT wa_xlstab EQ cl_abap_char_utilities=>newline.
    REPLACE ALL OCCURRENCES OF '|' IN wa_xlstab
    WITH cl_abap_char_utilities=>horizontal_tab.
    MODIFY t_xlstab FROM wa_xlstab .
    CLEAR wa_xlstab.
    wa_xlstab = cl_abap_char_utilities=>newline.
    IF lw_cnt NE 0 .
    lw_sytabix = lw_sytabix + 1.
    u2022     Insert new line for the excel data
    INSERT wa_xlstab INTO t_xlstab INDEX lw_sytabix.
    lw_cnt = lw_cnt - 1.
    ENDIF.
    CLEAR wa_xlstab.
    ENDIF.
    ENDLOOP.
    Sample code for creating attachment and sending mail:
    FORM send_mail .
    u2022     Define the attachment format
    lw_doc_type = 'XLS'.
    u2022     Create the document which is to be sent
    lwa_doc_chng-obj_name = 'List'.
    lwa_doc_chng-obj_descr = w_subject. "Subject
    lwa_doc_chng-obj_langu = sy-langu.
    u2022     Fill the document data and get size of message
    LOOP AT t_message.
    lt_objtxt = t_message-line.
    APPEND lt_objtxt.
    ENDLOOP.
    DESCRIBE TABLE lt_objtxt LINES lw_tab_lines.
    IF lw_tab_lines GT 0.
    READ TABLE lt_objtxt INDEX lw_tab_lines.
    lwa_doc_chng-doc_size = ( lw_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
    lwa_doc_chng-obj_langu = sy-langu.
    lwa_doc_chng-sensitivty = 'F'.
    ELSE.
    lwa_doc_chng-doc_size = 0.
    ENDIF.
    u2022     Fill Packing List For the body of e-mail
    lt_packing_list-head_start = 1.
    lt_packing_list-head_num = 0.
    lt_packing_list-body_start = 1.
    lt_packing_list-body_num = lw_tab_lines.
    lt_packing_list-doc_type = 'RAW'.
    APPEND lt_packing_list.
    u2022     Create the attachment (the list itself)
    DESCRIBE TABLE t_xlstab LINES lw_tab_lines.
    u2022     Fill the fields of the packing_list for creating the attachment:
    lt_packing_list-transf_bin = 'X'.
    lt_packing_list-head_start = 1.
    lt_packing_list-head_num = 0.
    lt_packing_list-body_start = 1.
    lt_packing_list-body_num = lw_tab_lines.
    lt_packing_list-doc_type = lw_doc_type.
    lt_packing_list-obj_name = 'Attach'.
    lt_packing_list-obj_descr = w_docdesc.
    lt_packing_list-doc_size = lw_tab_lines * 255.
    APPEND lt_packing_list.
    u2022     Fill the mail recipient list
    lt_reclist-rec_type = 'U'.
    LOOP AT t_recipient_list.
    lt_reclist-receiver = t_recipient_list-address.
    APPEND lt_reclist.
    ENDLOOP.
    u2022     Finally send E-Mail
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = lwa_doc_chng
    put_in_outbox = 'X'
    commit_work = 'X'
    IMPORTING
    sent_to_all = lw_sent_to_all
    TABLES
    packing_list = lt_packing_list
    object_header = lt_objhead
    contents_bin = t_xlstab
    contents_txt = lt_objtxt
    receivers = lt_reclist
    EXCEPTIONS
    too_many_receivers = 1
    document_not_sent = 2
    document_type_not_exist = 3
    operation_no_authorization = 4
    parameter_error = 5
    x_error = 6
    enqueue_error = 7
    OTHERS = 8.
    Hope it will help you
    regards
    Rahul sharma

  • How to extract data from BPC InfoCube via ABAP program?

    Hi experts!!
    I tried to extract data from a BPC InfoCube via ABAP program, but I did'n have succeed.
    I used the function 'RSDRI_INFOPROV_READ' to extract data from standard InfoCubes such as '0COPC_C07' and it run OK! However, when I change the InfoCube name to '/CPMB/WAIX8NE' (BPC InfoCube), everything goes wrong...
    Is there any difference between extracting data from BPC and standard InfoCubes?
    Thank you all!

    Moderator message - Welcome to SCN.
    But please do not cross and duplicate post.
    Thread locked.
    Rob

  • Job with Multiple Schedule of same time & only one is executed, Why

    Hi ALL,
    I've Created a package to notify report in email  as excel, which is using a path to render report and save it as excel.
    This package was need to be schedule every first day of month and on every Friday even at morning 7 AM.
    So logically these are two events.
    But if we see on 1 May 2015 we have Friday and plus first day of month
    So technically this should fail.
    either for IO operation for render &
    storing data over same location with same file name.
    To replicate this i created two three schedule
    Below is the job history, job is invoked by only one schedule
    Question-
    1) Why one one schedule execute?
    2) why "sched2" only , it could be "sched3" only or "DentalOperationStackAndRank-Sched1" Only?
    Another this i result into error if different job executing same package at same schedule.
    FYI- package is deployed at database level
    HS

    Hi HS,
    As described in this
    article, more than one job can run on the same schedule, and more than one schedule can apply to the same job.
    And I make a test about your scenario, when configuring a SQL Server job with three schedules that reference same dates and times, my job behaves as yours that only one schedule is executed, but the job is invoked by schedule2 or schedule 3 in my environment.
    It is a normal behavior of SQL Server job in my opinion. For more details about such scenario, you can track the job following this
    blog.
    However, when I configure three jobs that run on the same schedule, everything works well and the three jobs all run successfully.
     I recommend you configure three different jobs that execute same package at same schedule .
    Thanks,
    Lydia Zhang
    Lydia Zhang
    TechNet Community Support

  • One job with two steps - how to create one single spool?

    Hello experts,
    I have created two queries in SQVI. One is based on the table BSIK, the other on on BSAK.
    The report layout is the same in both queries.
    Now I schedule one job in SM36/SM37 with two steps corresponding to my queries.
    I want my second step to append the spool created in the first step. Is that possible?
    In order to do this I unchecked "New spool request" in the request attributes for the second step of the job.
    I use the same printer, the same format (X_65_80), but it doesnt work.
    The help on the field says
    ".... name, output device, number of prints and the format must match..." - What "name" do they mean?
    "In addition, the existent spool order must not already be competed. This can occur if a spool is released for output...." - I use "send to SAP spooler only" option, is that what thay mean? How cen you have an "uncompleted spool" in the job.
    If anybody knows ho to do this (without development!), please advise
    Best regards,
    Fatima

    Hi,
    Please do following steps :
    1. Go to transaction code SM36
    2. Do as per below screen shots
    You can see Job steps is empty
    Click on (Check and Save)
    Next Screen
    You can see one step created
    Click on Create
    You can see above it is showing as Step 2
    Give again program name and variant
    Click on (Check and Save)
    You can see two steps are created
    Go back (green arrow)
    You can see know SAP is showing 2 Step(s) successfully defined which was earlier blank
    Click on
    Next Screen
    Now schedule job as per your requirement.
    Prerequisite create variants for both the programs as we need to mention the same .
    Hope, this solves your issue else revert.
    Regards,
    Tejas

  • Excel download with multiple worksheets using ABAP webdynpro

    Content of Internal table should to downloaded  to an excel sheet with multiple worksheet.

    Excel doesn't support multiple worksheets with the text tab delimited or any of the other plain text formats.  So if you need multiple worksheets those approaches are out.  Multiple worksheets would only work with the Excel native format or the XML based format.  From ABAP the best approach would be to create the XML Excel format.  Search the forms and wiki has there has been tons of discussion in the mast on the XML Excel format.

Maybe you are looking for

  • CS5.5 Mobile Publish (iOS) - Displaying Office Documents Possible?

    Hey all, I would like to make a brochare-ware type mobile app. Many markets do it these days, such as the car market, to show off their product. I would like to show the users some office-esque documents without leaving the application. The document

  • The device "EHCI Root Hub Simulation" @ 0xfd000000 has caused an overcurren

    I Have the problem with my usb port When My Mac reboot the system in the log read this message USB Notification: The device "EHCI Root Hub Simulation" @ 0xfd000000 has caused an overcurrent condition. The hub it is attached to has been disabled I can

  • How can I change the time zone for a calendar entry with iOS 7?

    I want to make a new entry in my calendar (iOS 7) using a different time zone as the one I'm located in. There isn't any option to choose the time zone like there is in OS X. I know I can switch off the option to automatically change the time zone in

  • PCNFSD for Solaris 9 and 10

    Does anyone know where I can get the PCNFSD package for Solaris 9 and 10 for both sparc and x86?

  • Want to modify look of h:commandButton

    Hi , I need to create two tab like buttons in my JSF jsp. I dont want to show conventional buttons which <h:CommandButton > gives you. I can not use images as the name of the button should change dynamically. Can I do it with the help of div tag wher