ABAP program to resubmit itself with temp variant

Hi there,
I want a program to be able to re-submit itself in the background. I can do this, but if the user does not use a variant, how do I submit the program with the user-defined selections? This program may be run often and I don't want to create a massive list of variants. This must work whether they select a variant, or manually input selections.

lv_job_name will be the program name itself
CALL FUNCTION 'JOB_OPEN'
    EXPORTING
      jobname          = lv_job_name
    IMPORTING
      jobcount         = lv_job_nr
    EXCEPTIONS
      cant_create_job  = 1
      invalid_job_data = 2
      jobname_missing  = 3
      OTHERS           = 4.
  IF syst-subrc = 0.
*submit job with all the selection screen params...
<b>    SUBMIT (lv_job_name)
        WITH applfile = applfile     " all your variables go here
        WITH p_lines = p_lines
        WITH rfcdest = rfcdest
        WITH p_selmtd = lv_selmtd
        USER syst-uname
       VIA JOB lv_job_name NUMBER lv_job_nr AND RETURN.</b>
    IF sy-subrc = 0.
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = lv_job_nr
          jobname              = lv_job_name
          strtimmed            = 'X'
        IMPORTING
          job_was_released     = lv_job_released
        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 syst-subrc <> 0.
        MESSAGE i162(00) WITH
        'An error occured while closing the background job.'.
        STOP.
      ENDIF.
    ENDIF.
  ENDIF.
  SKIP 1.
  WRITE: / 'Background process', lv_job_name_string , 'called successfully' NO-GAP.
  WRITE: / 'You can check the job in transaction SM37'.
Message was edited by:
        Kris Donald

Similar Messages

  • ABAP program to take input parameter from variant, execute KSB1 and export

    Hi Friends,
    My client asking  change request in CO
    The Change request is "ABAP program to take input parameter from variant, execute KSB1 and export the output into an excel sheet and park the document in a designated location"
    Pls let me know  actually i am a FICO consultant what i can do in this change request
    Thanks,
    Santi

    Hi
    First I dont you would need to create a ABAP to generate the report in Excel.
    You can look at this option. Execute the report Go to->Change Layout, Click on the view option, On the Preferred View Select Microsoft Excel, Save the layout, provide a layout name with /XYZ.
    Now when you want to execute KSB1 with excel, just execute KSB1 with /XYZ layout, it would open in Excel, export to which ever location you want.
    Or just simply save the report as Excel using the Excel button on the tool bar.
    Regards,
    Suraj

  • How to copy/download  all ABAP programs in a text with a single report  ?

    How to copy/download  all ABAP programs in a text format with a single report/TC  ?
    How to copy/download  ABAP source code with all include programs ?....
    we need to search & copy all include programs everytime....

    Hi,
    check this link
    downloading programs
    Regards

  • Is there any way to run abap program in dialog process with process chain?

    Hi.
    I just want to run custom abap program in every 30min.
    so I made process chain and connect abap program.
    but it returns NOTHING when background running.
    the program has ABSOLUETLY no problem when it's running DIALOG process.
    custom program is modified from sap standard program for my use.
    so complicated and hard to read that I cann't figure out what's problem in backgound job and even hard to debug in background process.
    is there any way to run abap program in dialog process in every 30 min.?
    or call BSP page or call function.
    any solution will be helpful that excuting PROGRAM or FUNCTION or BSP PAGE in schedule job and should running dialog process.
    thanks.
    Lee.

    Hi,
    did you try using sm36 transaction?
    1Give these values in Gereral data
    Create one sample job "SAMPLE JOB"
    Priority "A"
    Execu target - Your application server
    2Click start conditon
    schedule according to ur requirements.
    3.Click Step button
    Give your ABAP program name.
    fill variants if it has any variants.
    if it is useful assign points
    Regard,
    Senthil Kumar.P

  • ABAP program for wage type variant report

    Hi experts,
    plz any one sen me the ABAP program for to create wage type variant report plz.
    Thanks
    Rajesh.

    Requesting for code is against forum rules. Please read the rules of the forum before posting.

  • Selective Deletion of the Cube contents in Abap Program of the PChain

    Dear Experts
    I need to selectively delete the contents in Basic Infocube using Process Type - ABAP Program in the Process Chain in BW 3.5
    For this I have to give the Variant and Program name in the Process Type - ABAP Program in the Process Chain
    The ABAP Program for this purpose can be generated automatically by the system in the the below navigation
    info cube> Manage>contents > system menu(in the Top)> Status
    but this abap program is changing dynamically every time and hence in the Process chain ABAP Program node is failing with error saying that that program is not available
    I have tried the same way  in the selective deletin navigation path also in the cube manage
    Please let me know how to get the system generated program to use in the Process type-ABAP Program in Process Chain
    Thanks for all in advance
    KSR

    Hi KSR,
    Try this.. start a selective deletion on the cube. you will get a background job running. Get the job name from SM37.
    Now write a ABAP program with the below code.
    parameter: p_Job_Name type sysuuid_c.
    CALL METHOD cl_rscrmbw_bapi=>exec_rep_in_batch
    EXPORTING i_barepid = l_jobnam.
    Execute the above program. Pass the job name which you got from SM37.
    Create a variant with that job name.
    Now schedule this newly created program. This should solve your issue.
    Note : The job name might vary from one server to another (Dev / Qual / Prod). So if you are planning to move your process chain from Dev, then pass the Job name (in prod) as the variant in yr Dev system and then transport it.
    Cheer,
    Balaji Venugopal

  • Regarding text attachment in Email in ABAP program

    Hello...
    Need your expertise in one of the issues. Requirement is seems to be simple
    but i am stuck up at this moment. i have refereed SDN with Several code but
    some point its not giving the proper solution. So its a request to you please
    do not provide any SDN link for reference as i am very much tried all of them.
    please share piece of code.
    Requirement : Need to develope one ABAP program, Email text attachment with Header line.thought its
    very simple but still facing difficulties.
    i have tried many code either its showing Data in single line without new line , in one of the Codes
    data is coming in successive line but there is lot of spacing within Words means all alphabates are tab
    separated. coud you please provide ,me the proper solution for this.
    in  one of the codes is working fine for excel but when Txt extension done data is not coming in successive line all
    data is coming in single line.
    Ex. Text file should contain 1 head and 4 colunns and Data size 50..
    Thanks
    Nishi

    Hi,
    Another option....
    Some sample code using cl_bcs .
    Note the use of cl_abap_char_utilities=>cr_lf .
    FORM mail_1_prep_10
    USING
        it_data         TYPE table
      CHANGING
        ob_document_bcs TYPE REF TO cl_document_bcs .
      DATA: txt_line TYPE string .
      DATA: txt_data TYPE string .
    * Create some text data .
      DO 20 TIMES .
        txt_line = '' .
        DO 10 TIMES .
          CONCATENATE txt_line '|' 'some data 01' '|'   INTO txt_line .
        ENDDO .
        CONCATENATE txt_line cl_abap_char_utilities=>cr_lf INTO txt_line .
        CONCATENATE txt_data txt_line INTO txt_data .
      ENDDO .
    * Mail stuf....
      DATA: it_solix TYPE solix_tab .
      CALL METHOD cl_bcs_convert=>string_to_solix
        EXPORTING
          iv_string = txt_data
        IMPORTING
          et_solix  = it_solix.
      DATA: attachment_subject TYPE so_obj_des .
      DATA: attachment_type TYPE so_obj_tp .
      attachment_subject = 'Some text data' .
      attachment_type = 'txt' .
      TRY.
          CALL METHOD ob_document_bcs->add_attachment
            EXPORTING
              i_attachment_type    = attachment_type
              i_attachment_subject = attachment_subject
              i_att_content_hex    = it_solix.
        CATCH cx_document_bcs .
      ENDTRY.
    ENDFORM .                    "mail_1_prep_10
    regards.
    This is how I see it in my mail :

  • Run info package from an ABAP program

    Hi all,
    I need to run an info-package based on values entered by user in a selection screen.
    How can I implement these values in the info-package using the abap program?
    I've searched the forum and found FM RSSM_SDL_START_INFOPACKAGE and BAPI_IPAK_START but there is no option to enter the selections, also I have found the option to select var type 6 - abap code in the info-package (tab  data selection) but didn't understand if I can connect it to an external abap program.
    Thanks,
    Hagit

    Along with BAPI_IPAK_START, you need to use the FM "BAPI_IPAK_CHANGE"...
    there you have the table with structure BAPI6109SEL, which is used to pass selections to infopackage at the run time...
    Sequence u can use is BAPI_IPAK_START, then BAPI_IPAK_CHANGE and finally BAPI_IPAK_START as per ur requirements...

  • How to execute application server file from abap program

    Hi Friends,
    i have a requirement to execute application server file using abap program.
    i got a file directory like '/home/im3/hrintf/xxx.sh' , it's of unix file, so they want me to execute through abap program.
    pls suggest me with relevant logic.
    Thank you.
    Regards
    Ramesh M

    Define the external command in SM49/SM69
    Try with SXPG_CALL_SYSTEM or SXPG_COMMAND_EXECUTE
    Also check this link
    link:[Execute Unix Script|http://searchsap.techtarget.com/tip/0,289483,sid21_gci774071,00.html]

  • How to create a job thru ABAP program for calling a program with variant???

    Hello experts,
    can u give me step wise procedure to create jobs for  a program with a variant name thru ABAP???
    Also, can a transaction can be scheduled as a job to run in background with a variant name???
    Edited by: SAP USER on Jul 22, 2008 6:08 AM

    Hi,
    To create a job through ABAP program you can do the following.
    Go to Menu bar.
    In there, go to   SYTSTEM> SERVICES> JOBS--> DEFINE JOB.
    Then give the JOB NAME and CLASS in the screen that comes up.
    This is how we schedule a program.
    Now, to create a variant for a program -
    First activate your program in SE38. Then execute it .
    Now, click on SAVE button. It will open up  the variant creation screen. Give the details there like variant name and value for the fields. Save and come back.
    Hope this helps.
    Regards,
    Hari Kiran

  • 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

  • Abap program to maintain variants in RSRPARAMETRIZA

    Hi,
    SAP provided an ABAP example to maintain 3.5 variants in NW04s
    Report Z_MASS_VARIANT_MAINTENANCE is available in the next u2018how tou2019 document.
    [http://www.sapadvisors.com/resources/HowtoInformationBroadcasting.pdf]
    This is only helpfull if you use 3.5 workbooks.
    7.0 workbook variants are not save in RSRVARIANT anymore. 7.0 variants are saved in table-field RSRPARAMETRIZA-STRING (xml field with selection values).
    I need to develop a program to maintain this variants. Can anybody save me some time and send me similar abap program for 7.0 workbooks ?
    Thanks,
    Pedro

    Hi,
    Bruno is right about class CL_RSR_PARA.
    This is an abap example is used to maintain 'ZRT_M4M_Q0016' Query variants. In this case variant BC_SALST001 is updated.
    If you need to update different report variant you have to change the 'form create_variant'.
    In this variant I'm updating:
    - 0S_MAT: empty
    - 0S_MATGR: 5300-5399
    - ZMM_STA2: Z0;ZZ
    *& Program to mass update BEx Variants within SAP Netwever 2004s
    REPORT Z_MASS_FR_BROADCAST_0003 .
    constants: C_PARAMNM type RSPARAMNM value 'BC_SALST001'.
    ---> TYPE DEFININTIONS --->
    NOTE: Ripped from class CL_RSR_PARA
    TYPES: BEGIN OF t_sx_int_var_value,
             vnam   TYPE rszvnam,
             data_prov TYPE string,
             range   TYPE STANDARD TABLE OF rrrange  WITH DEFAULT KEY
                                                     INITIAL SIZE 1,
       END OF  t_sx_int_var_value.
    TYPES: t_tx_int_var_value TYPE STANDARD TABLE OF t_sx_int_var_value
                                   WITH DEFAULT KEY
                                   INITIAL SIZE 1.
    <- TYPE DEFININTIONS <-
    DATA: l_s_rsrparametriza type rsrparametriza.
    DATA: l_s_range type rrrange.
    DATA: l_s_sx_int_var_value type t_sx_int_var_value.
    DATA: r_tsx_values type t_tx_int_var_value.
    perform create_variant.
    l_s_rsrparametriza-paramnm = c_paramnm.
    l_s_rsrparametriza-objvers = 'A'.
    l_s_rsrparametriza-parentcomponent = '1'.
    l_s_rsrparametriza-workbookid = ''.
    l_s_rsrparametriza-eltuid = 'ZRT_M4M_Q0016'.
    l_s_rsrparametriza-plnfuncnm = ''.
    l_s_rsrparametriza-template = ''.
    l_s_rsrparametriza-planningseqeunce = ''.
    l_s_rsrparametriza-version = ''.
    l_s_rsrparametriza-personal = ''.
    l_s_rsrparametriza-owner = sy-uname.
    CALL TRANSFORMATION
      id
      SOURCE page = r_tsx_values
      RESULT XML l_s_rsrparametriza-content.
    get time stamp field l_s_rsrparametriza-timestmp.
    l_s_rsrparametriza-conttimestmp = ''. " fix
    *For security reasons I just change existing variants field.
    update rsrparametriza
       set content = l_s_rsrparametriza-content
    where PARAMNM eq c_paramnm
       and OBJVERS eq 'A'.
    If sy-subrc eq '0'.
      Write: 'Update sucessfull'.
    else.
      Write: 'No update: Probably variant does not exist'.
    endif.
    form create_variant.
    *0S_MAT
      clear l_s_sx_int_var_value.
      l_s_sx_int_var_value-vnam = '0S_MAT'.
      l_s_sx_int_var_value-data_prov = 'DP_4'.
      " no selections
      append l_s_sx_int_var_value to r_tsx_values.
    *0S_MATGR
      clear l_s_sx_int_var_value.
      l_s_sx_int_var_value-vnam = '0S_MATGR'.
      l_s_sx_int_var_value-data_prov = 'DP_4'.
      clear l_s_range.
      l_s_range-sign = 'E'.
      l_s_range-opt = 'BT'.
      l_s_range-low = '5300'.
      l_s_range-high = '5399'.
      append l_s_range to l_s_sx_int_var_value-range.
      append l_s_sx_int_var_value to r_tsx_values.
    *ZMM_STA2
      clear l_s_sx_int_var_value.
      l_s_sx_int_var_value-vnam = 'ZMM_STA2'.
      l_s_sx_int_var_value-data_prov = 'DP_4'.
      clear l_s_range.
      l_s_range-sign = 'I'.
      l_s_range-opt = 'EQ'.
      l_s_range-low = 'ZO'.
      l_s_range-high = ''.
      append l_s_range to l_s_sx_int_var_value-range.
      l_s_range-low = 'ZZ'.
      append l_s_range to l_s_sx_int_var_value-range.
      append l_s_sx_int_var_value to r_tsx_values.
    That's all
    Pedro

  • From which table could i get all the Variants of a specific ABAP program?

    Hi,
    From which table could i get all the Variants name which belong to a specific ABAP program?
    Thanks.

    Hi,
    Check the table starting with TVAR*.
    Regards,
    Atish

  • Ending a process chain with abap program

    Hello friends.
    Can anyone help me please?
    I have a problem with a process chain in BW.
    The process chain is triggered by the MF BP_EVENT_RAISE in an custom MF. While the process chain works, the custom MF is monitoring the chain´s log.
    This process chain have 2 steps:  one is the initial process and the other is a ABAP program. In the abap program there are validations and if exists some error, the program abort and this job (BI_PROCESS_ABAP) is cancelled. The problem is that i have to go to the Tx. RSPC and view the logs fro this chain and in these moment ends th custom MF. In other wors, the MF ciustom ends until i go to the tx RSPC for view the logs.
    I need that the program ends the process chain naturally.
    Thanks for your help.
    Regards.

    Hi,
    You can end a process chain by seeing the variant name and instance name of teh process chain from and finding its corresponding log id,type of process from the table RSPCPROCESSLOG and then executing the standard FM RSPC_PROCESS_FINISH. Here you will have to give the log id,type of process ,vairant name and instance name alongwith the status of the process chain as R to end the process chains.
    If you want to aurtomate it you can do that by creating a Z program which will read LOG ID and teh TYPE of process from table RSPCPROCESSLOG on the basis of variant name and the instance name of the process chain and the execute the function module RSPC_PROCESS_FINISH from inside the program.
    Navesh

  • ABAP program is terminated with error Function ROLLBACK on connection R/3

    Hi,
    We are reading a DB table A and matching with table B and placing into a internal table and further looping at the internal table.
    Table A has 3- 5 million records
    Table B has 2-4 million records
    When the program run in batch or dialog process, it stops without apparently reason, it don not trace any log in ST22 transaction. When we trace it in SM21 trace the following log:
    22:18:33 BTC  014 100                BZ  Y Unexpected return value 1 when calling up DbSlR
    22:18:33 BTC  014 100                BY  J Function ROLLBACK on connection R/3 failed
    22:18:33 BTC  014 100                R3  9 Error in DB rollback/SyFlush, return code 016384
    22:18:33 BTC  014 100                Q0  2 Stop Workproc14, PID 729286
    22:18:33 BTC  014 100                F3  T Invalid object name for TemSe object: " "
    22:18:33 BTC  014 100                EC  F Failed to create log for job BIDTPR_291659_1 22085900%_IMMEDIATE %NEWSTEP/
    22:18:33 BTC  014 100                F2  0 Calling program reports invalid handle for TemSe object (magic==X'NULL-ptr'
    22:18:33 BTC  014 100                R4  7 Delete session 001 after error 023
    The tables and ABAP program are in a BW system.
    Any idea what would be the cause. I found  a similar problem in the forum but no solution provided there..
    Regards
    Rob

    Hi Rob,
    Please check the entries in the work process trace file from this time (dev_wp14 from the work directory)
    Error in DB rollback/SyFlush, return code 016384
    usually has a preceding entry in the wp log of
    SHO: Could not allocate SHO segment of ..... bytes (rc=1)
    Usually this is a result of a SELECT statement that returns a very large result set is executed.             
    While the result set is fetched the ABAP heap is exhausted. Since no             
    more memory is available the ABAP engine abruptly cancels the execution          
    and begins error handling. The database interface rejects to execute a           
    ROLLBACK statement while the SELECT statement is still active. As the            
    rollback fails the task handler restarts the SAP work process and no             
    ABAP short dump or job log entries can be written.                                                                               
    The rejected ROLLBACK is a direct result of the lack of ABAP heap memory         
    and does not represent an error in itself.                                                                               
    The solution here is to increase the memory areas "extended memory" and          
    / or "heap". Please check/adjust your SAP memory settings!
    As mentioned, Similar issues have been resolved with the note #741864.                     
    The key is that the abap/shared_object_size_MB is too small for the          
    system and the operation performed, please increase this to 100MB to         
    start from the default of 20MB and then increase further if the dump         
    persists as more maybe needed of course. There is no problem increasing      
    this parameter since you have a 64bit system and SAP kernel.                                                                               
    Similar issues have been resolved with the note #741864 and note #986790     
    along with the increase in abap/shared_object_size_MB. These notes may       
    not be necessary just the increase but this issue frequently occurs in       
    these areas so perhaps they can help.                                        
    Hope this helps,
    Paul

Maybe you are looking for