How to create a batch job through coding

Hi Experts,
How to create a batch job through coding?
Regards
Saroj

Hi, below is the code.
***Create Variant for the job
***Get the dynamic variant name
  DATA: variant_name TYPE  varid-variant value 'test'.
  DATA: vari_desc LIKE varid,
        vari_contents LIKE rsparams OCCURS 0 WITH HEADER LINE,
        vari_text     LIKE varit    OCCURS 0 WITH HEADER LINE.
  CLEAR: vari_desc,vari_contents,vari_text.
  REFRESH: vari_contents[], vari_text[].
  vari_desc-mandt = sy-mandt.
  vari_desc-report = 'ZCTRAOBJECT_CAL_FILEDAMT_JOB'.
  vari_desc-variant = variant_name.
  vari_desc-transport = 'F'.
  vari_desc-environmnt = 'A'.
  vari_desc-version = 1.
  vari_desc-mlangu = sy-langu.
***Varint Text
  vari_text-mandt = sy-mandt.
  vari_text-langu = sy-langu.
  vari_text-report = 'ZCTRAOBJECT_CAL_FILEDAMT_JOB'.
  vari_text-variant = variant_name.
  CONCATENATE 'job' 'Background' INTO vari_text-vtext SEPARATED BY space.
  APPEND vari_text.
***Partner
  IF ( p_partner-low IS NOT INITIAL ).
    vari_contents-selname = 'PARTNER'.
    vari_contents-kind    = 'S'.
    vari_contents-sign    = 'I'.
    IF ( ( p_partner-low IS NOT INITIAL ) AND ( p_partner-high IS INITIAL ) ).
      vari_contents-option = 'EQ'.
      vari_contents-low = p_partner-low.
    ENDIF.
    IF ( ( p_partner-low IS NOT INITIAL ) AND ( p_partner-high IS NOT INITIAL ) ).
      vari_contents-option = 'BT'.
      vari_contents-low = p_partner-low.
      vari_contents-high = p_partner-high.
    ENDIF.
    APPEND vari_contents.
  ENDIF.
***Contract Account
  IF ( p_cont_acct-low IS NOT INITIAL ).
    vari_contents-selname = 'CA_ACC'.
    vari_contents-kind    = 'S'.
    vari_contents-sign    = 'I'.
    IF ( ( p_cont_acct-low IS NOT INITIAL ) AND ( p_cont_acct-high IS INITIAL ) ).
      vari_contents-option = 'EQ'.
      vari_contents-low = p_cont_acct-low.
    ENDIF.
    IF ( ( p_cont_acct-low IS NOT INITIAL ) AND ( p_cont_acct-high IS NOT INITIAL ) ).
      vari_contents-option = 'BT'.
      vari_contents-low = p_cont_acct-low.
      vari_contents-high = p_cont_acct-high.
    ENDIF.
    APPEND vari_contents.
  ENDIF.
***Contract Object
  IF ( p_cont_obj-low IS NOT INITIAL ).
    vari_contents-selname = 'CO_OBJ'.
    vari_contents-kind    = 'S'.
    vari_contents-sign    = 'I'.
    IF ( ( p_cont_obj-low IS NOT INITIAL ) AND ( p_cont_obj-high IS INITIAL ) ).
      vari_contents-option = 'EQ'.
      vari_contents-low = p_cont_obj-low.
    ENDIF.
    IF ( ( p_cont_obj-low IS NOT INITIAL ) AND ( p_cont_obj-high IS NOT INITIAL ) ).
      vari_contents-option = 'BT'.
      vari_contents-low = p_cont_obj-low.
      vari_contents-high = p_cont_obj-high.
    ENDIF.
    APPEND vari_contents.
  ENDIF.
***Account Category
  IF ( p_ctra_acc_category  IS NOT INITIAL ).
    vari_contents-selname = 'P_CAT'.
    vari_contents-kind    = 'P'.
    vari_contents-low    = p_ctra_acc_category.
    APPEND vari_contents.
  ENDIF.
***filed_freq_to_change_from
  IF ( p_filed_freq_to_change_from  IS NOT INITIAL ).
    vari_contents-selname = 'P_TO_CH'.
    vari_contents-kind    = 'P'.
    vari_contents-low    = p_filed_freq_to_change_from.
    APPEND vari_contents.
  ENDIF.
***req_filed_freq_change
  IF ( p_req_filed_freq_change  IS NOT INITIAL ).
    vari_contents-selname = 'P_CHANGE'.
    vari_contents-kind    = 'P'.
    vari_contents-low    = p_req_filed_freq_change.
    APPEND vari_contents.
  ENDIF.
***Test Run p_tstrun
  vari_contents-selname = 'P_TSTRUN'.
  vari_contents-kind    = 'P'.
  vari_contents-low    = p_test_run.
  APPEND vari_contents.
***Update Filing Frequency Checkbox
  vari_contents-selname = 'P_FIL_FR'.
  vari_contents-kind    = 'P'.
  vari_contents-low    = p_update_filing_frequency.
  APPEND vari_contents.
***Update Incoming Payment Channel Checkbox
  vari_contents-selname = 'P_PAY_CH'.
  vari_contents-kind    = 'P'.
  vari_contents-low    = p_update_payment_channel.
  APPEND vari_contents.
***Update Filing Channel Checkbox
  vari_contents-selname = 'P_FIL_CH'.
  vari_contents-kind    = 'P'.
  vari_contents-low    = p_update_filing_channel.
  APPEND vari_contents.
***Use Current Filing Period Checkbox
  vari_contents-selname = 'P_CU_PER'.
  vari_contents-kind    = 'P'.
  vari_contents-low    = use_curr_per.
  APPEND vari_contents.
****Create Variant thru Function Module
  CALL FUNCTION 'RS_CREATE_VARIANT'
    EXPORTING
      curr_report   = 'ZCTRAOBJECT_CAL_FILEDAMT_JOB'
      curr_variant  = variant_name
      vari_desc     = vari_desc
    TABLES
      vari_contents = vari_contents
      vari_text     = vari_text.
  IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
****Prepare all the date for scheduling job
***Get the print parameters
  DATA: params LIKE pri_params.
  CLEAR params.
  CALL FUNCTION 'GET_PRINT_PARAMETERS'
    EXPORTING
      mode           = 'CURRENT'
      no_dialog      = 'X'
    IMPORTING
      out_parameters = params.
  params-paart = 'X_65_255'."'X_PAPER'.
***Open The scheduling job
  DATA: job LIKE tbtcjob-jobname,
        jobcount LIKE tbtcjob-jobcount.
  CLEAR: job,jobcount.
  job = 'ZCTRAOBJECT_CAL_FILEDAMT_JOB'.
  CALL FUNCTION 'JOB_OPEN'
    EXPORTING
      jobname  = job
    IMPORTING
      jobcount = jobcount
    EXCEPTIONS
      OTHERS   = 4.
***Job Submit
  DATA: authcknam LIKE tbtcjob-authcknam.
  CLEAR: authcknam.
  authcknam = sy-uname.
  params-primm = space.
  CALL FUNCTION 'JOB_SUBMIT'
    EXPORTING
      authcknam = authcknam
      jobcount  = jobcount
      jobname   = job
      priparams = params
      report    = 'ZCTRAOBJECT_CAL_FILEDAMT_JOB'
      variant   = variant_name.
***JOB_CLOSE
  DATA: sdlstrttm TYPE tbtcjob-sdlstrttm,
        released LIKE btch0000-char1.
  sdlstrttm = p_job_start_time + 30.
  CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
      sdlstrtdt        = p_job_start_date
      sdlstrttm        = sdlstrttm
      jobcount         = jobcount
      jobname          = job
    IMPORTING
      job_was_released = released.
Regs
Manas

Similar Messages

  • How to create a batch job for transaction SM13 or SM37

    How to create a batch job for transaction SM13 or SM37?
    I want to create a batch job for t-code SM13/SM37, the jobs will send a email to my inbox when the errors occurred in SM13/SM37.
    How to do this? thanks in advance.

    Hi,
    Check the link:
    http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/30237989-0901-0010-70a4-944691eb5e52 [original link is broken]
    Make sure the CCMS agent installation is in place as per the Monitoring setup guide.
    Follow the link Central auto reactions for configuring alert mails.
    Regards,
    Srikishan

  • How to create a batch job in IW41

    Dear all,
    I would like to create a print program batch job on the following scenario with the use of RSNAST00.
    We have created an output type in which when it is triggered by backflush (i.e. GI-261) via IW41 transaction, a PO will be created automatically in the background from this output type.
    Now for testing purpose, we would like to use to use program RSNAST00 to schedule the creation or triggering of this output.
    May I know how to do this?
    I know in VF04, I can click the variant,HOWEVER in IW41, the menu does not allow variant creation?
    Without variant creation, I cannot go to SM36 to create a batch job.
    thanks
    tuff

    Hi,
    Check the link:
    http://www.sdn.sap.com/irj/sdn/index?rid=/webcontent/uuid/30237989-0901-0010-70a4-944691eb5e52 [original link is broken]
    Make sure the CCMS agent installation is in place as per the Monitoring setup guide.
    Follow the link Central auto reactions for configuring alert mails.
    Regards,
    Srikishan

  • How to create a batch-job dynamically?

    Hello,
    I would like to create a batch-job from within my abap code.
    Therefore I want to determine a abap-report to be executed every X-Hours.
    Do you have some sample code for creating a batch job?
    I need to do it in abap because I want to create a TN to trigger the code creating the job.
    So the user interaction will be minimal to start a periodic batch job.
    thanks.

    Hi Daniel,
    select options could be stored by export/import to/from database:
          DESCRIBE TABLE t_vkpos LINES n.
          READ TABLE t_vkpos INDEX n.
          lastmaxvbeln = t_vkpos-vbeln.
          PERFORM get_varimemkey USING p_vari CHANGING vkposmemkey.
          EXPORT lastmaxvbeln TO DATABASE indx(zk) ID vkposmemkey.
          IF NOT sy-subrc IS INITIAL.
          PERFORM get_varimemkey USING p_vari CHANGING vkposmemkey.
          IMPORT lastmaxvbeln FROM DATABASE indx(zk) ID vkposmemkey.
          IF sy-subrc IS INITIAL.
            ls_vbeln-sign   = 'I'.
            ls_vbeln-option = 'GT'.
            ls_vbeln-low    = lastmaxvbeln.
            APPEND ls_vbeln.
          ENDIF
    FORM get_varimemkey USING    vari TYPE raldb_vari
                        CHANGING memkey TYPE char22.
      IF vari IS INITIAL.
        RAISE get_varimemkey_unexepected.
      ENDIF.
      CONCATENATE 'Z_VKPOS_' vari INTO memkey.
    ENDFORM.                    "
    regards
    Walter Habich

  • How to start a batch job through a web service call

    I have a batch job created Data Services that I would like to be able to start through a web service call.
    I have exposed the batch job as a Web Service through the mangement console.
    The Integrators guide is not the clearest piece of documentation that I have ever read so I'm now having a little trouble.
    In C# I'm issuing the following statements:
                DataServices.Batch_JobsClient batchClient = new DataServices.Batch_JobsClient();
                batchClient.Open();
                DataServices.Testjob_Match_GlobalVariables myVar = new DataServices.Testjob_Match_GlobalVariables();
                myVar.ptd_FilePath = "D:
    Jobs
    Test";
                batchClient.Testjob_Match(myVar);
    That all executes without error -- but the job is not started. Obviously I'm missing a step here but I can not figure out what is needed to acutally start the job execution from the Integrators Guide.
    Any help would be appricated.

    first test invoking the batch job webservice using SoapUI
    does your client application logs the SOAP message that is sent to DS WebServer ?
    Check the %LINK_DIR%\lg\webservices.log if there is any errors logged in it ?

  • Duplicate deliveries getting created by batch job against STO

    Hi Experts,
    I am facing one issue where duplicate deliveries are getting created by batch job against Intercopmany STO.
    Scenario is PO having one line item with ordered qty of 8000kg.
    Through batch job, two deliveries got created on same day for PO line item.
    One delivery got created for 8000kg and another delivery has got created for 7000Kg. So user has deleted second delivery of 7000kg.
    Next day again the delivery got created for 8000kg for the same PO line item through batch job.
    I am wondering how the duplicate deliveries are getting created by batch job for PO even though it has no open items.
    All deliveries got created through batch job only as cross checked the user name in delivery.
    Kindly help to fix the issue.

    Hi Amit
    I assume you are talking about outbound deliveries.  In this case it would be worth checking the customer master record for the receiving plant.  In the sales area data there is a shipping tab which contains several settings used to control delivery creation for customers.
    It is possible to control how the system behaves when you have a stock shortage and restrict the number of partial deliveries.  This might help you control this situation and might be the cause.
    Regards
    Robyn

  • How to find out batch job failure and taking action:

    Normally We will monitor the batch jobs  through transaction code sm37 for job monitoring. In SM37 we will give a batch job name date and time  as  input. In the first step we will check the batch job for the reason failure or check the spool request for the batch job for failures an help in analyzing the error
    I understand from the my experience is that the batch may fail due to below reasons.
    1.,Data issues :             ex: Invalid character in quantity (Meins) field  >>>> We will correct the corresponding document with correct value or we will manually run or request the team to rerun the batch job by excluding  the problematic documents from the batch job variant  so that it may process other documents.
    2.Configuration issues : Materials XXXX is not extended for Plant >>>> we will contact the material master team or business to correct the data or we will raise sub contract call with support team to correct he data. Once the data been corrected and will request the team to rerun the batch job.
    3.Performance issues : Volume of the data being processed  by the batch job ,network problems.>>>Normally these kind of issues we will encounter during the month end process as there will lot of accounting transactions or documents being posted business hence it may cause the batch job failure as there is enough memory to complete the program or select queries in the program will timeout because of volume of the records.
    4.Network issues. : Temporary connectivity issues in other partner systems :Outage in other partner systems like APO or other system like GTS  will cause the batch job failure as Batch job not in position to connect other system to get the inforamtion and proceed for further steps.Nornmally we will check RFC destination status by running a custom program  weather connectivity between system are in progress or not. then intimate other partner system  for the further actions, Once the partner system comes online then we will intimate the team to restart or manually submit batch job.
    Some times we will create a manual job by transaction code SM36.

    I'm not sure what the question is among all that but if you want to check on jobs that are viewable via SM37 and started via SM36. The tables are TBTCP -Background Job Step Overview and TBTCO - Job Status Overview Table.
    You can use the following FM to get job details:
    GET_JOB_RUNTIME_INFO - Reading Background Job Runtime Data

  • How to create new Batch No for An Item

    Dear All,
              I am doing Issue for production task through DI API. In that I need to Create a Batch no for an Item. That item was created as Batch with Release only in Item Master. Please help me how to create the batch no when I am Issue for Production ?.
    Thanks,
    lingam.

    Dear Lingam,
    If the process need manual selection as the one you are requesting, it will not be available to DI API. You may try UI API to see.
    Thanks,
    Gordon

  • Creating a Batch Job for Executing Later

    Hi Experts!
    I was wondering if there was a way to create a batch job, but to have it executed at a later time, since we do not have an exact date and time we need these jobs executed.  My goal is to create 12 batch jobs (1 for each month), but have them excuted, when I need them too, when I choose it.  Is this even possible?.  I tried looking through SM36/SM37, but could not find anything on it.  Please advise and thanks in advance!
    WC

    Hi Will,
    The standard job scheduler will not do this (SM36/7).  You do not mention what release you are using, but SAP Central Job Scheduling with Redwood does provide the ability to create jobs with boolean conditions like you describe (plus much, much more).  See the Service Marketplace http://service.sap.com/job-scheduling or the SDN page https://www.sdn.sap.com/irj/sdn/docs?rid=/webcontent/uuid/abb91c2a-0b01-0010-6ca6-9f0f62268454. [original link is broken]
    Best Regards,
    Matt

  • How to handel a Batch job in oracle database

    How to handel a Batch job in oracle database?
    Regards
    alok

    Alekh wrote:
    lists of jobs execute concurrently.Thats a definition we all aware of ;), I meant do you want to execute the jobs in a sequence? is there any dependency? is it more like scheduling?
    And What kind of jobs you are talking about? running PL/SQL programs? or stats collection? or DB backup?
    Regards,
    Prazy

  • How to create a Batch file for java application  ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    [http://static.springsource.org/spring-batch/]
    Assuming you want to develop a batch application rather than actually just create a .bat file ..

  • HOw to create a Batch file for java application and whats the use of this ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    First of all, you're OT.
    Second, you can find this everywhere in the net.
    If you got a manifest declaring main class (an classpath if needed), just create a file named whatever.bat, within same directory of jar file, containing:
    javaw -jar ./WhateverTheNameOfYourJarIs.jar %*By the way, assuming a Windows OS, you can just double click the jar file (no batch is needed).
    Otherwise use:
    javaw -cp listOfJarsAndDirectoriesSeparedBySemiColon country/company/application/package/className %*Where 'country/company/application/package/' just stands for a package path using '/' as separator instead of '.'
    Don't specify the .class extension.
    Javaw only works on Windows (you asked for batch, I assumed .BAT, no .sh), in Linux please use java.exe (path may be needed, Windows doesn't need it 'cause java's executables are copied to system32 folder in order to be always available, see PATH environment variable if you don't know what I'm talking about) and use ':' as classpath (cp) separator.
    The '%***' tail is there in order to pass all parameters, it only works on Windows, refer to your shell docs for other OSs (something like $* may work).
    This way you have a command you can call to launch your code (instead of opening NetBeans just to see your app working). You could schedule tasks on it or just call it in any command prompt (hope you know what it is 'cause there have been people in this very same forum with no clue about it, if not just hold the 'Windows button' and press 'R', then type 'cmd' and run it).
    Finally add dukes and give 'hem away.
    Bye.

  • Help needed in creating a batch job for delivery

    Hi gurus
    Can somebody tell me the process of creating a batch job ..for creation of delivery.. is this the same process to create the batch jobs for invoices also?
    thankyou
    bj

    hello jaya ,gsl
    thankyou very much for ur help .. I have tried creating a variant .. in vl10batch.. and ive assigned it a scheduled time .. i craeted a open order..  and when the scheduled time has arrived and is over,i went to the order and still i dont see any delivery doc created .. and in sm37 its shows that the job is finished ..i even tried sm36 .. of creating a job for the variant.that ive craeted in vl10batch .and then assigning the job in sm37.. i can see the job that ive created in sm37 it is changing its status from released to finished .. as per the scheduled time but the delivery is not created .. i tried vf06 for a billing   variant.. and went to sm36 craeted a job for the variant..using the program name.. and next to sm37 i can  see the created  job in the spool also..but somehow it is  not creating the billing doc also..
    can u help me to find where it actually went wrong with me ?
    thanksalot in advance..

  • How to create a background job without a variant ?

    How to create a background job without a variant ?

    Hi,
    Go to se38.. specify the program name and execute Or use Tcode
    On the selection screen specify the variant...
    Then from the menu options choose program->excute in background...
    In this way we can crate a backgroup job with out crateing any varinat for the report...
    Satya.

  • How to create a Sales Order through an EDI configuration.

    Hi
    How to create a Sales Order through an EDI configuration.
    Tell me the step-by-step procedure for this.
    Any power point presentation would be fine.
    Cheers
    Maruthi

    Hi,
    You can go to these links to know little bit about sales order creation through EDI/ALE by means of IDOCS.
    http://www.riyaz.net/blog/index.php/2008/01/19/beginners-guide-to-ale-and-idocs-a-step-by-step-approach/
    Sales Order Idoc Extension.
    http://www.*******************/2007/11/abap-idocs-basic-tools.html
    For any specific information, just do a google search(information like message t ype, IDOC type, Functoin module, etc. You will definitely get the information you are looking for
    Please reward if this helps you

Maybe you are looking for

  • Intel Mac mini and widescreen TV output (analog)

    I just replaced my 1.25 GHz mini with a dual-core Intel one, and are really disappointed that the wide-screen resolution options are nowhere to be found. I'm using the Apple DVI-to-Video adapter with an S-Video cable. On the G4 Mac mini, I would get

  • Not installed properly

    I have the macbook where the iLife was preinstalled. i did the system update already but when i try to make my own music through the preset 'beats' it says it must be installed first but when i click on updates for garage band it says it is up to dat

  • How to suppress a Security Notifcation for all users

    How can we suppress the notification If you open this document, anonymous usage data will be sent securely to this remote server: To learn more about what this means for you, please click on the 'Privacy and Security' button. check box - Allow collec

  • How to display flash file in adf pages

    how to display flash file in adf pages need help

  • Upgrade CS4 Extended to CS5 Standard

    Does anyone know if I can upgrade my CS4 extended version to the CS5 Standard?  I don't think I will use much of the Extended portion.  It talks about 3d capabilities, etc but I am a San Diego photographer and I don't need that stuff. Any pointers ar