Insert into sap r/3 table

hi,guruvulu
this is the program...............to insert the data into sap r/3 table
but record is not inserting....any commit i have to write in my program?
Created on Feb 20, 2007
TODO To change the template for this generated file go to
Window - Preferences - Java - Code Style - Code Templates
package comm;
@author sapusr006
TODO To change the template for this generated type comment go to
Window - Preferences - Java - Code Style - Code Templates
Example2.java
Property of SAP AG, Walldorf
(c) Copyright SAP AG, Walldorf, 2000-2005.
All rights reserved.
//import java.sql.Connection;
//import java.sql.PreparedStatement;
import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO;
@version 1.0
@author  SAP AG, Walldorf
public class Fm {
  // The MySAP.com system we gonna be using
     static final String SID = "R3";
// static String query="insert into BAPI_COMPANYCODE_GETLIST values(?,?)";
  // The repository we will be using
  IRepository repository;
                             //ESTABLISHING A CONNECTION TO SAP
  public Fm()
    try {
      JCO.addClientPool( SID,            // Alias for this pool
                         10,             // Max. number of connections
                         "800",          // SAP client
                         "RFCTEST",      // userid
                         "welcome",      // password
                         "EN",           // language
                         "10.10.88.170", // host name
                         "01" );
       //   Create a new repository
      //    The repository caches the function and structure definitions
      //    to be used for all calls to the system SID. The creation of
      //    redundant instances cause performance and memory waste.
        repository = JCO.createRepository("MYRepository", SID);
    catch (JCO.Exception ex) {
      System.out.println("Caught an exception: \n" + ex);
                           // RETRIEVES AND DISPLAY A  ZHR INFOTYPE OPERATION
  public void salesOrders()
    JCO.Client client = null;
    try {
      // Get a function template from the repository
         //System.out.println("goes to sales order");
      IFunctionTemplate ftemplate = repository.getFunctionTemplate("ZHR_INFOTYPE_OPERATION");
      System.out.println("hai");
           if(ftemplate != null) {
        // Create a function from the template
       JCO.Function function = ftemplate.getFunction();
       JCO.ParameterList paralist=function.getImportParameterList();
                         paralist.setValue("0000000011","PERNR");
                         paralist.setValue("UPD","ACTIO");
                         paralist.setValue("A","TCLAS");
                         System.out.println("hello");
                         paralist.setValue("20061215","BEGDA");
                         System.out.println("hello");
                         paralist.setValue("20061215","ENDDA");
                         paralist.setValue("1","OBJPS");
                         paralist.setValue("LTA","SUBTY");
          System.out.println("SETTING VALUES");
        // Get a client from the pool
          client = JCO.getClient(SID);
          System.out.println("goes to sales order");
          //function.getImportParameterList().setValue("QUERY_TABLE","ZHRJ2EETEST");
            //EXECUTING THE FUNCTION
           client.execute(function);
          System.out.println("after exeucting the function");
             // NO OF IMPORT PARAMS IT DISPLAY
                         //STRUCTURE
                          JCO.Structure returnStructure =
                                                                          function.getExportParameterList().getStructure("RETURN");
                          String structure=returnStructure.toString();
                          System.out.println(structure);
                                                                                JCO.Table sales_orders = function.getTableParameterList().getTable("PROPOSED_VALUES");
                         System.out.println("after function");
                           System.out.println("proposed111"+sales_orders.getNumRows());
                                                                                sales_orders.firstRow();
                                sales_orders.appendRows(3);
                             sales_orders.setValue("0582","INFTY");
                             sales_orders.setValue("P0582-AMTEX","FNAME");
                              sales_orders.setValue("200.00","FVAL");
                              sales_orders.nextRow();
                              sales_orders.setValue("0582","INFTY");
                              sales_orders.setValue("P0582-JBGDT","FNAME");
                              sales_orders.setValue("20061215","FVAL");
                              sales_orders.nextRow();
                              sales_orders.setValue("0582","INFTY");
                              sales_orders.setValue("P0582-JENDT","FNAME");
                              sales_orders.setValue("20061215","FVAL");
                              System.out.println("proposed222"+sales_orders.getNumRows());
                                                                                /*for (int i = 0; i <sales_orders.getNumRows(); i++) {
                              sales_orders.setRow(i);
                              System.out.println(sales_orders.getString("INFTY"));
                 JCO.Table sales_orders1 = function.getTableParameterList().getTable("MODIFIED_KEYS");
                         System.out.println("modified"+sales_orders1.getNumRows());
                                                                                sales_orders1.setRow(1);
                           sales_orders1.appendRows(1);
                           sales_orders1.setValue("0000000011","PERNR");
                           sales_orders1.setValue("0582","INFTY");
                           sales_orders1.setValue("LTA","SUBTY");
                           sales_orders1.setValue("1","OBJPS");
                           sales_orders1.setValue("20061215","BEGDA");
                           sales_orders1.setValue("20061215","ENDDA");
                         System.out.println("modified222"+sales_orders1.getNumRows());
                                                                                System.out.println("execute222"+sales_orders1.getNumRows());
                                                                                for (int i = 0; i <sales_orders1.getNumRows(); i++) {
                              sales_orders.setRow(i);
                              System.out.println("hia"+sales_orders1.getString("SUBTY"));
                                                                                System.out.println("NO OF ROWS ARE:---"+ sales_orders.getNumRows());
           String fieldName[]=new String[sales_orders.getFieldCount()];
           System.out.println("THE COLUMNS IN THE TABLE ARE:--"+sales_orders.getFieldCount());
           // sales_orders.firstRow();
           //COLUMNS NAMES
           System.out.println(fieldName.length);
           for (int iCtrst = 0;iCtrst < sales_orders1.getFieldCount();iCtrst++) {
                    fieldName[iCtrst] = sales_orders1.getName(iCtrst);
                    System.out.println(fieldName[iCtrst]);
        if (sales_orders.getNumRows() > 0) {
          // Loop over all rows
           do {
                 System.out.println("----
                 //int r=1;
            // Loop over all columns in the current row
            for (JCO.FieldIterator e = sales_orders.fields(); e.hasMoreElements();)
                   JCO.Field field = e.nextField();
                   String compcode=field.getString();
                   //pst.setString(r,compcode);
                   System.out.println(field.getName() + ":\t" + field.getString());
                  // r++;
               }//for
                // i=pst.executeUpdate();
            } while(sales_orders.nextRow());
        else {
          System.out.println("No results found");
        if (sales_orders1.getNumRows() > 0) {
            // Loop over all rows
             do {
                   System.out.println("----
                   //int r=1;
              // Loop over all columns in the current row
              for (JCO.FieldIterator e = sales_orders1.fields(); e.hasMoreElements();)
                         JCO.Field field1 = e.nextField();
                     //String compcode=field1.getString();
                     //pst.setString(r,compcode);
                     System.out.println(field1.getName() + ":\t" + field1.getString());
                    // r++;
                                                                                }//for
                  // i=pst.executeUpdate();
              } while(sales_orders1.nextRow());
          else {
            System.out.println("No results found");
           System.out.println("modified"+sales_orders1.getNumRows());
           System.out.println("modified"+sales_orders.getNumRows());
        //if
       /* if(i>=1)
             System.out.println("\t\t\tUpdated ORACLE successfully");
      else {
        System.out.println("FUNCTION MODULE not found in backend system.");
      }//if
    catch (JCO.AbapException ex) {
      System.out.println("Caught an exception: \n" + ex);
    }catch(Exception en){en.printStackTrace();}
    finally {
               JCO.releaseClient(client);
  protected void cleanUp() {
      JCO.removeClientPool(SID);
  public static void main(String[] argv)
    Fm e=new Fm();
   // e.systemInfo();
    e.salesOrders();
    e.cleanUp();
output:
TABLE: MODIFIED_KEYS
TABLE: PROPOSED_VALUES
IMPORT         ACTIO
IMPORT         BEGDA
IMPORT         DIALOG_MODE
IMPORT         ENDDA
IMPORT         LUW_MODE
IMPORT         MASSN
IMPORT         NO_ENQUEUE
IMPORT         NO_EXISTENCE_CHECK
IMPORT         OBJPS
IMPORT         PERNR
IMPORT         PERSG
IMPORT         PERSK
IMPORT         PLANS
IMPORT         SEQNR
IMPORT         SPRPS
IMPORT         SUBTY
IMPORT         TCLAS
IMPORT         WERKS
EXPORT          HR_RETURN
EXPORT          RETURN
EXPORT          RETURN1
appending
NO OF ROWS ARE:---3
THE COLUMNS IN THE TABLE ARE:--4
INFTY:     0582
FNAME:     P0582-AMTEX
FVAL:     200.00
SEQNR:     00
INFTY:     0582
FNAME:     P0582-JBGDT
FVAL:     20061215
SEQNR:     00
INFTY:     0582
FNAME:     P0582-JENDT
FVAL:     20061215
SEQNR:     00
PERNR:     00000011
INFTY:     0582
SUBTY:     LTA
OBJPS:     1
SPRPS:     
ENDDA:     2006-12-15
BEGDA:     2006-12-15
SEQNR:     000

hi jagadesh,
ur code is very length to see.
see the following code ,
JCO.Function objFunction =
               this
                    .objIRepository
                    .getFunctionTemplate("BAPI_MATERIAL_AVAILABILITY")
                    .getFunction();
          objFunction.getImportParameterList().setValue(strPlant, "PLANT");
          objFunction.getImportParameterList().setValue(strMaterial, "MATERIAL");
          objFunction.getImportParameterList().setValue(strQuantity, "UNIT");
          this.objClient.execute(objFunction);
          JCO.Structure ret =
               objFunction.getExportParameterList().getStructure("RETURN");
          String strRetMsg = ret.getString("MESSAGE");
System.out.println(strRetMsg);  // it will tell whether record is inserted or not
/*JCO.Function objFunction1 =
               this
                    .objIRepository
                    .getFunctionTemplate("BAPI_TRANSACTION_COMMIT")
                    .getFunction();
objFunction1.setValue("",WAIT);
objClient.execute(objFunction1);*/
CHECK THE RETURN MSG .IT WILL TELL THE PROBLEM
give me points if it is useful
regards
Guru
Message was edited by:
        Guruvulu Bojja
Message was edited by:
        Guruvulu Bojja
Message was edited by:
        Guruvulu Bojja

Similar Messages

  • How to insert into more than one table at a time also..

    hi,
    i am a newbee.
    how to insert into more than one table at a time
    also
    how to get a autoincremented value of an id say transactionid for a particular accountid.
    pls assume table as
    transactionid accountid
    101 50
    102 30
    103 50
    104 35
    i want 102 for accountid 30 and 103 for accountid 50.
    thank u

    @blushadow,
    You can only insert into one table at a time. Take a look here :
    Re: insert into 2 tables
    @Raja,
    I want how to extract the last incremented value not to insert.Also, I don't understand your thread title... which was "how to insert into more than one table at a time also.. "
    Insert, extract... ? Can you clarify your job ?
    Nicolas.

  • How do i insert into more than one table from temp table?

    Hi,
    I have three tables such as temp,stck and stol
    temp table contains data as below. It has 22 columns.
    STOCK     STOCKDESC     ALIAS1     ALIAS2     ALIAS3     ALIAS4     ALIAS5     ALIAS6     ALIAS7     ALIAS8     ALIAS9     ALIAS10     ALIAS11     ALIAS12     ALIAS13     ALIAS14     ALIAS15     ALIAS16     ALIAS17     ALIAS18     ALIAS19     ALIAS20
    bmg667691031      NOWE FINANSE LTD     yy     zz     B282DV3      TESTICKER      te     te1     bmg667691031BM     te     707943W     ex     IR-PRIME     IR-ALTID     IR-BLOOM     NT-PRIME     NT-ALTID     NT-BLOOM     AU-PRIME     AU-ALTID     AU-BLOOM     mm
    AA0098000181      UFACEX HOLDINGS VAR RT DUE 06-30-2010     kk     yy     mm     TESTICKER      aa     ff     AA0098000181GB     bb     031969W     cc     IR-PRIME     IR-ALTID     IR-BLOOM     NT-PRIME     NT-ALTID     NT-BLOOM     AU-PRIME     AU-ALTID     AU-BLOOM     ba
    AC1350Z7M923      CDA GOVT TREAS BILLS CDS- 08-05-2010     ee     ff     gg     TESTICKER      hh     ij     AC1350Z7M923CA     mn     1A1MTLU     op     IR-PRIME     IR-ALTID     IR-BLOOM     NT-PRIME     NT-ALTID     NT-BLOOM     AU-PRIME     AU-ALTID     AU-BLOOM     op
    stck table contains as below.It has six columns. But always first three columns will have values.
    stock_id   stock_code stock_description              stock_type terriory_code preferred code
    1185072     AED                    
    1185073     ARA     CURRENCY ARGENTINA PESO               
    1185074     ATS     CURRENCY AUSTRIAN SCHS     
    stol table contains as below. It has 6 columns.Terriory_code is always empty.
    stock_code        territory_code    stol_type stock_id  stck_code_type sys_entry_date
    AED          0 1185072     0     6/22/2007 3:59:13.000 PM
    ARA          0 1185073     0     6/22/2007 3:59:13.000 PM
    ATS          0     1185074     0     6/22/2007 3:59:13.000 PM
    Now, i want to insert into stck and stol table based on temp table records. constraints to insert into stck and stol tables are as below
    In temp table first column is called stock. This stock has to compare with stck table stock_code. If it is not present in stck table, then it has to insert into stck table with stock_id and stock_description. Here, I need to generate stock_id my self in the code.
    In temp table, column 3 to column 22, i have alias. Each column has to check with stol table stock_code column. For instance, column3 check with stock_code column. Then column4 check with stock_code. If stock_code is not present in stol table, then i have to insert into stol table.
    I need to generate stock,id in the code. How do i perform this insertion?
    Edited by: user12852882 on Jun 12, 2010 2:37 AM

    It can be done using SQL (no loops required)
    insert into stock_table (stock_id,stock_code,stock_description)
    select stock_id,get_stock_code,stockdesc  /* get_stock_code is a function providing stock_code - usually a sequence value */
      from (select t.stock stock_id,t.stockdesc,s.stock_id stock_stock_id
              from temp_table t,stock_table s
             where t.stock = s.stock_id(+)
    where s.stock_id is null;
    insert into stol_table (stock_code,sys_entry_date) /* not clear where other values to be inserted will come from */
    select stock_code,sysdate
      from (select t.stock_code,s.stock_code stol_stock_code
              from (select distinct stock_code
                      from (select alias1 stock_code from temp_table union all
                            select alias2 from temp_table union all
                            select alias3 from temp_table union all
                            select alias4 from temp_table union all
                            select alias5 from temp_table union all
                            select alias6 from temp_table union all
                            select alias7 from temp_table union all
                            select alias8 from temp_table union all
                            select alias9 from temp_table union all
                            select alias10 from temp_table union all
                            select alias11 from temp_table union all
                            select alias12 from temp_table union all
                            select alias13 from temp_table union all
                            select alias14 from temp_table union all
                            select alias15 from temp_table union all
                            select alias16 from temp_table union all
                            select alias17 from temp_table union all
                            select alias18 from temp_table union all
                            select alias19 from temp_table union all
                            select alias20 from temp_table
                           )                                           /* use unpivot instead if you are 11g */
                     where stock_code is not null
                   ) t,stol_table s
             where t.stock_code = s.stock_code(+)
    where s.stock_code is null;
    and think about damorgan's post, you'll never regret it (especially when you will not just think)
    Regards
    Etbin

  • Inserting into a doubly nested table through an object view

    Can anyone give me an example of an INSTEAD OF trigger that will mediate an INSERT into a doubly nested table of an Object View? Is there syntax that will allow it?

    Here's some code to demonstrate. Note that relational tables, not an object table, are used to store object instances:
    create or replace type TInnerNestedTable
    is table of varchar2(20)
    create or replace type TOuterNestedTable
    is table of TInnerNestedTable
    create or replace type TMyObject
    is object
         id     varchar2(20)
    ,     tab     TOuterNestedTable
    create
    table     T_MY_OBJECT
         id          varchar2(20)     not null
    ,     primary key (id)
    create
    table     T_MY_OBJECT_TAB_OUTER
         id          varchar2(20)     not null
    ,     outerIndex     integer          not null
    ,     primary key (id, outerIndex)
    ,     foreign key (id) references T_MY_OBJECT on delete cascade
    create
    table     T_MY_OBJECT_TAB_INNER
         id          varchar2(20)     not null
    ,     outerIndex     integer          not null
    ,     innerIndex     integer          not null
    ,     innerValue     varchar2(20)
    ,     primary key (id, outerIndex, innerIndex)
    ,     foreign key (id, outerIndex) references T_MY_OBJECT_TAB_OUTER on delete cascade
    create or replace view V_MY_OBJECT
    of TMyObject
    with object identifier (id)
    as
    select     t.id
    ,     cast(multiset(
              select     cast(multiset(
                        select     i.innerValue
                        from     T_MY_OBJECT_TAB_INNER i
                        where     i.id = o.id
                        and     i.outerIndex = o.outerIndex
                   ) as TInnerNestedTable)
              from     T_MY_OBJECT_TAB_OUTER o
              where     o.id = t.id
         ) as TOuterNestedTable)
    from     T_MY_OBJECT t
    create or replace trigger TR_II_V_MY_OBJECT
    instead of insert on V_MY_OBJECT
    for each row
    begin
         insert
         into     T_MY_OBJECT
              id
         values     (
              :new.id
         insert
         into     T_MY_OBJECT_TAB_OUTER
              id
         ,     outerIndex
         select     :new.id
         ,     rownum
         from     table(:new.tab) o;
         insert
         into     T_MY_OBJECT_TAB_INNER
              id
         ,     outerIndex
         ,     innerIndex
         ,     innerValue
         select     :new.id
         ,     o.outerIndex
         ,     rownum
         ,     value(i)
         from     (
              select     :new.id
              ,     rownum outerIndex
              ,     value(o) innerTab
              from     table(:new.tab) o
              ) o
         ,     table(o.innerTab) i;
    end;
    insert
    into     V_MY_OBJECT
    values     (
         new TMyObject(
              'A'
         ,     TOuterNestedTable(
                   TInnerNestedTable('A','B','C')
              ,     TInnerNestedTable('AA')
              ,     TInnerNestedTable('AB')
    insert
    into     V_MY_OBJECT
    values     (
         new TMyObject(
              'B'
         ,     TOuterNestedTable(
                   TInnerNestedTable('X','Y','Z')
              ,     TInnerNestedTable('Hello', 'World!')
    /Selecting from the view shows the results:
    select     value(o)
    from     V_MY_OBJECT o
    VALUE(O)(ID, TAB)
    TMYOBJECT('A', TOUTERNESTEDTABLE(TINNERNESTEDTABLE('A', 'B', 'C'), TINNERNESTEDTABLE('AA'), TINNERNESTEDTABLE('AB')))
    TMYOBJECT('B', TOUTERNESTEDTABLE(TINNERNESTEDTABLE('X', 'Y', 'Z'), TINNERNESTEDTABLE('Hello', 'World!')))
    2 rows selected.Hope that helps...
    Gerard

  • Trigger on a paritioned table to insert into a non-paritioned table

    Hi,
    I have a partitioned table which will have a high degree of concurrent DMLs (Updates). It has a initrans value set to 16. On this table a trigger is created which will insert into a non-partitioned table on update of highly updateable columns. I am planning to keep the initrans value and freelists value to 16 so that it does not serialize and wait for the block slots.
    Is the above set up performance inefficient? Is partitioning the table in which the trigger inserts will improve the performance?
    Thanks,
    Rajesh

    I think if you want to consider an efficient solution, I would look at not implementing your requirements using triggers. If possible consider an API approach where whatever "applicaiton" is being used calls a PL/SQL package that will update both tables if necessary. There are a number of disadvantages to using triggers.
    HTH!
    Edited by: Centinul on Jan 2, 2009 11:48 PM
    Check out this recent thread on triggers: Should one really avoid triggers???

  • Record not inserting into sap table with connector framework ?

    here is the code, but record not being inserting into the table ... but same piece of code working fine while updating ... the record ...
    try {
    interaction = connection.createInteractionEx();
    IInteractionSpec interactionSpec = interaction.getInteractionSpec();
    String functionName = "Z_XYZ";
    interactionSpec.setPropertyValue("Name", functionName);
    String writingTable = "MYTABLE";
    RecordFactory rf = interaction.getRecordFactory();
    MappedRecord importParams = rf.createMappedRecord("input");
    importParams.put("ATTR1", "VALUE1");
    importParams.put("ATTR2", "VALUE2");
    IFunction function = connection.getFunctionsMetaData().getFunction(functionName);
    IStructureFactory sf = interaction.retrieveStructureFactory();
    IRecordSet table = (IRecordSet) sf.getStructure(function.getParameter(writingTable).getStructure());
    table.insertRow();
    table.setString("ATNAME", "VALUE");
    table.setString("ATWRT", "VALUE");
    importParams.put(writingTable, table);
    MappedRecord output = (MappedRecord) interaction.execute(interactionSpec, importParams);
    } catch (Exception e) {
    any idea?
    than ks
    MMK

    Hi Mohan,
    Does a creation through SE37 with the same input work?
    Yoav.

  • Pl/sql block with "insert into" and schema qualified table throws "error"

    Simplified test case:
    Oracle9i EE Release 9.2.0.3.0
    Oracle JDeveloper 9.0.3.2 Build 1145
    create user u1 identified by u1
    default tablespace users
    quota unlimited on users;
    grant connect, resource to u1;
    revoke unlimited tablespace from u1;
    create user u2 identified by u2
    default tablespace users
    quota unlimited on users;
    grant connect, resource to u2;
    revoke unlimited tablespace from u2;
    As user u2:
    create table u2.t
    c1 number
    grant select, update, insert, delete on u2.t to u1;
    As user u1:
    create or replace package test_pkg as
    procedure do_insert (p_in number);
    end;
    create or replace package body test_pkg as
    procedure do_insert (p_in number) is
    begin
    insert into u2.t values (p_in);
    commit;
    end;
    end;
    All of the above works fine using command-line sql*plus, and is clearly a simplified version of the actual code to demonstrate the issue at hand. Using JDeveloper, it complains about 'expected ;' at the 'values' keyword in the insert statement. Removing the schema qualification from the table name allows JDeveloper to not flag the statement as an error, but I do not want to create synonyms (private or public) to point to all the tables in the real packages. Since JDeveloper flags the insert statement as an error, I can not browse the package structure etc, even though it compiles with no problems. What gives?
    Thanks in advance for any suggestions, etc...

    Hi Bryan,
    Thanks for following up on this. I will look for the bug fix to be published.
    - Mark

  • Data from 2 database blocks insert into the same base table?

    Hello,
    I have canvas C_NEW. On this canvas, items from 3 blocks are usable by the user.
    1. Block NEW_HEAD: 3 items say X1,X2,X3
    2. Block NEW : multi record text fields say Y1 thru Y10. Also a scrollbar.
    3. Block NEW_ACTION: 6 buttons say B1 thru B6 (One of them is N_OK which is the item in question)
    both the blocks NEW, NEW_HEAD are db blocks and have the same base table say BT. When the users click on the N_OK (after filling out the data in the NEW_HEAD block and then NEW in that order) I need the data from both the NEW, NEW_HEAD to go into the BT. Currently only the data from the NEW is going into BT. Fields in the BT table which correspond to the fields X1,X2,X3 in the NEW_HEAD remain null after clicking the N_OK button. I put commit_form in the N_OK code since both the blocks are db blocks( and as suggested by folks, it is easier to issue a commit_form than do a lot more work in writing my own SQL).
    How can I achive this?
    Thanks,
    Chiru

    I tried doing what you suggested by putting the following code in the program unit which gets called when_button_pressed.
    PROCEDURE P_SAVE IS
    v_lc_no number;
    v_lc_seq number;
    v_dmg_allow number;
    BEGIN
      Go_Block('B_new_head');
      v_lc_no:= :B_new_head.N_LC_NO;
      v_lc_seq:= :B_new_head.N_LC_SEQ;
      v_dmg_allow:= :B_new_head.N_LC_DMG_ALLOW;
      Go_Block('B_new');      
    FIRST_RECORD;
    LOOP     
         emessage('before insert'||v_lc_no||'-'||v_lc_seq||'-'||:B_new.order_no);
      INSERT INTO ct_lc_import(
        LC_NUMBER,
        LC_SEQ,
        DAMAGE_ALLOWANCE,
        ORDER_NO,
        QTY_SHIPPED,
        UNIT_PRICE,
        DRAFT_AMOUNT,
        TICKET_DEDUCTION,
        SHIPMENT_PENALTY,
        TOTAL_DEBIT,
        DEBIT_DATE)
        VALUES (v_lc_no,
                v_lc_seq,
                v_dmg_allow,
                :B_new.order_no,
                :B_new.qty_shipped,
                :B_new.unit_price,
                :B_new.draft_amount,
                :B_new.ticket_deduction,
                :B_new.shipment_penalty,
                :B_new.total_debit,
                :B_new.debit_date);
       commit;
      NEXT_RECORD;
       if :SYSTEM.LAST_RECORD='TRUE' then
             emessage('last record');
             EXIT;
       end if;
      --NEXT_RECORD;
    END LOOP;
    EXCEPTION
       when FORM_TRIGGER_FAILURE then
          raise;
       when OTHERS then
          emessage(SQLERRM);
          raise FORM_TRIGGER_FAILURE;
    END;But I can't see the records in the table eventhough the message pops up with the values before inserting the 1st record. It then exits. I would think it would atleast insert the very first record into the the table at the least.
    Thanks,
    Chiru

  • Decide to insert into one or another table

    Hi guys,
    I have the following problem:
    Need to run a process which inserts records into TABLE A (COL1, COL2, COL3), but then if COL3 = 3 then I have to insert the current record in TABLE B without inserting in table A.
    Table A = Table B in structure.
    I cannot modify the process to do this as I will loose my warranty period, so I think it can be possible to do it by triggers, as I thought in "INSTEAD OF" but this solution only apply (I guess) to views.
    Any clues?
    Thanks in Advance.
    -Ed

    I figured out this code. The only thing is that is crying for the null insert (ORA-01400 cannot insert null).
    What I want to see is if this error will cut the insertion process as a whole.
    Let me know your comments please and thanks for help.
    CREATE OR REPLACE TRIGGER SCOTT.TRG_INDICES_INS
    BEFORE INSERT
    ON SCOTT.INDICES
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    DECLARE
    falla EXCEPTION;
    pragma AUTONOMOUS_TRANSACTION;
    BEGIN
    IF :NEW.col1 = 1
    THEN
    RAISE falla;
    END IF;
    EXCEPTION
    WHEN falla
    THEN
    INSERT INTO asoc
    VALUES (:NEW.col1, :NEW.col2, :NEW.col3);
         COMMIT;
         :NEW.COL1:=NULL;
    -- INDICES TABLE ATTRIBUTES CANNOT BE NULL
    WHEN OTHERS
    THEN
    null;
    END trg_indices_ins;

  • Retriving unique records and insert into cust and cust_det table

    Hi,
    uniq Table : EMP
    column name
    name
    addr
    city
    addr1
    city1
    EMP table contains only unique records.
    we neet to get the records from emp and insert into cust and cust_det accordingly
    table : cust
    empno : auto generated
    name
    addr
    tabel : cust_det
    empno : refer from cust
    addr1
    city1
    plese help me to do this.

    user10069916 wrote:
    can some one help me to resolve this plz. bit urgent..My boss says my work is more urgent than yours.
    As I said, please read: {message:id=9360002} (especially point 2)
    If you post sufficient information, then people can help you. the better the information you provide the faster people will be able to help... but still, if it's "urgent" then we can only assume you have a live production system that is failing, in which case you need to raise an SR with Oracle Support, as the forums are not the place for logging "urgent" production system issues.

  • Insert into SAP table from external program

    Hi Gurus,
    I need to perform an insert of several records into a couple of SAP tables from an external program.
    Do you know of an RFC (if it is remote enabled the better) that allows me to specify the table and records to perfom an insert?
    Many thanks
    Mauricio Pego

    I don't know ABAP and wanted to avoid writing my own function if one standard exists.
    My requirement stands like this, I have a few z tables that need to populate from my C# application by use of the .Net connector.
    I haven't found a BAPI or RFC that allows me to add records to any table, but I don't know all the RFCs.
    May be one of you passed throu this already.
    Mauricio

  • Inserting data into sap

    hi guys,
      i want to insert data into sap r/3 table....
       they have given some values related to import parameters,
       in that 2 tables are there modified_values,proposed_keys
       i want to insert the data into that tables...how?
      plz send me code....
    thanks

    Hi, Tony!
    Are you using NWDS and SAP Web AS or another IDE / Application Server. If you're working with NWDS, simply create a new Enterprise Connector Project, select the R/3-System you like to access, choose an appropriate bapi/function module (best via application hierarchy) and let the IDE generate appropriate Java classes. Next reference the EC project in your Java Project and use the proxy classes according to <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/79/c6213e225f9a0be10000000a114084/frameset.htm">help.sap.com</a>.
    If you' re using alternative IDEs, refer to their documentation.
    Regards,
    Thomas

  • INSERT INTO table. . . SELECT field1, field2 From. . . .bug

    Hi,
    I should remember this but . . . bug with t-sql  using Insert Into  on a temp table.  It is unhappy with fields I'm trying to insert.
    It's probably the fact that I'm trying to using some default data w/ aliases for a couple of the fields. 
    Have a look at code please, and tell me how to correct. Thanks!
    DECLARE @OrderNo varchar(6)
    USE tempdb;
    set @OrderNo = '909773' ;
    IF OBJECT_ID ('#tmpNCGLITEMS') IS NOT NULL --how to get this to work with SSMS w/o reloading the qry window. i.e. how to release to delete????
    DROP TABLE #tmpNCGLItems
    use DEV_ORDERS;
    SELECT distinct od.lline as OrdLine, od.ldrcolor as ClrCode, od.ldrspec as SpecCode, ad.Addon_Mod_GL_Acct as ncGLCode
    INTO #tmpNCGLItems
    FROM OODETL od
    INNER JOIN [Dev_Products].[dbo].[Addon_Master] ad on od.lfg = ad.Addon_Mod_Mod_Code_ID AND ad.Addon_Mod_A_C_D_ID = 'C'
    WHERE od.LOrder = @OrderNo and ad.Addon_Mod_GL_Acct is not null
    select * from #tmpNCGLItems
    USE tempdb;
    IF OBJECT_ID ('#tmpNCGLITEMS1') IS NOT NULL
    DROP TABLE #tmpNCGLItems1
    USE DEV_ORDERS;
    CREATE TABLE [dbo].[#tmpNCGLItems1](
    [OrdLine] [char](4) NOT NULL,
    [ClrCode] [char](6) NULL,
    [SpecCode] [varchar](6) NULL,
    [ClrUPorDiscAmt] money NULL, [SpecUPorDiscAmt] money NULL,
    [ncGLCode] [varchar](10) NULL, [lPrice] money Null
    ) ON [PRIMARY]
    --insert into below is failing. Says fields don't match----Msg 213, Level 16, State 1, Line 33
    --Insert Error: Column name or number of supplied values does not match table definition.
    --but. . . I think I have 7 fields and I think the datatypes match?
    INSERT INTO #tmpNCGLItems1
    SELECT ordLine, ClrCode, SpecCode, 0 as [ClrUPorDiscAmt], 0 as [SpecUPorDiscAmt], ncGLCode,
    SUM(od.lextendprice) as lPrice
    FROM #tmpNCGLItems tmp JOIN OODETL od on tmp.OrdLine = od.lline
    WHERE od.lorder = @OrderNo
    GROUP BY ordLine, ClrCode, SpecCode, NcGLCode

    >> I should remember this but . . . bug with T-SQL  using Insert Into  on a temp table.  It is unhappy with fields [sic] I'm trying to insert. It's probably the fact that I'm trying to using some default data w/ aliases for a couple
    of the fields [sic: columns are not fields]. <<
    Temp tables are how a bad programmer fakes a scratch tape so his SQL can look like magnetic tape files. We do not like to materialize data  on the disk unless we have to. 
    And data element do not change names from table to table in a schema! Get rid of the aliases, even tho they are closer to ISO-11179 than the base table crap. 
    But you are an old FORTRAN programmer! Your "OODETL” is six uppercase letters as required by FORTRAN I; an SQL programmer would have used something like “Order_Details” instead. The mix of camelCase, FORTRAN and several other non-SQL languages is scary. 
    Why did you use MONEY? It is not portable and the math is wrong. Google it! Why do you think that “<something>_code_id” makes any sense? A data element can be a “<something>_code” or a “<something>_id” but never that hybrid disaster. 
    I would do this with VIEWs so that I know the data is always current. 
    CREATE VIEW NC_GL_Items (..)
    AS 
    SELECT DISTINCT OD.l_line, OD.ldr_color, OD.ldr_spec,
           AD.addon_mod_gl_acct  
      FROM Oodetl AS OD,
           Addon_Master AS AD
     WHERE ..;
    The SELECT DISTINCT should not be there. An account should not be NULL, etc. Why do you have more nulls in one table than entire accounting systems? Why do you set integer zero to an amount, which should be a decimal for money? 
    This is a crazy quilt that is clearly a bitch to maintain or even read. Can you clean it up or are you screwed? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Multi-table mapping is not inserting into the primary table first.

    I have an inheritance mapping where the children are mapped to the parent table oids with the "Multi-Table Info" tab.
    One of children is not inserting properly. Its insert is attempting to insert into one of the tables from the "Additional Tables" of "Multi-Table Info" instead of the primary table that it is mapped to.
    The other children insert correctly. This child is not much different from those.
    I looked through the forums, but found nothing similiar.

    I would expect the Children to be inserted into both the primary table and the Additional Table? Is the object in question inserted into the primary table at all? Is the problem that it is being inserted into the Additional Table first? If it is, are the primary key names different? Is it a foreign key relationship?
    If the object in question has no fields in the additional table is it mapped to the additional table? (it should not be)
    Perhaps providing the deployment XML will help determine the problem,
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Trigger on Insert into a custom table from external application

    This is the problem I am facing.
    External Application using a different schema lets say extdb on a different server. This writes into a table in a schema called appscustom schema. Appscustom schema is under Oracle Apps.
    A trigger in Oracle Apps to be executed on insert into the appscustom schema table.
    This trigger inturn will run a concurrent job to create the invoice and gl interface tables.
    THe problem I am facing is, The trigger get executed but the concurrent job does not get triggered/run.
    Here is the trigger. Let me know, what might be wrong.
    THe values for vRESP_APPL_Id,vRESP_ID, vUSER_ID becomes null in the test_pims table.
    Whereas when I manually insert from backend into appscustom schema table the concurrent job gets submitted.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~
    -- Start of DDL Script for Trigger APPS.RWJF_PIMS_ORACLE_INT
    -- Generated 5/25/2005 22:10:52 from APPS@HENRY_DEVL
    CREATE OR REPLACE TRIGGER rwjf_pims_oracle_int
    AFTER
    INSERT
    ON rwjf_pimstxnbatch
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    WHEN (new.status = 'U' )
    Declare
    ReturnCode BOOLEAN;
    ConcReqID NUMBER := 0;
    vRESP_APPL_ID NUMBER;
    vRESP_ID NUMBER;
    vUSER_ID NUMBER;
    LoadToAp NUMBER :=0;
    LoadToGl NUMBER :=0;
    Begin
    -- vRESP_APPL_ID := apps.fnd_profile.value(200); -- AP --('RESP_APPL_ID');
    -- vRESP_ID := apps.fnd_profile.value(20639); -- 20639 for payables mgr. for rwjf_payables Mgr (50001); --('RESP_ID');
    -- vUSER_ID := apps.fnd_profile.value(1247); -- 1247 for sury 1065 for interface -- ('USER_ID');
    LoadToAp := 0;
    SELECT COUNT(*)
    INTO LoadToAp
    FROM rwjf.RWJF_PimsTxnBatchDtl
    WHERE GL_OR_AP = 'A'
    AND pims_txn_batch_id = :NEW.Pims_Txn_Batch_id;
    LoadToGl := 0;
    SELECT COUNT(*)
    INTO LoadToGl
    FROM rwjf.RWJF_PimsTxnBatchDtl
    WHERE GL_OR_AP = 'G'
    AND pims_txn_batch_id = :NEW.Pims_Txn_Batch_id;
    IF LoadToAp > 0 THEN
    vRESP_APPL_ID := 200; -- Application Id 200 Account payables
    vRESP_ID := 50001; -- RWJF_Payables Mgr for user interface
    vUSER_ID := 1065; -- user id for user name interface
    apps.fnd_global.apps_initialize(vUSER_ID,vRESP_ID,vRESP_APPL_ID);
    ConcReqID := 0;
    ReturnCode := FND_REQUEST.SET_MODE(TRUE);
    ConcReqID := FND_REQUEST.SUBMIT_REQUEST('RWJF',
    'RWJF_PIMS_INT',
    '', '', FALSE,
    :NEW.Pims_Txn_Batch_id,'AP', chr(0),
    END IF;
    IF LoadToGl > 0 THEN
    vRESP_APPL_ID := 20003;
    vRESP_ID := 50003;
    vUSER_ID := 1065;
    apps.fnd_global.apps_initialize(vUSER_ID,vRESP_ID,vRESP_APPL_ID);
    ConcReqID := 0;
    ReturnCode := FND_REQUEST.SET_MODE(TRUE);
    ConcReqID := FND_REQUEST.SUBMIT_REQUEST('RWJF',
    'RWJF_PIMS_INT',
    '', '', FALSE,
    :NEW.Pims_Txn_Batch_id,'GL',chr(0),
    END IF;
    insert into test_pims
    values
    ('Test3',:New.Pims_Txn_Batch_id,vUSER_ID,vRESP_ID,vRESP_APPL_ID);
    insert into test_pims
    values
    ('Test3',ConcReqID,vUSER_ID,vRESP_ID,vRESP_APPL_ID);
    IF ConcReqID = 0 THEN
    DBMS_OUTPUT.PUT_LINE('Problem Submitting Program to get pims txn batch'); /* Handle Error */
    END IF;
    End;
    -- End of DDL Script for Trigger APPS.RWJF_PIMS_ORACLE_INT

    don't quite understand the structure of your tables but it sounds similiar to a merge statement.
    (contiditonally insert, update records depending on whether or not corresponding records exist)
    create table custom_table
    (cust_no number,
    line_no number,
    party_id number
    create table hz_parties
    as (
    select 1 party_id, 'A' bill_to_location, 10 cust_no, 100 line_no from dual union
    select 2, 'B', 20, 200 from dual union
    select 3, 'C', 30, 300 from dual union
    select 4, 'D', 40, 400 from dual
    merge into custom_table t1
    using (select * from hz_parties) t2
    on (t1.party_id = t2.party_id)
    when not matched then insert (t1.cust_no, t1.line_no, t1.party_id)
    values (t2.cust_no, t2.line_no, t2.party_id);
    Edited by: pollywog on Mar 5, 2010 6:52 AM

Maybe you are looking for

  • I just want my music back.

    Allllright. So iTunes has been deleting my library every time I open it, and I'd really like to have my music back. So I went to bestbuy last night and bought Tunes Plus (I was assured that this would work), and of course..it doesn't. My problem is t

  • I'm going to Europe in a week and have some questions about charging my computer.

    I'm going to Europe in a week. I know there is a built in power thing or something but do I have to change a setting on my computer or will it adjust automatically? And what kind of converter do I need to charge it/plug it in? Will the same one work

  • Canon iR7105, iR-ADV9065 with GX300 server, and Mountain Lion

    I am having no luck setting up two relatively recent, large and expensive Canon printers in Mountain Lion. The situations are different so there are two chapters to this wall of text. This is a fresh Mac, so it didn't have any 'old' Canon driver tras

  • PMS on SAP 4.7

    Hi, I am putting this query after searching everywhere. I may have miss on links then please excuse. I am looking for the Pros & Cons of using PMS (Performance Management System) on SAP Version 4.7. Please advice. Thanks, Amit Khare

  • Create a view problem on nested tables

    I have a table which has a column of nested table: create table Person ( id NUMBER(10), --primary key attr1 varchar2(10), attr2 varchar2(10), kids KIDS_NT --KIDS_NT is a nested table of object --which has two columns: name, age. ) nested table store