Database Updation and Insertion using Modify Statement

Hi All,
I am using Modify statment for data insertion and updation
MODIFY zmpit_ven_bgg_rg FROM TABLE t_ven_bgg .
But I am getting error
The type of the database table and work area (or internal table) "T_VEN_BGG" are not compatible.
I have defined my internal table of below type :
TYPES : BEGIN OF ty_ven_bgg,
        mandt             TYPE mandt,
        lifnr                 TYPE lfa1-lifnr,
        bgg                 TYPE zmpit_ven_bgg_rg-matkl,
        ind                  TYPE zmpit_ven_bgg_rg-active_ind,
        created_by      TYPE zmpit_ven_bgg_rg-created_by,
        created_on      TYPE zmpit_ven_bgg_rg-created_on,
        last_changed_by TYPE zmpit_ven_bgg_rg-last_changed_by,
        last_changed_on TYPE zmpit_ven_bgg_rg-last_changed_on,
        remarks              TYPE zmpit_ven_bgg_rg-remarks,
        ind1(1)                TYPE c,
             END OF ty_ven_bgg.
Here, ind1 is not field  of the table.
I have added a new field Remarks in the table and thus i included it in the Internal table also.
Above Modify statement was working fine without Remarks field. I am not able to understand the error
as work area is also of type ty_ven_bgg.
Please suggest some solution.
Regards,
Nibha

Hi,
Though you have creaated one more internal tsble without the indc field, but you can do it using the same intrenal table by simply using
1. MOVE-CORRESPONDING <internal table> to <ztable>.
2.MODIFY <ztable>.
will solve your problem
Secondly declare the internal table using DATA after structure has been declared using TYPES.
This is better approach to follow.
Pooja

Similar Messages

  • How can we do policy updations and insertion using procedures in insurence?

    how can we do policy updations and insertion using procedures in insurence?
    please answer for this post i need faced in interview.how can we write the code for that procedure in policy details using procedures in plsql.

    997995 wrote:
    how can we do policy updations and insertion using procedures in insurence?
    please answer for this post i need faced in interview.how can we write the code for that procedure in policy details using procedures in plsql.You are asking about a specific business area (Insurance) and the nuances of that business (Insurance Policies) and providing no technical details about what is required, on a technical forum. There are many varied businesses in the world and not everyone here is going to be familiar with the area of business you are referring to.
    As a technical forum, people are here to assist with technical issues, not to try and help you answer questions in an interview for something you clearly know nothing about, so that you can get a job that you won't know how to do.
    If you have a specific technical issue, post appropriate details, including database version, table structures and indexes, example data and expected output etc. as detailed in the FAQ: {message:id=9360002}

  • Rows updated and inserted by  MERGE

    Hi,
    Is there any way I can come to know, How many rows are updated and inserted using a MERGE statement.
    Thanks in advance

    Something like this ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>
    satyaki>desc aud_emp;
    Name                                      Null?    Type
    EMPNO                                              NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    AUDIT_TMP                                          TIMESTAMP(6)
    AUDIT_IP_ADDR                                      VARCHAR2(15)
    OPR_DESC                                           VARCHAR2(30)
    USER_NM                                            VARCHAR2(40)
    REMARKS                                            VARCHAR2(200)
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>select * from aud_emp;
    no rows selected
    Elapsed: 00:00:00.04
    satyaki>
    satyaki>
    satyaki>select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    13 rows selected.
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>select * from e_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 02-APR-81    3718.75                    20
          7782 CLARK      MANAGER         7839 09-JUN-81     3062.5                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82      11700                    10
    7 rows selected.
    Elapsed: 00:00:00.07
    satyaki>CREATE OR REPLACE TRIGGER trg_aud
    before insert or update or delete on e_emp
    for each row
    declare
         S_IP_ADDR    varchar2(30);
         str          varchar2(320);
         s_empno      varchar2(40);
         s_ename      varchar2(40);
         s_job        varchar2(40);
         s_mgr        varchar2(40);
         s_hrdate     varchar2(40);
         s_sal        varchar2(40);
         s_comm       varchar2(40);
         s_deptno     varchar2(40);
    begin
         SELECT SYS_CONTEXT('USERENV','IP_ADDRESS')
         into S_IP_ADDR
         from dual;
         str:= null;
         if inserting then
             insert into aud_emp values(:new.empno,
                                        :new.ename,
                                        :new.job,
                                        :new.mgr,
                                        :new.hiredate,
                                        :new.sal,
                                        :new.comm,
                                        :new.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'INSERT',
                                        USER,
                                        NULL);
         elsif updating then
           if :old.empno <> :new.empno then
              s_empno := 'Employee No: '||:old.empno;
           elsif :old.ename <> :new.ename then
              s_ename := 'Employee Name: '||:old.ename;
           elsif :old.job <> :new.job then
              s_job := 'Job: '||:old.job;
           elsif :old.mgr <> :new.mgr then
              s_mgr := 'Mgr: '||:old.mgr;
           elsif :old.hiredate <> :new.hiredate then
              s_hrdate := 'Hire Date: '||:old.hiredate;
           elsif :old.sal <> :new.sal then
              s_sal := 'Salary: '||:old.sal;
           elsif :old.comm <> :new.comm then
              s_comm := 'Commission: '||:old.comm;
           elsif :old.deptno <> :new.deptno then
              s_deptno := 'Department No: '||:old.deptno;
           end if;
           str:= 'Updated Records Details -> '||s_empno||' '||s_ename||' '||s_job||' '||s_mgr||' '||s_hrdate||' '||s_sal||' '||s_comm||' '||s_deptno;
             insert into aud_emp values(:new.empno,
                                        :new.ename,
                                        :new.job,
                                        :new.mgr,
                                        :new.hiredate,
                                        :new.sal,
                                        :new.comm,
                                        :new.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'UPDATE',
                                        USER,
                                        str);
         elsif deleting then
             insert into aud_emp values(:old.empno,
                                        :old.ename,
                                        :old.job,
                                        :old.mgr,
                                        :old.hiredate,
                                        :old.sal,
                                        :old.comm,
                                        :old.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'DELETE',
                                        USER,
                                        'Old Records before deletion');
         end if;
    exception
        when others then
          raise_application_error(-20501,'Contact With Your Admin....');
    end;
    Trigger Created.
    Elapsed: 00:00:00.09
    satyaki>ed
    Wrote file afiedt.buf
      1  merge into e_emp o
      2     using emp n
      3     on ( o.empno = n.empno)
      4     when matched then
      5       update set o.ename = n.ename,
      6                  o.job   = n.job,
      7                  o.mgr   = n.mgr,
      8                  o.hiredate = n.hiredate,
      9                  o.sal = n.sal,
    10                  o.comm = n.comm,
    11                  o.deptno = n.deptno
    12     when not matched then
    13       insert( o.empno,
    14               o.ename,
    15               o.job,
    16               o.mgr,
    17               o.hiredate,
    18               o.sal,
    19               o.comm,
    20               o.deptno)
    21       values( n.empno,
    22               n.ename,
    23               n.job,
    24               n.mgr,
    25               n.hiredate,
    26               n.sal,
    27               n.comm,
    28*              n.deptno)
    satyaki>/
    13 rows merged.
    Elapsed: 00:00:03.95
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.07
    satyaki>
    satyaki>
    satyaki>select * from aud_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO AUDIT_TMP                                                                   AUDIT_IP_ADDR   OPR_DESC                       USER_NM                                  REMARKS
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20 31-DEC-08 10.54.06.667000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 3718.75
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10 31-DEC-08 10.54.06.686000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 3062.5
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20 31-DEC-08 10.54.06.687000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7839 KING       PRESIDENT            17-NOV-81       7000                    10 31-DEC-08 10.54.06.697000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 5000
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20 31-DEC-08 10.54.06.698000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20 31-DEC-08 10.54.06.699000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30 31-DEC-08 10.54.06.720000 PM                                                10.23.99.77     INSERT                         SCOTT
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10 31-DEC-08 10.54.07.059000 PM                                                10.23.99.77     INSERT                         SCOTT
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30 31-DEC-08 10.54.07.060000 PM                                                10.23.99.77     INSERT                         SCOTT
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30 31-DEC-08 10.54.07.060000 PM                                                10.23.99.77     INSERT                         SCOTT
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30 31-DEC-08 10.54.07.061000 PM                                                10.23.99.77     INSERT                         SCOTT
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO AUDIT_TMP                                                                   AUDIT_IP_ADDR   OPR_DESC                       USER_NM                                  REMARKS
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10 31-DEC-08 10.54.07.061000 PM                                                10.23.99.77     INSERT                         SCOTT
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30 31-DEC-08 10.54.07.062000 PM                                                10.23.99.77     INSERT                         SCOTT
    13 rows selected.
    Elapsed: 00:00:00.22
    satyaki>
    satyaki>set lin 80Hope this will help you.
    Regards.
    Satyaki De.

  • Use of the "updlock" hint with update and insert statements

    I have inherited some stored procedures and am trying to figure out why the developers decided to use the "updlock" hint on many of the update and insert statements. I have looked around everywhere and have found only one explanation of why "update...with
    (updlock)" can be useful, namely when a table has no clustered index:
    http://www.sqlnotes.info/2012/10/10/update-with-updlock/ I have found nothing yet that mentions why "insert into...with (updlock)" might be used. I understand why the hint
    might be useful on select statements in some cases, but if all of the tables have clustered indexes, is there any good reason to use it on update and insert statements?
    Thanks,
    Ron
    Ron Rice

    This form of deadlock error can occur on a table which has a clustered index.
    If you are doing updates on a table which has a clustered index and that table also has a nonclustered index and the nonclustered index is used to find the row to update you can see this type of deadlock.  For example create a table with a clustered
    primary key index and a nonclustered index by running
    Create Table Foo(PK int primary key identity, OtherKey varchar(10), OtherData int);
    go
    Insert Foo Default Values;
    go 10000
    Update Foo Set OtherKey = 'C' + Cast(PK As varchar(10))
    Create Unique Index FooIdx On Foo(OtherKey);
    That creates a table with 10000 rows, a clustered index and a nonclustered index.  Then run
    Begin Transaction
    Update Foo Set OtherData = 1 Where OtherKey = 'C5'
    That will use the FooIdx index to find the row that needs to be updated.  It will get a U lock on the index row in the FooIdx index, then an X lock on the row in the clustered index, update that row, then free the U lock on FooIdx, but keep the X lock
    on the row in the clustered index.  (There is other locking going on, but to simplify things, I'm only showing the locks that lead to the deadlock).
    Then in another window, run
    Begin Transaction
    Update Foo Set OtherData = 2 Where OtherKey = 'C5'
    This will get a U lock on the index row in the FooIdx index, then try to get an X lock on the row in the clustered index.  But that row is already exclusively locked, so this second window will wait holding a U lock on FooIdx row and is waiting for
    an X lock on the clustered index row.
    Now go back to the first window and run
    Update Foo Set OtherData = 3 Where OtherKey = 'C5'
    This will once again try to get the U lock on the FooIdx row, but it is blocked by the U lock the second window holds.  Of course the second window is blocked by the X lock on the clustered index row and you have a deadlock.
    All that said, I certainly do not routinely code my updates with UPDLOCK.  I try to design databases and write code so that deadlocks will be rare without holding excessive locks.  The more locks you hold and the longer you hold them, the more
    blocking you will get and the slower your system will run.  So I write code that if a deadlock exception occurs, it is properly handled.  Then if too many deadlocks occur, that is the time to go back to the code to see what changes are needed to
    decrease the number of deadlocks (one way to do that may be to get locks earlier and/or hold them longer. 
    But I wouldn't worry much about this form of deadlock.  It is, in my experience, vary rare.  I don't recall ever seeing it in a production environment.
    Tom

  • How to update and insert the records without using Table_comparison and Map_operation?

    How to update and insert the records without using Table_comparison and Map_operation?

    Use either join or MERGE see this Inserting, Updating, and Deleting Data by Using MERGE

  • INSERT or MoDIFY statement

    hi,
    I have to insert a data for my ztable,for 1st time it is updating the data,but for the second time (since all the key fields are same as 1st record),it is going to modify the data in my table.(since i have used modify statement),But i want both the records.
    any idea?

    hi
    MODIFY - Will update the table, if the data already exists, if NOT inserts new rows.
    UPDATE - Will update the table, errors out if the data is not found.
    In case of MODIFY the sy-subrc is always 0 so you would't know whether the data is actually updated or not.
    INSERT - Inserting Data in Database Tables
    Update Modify Insert stmts we use when we want to do some change / Insertion
    (1) to database table from internal table or
    (2) from work area to internal table.
    ( AA ) Update
    If the intended record in the internal table is found in databse table means it will just update that record.
    syntax to update database table from itab:::::
    UPDATE dbtab FROM TABLE itab
    Changes to lines made with the UPDATE command only becomefinal after a database commit
    Without using internal table we can update database table directly as shown below:::::::::::::::::::::
    TABLES SFLIGHT.
    UPDATE SFLIGHT SET SEATSOCC = SEATSOCC + 3
    WHERE CARRID = 'LH' AND
    CONNID = '0400' AND
    FLDATE = '19950228'.
    ( BB ) Modify is used to insert new record if the record doesnt exist in datbase table.system check this on primary key basis.
    If the intended record in the internal table is found in databse table means it will just update that record.So here its equal to UPDATE stmt.
    For changes to database table we use syntax as below ::::
    MODIFY DatabaseTable FROM TABLE itab.
    For changes to Internal table we use syntax as below ::::
    MODIFY itab FROM wa INDEX idx.
    http://TRANSPORTING f1 ... fn WHERE cond.
    ( CC ) Insert stmt is used to insert New records into databse table from internal table or to internal table from work area.
    By default, data is only inserted in the current client. However, ifyou use the CLIENT SPECIFIED addition, you can switch off theautomatic client handling.
    You cannot insert a table line if the table alreadycontains a record with the same primary key.
    Syntax::::::::::
    INSERT INTO dbtab CLIENT SPECIFIED VALUES wa.
    or
    INSERT (dbtabname) CLIENT SPECIFIED FROM TABLE itab.
    Example
    Adding customer "Robinson" to client 002:
    TABLES SCUSTOM.
    SCUSTOM-MANDT = '002'.
    SCUSTOM-ID = '12400177'.
    SCUSTOM-NAME = 'Robinson'.
    SCUSTOM-POSTCODE = '69542'.
    SCUSTOM-CITY = 'Heidelberg'.
    SCUSTOM-CUSTTYPE = 'P'.
    SCUSTOM-DISCOUNT = '003'.
    SCUSTOM-TELEPHONE = '01234/56789'.
    INSERT INTO SCUSTOM CLIENT SPECIFIED VALUES SCUSTOM.
    Re: difference update and insert
    The specified item was not found.
    /message/4622903#4622903 [original link is broken]
    regards,
    Vipul

  • Number of rows inserted is different in bulk insert using select statement

    I am facing a problem in bulk insert using SELECT statement.
    My sql statement is like below.
    strQuery :='INSERT INTO TAB3
    (SELECT t1.c1,t2.c2
    FROM TAB1 t1, TAB2 t2
    WHERE t1.c1 = t2.c1
    AND t1.c3 between 10 and 15 AND)' ....... some other conditions.
    EXECUTE IMMEDIATE strQuery ;
    These SQL statements are inside a procedure. And this procedure is called from C#.
    The number of rows returned by the "SELECT" query is 70.
    On the very first time call of this procedure, the number rows inserted using strQuery is *70*.
    But in the next time call (in the same transaction) of the procedure, the number rows inserted is only *50*.
    And further if we are repeating calling this procedure, it will insert sometimes 70 or 50 etc. It is showing some inconsistency.
    On my initial analysis it is found that, the default optimizer is "ALL_ROWS". When i changed the optimizer mode to "rule", this issue is not coming.
    Anybody faced these kind of issues?
    Can anyone tell what would be the reason of this issue..? any other work around for this...?
    I am using Oracle 10g R2 version.
    Edited by: user13339527 on Jun 29, 2010 3:55 AM
    Edited by: user13339527 on Jun 29, 2010 3:56 AM

    You have very likely concurrent transactions on the database:
    >
    By default, Oracle Database permits concurrently running transactions to modify, add, or delete rows in the same table, and in the same data block. Changes made by one transaction are not seen by another concurrent transaction until the transaction that made the changes commits.
    >
    If you want to make sure that the same query always retrieves the same rows in a given transaction you need to use transaction isolation level serializable instead of read committed which is the default in Oracle.
    Please read http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_sqlproc.htm#ADFNS00204.
    You can try to run your test with:
    set  transaction isolation level  serializable;If the problem is not solved, you need to search possible Oracle bugs on My Oracle Support with keywords
    like:
    wrong results 10.2Edited by: P. Forstmann on 29 juin 2010 13:46

  • Update and insert in to table

    Hi All,
    I am uploading data from a txt file into itab_infile and wants to update the table Zppprice based on itab_infile. It the record is existing it has to update and when it is a new record it has to insert the record. And I need to capture how many records havebeen updated and inserted.
    Please help me.
    Thanks,
    Veni.
    REPORT ZSD_PRICEPROTEC NO STANDARD PAGE HEADING
           LINE-SIZE 132
           LINE-COUNT 60.
    TABLES: KNA1,ZPPPRICE.
    TYPES: BEGIN OF type_infile,
             KUNNR(10) TYPE c,  "Customer Number
             MATNR(18) TYPE c,  "Material Number
             CRDATE(10) TYPE c,  "Creation Date
             EFDATE(10) TYPE c,  "Effective date
             SPRICE(15) TYPE c,  "Old Price
             EPRICE(15) TYPE c,  "New Price
             EOHQTY(09) TYPE c,  "Estimated Quantity
             AOHQTY(09) TYPE c.  "Actual Quantity
          TYPES: END OF type_infile.
    * Internal tables
    DATA: itab_infile TYPE STANDARD TABLE OF type_infile with header line.
    * Work areas
    DATA: wa_infile TYPE type_infile.
    * Global variables.
    DATA:  gc_tcode  LIKE sy-tcode VALUE 'VA01'. "Transaction code
    SELECTION-SCREEN BEGIN OF BLOCK one WITH FRAME TITLE text-001.
    PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK one.
    START-OF-SELECTION.
      PERFORM upload_text_file.
    *&      Form  UPLOAD_TEXT_FILE
    FORM upload_text_file.
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                filename                = p_file
                filetype                = 'DAT'
           TABLES
                data_tab                = itab_infile
           EXCEPTIONS
                conversion_error        = 1
                file_open_error         = 2
                file_read_error         = 3
                invalid_type            = 4
                no_batch                = 5
                unknown_error           = 6
                invalid_table_width     = 7
                gui_refuse_filetransfer = 8
                customer_error          = 9
                OTHERS                  = 10.
      IF sy-subrc <> 0.
        MESSAGE e208(00) WITH 'Error in loading text file'.
      ENDIF.
    ENDFORM.                    " UPLOAD_TEXT_FILE

    Hi Veni,
    Simple thing ,you can use MODIFY Command,it works both insert as well update.
    check the documentation.
    see the below program and i am getting data from XLS file and i am updating to Ztable( same as ur case ).
    Program    : ZLWMI151_UPLOAD(Data load to ZBATCH_CROSS_REF Table)
    Type       : Upload program
    Author     : Seshu Maramreddy
    Date       : 05/16/2005
    Transport  : DV3K919574
    Transaction: None
    Description: This program will get the data from XLS File
                 and it upload to ZBATCH_CROSS_REF Table
    REPORT ZLWMI151_UPLOAD no standard page heading
                           line-size 100 line-count 60.
    *tables : zbatch_cross_ref.
    data : begin of t_text occurs 0,
           werks(4) type c,
           cmatnr(15) type c,
           srlno(12) type n,
           matnr(7) type n,
           charg(10) type n,
           end of t_text.
    data: begin of t_zbatch occurs 0,
          werks like zbatch_cross_ref-werks,
          cmatnr like zbatch_cross_ref-cmatnr,
          srlno like zbatch_cross_ref-srlno,
          matnr like zbatch_cross_ref-matnr,
          charg like zbatch_cross_ref-charg,
          end of t_zbatch.
    data : g_repid like sy-repid,
           g_line like sy-index,
           g_line1 like sy-index,
           $v_start_col         type i value '1',
           $v_start_row         type i value '2',
           $v_end_col           type i value '256',
           $v_end_row           type i value '65536',
           gd_currentrow type i.
    data: itab like alsmex_tabline occurs 0 with header line.
    data : t_final like zbatch_cross_ref occurs 0 with header line.
    selection-screen : begin of block blk with frame title text.
    parameters : p_file like rlgrap-filename obligatory.
    selection-screen : end of block blk.
    initialization.
      g_repid = sy-repid.
    at selection-screen on value-request for p_file.
      CALL FUNCTION 'F4_FILENAME'
           EXPORTING
                PROGRAM_NAME = g_repid
           IMPORTING
                FILE_NAME    = p_file.
    start-of-selection.
    Uploading the data into Internal Table
      perform upload_data.
      perform modify_table.
    top-of-page.
      CALL FUNCTION 'Z_HEADER'
      EXPORTING
        FLEX_TEXT1       =
        FLEX_TEXT2       =
        FLEX_TEXT3       =
    *&      Form  upload_data
          text
    FORM upload_data.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                FILENAME                = p_file
                I_BEGIN_COL             = $v_start_col
                I_BEGIN_ROW             = $v_start_row
                I_END_COL               = $v_end_col
                I_END_ROW               = $v_end_row
           TABLES
                INTERN                  = itab
           EXCEPTIONS
                INCONSISTENT_PARAMETERS = 1
                UPLOAD_OLE              = 2
                OTHERS                  = 3.
      IF SY-SUBRC <> 0.
        write:/10 'File '.
      ENDIF.
      if sy-subrc eq 0.
        read table itab index 1.
        gd_currentrow = itab-row.
        loop at itab.
          if itab-row ne gd_currentrow.
            append t_text.
            clear t_text.
            gd_currentrow = itab-row.
          endif.
          case itab-col.
            when '0001'.
              t_text-werks = itab-value.
            when '0002'.
              t_text-cmatnr = itab-value.
            when '0003'.
              t_text-srlno = itab-value.
            when '0004'.
              t_text-matnr = itab-value.
            when '0005'.
              t_text-charg = itab-value.
          endcase.
        endloop.
      endif.
      append t_text.
    ENDFORM.                    " upload_data
    *&      Form  modify_table
          Modify the table ZBATCH_CROSS_REF
    FORM modify_table.
      loop at t_text.
        t_final-werks = t_text-werks.
        t_final-cmatnr = t_text-cmatnr.
        t_final-srlno = t_text-srlno.
        t_final-matnr = t_text-matnr.
        t_final-charg = t_text-charg.
        t_final-erdat = sy-datum.
        t_final-erzet = sy-uzeit.
        t_final-ernam = sy-uname.
        t_final-rstat = 'U'.
        append t_final.
        clear t_final.
      endloop.
      delete t_final where werks = ''.
      describe table t_final lines g_line.
      sort t_final by werks cmatnr srlno.
    Deleting the Duplicate Records
      perform select_data.
      describe table t_final lines g_line1.
      modify zbatch_cross_ref from table t_final.
      if sy-subrc ne 0.
        write:/ 'Updation failed'.
      else.
        Skip 1.
        Write:/12 'Updation has been Completed Sucessfully'.
        skip 1.
        Write:/12 'Records in file ',42 g_line .
        write:/12 'Updated records in Table',42 g_line1.
      endif.
      delete from zbatch_cross_ref where werks = ''.
    ENDFORM.                    " modify_table
    *&      Form  select_data
          Deleting the duplicate records
    FORM select_data.
      select werks
             cmatnr
             srlno from zbatch_cross_ref
             into table t_zbatch for all entries in t_final
             where werks = t_final-werks
             and  cmatnr = t_final-cmatnr
             and srlno = t_final-srlno.
      sort t_zbatch by werks cmatnr srlno.
      loop at t_zbatch.
        read table t_final with key werks = t_zbatch-werks
                                    cmatnr = t_zbatch-cmatnr
                                    srlno = t_zbatch-srlno.
        if sy-subrc eq 0.
          delete table t_final .
        endif.
        clear: t_zbatch,
               t_final.
      endloop.
    ENDFORM.                    " select_data
    Thanks
    Seshu

  • Difference update and insert

    what is the difference between update and insert in the case of database tables?  what does update do  and what does insert do?

    Hi,
    Insert Functionality,
    Inserts new lines in a database table.By default, data is only inserted in the current client. Data can only be inserted using a view if the view refers to a single table and was defined in the ABAP Dictionary with the maintenance status "No restriction".
    Update Functionality,
    Updates values in a database table. Normally, lines are updated only in the current client.
    INSERT & UPDATE belongs to the Open SQL command set.
    Thanks
    Nimesh S. Patel

  • Can I recover notes I accidentally erased from my iPhone? I have the newest software and updates and I use iCloud.

    Can I recover notes I accidentally erased from my iPhone? I have the newest software and updates and I use iCloud.

    Is your carrier still AT&T? What error message do you get when you try to activate it?
    Have you tried a new SIM? Was the phone jailbroken? Was the computer you used to update it ever used to jailbreak a phone? In general, this problem is caused by one of the following:
    1. Your antivirus is blocking access to gs.apple.com.
    2. Your phone is jailbroken.
    3. Your computer has been used at some time in the past to jaibreak some iOS device (not necessarily the phone with the problem), and its network database was corrupted by the hacking software that was used.
    4. Apple's activation servers are down (very rare, and never for more than an hour or so).
    For 1. try disabling your antivirus.
    For 2. & 3. you need to go somewhere other than an apple forum for help. Although you can try deleting lines containing gs.apple.com from your "hosts" file on your computer.

  • Problem in using modify statement inside a Perform

    Hi Experts,
    loop at t_data into wa_data.
    IF wa_data1-zbukrs IS INITIAL.
            wa_data1-zstat = 'E'.
            w_messg =  'Company code is blank in upload data'.
            CONCATENATE wa_data1-zbukrs w_messg INTO w_msg
              SEPARATED BY space.
              CONCATENATE w_msg  wa_data1-zmsg INTO w_msg
    SEPARATED BY
    '|'.
              wa_data1-zmsg = w_msg.
              MODIFY t_data1 FROM wa_data1.
    endif.
    IF wa_data1-zfwcd IS INITIAL.
             wa_data1-zstat = 'E'.
             w_messg =  'Forwarder code is blank in upload data'.
            CONCATENATE wa_data1-zfwcd w_messg INTO w_msg
              SEPARATED BY space.
              CONCATENATE w_msg  wa_data1-zmsg INTO w_msg
    SEPARATED BY
    '|'.
              wa_data1-zmsg = w_msg.
              MODIFY t_data1 FROM wa_data1.
    endif.
    IF wa_data1-zinvno IS INITIAL.
              wa_data1-zmsg = w_msg.
              MODIFY t_data1 FROM wa_data1.
       wa_data1-zstat = 'E'.
             w_messg =  'Invoice number is blank in upload data'.
            CONCATENATE wa_data1-zinvno w_messg INTO w_msg
              SEPARATED BY space.
              CONCATENATE w_msg  wa_data1-zmsg INTO w_msg
    SEPARATED BY
    '|'.
              wa_data1-zmsg = w_msg.
              MODIFY t_data1 FROM wa_data1.
    endif.
    endloop.
    My doubt is:
            wa_data1-zstat = 'E'.
            w_messg =  'Company code is blank in upload data'.
            CONCATENATE wa_data1-zbukrs w_messg INTO w_msg
              SEPARATED BY space.
              CONCATENATE w_msg  wa_data1-zmsg INTO w_msg
    SEPARATED BY
    '|'.
              wa_data1-zmsg = w_msg.
              MODIFY t_data1 FROM wa_data1.
    i want write the above code to be written in a perform statement
    becos iam using the above code in multiple places in my program.
    but the problem iam facing is modify not working in perform statement.
    Regards,
    Raj.

    hi Raj,
       use FIELD-SYMBOLS so that you don't have to use MODIFY statement.
    FIELD-SYMBOLS: <fs> like line of T_data.
    loop at t_data ASSIGNING <fs>.
    IF  <fs>-zbukrs IS INITIAL.
    <fs>-zstat = 'E'.
    w_messg = 'Company code is blank in upload data'.
    CONCATENATE <fs>-zbukrs w_messg INTO w_msg
    SEPARATED BY space.
    CONCATENATE w_msg <fs>-zmsg INTO w_msg
    SEPARATED BY   '|'.
    <fs>-zmsg = w_msg.
    endif.
    IF <fs>-zfwcd IS INITIAL.
    <fs>-zstat = 'E'.
    w_messg = 'Forwarder code is blank in upload data'.
    CONCATENATE <fs>-zfwcd w_messg INTO w_msg
    SEPARATED BY space.
    CONCATENATE w_msg <fs>-zmsg INTO w_msg
    SEPARATED BY '|'.
    <fs>-zmsg = w_msg.
    endif.
    endloop.

  • Moving 9.2.0.6 database files and redologs using dd command.

    Hi at all,
    I need to know if someone have take a cold copy of database (datafile and redologs) using dd unix command.
    The trouble is related to the value to assign to "bs" during dd.
    For datafile I know it has to do the same of block_size of tablespace. I'm not sure about the value to assign to "bs" for redologs.
    Any suggestions are appreciated.
    thank you in advance
    Adriano
    Ps. I'm moving the raw partitions of database files and redologs from HP-UX RISC 11.11 on SYMM8830 to HP-IA64 using lvm on HP XP24000 with veritas.
    Edited by: adriano.ba on Oct 17, 2008 12:23 PM

    Why copy the redo logs ? You would be shutting down the database before you run the "dd" to copy out datafiles. With a proper shutdown, if you copy datafiles after the shutdown, you don't need the redo logs.
    Recreate redo logs at the target location.
    You'd have to "simulate" an incomplete Recovery using "RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL " followed by "ALTER DATABASE OPEN RESETLOGS" so that Oracle allows you to do the RESETLOGS.
    Or Recreate the ControlFile with a RESETLOGS in the CREATE CONTROLFILE.

  • Mutilple updations and insertions by BAPI_SALESORDER_CHANGE at one time

    Hi ,
    I just want to know whether it is possible to insert and update multiple line items in a sales order through the BAPI BAPI_SALESORDER_CHANGE .
    we tried doin it for single record ( update and insert ) , it is working fine . but when we try for mutiple items , it gives a system dump.
    could you plz help out , how to pass the parameters for mutiple updation and insertions at a time?

    HI ALL,
    I THINK IF WE MAKE THE SCHEDULE LINE ITEM NO. TO BE UNIQUE FOR EACH LINE ITEM IT GETS UPLOADED PROPERLY. THE VBEP-ETENR IS 001 ONLY. PEOPLE WITH ALTERNAT ANSWERS PLZ. CORRECT.
    SEE CODES BELOW.
    **This creates additional line no. in the sales order.
    **Material no is hard coded, you need to change the materisl no in
    **available in ur system.
    T_ITEM-itm_number = ''.
    T_ITEM-material = 'AGA350'.
    T_ITEM-target_qty = '2'.
    APPEND T_ITEM.
    T_ITEMx-itm_number = ''.
    T_ITEMX-UPDATEFLAG = 'I'.
    T_ITEMX-target_qty = 'X'.
    T_ITEMX-material = 'X'.
    APPEND T_ITEMX.
    T_SCHE-SCHED_LINE = '1'.
    T_SCHE-REQ_QTY = 2.
    t_sche-req_date = '20080204'.
    APPEND T_SCHE.
    T_SCHEX-updateflag =  c_insertflag.
    t_schex-req_date = 'X'.
    T_SCHEX-SCHED_LINE = '1'.
    t_schex-req_qty = 'X'.
    APPEND T_SCHEX.
    **This also creates additional line no. in the sales order.
    **Material no is hard coded, you need to change the materisl no in
    **available in ur system.
    *T_ITEM-itm_number = ''.
    T_ITEM-material = 'AGA350'.
    T_ITEM-target_qty = '1'.
    APPEND T_ITEM.
    *T_ITEMx-itm_number = ''.
    T_ITEMX-UPDATEFLAG = 'I'.
    T_ITEMX-target_qty = 'X'.
    T_ITEMX-material = 'X'.
    APPEND T_ITEMX.
    T_SCHE-SCHED_LINE = '4'.
    t_sche-req_date = '20080202'.
    T_SCHE-REQ_QTY = 1.
    APPEND T_SCHE.
    T_SCHEX-updateflag =  c_insertflag.
    t_schex-req_date = 'X'.
    T_SCHEX-ITM_NUMBER = 'X'.
    T_SCHEX-SCHED_LINE = '4'.
    T_SCHEX-REQ_QTY = 'X'.
    APPEND T_SCHEX.
    **This also creates additional line no. in the sales order.
    **Material no is hard coded, you need to change the materisl no in
    **available in ur system.
    *T_ITEM-itm_number = ''.
    T_ITEM-material = 'AGA350'.
    T_ITEM-target_qty = '1'.
    APPEND T_ITEM.
    *T_ITEMx-itm_number = ''.
    T_ITEMX-UPDATEFLAG = 'I'.
    T_ITEMX-target_qty = 'X'.
    T_ITEMX-material = 'X'.
    APPEND T_ITEMX.
    T_SCHE-SCHED_LINE = '5'.
    t_sche-req_date = '20080202'.
    T_SCHE-REQ_QTY = 1.
    APPEND T_SCHE.
    T_SCHEX-updateflag =  c_insertflag.
    t_schex-req_date = 'X'.
    T_SCHEX-ITM_NUMBER = 'X'.
    T_SCHEX-SCHED_LINE = '5'.
    T_SCHEX-REQ_QTY = 'X'.
    APPEND T_SCHEX.
    **This also creates additional line no. in the sales order.
    **Material no is hard coded, you need to change the materisl no in
    **available in ur system.
    *T_ITEM-itm_number = ''.
    T_ITEM-material = 'AGA350'.
    T_ITEM-target_qty = '1'.
    APPEND T_ITEM.
    *T_ITEMx-itm_number = ''.
    T_ITEMX-UPDATEFLAG = 'I'.
    T_ITEMX-target_qty = 'X'.
    T_ITEMX-material = 'X'.
    APPEND T_ITEMX.
    T_SCHE-SCHED_LINE = '6'.
    t_sche-req_date = '20080202'.
    T_SCHE-REQ_QTY = 1.
    APPEND T_SCHE.
    T_SCHEX-updateflag =  c_insertflag.
    t_schex-req_date = 'X'.
    T_SCHEX-ITM_NUMBER = 'X'.
    T_SCHEX-SCHED_LINE = '6'.
    T_SCHEX-REQ_QTY = 'X'.
    APPEND T_SCHEX.
    *i_order_header_in-sd_doc_cat

  • Possible to update and insert in a table at a same time

    Hi friends,
    I have a table with six columns in it.
    Initially that table will have seven rows with six columns, but all the columns wont have a content in it. But only one column will have the content of seven rows. so that's why initially it will have seven rows.
    Assume that first column consist of the following seven content each in a row(so seven row)
    *)A
    *)B
    *)C
    *)D
    *)E
    *)F
    *)G
    So what i need to do is set DML operation such that for the existing seven rows which is in the table i need to update the value of the remaining six column and at the same time i need to insert all the seven rows of only the first column in the next seven rows.
    Whether it is possible to do it.
    How to achieve it friends,
    Thanks
    Regards,
    Mini

    Hi,
    It should be like
    Initially my table would be like the below
    *questions            StronglyAgree              DA               AG          suggestions*
    what is ur name?          
    what is ur age?                                 
    which is ur pet?                                    My DML operation should be like it should update and insert
    Update in the sense, it should be like
    *questions            StronglyAgree              DA               AG                    suggestions*
    what is ur name?              y                                                                my name
    what is ur age?                                        y                                        my age
    which is ur pet?                                                         y                       my petSoon after that insert should be like
    *questions            StronglyAgree              Disagree             Agree                    suggestions*
    what is ur name?              y                                                                          my name
    what is ur age?                                          y                                                 my age
    which is ur pet?                                                                y                          my pet
    what is ur name?
    what is ur age?
    which is ur pet?It should be like the above..
    All izz well
    GTA
    Edited by: GTA on Jun 13, 2011 6:43 AM
    Edited by: GTA on Jun 13, 2011 6:43 AM

  • How to replace the update staement with a modify statement

    how to convert this update stat to a modify stat?
    Message was edited by:
            Ashwin A

    Hi
    MODIFY <DB TABLE> FROM <INTERNAL TABLE>
    To insert or change a single line in a database table, use the following:
    MODIFY <target> FROM <wa> .
    The contents of the work area <wa> are written to the database table <dbtab>. The work area <wa> must be a data object with at least the same length and alignment as the line structure of the database table. The data is placed in the database table according to the line structure of the table, and regardless of the structure of the work area. It is a good idea to define the work area with reference to the structure of the database table.
    If the database table does not already contain a line with the same primary key as specified in the work area, a new line is inserted. If the database table does already contain a line with the same primary key as specified in the work area, the existing line is overwritten. SY-SUBRC is always set to 0.
    A shortened form of the above statement is:
    MODIFY <dbtab>.
    In this case, the contents of the table work area <dbtab> are inserted into the database table with the same name. You must declare this table work area using the TABLES statement. In this case, it is not possible to specify the name of the database table dynamically. Table work areas with the same name as the database table (necessary before Release 4.0) should no longer be used for the sake of clarity.
    Reward points if useful
    Regards
    Anji

Maybe you are looking for

  • MacBook White Built-in iSight Camera stuck on after 10.7.3 upgrade but not producing video

    I upgraded today the OS of my iMac and MacBook from Lion 10.7.2 to 10.7.3. The iMac is fine but the MacBook is always having the iSight camera on (light is constantly green.) But no video is produced in Skype, FaceTime, and iChat. I rebooted several

  • Where can I download Adobe Acrobat X Pro?

    I am moving from a dying laptop to a new desktop. I have a license for Adobe Acrobat X Pro but can only find the download link for XI.

  • Hp 2540 air print

    Just got an iPad Air plus a 2540 deskjet because it supports Airprint. However.. the pad cannot see the printer. The PC prints wirelessly, the Mac prints to an IP address but no tablet printing. The support for Air print on the support site is non-ex

  • Missing driver for TestSTand - Agilent 34401

    Hi, I looked up in your driver library for a  Agilent 34401 and I did not find anything for TEstStand. All drivers were either for LabWindows or LabView. Can I use them for teststand as well or it must be explicit that it is designed for TestStand? t

  • Problem mit JPA Diagram Editor

    Mein Eclipse JPA Diagram Editor bringt seit kurzem eine Fehlermeldung: Failed to create the part's controls Ich habe schon verschiedene Dinge ausprobiert - Projekt neu aufsetzen - Diagram Editor deinstallieren und installieren - Alles leider ohne Erf