Schedule a background job for a program using ABAP code.

Hi,
I have to write a program to schedule a background job for another program.
Need your help to understand how we can achieve this functionality.Any example of an abap code would be of great help.
Need it urgently.
Thanks in advance.
Sandeep.

Hi Sandeep,
Here is the demo program regarding the BDC For the background job.
report zprprbdc1
       no standard page heading line-size 255.
include bdcrecx1.
parameters: dataset(132) lower case.
***    DO NOT CHANGE - the generated data section - DO NOT CHANGE    ***
*   If it is nessesary to change the data section use the rules:
*   1.) Each definition of a field exists of two lines
*   2.) The first line shows exactly the comment
*       '* data element: ' followed with the data element
*       which describes the field.
*       If you don't have a data element use the
*       comment without a data element name
*   3.) The second line shows the fieldname of the
*       structure, the fieldname must consist of
*       a fieldname and optional the character '_' and
*       three numbers and the field length in brackets
*   4.) Each field must be type C.
*** Generated data section with specific formatting - DO NOT CHANGE  ***
***data: begin of itab occurs 0 ,
***       matnr(20) type c,
***       mbrsh(30) type c,
***       mtart(30) type c,
***       kzsel(20) type c,
***       maktx(40) type c,
***       meins(5) type c,
***       end of itab.
data: begin of record occurs 0,
* data element: MATNR
        matnr_001(018),
* data element: MBRSH
        mbrsh_002(001),
* data element: MTART
        mtart_003(004),
* data element: XFELD
        kzsel_01_004(001),
* data element: MAKTX
        maktx_005(040),
* data element: MEINS
        meins_006(003),
* data element: MTPOS_MARA
        mtpos_mara_007(004),
      end of record.
*** End generated data section ***
start-of-selection.
*perform open_dataset using dataset.
perform open_group.
**do.
**read dataset dataset into record.
**if sy-subrc <> 0. exit. endif.
call function 'GUI_UPLOAD'
  exporting
    filename                      = 'c:\jitu\bdc\10002.txt'
   filetype                      = 'ASC'
   has_field_separator           = 'x'
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   CHECK_BOM                     = ' '
*   VIRUS_SCAN_PROFILE            =
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
  tables
    data_tab                      = record
* 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
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
loop at record .
perform bdc_dynpro      using 'SAPLMGMM' '0060'.
perform bdc_field       using 'BDC_CURSOR'
                              'RMMG1-MATNR'.
perform bdc_field       using 'BDC_OKCODE'
                              '/00'.
perform bdc_field       using 'RMMG1-MATNR'
                              record-matnr_001.
perform bdc_field       using 'RMMG1-MBRSH'
                              record-mbrsh_002.
perform bdc_field       using 'RMMG1-MTART'
                              record-mtart_003.
perform bdc_dynpro      using 'SAPLMGMM' '0070'.
perform bdc_field       using 'BDC_CURSOR'
                              'MSICHTAUSW-DYTXT(01)'.
perform bdc_field       using 'BDC_OKCODE'
                              '=ENTR'.
perform bdc_field       using 'MSICHTAUSW-KZSEL(01)'
                              record-kzsel_01_004.
perform bdc_dynpro      using 'SAPLMGMM' '4004'.
perform bdc_field       using 'BDC_OKCODE'
                              '=BU'.
perform bdc_field       using 'MAKT-MAKTX'
                              record-maktx_005.
perform bdc_field       using 'BDC_CURSOR'
                              'MARA-MEINS'.
perform bdc_field       using 'MARA-MEINS'
                              record-meins_006.
perform bdc_field       using 'MARA-MTPOS_MARA'
                              record-mtpos_mara_007.
perform bdc_transaction using 'MM01'.
**enddo.
endloop.
perform close_group.
*perform close_dataset using dataset.
&*****************Reward point if helpful************&

Similar Messages

  • Program works but background job for that program fails....

    I have a requirement where I have to collect the details of the purchase order and put the details in XML file format and FTP the XML file to an external third party FTP Server.
    To realize this I developed a report program which follows following logic.
    1)     First I collected the PO details by calling the BAPI BAPI_PO_GETDETAIL1.
    2)     Then using the following link "/people/r.eijpe/blog/2005/11/10/xml-dom-processing-in-abap-part-i--convert-an-abap-table-into-xml-file-using-sap-dom-approach
    I converted these PO details to the XML file format that the third party people accept.
           In the code I used u201CCALL METHOD cl_gui_frontend_services=>gui_downloadu201D and in this process first the XML file is generated and is getting stored on my deskytop.
    3)     Then I called HTTP_SCRAMBLE, FTP_CONNECT, FTP_COMMAND , FTP_DISCONNECT and RFC_CONNECTION_CLOSE.
    This works perfectly well and each time I execute the report the file is getting FTPu2019ed to the third party FTP server.
    Now I tried to schedule a batch job for this and the batch job fails with follwing errors
    02/25/2009 15:08:47 Error in Control Framework
    Message Class  = FES         
    Message Number = 022  
    Message Type   = E
    02/25/2009 15:08:47 Job cancelled after system exception ERROR_MESSAGE 
    Message Class  = 00        
    Message Number = 564  
    Message Type   = A                
    Can some one tell me what is going wrong. My report works perfect in front end but fails if I try to schedule a background job for it in SM36.
    Can you please tell me whatz going wrong with batch job? Any Help is highly appreciated.
    Regards,
    JEssica SAm

    Robert...Thanks for the reply...
    I am using follwing code
    l_xml_size = l_ostream->get_num_written_raw( ).
        CALL METHOD cl_gui_frontend_services=>gui_download
          EXPORTING
            bin_filesize = l_xml_size
            filename     = FILEPATH
            filetype     = 'BIN'
          CHANGING
            data_tab     = l_xml_table
          EXCEPTIONS
            OTHERS       = 24.
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    Now what changes should i make..where should i store my XML file then instead of my desktop?
    and whih Function Module should i Use..

  • How to create Background job for Dialog program

    Hi Experts,
    I have copied Standard tcode to Z-tcode (CS12 tcode).
    Now my requirement is to create background job for this program (but program is not a 'E' type its 'I').
    How we can schedule Dialog program to Background.
    Pls suggest me.
    Regards
    SK

    Hi do as below :
    Reefer below :
    Bakcground Job Creation
    You will have to submit your report using Submit statement ,
    then inside the submitted report write open_job.
    Regards,
    Uma

  • Scheduling a Background Job for PM/CO Settlements (KO8G)

    Hi All,
    I've created variants for settlements of PM & CO orders using transaction KO8G. Now I want to schedule a background job using TCode SM36. What program name/ABAP name should I use for settlements when scheduling background jobs?
    Regards,
    Tso

    Hello Tso,
    Try transaction SCMO which provides you the option to set
    the start date to finish date and can also set the start time and
    finish time and allows you to specify the variant to be used.
    When in transaction KO8G fill out the fields as you wish them for
    the background job and then same the selection as a variant. There is
    an option to have the variant for background jobs and save the variant
    then you can specify this variant in the SCMO screen.
    SCMO is the sceduele manager which will allow you to scehedule many
    jobs as necessary.
    Some notes:
      332149  SCMA: Required workflow settings
      325118  Schedule Manager: link customer-specific reports
      317601  Schedule Manager: Customer reports for multilevel worklist
      332149  SCMA: Required workflow settings
      891042  SCHEDMAN: Automatic start of several flow definitions
    I hope this helps.
    Regards,
    Lucas

  • Changing Field Label length for Data Element using ABAP code.

    Hi Experts,
    We have a scenario where we have to update the maximum length of the various Field Labels (Short, Medium, Long..) for a Data Element using ABAP code.
    Does anyone know how to do this ? Is there a Function Module available for this purpose ?
    Appreciate your valuable inputs.

    Hi ,
    Use the view
    DD03M
    Give
    TABNAME as table name,
    DDLANGUAGE = EN / sy-langu
    and order by position. (for correct sequencing)
    You will get description of the fields (short,medium, long etc). You will also get the length and other details.

  • How to schedule a background jobs for a function module

    HI all,
    I have created a function module (zrfc_test). Now I need to schedule it daily around 8am . the 2 tcodes used is sm36 & sm37. But I need a detail description for a function module.
    Points will be rewarded
    thanks in advance

    As there is no direct way of scheduling a function module, you may write a online program (program type 1) and call this function module in side it and schedule the program using SM36. Or you may record a CATT procedure for the function module and schedule it using SCAT transaction.Hope this helps
    Krishna

  • Schedule a background job

    Hi All,
    I have an urgent query here regarding the Bakcground job.
    Let's say I need to schedule a background job on hourly basis to fetch the data.
    If first job runs more than 60 minutes, then will the second job will fetch the data.
    What will happen in this scenario?
    Thanks
    Neeraj Manocha

    My question is............
    Let's say, I have a SAP standard table. In which our transactional data stores. I have also maintained my our database and build a program (i.e. Ztest) to fetch the data from the SAP standard table and store into my own database.
    So I schedule a background job for the program (Ztest) to fetch the data. I schedule this job on hourly basis.
    once first job will be runnig it will create one more instance to run after one hour.
    Here my question is...
    What if first job schedule on 1pm and runs for more than 60 mins (let's say it takes 90 mins to complete)?
    Till what time it will fetch data (either till 1pm or 1pm +90 mins)?
    If it fetch the data till 1pm +90 mins, then when second job will start and from what time it will start to fetch the data.
    Hope this clears.
    Thanks
    Neeraj Manocha

  • Scheduling a background job depending on the output lenght.

    Hi every one,
    I have a small requirement. My client want me to run a program in a foreground if the output is small and should the program in background if the output is large.This has to be achieved through coding. The program downloads the netprices of products. The downloaded file is of .dat format. It is an urgent requirement.
    Guys you would throughly rewarded for your help.
    Thanks,
    Kumar.9886185040.

    Hi Nag
    that is not possible with codeing. To create a schedule a background job for the same program depending on its output is not possible.
    being a programmer you need to decide, how long the code will take to execute.. accordingly you can either schedule or run in foreground. You can make some mandatory fields in the selection screen, so that the output is big mostly.
    see the sample code for the Job scheduling using the fun modules
    IF p_bjob = 'X'.
    CONCATENATE sy-cprog sy-datum sy-uzeit
    INTO jobname SEPARATED BY '_'.
    CALL FUNCTION 'JOB_OPEN'
    EXPORTING
    jobname = jobname
    IMPORTING
    jobcount = jobcount
    EXCEPTIONS
    cant_create_job = 1
    invalid_job_data = 2
    jobname_missing = 3
    OTHERS = 4.
    CALL FUNCTION 'GET_PRINT_PARAMETERS'
    IMPORTING
    out_archive_parameters = arc_params
    out_parameters = print_params
    valid = valid
    EXCEPTIONS
    archive_info_not_found = 1
    invalid_print_params = 2
    invalid_archive_params = 3
    OTHERS = 4.
    IF valid = chk.
    SUBMIT yREP WITH s_kunnr IN s_cust
    AND RETURN
    USER sy-uname
    VIA JOB jobname
    NUMBER jobcount
    TO SAP-SPOOL
    SPOOL PARAMETERS print_params
    ARCHIVE PARAMETERS arc_params
    WITHOUT SPOOL DYNPRO.
    CALL FUNCTION 'JOB_CLOSE'
    EXPORTING
    jobcount = jobcount
    jobname = jobname
    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.
    ELSE.
    MESSAGE i029 WITH jobname.
    ENDIF.
    ELSE.
    MESSAGE s000 WITH text-003.
    STOP.
    ENDIF.
    ENDIF.
    Also,
    Yes you can use job functions:
    JOB_OPEN
    JOB_SUBMIT
    JOB_CLOSE
    * You can add multiple steps into one job by using JOB_SUBMIT.
    Regards
    JJ

  • Is it possible to reset password for any user using abap program

    Hi friends,
    Is it possible to reset password for any user using abap program by specifying client number and user id. in selection screen.
    if any code for that to reset password please mail me.
    Thanks & Regards,
    Yogesh

    Hello Yogesh,
    Yes you can reset the password for any body using ABAP Code. But for that you really don't need any client number.
    If this process is on regular basis, then recommended is to use BAPI for changing the user details Otherwise BDC also works fine.
    => Function Module - BAPI_USER_CHANGE
    Call this in the program for resetting the password.
    => CALL TRANSACTION 'SU01' USING InternalTable
    This will be executed in the BDC of SU01 transaction recording. Use the Password Change button in the application toolbar of transaction while recording.
    Hope this helps.
    PS If the answer solves your query, plz close the thread by marking it solved and rewarding each reply.
    Regards

  • 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.

  • BAPI for Scheduling a background job

    Hi all,
    is there any bapi for scheduling a background job?
    i mean can we do background job using bapi
    If not how can we create a bapi for scheduling a background job.
    Thanks & Regards,
    Azhar

    Hi,
    Use following BAPIs for scheduling a job in background
    BAPI_XBP_JOB_OPEN - This BAPI solves the first step in scheduling a job in the R/3 background processing system. You can create the job with this method.
    Using additional BAPI calls BAPI_XBP_JOB_ADD_ABAP_STEP and BAPI_XBP_JOB_ADD_EXT_STEP, you can add job steps to the job.
    With the BAPI call BAPI_XBP_JOB_CLOSE, you can finish defining the job and transfer it to the background processing system with the status Scheduled without start date.
    You have execute the job with the BAPI calls BAPI_XBP_JOB_START_IMMEDIATELY or BAPI_XBP_JOB_START_ASAP.
    I hope it would help you.
    Regards,
    Venkatram

  • BPM - Background Job for Reorganization = Not Scheduled

    Good afternoon, first of all thank you very much for the support they can provide. I have developed a JDBC interface -> BPM (Multimapping) which works well. Modify a Message Mapping in the BPM that I use for an RFC Lookup, I have added the Configurable Parameters in the BPM and Integration Directory and everything works fine at design time. But when running the interface at run time the message reaches the BPM and the error "error in BPE inbound Permanent processing".
    I have reviewed the Business Process Engine in the RWB and the item is Red Schedule Background Job for Reorganization and detail reads: "Background Job for Reorganization = Not Scheduled".
    As I can solve this problem. Thank you very much.

    Re: Importing trans request failed
    Re: Transports Erroring
    Re: What is RDDIMPDP .....
    have a look it may help you
    Message was edited by:
            Vinod Udapudi
    Message was edited by:
            Vinod Udapudi

  • Automatic workflow customizing :Schedule background job for condition evalu

    Hai,
    I have one problem in automatic customizing SWU3(Maintain runtime environment)-Schedule background job for condition evaluation.
    How to turn  green tick from red cross? All other steps are OK in SWU3 except this problem.
    Please give me some tips.
    -Jaheer
    _______Thanks in terms of BIG points_______________________

    Hi Jaheer
    If the only red cross is next to the condition evaluation job, I suppose you could just schedule up the job automatically in SM36. Just be sure that the RFC Destination is correctly configured.
    The program that you need to schedule is <b>RSWWCOND</b>. The SAP default is to call the job SWWCOND and schedule it to run every 30min. That should get rid of the red cross. And if not, you might find along the way why the Auto-Customising didn't work.
    Cheers
    Lyal

  • Error in Schedule Background Job for Deadline Monitoring of swu3

    While Auto Customization swu3 i am getting error message 'Output device "" not known' in 'Schedule Background Job for Deadline Monitoring'
    Please advice what could be cause of it

    the earlier problem of background job was solved by changing the  output device assigned to user wf-batch .
    regarding the transport request :
    when i was trying to execute the step : "Schedule bakgrd for missed deadlines " MANUEL it was giving me an option of SAVE AND SCHEDULE . which was creating the transport request . but when i executed it automatically it worked fine without asking a request to me ... i don't know why )-: ... probablly we can specify a different interval then the standard of three minutes and which will be transported (it's just a guess) . i have  executed it  automatically ...
    well thanks all for u r help

  • How to schedule the background job using current selection screen field val

    Hello Friends,
    How to schedule the background job using current selection screen field values.
    after completion of the job the spool should be sent as a mail to SAP Inbox.
    Is there any way to create the variant dynamically by reading the current selection screen values.
    Thanks,
    Ravi

    Hi,
    To get the variant details you can use teh following FM.
    'RS_VARIANT_CONTENTS'.
    Regards,
    Ankur Parab

Maybe you are looking for

  • Mac webcan to pc msn

    hi, not sure if i am in the right topic i have a mac osx 10.3.9 i need to chat on webcam via msn to a friend overseas who will chat via webcam in a net cafe thru msn i think msn will be the only app in the net cafe will this work? me being on mac and

  • While upgrading oim 11gr1 toR2 problem with configuration of security store

    /hae/idmt/as/mw/iam/oracle_common/common/bin/wlst.sh Info: DB JDBC driver: oracle.jdbc.OracleDriver Info: DB JDBC URL: jdbc:oracle:thin:@haeidmdb01.dataintensity.com:1521/HAEIDMT [oracle.security.jps.internal.config.db.DbCredStoreServiceConfigurator]

  • Sort records when there is no timestamp

    Hello All, I'd like to know how we can do a sort based on timestamp on an oracle table when there is no timestamp column. I have a table create table x_log (A varchar,B varchar,C varchar); /* note I do not have a timestamp col */ I'd like to know if

  • How can I attach a jpg file in a mail message as the file icon, not as an opened image in the text?

    How can I attach a jpg file in a mail message as the file icon, not as an opened image in the text?

  • Error After KB2892899 Hotfix

    The 'Microsoft_BusinessFramework_Configuration' start tag on line 2 does not match the end tag of 'Microsoft.Dynamics.DataLocationPolicyConfig'. Line 75, position 891. Description: An unhandled exception occurred during the execution of the current w