Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Iterate through a User Table

Former Member
0 Likes
481
  • SAP Managed Tags

Hi everyone, hope someone can help. I would like to run through the lines of a user table, once I have two values from a recordset. Let's say I have one record with Code=1 and U_MyValue=1 and another with Code=1 and U_MyValue=2. How can I fetch then every record from the user table in order to update it?

public IRecordset getRecordsetFromSQL( String sql ) {
    IRecordset rs = null;
    try {
        rs = SBOCOMUtil.newRecordset(getICompany());
        rs.doQuery(sql);
    } catch ( SBOCOMException e ) {
        e.printStackTrace();
    }
    return rs;
}


public void updateUserTable() {
      try {
        String sql = "SELECT Code, [U_MyValue] FROM [@MYTABLE]";
        IRecordset rs = getRecordsetFromSQL(sql);
        IUserTables iUserTables = iCompany.getUserTables();
        IUserTable iUserTable = iUserTables.item("MYTABLE");
        rs.moveFirst();
        while ( !rs.isEoF() ) {
            String key= rs.getFields().item("Code").getValue().toString();
            String myValue= rs.getFields().item("U_MyValue").getValue().toString();
            
           
         // HERE I DON'T KNOW HOW TO FETCH EVERY RECORD IN ORDER TO UPDATE IT
            iUserTable.update();

            rs.moveNext();
        }
    } catch ( Exception ex ) {
        System.out.println(iCompany.getLastError().getErrorMessage());
    } 

}

Thanks in advance.

Hi everyone, hope someone can help. I would like to run through the lines of a user table, once I have two values from a recordset. Let's say I have one record with Code=1 and U_MyValue=1 and another with Code=1 and U_MyValue=2. How can I fetch then every record from the user table in order to update it?

public IRecordset getRecordsetFromSQL( String sql ) {
    IRecordset rs = null;
    try {
        rs = SBOCOMUtil.newRecordset(getICompany());
        rs.doQuery(sql);
    } catch ( SBOCOMException e ) {
        e.printStackTrace();
    }
    return rs;
}


public void updateUserTable() {
      try {
        String sql = "SELECT Code, [U_MyValue] FROM [@MYTABLE]";
        IRecordset rs = getRecordsetFromSQL(sql);
        IUserTables iUserTables = iCompany.getUserTables();
        IUserTable iUserTable = iUserTables.item("MYTABLE");
        rs.moveFirst();
        while ( !rs.isEoF() ) {
            String key= rs.getFields().item("Code").getValue().toString();
            String myValue= rs.getFields().item("U_MyValue").getValue().toString();
            
           
         // HERE I DON'T KNOW HOW TO FETCH EVERY RECORD IN ORDER TO UPDATE IT
            iUserTable.update();

            rs.moveNext();
        }
    } catch ( Exception ex ) {
        System.out.println(iCompany.getLastError().getErrorMessage());
    } 

}

Thanks in advance.

0 REPLIES 0