Data updates as inserts

Hi,
I have a DB table and I am showing the details from the table in the UI to the user.
The users can edit the details, add new rows and upon saving, all these records in the UI should go as new records into the table and should not update the existing records.
Is this can be implemented using the EO-VO or should go for JDBC DML operations ??
Thanks,
SenthilKumar J

Senthil,
This is a standard approach usually in this scenario, what you described!
Move ahead with this approach only!
--Mukul                                                                                                                                                                                                                                                                                               

Similar Messages

  • Creating process for multiple Date fields for update or insert in APEX

    hello there,
    could someone please help me?
    i have a form on Apex based on view that is based on three tables and updating and inserting ok using trigger instead of.
    i have a problem now as in my form i have around 75 fileds (items) incuding 30 or more date fields which could be populated or left blank or update later.
    so for each date field i have two boxs; one for date, input as dd/mm/yyyy (text field) and second for time, input as 23:45. All dates will be insert or update manually by user. so as i mentioned not all date fields could be poulated at one stage.
    so i have created some process and validations and all of them work fine but i came accross if date left blank then (:) giving me problem so i have done following further process for each date field. In real table all the date fields have data type date.
    declare
    v_my_var date; -- for first date field
    str_dy VARCHAR2(10);
    dt_indx date;
    str_tm VARCHAR2(20);
    tm_indx date;
    begin
    str_dy := :p4_first_date
    str_tm := str_dy||' '||substr(:p8_first_date_hh,1,2)||':'||substr(:p8_first_date_HH,4,2);
    dt_indx := to_date(str_tm,'DD/MM/YYYY HH24:MI');
    IF str_dy is not null then
    v_my_var :=dt_indx;
    ELSE
    v_my_var := NULL;
    END IF;
    update table 1 set my_date = v_my_var where d_id= :p4_d_id;
    end;
    above code work fine but one date field of course therefore i have to do same code for each date field with changes and initialise variable again and again for each field.
    so i like to ask is there any easy way that is more professional. i was thinking about the procedure and using collection or similar but honestly not much experience on that so could some one please help me?
    I will be very thankful.
    KRgds

    Hi,
    You can do the needful by re-using the code if you can give the item names as P8_DATE1, P8_DATE_hh1, P8_DATE2, P8_DATEhh2 etc..So your item name just differs by a sequence.
    Now you write function which will return desired date value taking above items as input. Pass item names to this function, get session state using APEX_UTIL.GET_SESSION_STATE('item_name') API.
    Now modify you code as
    FOR i IN 1..30
    LOOP
    v_date_array[i] = f_get_date('P8_DATE'||i, 'P8_DATEhh'||i);
    END LOOP;
    ....Now you have all date valus in array. Just write one update as follows
    UPDATE  TABLE1
    SET date1 = my_date_array[1], date2 = my_date_array[2]..
    WHERE ....Hope it helps :)
    Cheers,
    Hari

  • I want to use the SQL query IF EXIST to update or insert data in a ms access table, but it doesn´t work

    Hi,
    I want to use the SQL query IF EXIST to update or insert data in a ms access table, but it doesn´t work
    (fault number -2147217900)
    I want to search for a value in a ms access table , if it exist i want to update it, if not i want to insert a new row.
    Working with LabView 7.1, database con. toolset.
    Who can HELP?
    Thanks a lot
    Marco

    Hello,
    I think that If exist is not a standar SQL command (I know it exists I think in Oracle and SQL server), MS access doesn't support it, so I think the best way to do it is first make a Select and then either an Update or an insert, sorry...
    Paulo

  • FM to update or insert  master data?

    Hi Brothers,
    I am looking for a FM that updates or inserts master data by a given structure.
    I mean something like that:
    DATA: table_to_update TYPE some_table.
    LOOP thru table INTO structure.
    CALL METHOD fm_i_am_looking_for
    EXPORTING
    infoobject_name = 'my_io'
    struc_to_update = structure.
    ENDLOOP.
    FM should then update the values in structure
    Thanks, Johannes

    Hi,
    for updating attributes you can also use FM RSNDI_MD_ATTRIBUTES_UPDATE.
    check: http://help.sap.com/saphelp_nw2004s/helpdata/en/44/bd9b2916fd08cfe10000000a155369/content.htm
    excample call:
    Re: Adding Master data Via ABAP

  • Creation of a Single button for both Update and Insert

    Hi,
    I want to create a button which performs both Insert and Update function. As of now i have 2 seperate buttons. Can I combine them in to one by writing a procedure which checks for the data in the database...If the record exists, then it should update the record, if not it should insert...Please guide me
    Regards,
    Pa

    Hi,
    If I am inserting in to the table a new record, how do I check for that column in the table...
    It should work this way..
    I have a list of users in a page, if I click on any user name, it will redirect me to another screen which will allow me to create a record for the selected user name. I want to check the selected user name in the table. If it is already existing then need to update, else insert.
    Regards,
    Pa

  • Using an on update or insert trigger on a SAP table

    Hi all,
    A question for you regarding using a database trigger in and SAP system. 
    We are needing to export data for our datawarehouse.  Currently we export all the data.  That data is getting quite large tho and time is becoming an issue.
    One suggestion has been to add a custome field to an existing SAP table to hold a flag to indicate the record has changed but not been extracted.  Thenput a trigger on the table in question so that the new field is updated upon update or insert of the record.  Then when the extract runs, it will only extract those records with the flag set, then reset the flag.
    we are using ERP 6 and SQL Server 2005 (or soon to as we will be upgrading next month).
    Any suggestions regarding triggers?  Or other options for flagging changed records in large table so we don't have to extract all records every time?
    Thanks
    Laurie
    Edited by: Laurie McGinley on Oct 27, 2008 10:51 PM

    Hi Laurie,
    just really shouldn't consider to put triggers into your application.
    The problem here is the very nature of triggers to do things 'in the background'.
    If you have problems due to the trigger, you won't see it anywhere in the SAP environment.
    In a while you probably forget about the trigger at all and then nobody can see, what is happening to the database, just because something is changed "in the background".
    Besides that you don't get support for this from SAP, you will make your life a lot harder.
    Tabledefinitions may change - your trigger might break.
    Put application logic where it belongs - to the application layer!
    regards,
    Lars

  • 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

  • How to use the mirrored and log shipped secondary database for update or insert operations

    Hi,
    I am doing a DR Test where I need to test the mirrored and log shipped secondary database but without stopping the mirroring or log shipping procedures. Is there a way to get the data out of mirrored and log shipped database to another database for update
    or insert operations?
    Database snapshot can be used only for mirrored database but updates cannot be done. Also the secondary database of log shipping cannot used for database snapshot. Any ideas of how this can be implemented?
    Thanks,
    Preetha

    Hmm in this case I think you need Merge Replication otherwise it breaks down the purpose of DR...again in that case.. 
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • 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

  • Make Item of Data Entry Form Insert Only, Non Updateable

    Hi,
    Can someone please tell me how to make an item on a data entry form insert only and not updateable. The user can enter the text item in insert mode but cannot update the text item in update mode. This was really simple in Oracle Forms, hoping it is as simple in APEX.
    Thanks

    I think that's too much of the wrong information.
    It sounds like you have multiple forms. Are they Modal or Non-Modal?
    What code do you use to call the form that's not working?
    Does it work initially and then stop working?
    James.

  • Whats the alternative to sqlldr because I want to add (update) not insert..

    mornin gurus..
    As title asks, Ive just sussed that SQLLDR just inserts into an empty table, but I need to update AND Insert..
    I'll be running the code/command from a UNIX script. But just to get me started - how do I do this..?
    I'll be calling a file, then asking each record in the data file specified to either update or insert into an ORACLE table..
    If you need any more info just let me know..
    cheers
    E

    ahh! Append -great stuff thanks..
    Don't suppose I could be cheeky as to ask why its now failing though ()Its been soo long since Ive used ctl files....
    error message I'm getting is..
    Record 1: Rejected - Error on table SU_EMP_AUDIT.
    ORA-00001: unique constraint (APPS.SYS_C00555887) violated
    Record 2: Rejected - Error on table SU_EMP_AUDIT.
    ORA-00001: unique constraint (APPS.SYS_C00555887) violated..I'm guesing its something I need to add to the ctl file that allos the datafile to have either '0's or null values..
    data file looks like..
    0022150,Young,Valerie,Valerie,0,0,20100913,,FAC202,Domestic Assistant,27.03,FACI,FACR,SUPP,T4,0,0,0,0,0,0,0,0,,Mrs,PT,PT,New
    0022151,Keen,Roxanne,Roxanne,0,0,20100913,,FAC202,Domestic Assistant,27.03,FACI,FACR,SUPP,T4,0,0,0,0,0,0,0,0,,Miss,PT,PT,New..and ctl file looks like..
    -- Load data control file. External data file, variable length, delimited.
    LOAD DATA
    APPEND
    INTO TABLE SU_EMP_AUDIT
    FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
       staff_member
    ,surname
    ,forename
    ,preferred_name
    ,email_id
    ,email_address
    ,start_date DATE "YYYYMMDD" NULLIF (start_date=BLANKS)
    ,end_date  DATE  "YYYYMMDD" NULLIF (end_date=BLANKS)
    ,posishun
    ,job_title
    ,FTE
    ,fac_service
    ,area 
    ,gruup 
    ,LOCATIONs 
    ,mpoposit 
    ,mpopstart 
    ,mpopend 
    ,mpo_fte 
    ,mpo_fac 
    ,mpo_dept 
    ,mpo_group 
    ,mpo_loc 
    ,termin_date  DATE  "YYYYMMDD" NULLIF (end_date=BLANKS)
    ,title  
    ,ft_pt 
    ,cp_mode 
    ,new_status   
    {code}
    {code}
       Column Name                  Position   Len  Term Encl Datatype
    STAFF_MEMBER                        FIRST     *   ,  O(") CHARACTER
    SURNAME                              NEXT     *   ,  O(") CHARACTER
    FORENAME                             NEXT     *   ,  O(") CHARACTER
    PREFERRED_NAME                       NEXT     *   ,  O(") CHARACTER
    EMAIL_ID                             NEXT     *   ,  O(") CHARACTER
    EMAIL_ADDRESS                        NEXT     *   ,  O(") CHARACTER
    START_DATE                           NEXT     *   ,  O(") DATE YYYYMMDD
    END_DATE                             NEXT     *   ,  O(") DATE YYYYMMDD
    POSISHUN                             NEXT     *   ,  O(") CHARACTER
    JOB_TITLE                            NEXT     *   ,  O(") CHARACTER
    FTE                                  NEXT     *   ,  O(") CHARACTER
    FAC_SERVICE                          NEXT     *   ,  O(") CHARACTER
    AREA                                 NEXT     *   ,  O(") CHARACTER
    GRUUP                                NEXT     *   ,  O(") CHARACTER
    LOCATIONS                            NEXT     *   ,  O(") CHARACTER
    MPOPOSIT                             NEXT     *   ,  O(") CHARACTER
    MPOPSTART                            NEXT     *   ,  O(") CHARACTER
    MPOPEND                              NEXT     *   ,  O(") CHARACTER
    MPO_FTE                              NEXT     *   ,  O(") CHARACTER
    MPO_FAC                              NEXT     *   ,  O(") CHARACTER
    MPO_DEPT                             NEXT     *   ,  O(") CHARACTER
    MPO_GROUP                            NEXT     *   ,  O(") CHARACTER
    MPO_LOC                              NEXT     *   ,  O(") CHARACTER
    TERMIN_DATE                          NEXT     *   ,  O(") DATE YYYYMMDD
    TITLE                                NEXT     *   ,  O(") CHARACTER
    FT_PT                                NEXT     *   ,  O(") CHARACTER
    CP_MODE                              NEXT     *   ,  O(") CHARACTER
    NEW_STATUS                           NEXT     *   ,  O(") CHARACTER
    Column START_DATE is NULL if START_DATE = BLANKS
    Column END_DATE is NULL if END_DATE = BLANKS
    Column TERMIN_DATE is NULL if END_DATE = BLANKS
    {code}
    Thanks for looking..
    E                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

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

  • Dynamical Call of ALV - No data update

    Hi,
    I tried to use use the ALV dynamically. With dynamically I mean that I that I have diffrent data structures, depending what was selected by the user. The first call of the program is always correct. The data is displayed correctly. But when the data structure is changing, the ALV display is not updated.  For a better understanding I post a extract of my coding:
    <b>1. Creation of Container</b>
    CREATE OBJECT g_custom_container
        EXPORTING              
          container_name              = 'PARENT_CONT'
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5.
      IF sy-subrc <> 0.
        ASSERT 1 = 2.
      ENDIF.
    <b>2.Creation of splitter container</b>
      CREATE OBJECT splitter
         EXPORTING
           parent            = g_custom_container
           rows              = 2
           columns           = 2
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
        ASSERT 1 = 2.
      ENDIF.
    container_2 = splitter->get_container(
                                row       = 1
                                column    = 2 ).
    <b>3.Dynamic Creation of alv object</b>
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = container_2.
    <b>4. Get Fieldcatalogue</b>
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = lv_structure_name
        CHANGING
          ct_fieldcat            = lt_fieldcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF sy-subrc <> 0.
        ASSERT 1 = 2.
      ENDIF.
    <b>5. Set table for first display</b>
      CALL METHOD go_grid->set_table_for_first_display
    *    EXPORTING
    *      i_structure_name = lv_structure_name
        CHANGING
          it_fieldcatalog  = lt_fieldcat
          it_outtab        = <lt_out_data>.
      CALL METHOD ls_alv_ref-alv_ref->refresh_table_display.
      CALL METHOD cl_gui_cfw=>flush.
    Perhaps someone could help.....
    Best Regards, Edgar

    Hello Edgar
    The following sample report <b>ZUS_SDN_TWO_ALV_GRIDS_8</b> shows how to solve your problem. Please note that for the sake of simplicity I replaced the tree containing the structure names with an ALV list. However, the switch between the different structures is triggered by the <b>DOUBLE_CLICK</b> event.
    I like to add that the integration of the first displayed ALV list (DD02L) into GT_OUTTAB is not really elegant. In addition, with <b>$TMP</b> I marked a problematic part of the coding with respect to your requirement to have the right layout for each displayed ALV list:
    If you have a <b>fixed </b>assignment of <i>tabname -> 4-digit handle</i> then it is ok. I my sample report the layouts only work if you select the tabnames in the very same order.
    Before showing the entire coding I describe crucial parts of the coding:
    [code]TYPES: BEGIN OF ty_s_outtab.
    TYPES: tabname    TYPE tabname.
    TYPES: layout     TYPE lvc_s_layo.
    TYPES: variant    TYPE disvariant.
    TYPES: fcat       TYPE lvc_t_fcat.
    TYPES: data       TYPE REF TO data.
    TYPES: END OF ty_s_outtab.[/code]
    Every time a new structure is selected the corresponding ALV data are stored as new record in GT_OUTTAB which is of line type TY_S_OUTTAB.
    [code]  READ TABLE gt_outtab INTO gs_outtab INDEX 2.
      ASSIGN gs_outtab-fcat    TO <gt_fcat>.
      ASSIGN gs_outtab-data->* TO <gt_outtab>.[/code]
    Since the ALV list data and the fieldcatalog are fully dynamic I use global field-symbols for these data.
    [code]&----
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
    SET TITLEBAR 'xxx'.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = gs_outtab-tabname
          is_layout        = gs_outtab-layout
          is_variant       = gs_outtab-variant
          i_save           = 'A'
        CHANGING
          it_outtab        = <gt_outtab>
          it_fieldcatalog  = <gt_fcat>
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT[/code]
    The second ALV list which displays the table records is always newly displayed in the PBO module.
    In the event handler method <b>HANDLE_DOUBLE_CLICK</b> we need to do two things:
    - store the current fieldcatalog back to GT_OUTTAB
    - store the name of the new selected table/structure -> trigger PAI
    In routine <b>HANDLE_DB_CLICK</b> we create a new entry for GT_OUTTAB if it does not yet exist. Next we select this entry and display it again as second ALV list.
    [code]
    *& Report  ZUS_SDN_TWO_ALV_GRIDS_8
    *& Description: Display two ALV lists in splitter container (left/right)
    *&              Left ALV list contains DB table names,
    *& right ALV list displays entries of selected DB table
    *& SDN thread: Dynamical Call of ALV - No data update
    *&       Link: https:||Dynamical Call of ALV - No data update
    *& Screen '0100' contains no elements.
    *& ok_code -> assigned to GD_OKCODE
    *& Flow logic:
    PROCESS BEFORE OUTPUT.
       MODULE STATUS_0100.
    PROCESS AFTER INPUT.
       MODULE USER_COMMAND_0100.
    REPORT  zus_sdn_two_alv_grids_8.
    TYPE-POOLS: abap.
    DATA:
      gd_repid         TYPE syst-repid,
      gd_okcode        TYPE ui_func,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_splitter      TYPE REF TO cl_gui_splitter_container,
      go_cell_left     TYPE REF TO cl_gui_container,
      go_cell_right    TYPE REF TO cl_gui_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid,
      gs_layout        TYPE lvc_s_layo.
    TYPES: BEGIN OF ty_s_outtab.
    TYPES: tabname    TYPE tabname.
    TYPES: layout     TYPE lvc_s_layo.
    TYPES: variant    TYPE disvariant.
    TYPES: fcat       TYPE lvc_t_fcat.
    TYPES: data       TYPE REF TO data.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab  TYPE STANDARD TABLE OF ty_s_outtab
                        WITH DEFAULT KEY.
    DATA:
      gt_dd02l         TYPE STANDARD TABLE OF dd02l,
      gs_outtab        TYPE ty_s_outtab,
      gt_outtab        TYPE ty_t_outtab.
    FIELD-SYMBOLS:
      <gt_fcat>        TYPE lvc_t_fcat,
      <gt_outtab>      TYPE table.
          CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          md_tabname_selected  TYPE tabname  READ-ONLY.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
          CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_double_click.
      define local data
        DATA:
          ls_dd02l       TYPE dd02l,
          ls_outtab      TYPE ty_s_outtab.
        CHECK ( sender = go_grid1 ).
        READ TABLE gt_dd02l INTO ls_dd02l INDEX e_row-index.
        "   Store data of currently displayed ALV list (except for DD02L)
        IF ( md_tabname_selected = space ).
        ELSE.
          READ TABLE gt_outtab INTO ls_outtab
               WITH KEY tabname = md_tabname_selected.  " old
          CALL METHOD go_grid2->get_frontend_fieldcatalog
            IMPORTING
              et_fieldcatalog = ls_outtab-fcat.
          MODIFY gt_outtab FROM ls_outtab INDEX syst-tabix.
        ENDIF.
        md_tabname_selected = ls_dd02l-tabname.  " new selected DB table
      Triggers PAI of the dynpro with the specified ok-code
       cl_gui_cfw=>set_new_ok_code( 'HANDLE_DB_CLICK' ).  " not 4.6c
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'HANDLE_DB_CLICK'
         IMPORTING
           RC       =
      ENDMETHOD.                    "handle_double_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      gd_repid = syst-repid.
      SELECT        * FROM  dd02l INTO TABLE gt_dd02l
             WHERE  tabname LIKE 'KN%1'   OR
                    tabname LIKE 'LF%1'   OR
                    tabname LIKE 'VB%'   OR
                    tabname LIKE 'MAR%'   OR
                    tabname LIKE 'E07%'
             AND    tabclass = 'TRANSP'.  " transparent table
      SORT gt_dd02l BY tabname.
      PERFORM init_controls.
      PERFORM add_first_table.
    Set event handler
      SET HANDLER:
        lcl_eventhandler=>handle_double_click FOR go_grid1.
      READ TABLE gt_outtab INTO gs_outtab INDEX 1.
    Display data
      CALL METHOD go_grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = gs_outtab-tabname
          is_layout        = gs_outtab-layout
        CHANGING
          it_outtab        = gt_dd02l
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE gt_outtab INTO gs_outtab INDEX 2.
      ASSIGN gs_outtab-fcat    TO <gt_fcat>.
      ASSIGN gs_outtab-data->* TO <gt_outtab>.
    NOTE: method called in PBO module
    CALL METHOD go_grid2->set_table_for_first_display
       EXPORTING
         i_structure_name = gs_outtab-tabname
         is_layout        = gs_outtab-layout
         is_variant       = gs_outtab-variant
         i_save           = 'A'
       CHANGING
         it_outtab        = <gt_outtab>
         it_fieldcatalog  = <gt_fcat>
       EXCEPTIONS
         OTHERS           = 4.
    IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
         CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    NOTE: dynpro does not contain any elements
      CALL SCREEN '0100'.
    Flow logic of dynpro (does not contain any dynpro elements):
    *PROCESS BEFORE OUTPUT.
    MODULE STATUS_0100.
    *PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0100.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
    SET TITLEBAR 'xxx'.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = gs_outtab-tabname
          is_layout        = gs_outtab-layout
          is_variant       = gs_outtab-variant
          i_save           = 'A'
        CHANGING
          it_outtab        = <gt_outtab>
          it_fieldcatalog  = <gt_fcat>
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
      User has pushed button "Display Details"
        WHEN 'HANDLE_DB_CLICK'.
          PERFORM handle_db_click.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  HANDLE_DB_CLICK
          text
    -->  p1        text
    <--  p2        text
    FORM handle_db_click.
    define local data
      DATA:
        ld_handle(4) TYPE n,
        ls_outtab    TYPE ty_s_outtab.
      READ TABLE gt_outtab INTO ls_outtab
           WITH KEY tabname = lcl_eventhandler=>md_tabname_selected.
      IF ( syst-subrc NE 0 ).
        CLEAR: ls_outtab.
        ls_outtab-tabname = lcl_eventhandler=>md_tabname_selected.
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
        I_BUFFER_ACTIVE              =
          i_structure_name             = ls_outtab-tabname
        I_CLIENT_NEVER_DISPLAY       = 'X'
        I_BYPASSING_BUFFER           =
        I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = ls_outtab-fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
        IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        CREATE DATA ls_outtab-data TYPE TABLE OF (ls_outtab-tabname).
        ASSIGN ls_outtab-data->* TO <gt_outtab>.
        SELECT * FROM (ls_outtab-tabname) UP TO 50 ROWS
          INTO TABLE <gt_outtab>.
        ls_outtab-layout-no_toolbar = abap_false.
        ls_outtab-layout-zebra      = abap_true.
        ls_outtab-layout-smalltitle = abap_true.
        CONCATENATE ls_outtab-tabname ':'
          INTO ls_outtab-layout-grid_title.
        CONCATENATE ls_outtab-layout-grid_title 'Table Records'
          INTO ls_outtab-layout-grid_title
          SEPARATED BY space.
        ls_outtab-variant-report    = gd_repid.
        DESCRIBE TABLE gt_outtab.
        ld_handle = syst-tfill + 1.
        WRITE ld_handle TO ls_outtab-variant-handle.  " $TMP: Problem!!!
        APPEND ls_outtab TO gt_outtab.
      ENDIF.
      " NOTE: read into GLOBAL variable gs_outtab !!!!
      READ TABLE gt_outtab INTO gs_outtab
            WITH KEY tabname = lcl_eventhandler=>md_tabname_selected.
      ASSIGN gs_outtab-fcat    TO <gt_fcat>.
      ASSIGN gs_outtab-data->* TO <gt_outtab>.
    ENDFORM.                    " HANDLE_DB_CLICK
    *&      Form  INIT_CONTROLS
          text
    -->  p1        text
    <--  p2        text
    FORM init_controls .
    Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_docking->set_extension
        EXPORTING
          extension  = 99999 " full-size screen
        EXCEPTIONS
          cntl_error = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Create splitter container
      CREATE OBJECT go_splitter
        EXPORTING
          parent            = go_docking
          rows              = 1
          columns           = 2
         NO_AUTODEF_PROGID_DYNNR =
         NAME              =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Get cell container
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 1
        RECEIVING
          container = go_cell_left.
      CALL METHOD go_splitter->get_container
        EXPORTING
          row       = 1
          column    = 2
        RECEIVING
          container = go_cell_right.
      CALL METHOD go_splitter->set_column_mode
        EXPORTING
          mode              = cl_gui_splitter_container=>mode_relative
       IMPORTING
         RESULT            =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_splitter->set_column_width
        EXPORTING
          id                = 1
          width             = 25
       IMPORTING
         RESULT            =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_splitter->set_column_sash
        EXPORTING
          id                = 1
          type              = cl_gui_splitter_container=>type_movable
          value             = cl_gui_splitter_container=>false
       IMPORTING
         RESULT            =
        EXCEPTIONS
          cntl_error        = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Create ALV grids
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent          = go_cell_left
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid2
        EXPORTING
          i_parent          = go_cell_right
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  ADD_FIRST_TABLE
          text
    -->  p1        text
    <--  p2        text
    FORM add_first_table .
    define local data
      DATA:
        ls_outtab    TYPE ty_s_outtab.
      ls_outtab-tabname = 'DD02L'.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
      I_BUFFER_ACTIVE              =
        i_structure_name             = ls_outtab-tabname
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           =
      I_INTERNAL_TABNAME           =
      CHANGING
        ct_fieldcat                  = ls_outtab-fcat
      EXCEPTIONS
        inconsistent_interface       = 1
        program_error                = 2
        OTHERS                       = 3.
      IF sy-subrc <> 0.
    *MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      GET REFERENCE OF gt_dd02l INTO ls_outtab-data.
      ls_outtab-layout-no_toolbar = abap_false.
      ls_outtab-layout-zebra      = abap_true.
      ls_outtab-layout-smalltitle = abap_true.
      CONCATENATE ls_outtab-tabname ':'
        INTO ls_outtab-layout-grid_title.
      CONCATENATE ls_outtab-layout-grid_title 'Table Records'
        INTO ls_outtab-layout-grid_title
        SEPARATED BY space.
      ls_outtab-variant-report    = gd_repid.
      ls_outtab-variant-handle    = '0002'.
      INSERT ls_outtab INTO gt_outtab INDEX 1.
      ls_outtab-layout-no_toolbar = abap_true.
    ls_outtab-layout-zebra      = abap_true.
    ls_outtab-layout-smalltitle = abap_true.
      ls_outtab-layout-grid_title = 'DB Tables'.
    ls_outtab-variant-report    = gd_repid.
      ls_outtab-variant-handle    = '0001'.
      DELETE ls_outtab-fcat WHERE ( fieldname NE 'TABNAME' ).
      INSERT ls_outtab INTO gt_outtab INDEX 1.
    ENDFORM.                    " ADD_FIRST_TABLE[/code]
    Regards,
      Uwe

  • Retrieving latest updated or inserted records without using a trigger

    I have to retrieve the latest updated/inserted records from a set of database tables. Say, if 'n' sets of different records have been updated or inserted into one or more different database tables then all the 'n' records of data should be retrieved using a java code without using a trigger.

    helpmeplz wrote:
    Thanks for your reply.
    But I don't know when or from where or what kind of data gets inserted/updated into the tables. I need a listener or a component which can handle events occured on the particular set of database tables, and get the event data. the java code should get the updated/inserted rows that have been inserted into a set of database tables by a third party.
    Please lemme know how I can do this.Realistically you can't.
    If and only if the tables have a modification timestamp then you could use that. Every table would need it.
    Other than that the only othe possibility would require that you keep an entire copy of each table in the memory, poll at a set interval and then do an entire comparison for each table. For very small data volumes (on the target tables) that is practical. For larger volumes it isn't.

  • How to find out the column causing the error while doing update or insert

    I'm getting the below error when attempt to update or insert a long string that is more than its defined length in the DB2. For example in table the column length is defined as 50, however from UI the data for that column is more than 50 chars.
    {color:#ff0000}**Caused by: com.ibm.db2.jcc.b.SqlException: DB2 SQL error: SQLCODE: -302, SQLSTAT**
    **E: 22001, SQLERRMC: null**
    **at com.ibm.db2.jcc.b.hh.b(hh.java:1369)**
    **at com.ibm.db2.jcc.b.hh.c(hh.java:1356)**{color}
    The above issue can be fixed by setting maxlength in the UI itself. However in my case, there is a backend program trying to insert or update load of records. If the exact column name causing the error is known, it will be helpful to load the data properly in the next attempt.
    I have worked around it using SQLWarning and DataTruncation, but couldn't find the solution yet.
    Any help on this issue will be really appreciated.

    Medraf wrote:
    what is validator? Is it like validation.xml in struts? Are you suggesting like defining set of validation rules in the xml and apply the same for each record before doing any update or insert in DB? If so, then I could implement this validation logic in my backend code, however it may take more time to complete the batch prcoess.
    How you implement doesn't matter.
    However given a schema generating code for such validation is trivially simple at least for field types and sizes. Relationships are harder but those can be handled via custom rules.
    Alternatively I'm looking for some kind of API in JDBC or Hibernate which gives the detailed sql exception message containing the error info like the column name and the reason for failure while update or insert. If not possible, then validation logic needs to be implemented.Having seen something similar in Oracle years ago I seriously doubt that you are going find it magically appearing in JDBC/hibernate. There might be warning on the SQLException (see the java docs for SQLException) but I wouldn't count on it. Other than that the only possibility is making some sort of call in db2 itself that tells you the error. Only problem with that is it might require the context which might not be available once you see the error (presuming, especially for performance, that you are using batch processing.)
    As a start figure out how to find out using only db2 (docs and/or db2 forums.)

Maybe you are looking for