Newbie: how to handle pipes and semicolons while launching UNIX commands?

Good afternoon,
I am trying to write a Java class that can launch UNIX commands.
Launching simple commands (date, ps -ef) works fine, but when I start using pipes and semicolons, it goes wrong:
Java code (pipe example):
        String command = "ps -ef | grep config";
        Process child = Runtime.getRuntime().exec(command);Result:
usage: ps [ -aAdeflcjLPy ] [ -o format ] [ -t termlist ]
        [ -u userlist ] [ -U userlist ] [ -G grouplist ]
        [ -p proclist ] [ -g pgrplist ] [ -s sidlist ]
  'format' is one or more of:
        user ruser group rgroup uid ruid gid rgid pid ppid pgid sid taskid
        pri opri pcpu pmem vsz rss osz nice class time etime stime
        f s c lwp nlwp psr tty addr wchan fname comm args projid projectJava code (semicolon example):
        String command = "date;ps -ef";
        Process child = Runtime.getRuntime().exec(command);Result:
date;ps: not foundClearly the pipes and the semicolons are handled by the UNIX shell and cannot be put in the Java source code as such.
Does anybody know a way around this?
Thanks
Dominique

Pipes and semicolons are interpreted by a shell (bash, csh etc) and when one executes as you are doing no shell is involved. This is easy to solve by using the alternate version of exec() which takes an array as an argument and to use your shell of choice. For example :-
String[] command = {"bash", "-c", "date;ps -ef"};Note that the third argument is the whole of the command to be interpreted.
Two points to consider. First you should read, digest and implement all the recommendations in http://www.javaworld.com/jw-12-2000/jw-1229-traps.html; failure to do so will at some point lead to significant loss of hair. Second you should probably use ProcessBuilder rather than Runtime.exec(). Behind the scenes Runtime.exec() uses ProcessBuilder but ProcessBuilder provides a better interface with more features.

Similar Messages

  • Newbie: how to temporary results and handle sessions running UNIX commands?

    Hello,
    I have just asked a question concerning launching UNIX commands using Java classes, see thread "_https://forums.oracle.com/forums/thread.jspa?threadID=2429211&tstart=0_".
    I have followed the mentioned advises (using "bash","-c" parameters) but now I have stumbled into other issues:
    My intention is to write a UNIX class, that can handle UNIX commands, in order to be used in other Java programs, so that the following example becomes possible:
    UNIX.launch("cd /var/core");
    UNIX.launch("rm obsolete_core_file");
    UNIX.launch("sqlplus <Oracle_database>");
    UNIX.launch("select * from cat;");Unfortunately I have stumbled into a strange behaviour: until now, I have created the UNIX class as a single class, containing a "main" method. When I launch the following commands:
    java UNIX "cd /var/core";
    java UNIX "rm obsolete_core_file"I have the problem that the "cd /var/core" command is executed while UNIX class is running, but afterwards I jump back to my current directory:
    pwd => current directory
    java UNIX "cd /var/core" (this is executed, e.g. verifying "ls" output)
    pwd => current directoryI would like to have:
    pwd => current directory
    java UNIX "cd /var/core"
    pwd => /var/coreOne other thing is the handling of sessions: until now, when I launch following commands:
    UNIX.launch("sqlplus <Oracle_database>");
    UNIX.launch("select * from cat;");Then I get into a "sqlplus" session, but afterwards my Telnet session hangs. Is there a way to see that I have fallen into a session, and handle it? (Exit, launch internal session (SQL-plus) command, ...)
    Thanks again
    Dominique

    scampsd wrote:
    Hello,
    I have just asked a question concerning launching UNIX commands using Java classes, see thread "_https://forums.oracle.com/forums/thread.jspa?threadID=2429211&tstart=0_".
    I have followed the mentioned advises (using "bash","-c" parameters) but now I have stumbled into other issues:
    My intention is to write a UNIX class, that can handle UNIX commands, in order to be used in other Java programs, so that the following example becomes possible:
    UNIX.launch("cd /var/core");
    UNIX.launch("rm obsolete_core_file");
    UNIX.launch("sqlplus <Oracle_database>");
    UNIX.launch("select * from cat;");Unfortunately I have stumbled into a strange behaviour: until now, I have created the UNIX class as a single class, containing a "main" method. When I launch the following commands:
    java UNIX "cd /var/core";
    java UNIX "rm obsolete_core_file"I have the problem that the "cd /var/core" command is executed while UNIX class is running, but afterwards I jump back to my current directory:
    pwd => current directory
    java UNIX "cd /var/core" (this is executed, e.g. verifying "ls" output)
    pwd => current directoryI would like to have:
    pwd => current directory
    java UNIX "cd /var/core"
    pwd => /var/coreOne other thing is the handling of sessions: until now, when I launch following commands:
    UNIX.launch("sqlplus <Oracle_database>");
    UNIX.launch("select * from cat;");Then I get into a "sqlplus" session, but afterwards my Telnet session hangs. Is there a way to see that I have fallen into a session, and handle it? (Exit, launch internal session (SQL-plus) command, ...)
    Thanks again
    DominiqueWhy not just use plain java File I/O http://docs.oracle.com/javase/tutorial/essential/io/fileio.html and JDBC http://docs.oracle.com/javase/tutorial/jdbc/basics/processingsqlstatements.html for fulfilling your requirements?
    Edited by: maheshguruswamy on Aug 20, 2012 10:32 AM

  • How to handle the table control While working with LSMW?

    How to handle the table control While working with LSMW?

    its possible in lsmw,
    Hi,
    LSMW will have a Indicator for headr and itam, i do not remember the correct field, but it will have an indicator, check the fields, there will be a single charecter lenght field, that should be the indicator, and using that we can write the logic.
    check that single charecter field, it that is X that means the header record is processed, and do the items.
    and, this is another way, try this out also
    YOu can do this in "Define Source Structures" step,
    the HEADER is defined first,
    then the DETAIL below the HEADER.
    add the fields to the structures.
    Both should have some common key field
    Please take care that the name of the common field is the same.
    Once you do this it is linked. The you have a header and item corresponding to that header. then run the LSMW as you would.
    Thanks

  • How to handle rules and activities in AII

    Hi experts,
                     How to handle rules and activities in AII. Is there any transaction code for it. please give some information, it will be hepful for me

    In IMG go to Conditions & Rules to configure the relevant rules.
    Rules in AII represent business process you intend to RFID enable. Each rule is made up of multiple activities that defines exactly how a particular rule functions.
    SAP delivers standard rules & activities for standard scenarios of Pack, Load etc. processes.
    For more information on AII rules and activities refer to the performance assistant available in IMG or read more at the link below:
    http://help.sap.com/saphelp_autoid40/helpdata/en/index.htm
    Hope this helps.
    -Ashish

  • How To Handle Tickets and What are those

    Hi Everybody,
    Can anybody tell me, How to handle tickets and what are those.
    srinivas

    Hi,
    Tickets are basically assocaited with Production support type of work.
    Tickets are nothing but the medium through which problems reported either in the system or by users to the Production support team.
    There are certain problem management tools that every organization uses (tickets are created and worked on using those tools). There are tools like Vantive, Remedy, CASE, etc.
    Usually the helpdesk gets the first contact for any user problems and then they log a ticket with the appropriate support teams. The support teams then pick up those tickets and work on them till they are resolved. There are tickets created for user problems or any batch job failures, system failures, etc.
    Tickets are usually classified as Critical, High or Low and again they are categorized as High Severity, Medium Severity or Low Severity. All these types of tickets have SLAs (Service level agreements) for the Support teams to respond and the resolve the tickets in.
    Look at the threads below for similar posts :
    tickets
    Tickets
    tickets
    Cheers,
    Kedar

  • How to handle "ok" and "cancel" button of dialog popup?

    Hello everyone,
    I'm using a dialog with type="okCancel". My question is how to handle ok and cancel button of this popup window. Here is my code below:
    <af:popup id="kriterPopup">
    <af:dialog title="Kriter Seçiniz" type="okCancel" inlineStyle="width:500px;height:400;" id="d2"
    dialogListener="#{BasvuruDegerlendirmeBean.kriterDialog}">
    <af:selectManyCheckbox label="Kriterler :" id="smc2"
    binding="#{BasvuruDegerlendirmeBean.kritersCheckbox}">
    <af:forEach items="#{BasvuruDegerlendirmeBean.kriterList}" var="item">
    <f:selectItem itemLabel="#{item.ybKriter.tur}" itemValue="#{item.ybKriter.tur}" id="si3"/>
    </af:forEach>
    </af:selectManyCheckbox>
    </af:dialog>
    </af:popup>
    I want to handle ok and cancel button of this window, and redirect to the pages which I want.
    Can anyone help me how I can do?
    Thanks, with my regards.
    Ali

    You need dialogListener..
        public void dialog1_dialogListener(DialogEvent dialogEvent) {
            if (dialogEvent.getOutcome().equals(DialogEvent.Outcome.yes)){ //for Yes
            }else{ //for Cancel
        }

  • How to restore views and procedures after drop user command?

    How to restore views and procedures after drop user command?
    We have 817 EE on NT and one developer created a lot of procedures, functions and vews. DB was not backuped and archived and export has not been done - our fault and we understand it. Sorry for this.
    Ok, now the story: another developer dropped this db user and we lost everything: procedures, functions and vews. The new user with trhe same name was created and new schema was imported in this user, but all old objects are lost. We don't have export and backup and archive log files.
    Question: may we can restore this lost stuff from some other sources. We are looking for lost codes, not data. May be we can use redo logs or shared pool or any other things. Any idea will be appreciated.
    Thanks.
    Victor
    [email protected]

    The switch has occurred after user was dropped, the data has been overwritten and there is be no way to use redo log files.
    I would like to explore another opportunity. Is possible to use Shared Pool or any Data Dictionary internal information to restore texts of the lost SQL and PL/SQL scripts executed in this DB before user was dropped? Not too many scripts are executed in this DB and the lost ones may still be in stack. I remember that Shared Pool (cash) should keep last executed scripts in order to improve performance. They probably are kept in some special format. Can we restore these scripts? Of course they also might be pushed out by Import that had been done after user was dropped.
    Thanks for your help,
    Victor

  • (com.apple.collabd[15483]): Service setup event to handle failure and will not launch until it fires.

    Hello,
    I am fairly new at Xserve administration, but I got thrown in the fire and i need your help.
    My system.log is being hammered with this error:
    (com.apple.collabd[15483]): Service setup event to handle failure and will not launch until it fires.
    I did my research and it seems to be related to Wiki, but I disabled wiki and restarted and it is still coming up. Any advice would really help
    System Version: OS X 10.10.1 (build 14B25)
    Server Version: Server 4.0.3 (Build 14S350)

    Try deleting the preferences file

  • How to handle the Timestamp datasource while migration

    Hi All
    " I tried searching the forum,but didnt get the relevant one,hence posting this question".
    While migration from 4.7 to ECC in R/3 system,
    how to handle the Timestamp datasources( especially FI like COPA and other ) while extarcting the data from source to BW during source system migration.Since we need to empty the delta queue and should make sure that there are no delta records exists in delta queue.
    Like for sales datasources using LO,we will be executing the V3 jobs for execting the LUW's from LBWQ to RSA7?  In the same way is there any particular way for this also.
    Anyone whi knows abt this pls share your views
    Regards
    Shankar

    Hello Shankar.
    Before the upgrade (import of a queue), all extraction queues and open
    update orders in all clients must be processed. The content of the setup
    tables must be deleted. To avoid problems during the upgrade or to
    correct them, carry out the following steps:
    1. Call transaction SMQ1 and check whether all queues in all clients
    (client = '', queue name 'MCEX') have been processed. To process the
    queues, start the collective run report for each application in the
    displayed clients. If you no longer need the data in the BW system,
    deactivate the relevant extraction queues and DataSource in the LO
    cockpit (transaction LBWE) and delete the queue entries in transaction
    SMQ1.
    2. If you use the V3 update that is not serialized (usually only for
    application 03): Start collective run report RMBWV303. Then check the
    update orders in transaction SM13. If there are incorrect update orders
    in transaction SM13, correct the orders and then start the collective
    run report again. If you no longer require the update orders, you can
    delete them. There may be inconsistencies between tables VBMOD and
    VBHDR. For further information about this, see Notes 652310 and 67014.
    3. Before the upgrade, delete the contents of the setup tables. Execute
    report RMCEX_SETUP_ENTRIES to find out which setup tables still contain
    entries. You can use transaction LBWG to delete the contents of the
    setup tables for all clients.
    Unfortunately the check that the system carries out during the upgrade
    or when you import a Support Package does not display all affected
    applications. Therefore, Note 1083709 provides a check report that you
    can use to determine all affected applications and tables or queues.
    More detailed information please check these following notes:
    1083709-Error when you import Support Packages
    1081287-Data extraction orders block the upgrade process
    I hope I can be helpful.
    Thanks,
    Walter Oliveira.

  • How to handle local bank charges while our customer payment in USD

    Hi All Expert,
    How we handle customer payment with local bank charges rm5 at incoming payment?
    Examples :
    Customer invoice in USD 1000, while payment USD1000 by bank transfer with local bank will charges rm5 for each transaction.
    May i know how does the B1 handle this bank charges in local currency?

    Hello Eric,
    I presume that the bank charge will not be paid by the customer. In this case, the actual Invoice of USD 1000 is considered fully paid.
    I think the only way to proceed is to create a manual journal entry to Debit the Bank Charges and Credit the Bank Account. Or you can take it up when you post other bank reconciliation items at month end.
    Hope this helps.
    Regards,
    Lorna

  • 0Person to 0employee loading, how to handle start and end date

    Hi
    I need help on some basic understanding of time dependent master data object.
    In my scenario i am loading 0employee and 0Person from R/3. I need to update 0employee from 0person.
    0employee
    BEGDA            ENDDA             PERNR        Position....................So many fields
    10.10.2001     10.10.2004        8000123    Associate
    11.10.2004     10.10.2008        8000123    Consultant
    11.10.2008     31.12.9999        8000123    Senior Consultant
    0Person
    BEGDA            ENDDA             PERNR         City....................So many fields
    10.10.2001     10.10.2003        8000123      Singapore
    11.10.2003     10.10.2007        8000123      Tokyo
    11.10.2007     31.12.9999        8000123      Newyork
    As the begining and end date are different i can't simply read City from 0person into 0employee. If i go for checking the city for the start and end date in 0employee, i will get multiple records ( If try to get city for 0employee's first record, i will get 2 city Singapore and Tokyo).
    Please help me out how to handle this ...... i think i am missing somelink somewhere
    Thanks
    Tripple k

    Hi Srini
    Yes i need to have parallel flow for both and in the cube where my reporting will be on monthly basis i need to read these 2 master data and get the required attributes ( considering last/first day of that month as per the requirement).......but i am just wondering this is common scenario....while there are so many threads written for populating 0employee from 0person......don't they have such requirement.....
    Thanks
    Tripple k

  • How to handle vacation and daily business workload in cProjects

    Hi,
    we are planning to use cProjects for our ressource-management. The goal is also to take care of vacation and daily business workload. We would like to see that a ressource is not available on the specified day. Therefore we are thinking about a project with vacation and a workload and assign people to this project? Is there a best practice to handle vacation and the daily business workload?
    Regards, Vanessa

    Hi Sammar,
    thanks a lot for your answer. This helps.
    I have seen that my question is not really clear and therefore I would like to make it more concrete.
    I am searching for a possibility to see - during staffing - that an employee is not available on several days. I don't care about the reason the ressource is not available but need to see this that the ressource is not available. If the worker is assigned to another task the demand is clear because it is handled within cProjects. But what about blocking of ressources (i.e. vacation) because this happens in an external system / HCM module? (Therefore I was thinking about to create a project for vacation and plan there the absences of my workers (because of vacation and other reasons). But is it not possible out-of-the-box to specify that the worker is not available on several days because I would setup a task for vacation and would need to assign him on several days and not only for a given time range.) Am I right with this assumption?
    Also for the ressource planning: Sorry but I don't get the point with your answer (surely because I am not deep enough into the topic). How is it possible to have a project (lets call the task "daily business") and assign several ressources 25% to this tasks? I need to distribute the demand to several days. For example there is a worker that is using 25% for his daily time for training. In this time he is not available for other tasks. Therefore I would like to create the task, assign him to the task and cProjects should take the demand (8hrs / week) and split it into an demand of 2hrs / day. In this way I can block a ressource for everyday and in the ressource planning I see that he is only available 6hrs because there is already the demand of 2hrs on a daily base.... It this possible?
    Regards, Vanessa

  • How to handle the bad record while using bulk collect with limit.

    Hi
    How to handle the Bad record as part of the insertion/updation to avoid the transaction.
    Example:
    I am inserting into table with LIMIT of 1000 records and i've got error at 588th record.
    i want to commit the transaction with 588 inserted record in table and log the error into
    error logging table then i've to continue with transaction with 560th record.
    Can anyone suggest me in this case.
    Regards,
    yuva

    >
    How to handle the Bad record as part of the insertion/updation to avoid the transaction.
    >
    Use the SAVE EXCEPTIONS clause of the FORALL if you are doing bulk inserts.
    See SAVE EXCEPTIONS in the PL/SQL Language doc
    http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/tuning.htm
    And then see Example 12-9 Bulk Operation that continues despite exceptions
    >
    Example 12-9 Bulk Operation that Continues Despite Exceptions
    -- Temporary table for this example:
    CREATE TABLE emp_temp AS SELECT * FROM employees;
    DECLARE
    TYPE empid_tab IS TABLE OF employees.employee_id%TYPE;
    emp_sr empid_tab;
    -- Exception handler for ORA-24381:
    errors NUMBER;
    dml_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT(dml_errors, -24381);
    BEGIN
    SELECT employee_id
    BULK COLLECT INTO emp_sr FROM emp_temp
    WHERE hire_date < '30-DEC-94';
    -- Add '_SR' to job_id of most senior employees:
    FORALL i IN emp_sr.FIRST..emp_sr.LAST SAVE EXCEPTIONS
    UPDATE emp_temp SET job_id = job_id || '_SR'
    WHERE emp_sr(i) = emp_temp.employee_id;
    -- If errors occurred during FORALL SAVE EXCEPTIONS,
    -- a single exception is raised when the statement completes.
    EXCEPTION
    -- Figure out what failed and why
    WHEN dml_errors THEN
    errors := SQL%BULK_EXCEPTIONS.COUNT;
    DBMS_OUTPUT.PUT_LINE
    ('Number of statements that failed: ' || errors);
    FOR i IN 1..errors LOOP
    DBMS_OUTPUT.PUT_LINE('Error #' || i || ' occurred during '||
    'iteration #' || SQL%BULK_EXCEPTIONS(i).ERROR_INDEX);
    DBMS_OUTPUT.PUT_LINE('Error message is ' ||
    SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
    END LOOP;
    END;
    DROP TABLE emp_temp;

  • Newbie: How to handle a multi-step dialogue with no session?

    I can't see how to handle the following trivial problem:
    1. The user clicks on a button to retrieve values from the database
    2. The values returned are displayed in a table on the same page
    3. The user clicks a button next to the desired element
    4. Some action is performed
    I can achieve steps 1, 2, 3 but fail on step 4: the action is not called.
    One prerequisite is that I don't want to store anything in the session or application scope.
    In the example that follows, when you click on "Show Element" the action is not performed.
    This is myExample.jsp:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
    <HTML>
    <HEAD>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <TITLE>Test</TITLE>
    </HEAD>
    <f:view>
         <BODY>
         <h:form>
              <h:commandButton action="#{myExample.doSearch}" value="Search Database" />
              <p/>
              <h:dataTable value="#{myExample.elements}" var="elem" binding="#{myExample.dataTable}">
                   <h:column>
                        <h:outputText value="#{elem}"/>
                   </h:column>
                   <h:column>
                        <h:commandButton type="submit" value="Show Element"     action="#{myExample.doShowElement}"/>
                   </h:column>
              </h:dataTable>
         </h:form>
         </BODY>
    </f:view>
    </HTML>This is myExample.java:
    package example;
    import javax.faces.component.html.HtmlDataTable;
    public class MyExample {
         private HtmlDataTable dataTable;
         private String[] elements;
         public MyExample() {
         private String[] readFromDatabase() {
              return new String[] {"one", "two", "three"};
         public String[] getElements() {
              return elements;
         public void setElements(String[] elements) {
              this.elements = elements;
         public HtmlDataTable getDataTable() {
              return dataTable;
         public void setDataTable(HtmlDataTable dataTable) {
              this.dataTable = dataTable;
         public String doSearch() {
              elements = readFromDatabase();
              return "";
         public String doShowElement() {
              String selected = (String) dataTable.getRowData();
              System.out.println("Selected element: " + selected);
              return "";
    }This is in faces-config.xml
         <managed-bean>
              <managed-bean-name>myExample</managed-bean-name>
              <managed-bean-class>example.MyExample</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
         </managed-bean>

    Thank you for your answer.
    I didn't realise I could use inputHidden for anything more complex than a single string...
    I have added a h:inputHidden for the elements array but it still doesn't work.
    How should it be used?
         <h:form>
              <h:inputHidden value="#{myExample.elements}"/>
              <h:commandButton action="#{myExample.doSearch}" value="Search Database" />
    ...While debugging I noticed that at the last button-press the getElements method is called twice before setElements, returning null.

  • How to handle duplicate price creation while using RV_CONDITION_COPY

    Hi,
    I using FM RV_CONDITION_COPY in my BAPI to create the price but if the same record is being passed again either with same validation date or different validation dates then system pops up a window with message "The validity period of the condition created overlaps with conditions with shorter validity periods. These conditions will be deleted when you save." and other detail. This screen is same as when we try to create price using VK11.
    Does anybody know how to handle this issue.
    Thanks and Regards,
    Seema

    this may helps you.
    Look at the below thread ....
    Check if the below code can help you:
    U can try like this
    CONSTANTS:
    CON_A(1) TYPE C VALUE 'A',
    CON_B(1) TYPE C VALUE 'B',
    CON_C TYPE C VALUE 'C',
    CON_D TYPE C VALUE 'D',
    CON_E TYPE C VALUE 'E',
    CON_F TYPE C VALUE 'F',
    CON_G TYPE C VALUE 'G',
    CON_K TYPE C VALUE 'K',
    CON_T TYPE C VALUE 'T',
    CON_S(1) TYPE C VALUE 'S',
    CON_V LIKE T681A-KAPPL VALUE 'V',
    CON_X TYPE C VALUE 'x',
    CON_XX TYPE C VALUE 'X',
    CON_T074 LIKE T681-KOTABNR VALUE '074',
    CON_PREF LIKE T685A-KSCHL VALUE 'PREF',
    CON_ULTIMO LIKE RV13A-DATAB VALUE '99991231',
    CON_DATA_LOG_NAME(8) TYPE C VALUE 'PREF',
    CON_ERROR_LOG_NAME(8) TYPE C VALUE 'ERROR',
    CON_CUSTOM_LOG_NAME(8) TYPE C VALUE 'P_CUSTOM'.
    Verkaufsmengeneinheit
    PERFORM f3_vkme_ermitteln.
    Hauswährung
    IF t001w-werks NE cstmat-werks.
    PERFORM f3_waehrung_ermitteln USING cstmat-werks.
    ENDIF.
    pro Zollgebiet Konditionssatz anlegen
    LOOP AT t_matwerte.
    CHECK t_matwerte-noupd_cond IS INITIAL.
    CLEAR: komk,
    komp,
    komg,
    w_komv.
    REFRESH w_komv.
    Schlüssel füllen
    komg-werks = w_marc-werks.
    komg-matnr = w_marc-matnr.
    komg-gzolx = t_matwerte-gzolx.
    komg-land1 = t001w-land1. "101298
    Preisinfo füllen
    w_komv-kappl = 'V '.
    w_komv-kschl = con_pref.
    IF t_matwerte-kp = kp_max.
    w_komv-kpein = 1.
    MOVE kp_max TO w_komv-kbetr.
    ELSE.
    w_komv-kpein = pm_peinh.
    COMPUTE w_komv-kbetr = t_matwerte-kp * pm_peinh / hlp_ameng.
    ENDIF.
    IF w_komv-kbetr = 0.
    COMPUTE w_komv-kbetr = 1 / 100 * -1.
    ENDIF.
    w_komv-waers = t001-waers.
    w_komv-kmein = hlp_ame.
    APPEND w_komv.
    CHECK f3_kz_update_cond IS INITIAL OR
    NOT pm_simu IS INITIAL.
    IF NOT pm_mdmps IS INITIAL.
    MOVE komg-werks TO bg_kond-werks.
    MOVE komg-matnr TO bg_kond-matnr.
    MOVE komg-gzolx TO bg_kond-gzolx.
    MOVE w_komv-kpein TO bg_kond-kpein.
    MOVE w_komv-kbetr TO bg_kond-kbetr.
    MOVE w_komv-kmein TO bg_kond-kmein.
    MOVE w_komv-waers TO bg_kond-waers.
    *{ REPLACE D20K904946 1
    APPEND bg_kond.
    Siemens: Fehlerkorektur SAP-Standard
    READ TABLE BG_KOND TRANSPORTING NO FIELDS
    WITH KEY WERKS = BG_KOND-WERKS
    MATNR = BG_KOND-MATNR
    GZOLX = BG_KOND-GZOLX
    BINARY SEARCH.
    INSERT BG_KOND INDEX SY-TABIX.
    *} REPLACE
    ENDIF.
    CHECK f3_kz_update_cond IS INITIAL.
    CALL FUNCTION 'RV_CONDITION_COPY'
    EXPORTING
    application = con_v
    condition_table = con_t074 "Konditionstabelle
    condition_type = con_pref "Konditionsart
    date_from = sy-datlo "Von jetzt an
    date_to = con_ultimo "Bis Ultimo
    enqueue = 'X' "Sperren ist besser
    i_komk = komk
    i_komp = komp
    key_fields = komg "Schlüssel
    maintain_mode = 'A' "Lieber A als B
    no_authority_check = 'X' "X wie nix
    keep_old_records = ' '
    OVERLAP_CONFIRMED = 'X'
    IMPORTING
    e_komk = komk
    e_komp = komp
    new_record = i_new_record
    TABLES
    copy_records = w_komv
    EXCEPTIONS
    enqueue_on_record = 01
    invalid_application = 02
    invalid_condition_number = 03
    invalid_condition_type = 04
    no_authority_ekorg = 05
    no_authority_kschl = 06
    no_authority_vkorg = 07
    no_selection = 08
    table_not_valid = 09.
    CASE sy-subrc.
    WHEN 0.
    WHEN OTHERS.
    MESSAGE A???
    ENDCASE.
    CALL FUNCTION 'RV_CONDITION_SAVE'.
    CALL FUNCTION 'RV_CONDITION_RESET'.
    ENDLOOP.

Maybe you are looking for