More problems storing a passed table to a class.

Yesterday I posted a question regarding the need to pass an internal table to a class, have the class 'store' the table so any method in the class could then access the data.
I had loads of help and got this reply which work well
Unofrtuantely I cannot seem to loop through the table to get the data eg in the normal way
table = internal_table.
wa_table like line of table.
loop at table into wa_table.
   write wa_table-field1.
   write wa_table-field2.
   write wa_table-field3.
endloop.
Also I will I think also need to pass this table into salv class, as I understand it is at the moment a pointer to a table?
I am a little lost as to why the TYPE ANY TABLE cannot be used on the DATA command, this would from what I have seen solve so many problems and reduce the amount of code 10 fold. Does anyone think or know if SAP will implement this or realse a patch to update OO?
Sorry for the silly questions, but I have onlly be coding ABAP for a week or so and coming from a python and C((+)) ABAP types are quite limiting..
CLASS lcl_some_class DEFINITION.
  PUBLIC SECTION.
    DATA mdo_table_object TYPE REF TO data.
    METHODS:  constructor
                IMPORTING it_table TYPE STANDARD TABLE,
              some_method.
ENDCLASS.                    "lcl_some_class DEFINITION
CLASS lcl_some_class IMPLEMENTATION.
  METHOD constructor.
    FIELD-SYMBOLS <gt_table> TYPE ANY TABLE.
    CREATE DATA me->mdo_table_object LIKE it_table.
    ASSIGN me->mdo_table_object->* TO <gt_table>.
    <gt_table> = it_table.
  ENDMETHOD.                    "constructor
  METHOD some_method.
    DATA ldo_line_object TYPE REF TO data.
    DATA lo_struct_descr TYPE REF TO cl_abap_structdescr.
    FIELD-SYMBOLS <lt_table> TYPE ANY TABLE.
    FIELD-SYMBOLS <comp_wa>  TYPE abap_compdescr.
    ASSIGN me->mdo_table_object->* TO <lt_table>.
    CREATE DATA ldo_line_object LIKE LINE OF <lt_table>.
    lo_struct_descr ?= cl_abap_typedescr=>describe_by_data_ref( ldo_line_object ).
    LOOP AT lo_struct_descr->components ASSIGNING <comp_wa>.
      WRITE: / <comp_wa>-name, <comp_wa>-type_kind,
               <comp_wa>-length, <comp_wa>-decimals.
    ENDLOOP.
    ULINE.
  ENDMETHOD.                    "some_method
ENDCLASS.                    "lcl_some_class IMPLEMENTATION
TYPES: BEGIN OF type_eina,
        infnr TYPE infnr,
        matnr TYPE matnr,
        lifnr TYPE lifnr,
       END OF type_eina.
TYPES: BEGIN OF type_mara,
        matnr TYPE matnr,
        ersda TYPE ersda,
        ernam TYPE ernam,
       END OF type_mara.
DATA gt_eina TYPE STANDARD TABLE OF type_eina.
DATA gt_mara TYPE STANDARD TABLE OF type_mara.
DATA go_object_of_some_class TYPE REF TO lcl_some_class.
START-OF-SELECTION.
  SELECT infnr matnr lifnr
    FROM eina
    INTO TABLE gt_eina
    UP TO 10 ROWS.
  SELECT matnr ersda ernam
    FROM mara
    INTO TABLE gt_mara
    UP TO 20 ROWS.
  CREATE OBJECT go_object_of_some_class
    EXPORTING
      it_table = gt_eina.
  go_object_of_some_class->some_method( ).
  CREATE OBJECT go_object_of_some_class
    EXPORTING
      it_table = gt_mara.
  go_object_of_some_class->some_method( ).
Cheers again for all your help
Ian
PS (please dont get me wrong I am not knocking ABAP, I know with any language there is a learning curve, and I have seen so nice tools that other languages do not provide, and the speed of creating apps is real quick)

Hi Ian,
change implementation of method "some_method" according to the following code:
METHOD some_method.
    DATA ldo_line_object TYPE REF TO data.
    DATA lo_struct_descr TYPE REF TO cl_abap_structdescr.
    FIELD-SYMBOLS <lt_table> TYPE ANY TABLE.
    FIELD-SYMBOLS <ls_line>  TYPE ANY.
    FIELD-SYMBOLS <ld_comp>  TYPE ANY.
    FIELD-SYMBOLS <comp_wa>  TYPE abap_compdescr.
    ASSIGN me->mdo_table_object->* TO <lt_table>.
    CREATE DATA ldo_line_object LIKE LINE OF <lt_table>.
    ASSIGN ldo_line_object->* TO <ls_line>.
    lo_struct_descr ?= cl_abap_typedescr=>describe_by_data_ref( ldo_line_object ).
* Create header
    LOOP AT lo_struct_descr->components ASSIGNING <comp_wa>.
      WRITE: <comp_wa>-name.
    ENDLOOP.
    NEW-LINE.
* value output
    LOOP AT <lt_table> ASSIGNING <ls_line>.
      DO.
        ASSIGN COMPONENT sy-index OF STRUCTURE <ls_line> TO <ld_comp>.
        IF sy-subrc = 0.
          WRITE <ld_comp>.
        ELSE.
          NEW-LINE.
          EXIT.
        ENDIF.
      ENDDO.
    ENDLOOP.
    ULINE.
  ENDMETHOD.                    "some_method
( Using markup for code, really helps reading code... )
Kind Regards
REA
Edited by: Ramy El-Arnaouty on Apr 15, 2011 10:55 AM

Similar Messages

  • Passing Table Name to Stored Procedure for From Clause

    Is it possible to pass a table name to a stored procedure to be used in the From clause? I have the same task to perform with numerous tables and I'd like to use the same SP and just pass the table name in. Something like this:
    =======================================
    CREATE OR REPLACE PROCEDURE SP_TEST(
    in_TABLE IN VARCHAR2,
    AS
    V_TABLE VARCHAR2(10);
    BEGIN
    V_TABLE := 'st_' || in_TABLE; -- in_TABLE is 2-3 character string
    SELECT some_columns
    INTO some_variables
    FROM V_TABLE
    WHERE some_conditions...;
    END;
    =======================================
    I'm also using the passed table name to assign to variables in the Select and Where clauses. What I'm getting is an error that V_TABLE must be declared. When I hard code the table name, I don't get any errors, even though I'm also using the same method to assign values in the Select and Where clauses.
    Thanks,
    Ed Holloman

    You need to use dynamic SQL whenever you are swapping out object names (tables, columns).
    create or replace procedure sp_test
      (in_table in varchar2)
    is
      -- variables
    begin
      execute immediate 'select a, b, c from st_' || in_table || ' where x = :xval and y = :yval'
         into v_a, v_b, v_c using v_x, v_y;
    end;

  • Is it possible to pass TABLE as the output parameter in stored procedure

    Hey Experts,
      Is it possible to pass TABLE as the output parameter in stored procedure.
    eg
    create procedure spGetData
    @tableName as TABLE(intValue INT NOT NUL)
    as 

    You can use OPENQUERY or OPENROWSET, as mentioned above, to make stored procedure results table like. There are
    some limitations with these methods:
    http://technet.microsoft.com/en-us/library/ms188427.aspx
    In OPENQUERY this-sql-server-instance can be used instead of a linked server name. It requires setting data accces server option:
    exec sp_serveroption @server = 'PRODSVR\SQL2012'
    ,@optname = 'DATA ACCESS'
    ,@optvalue = 'TRUE'
    LINK: http://www.sqlusa.com/bestpractices/select-into/
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Passing table to web service - using javascript

    Hi All,
    I need to pass table structure to web service using data connection.
    I dont know how to accesss the request node and create table and pass data to it.
    Request you all to help me to achievev this functionality.
    A long needs to split of 50 characters each. Then create a new instance for request node table structure assign the values.
    All this needs to be done using CODE i.e javasript
    how to do this ???
    Regards,
    Aditya Deshpande

    HIi,
    Let me explain the scenario once more:
    Scenario:
    Pdf has two Text edit field and one button. Where the end user would enter the values.
    The PDF is integrated with Web service for Offline scneario.
    Field 1 is a notification number.
    Field 2 is description - unlimited entry into PDF.
    Button: is used to execute the web service.
    It is done using the blog:
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=(J2EE3417700)ID0394564950DB01118597046218481719End?blog=/pub/wlg/7588
    Field1 is mapped to corresponding field in web service by IMPORT/EXPORT bindings.
    Problem:
    Field 2 is a text field. But this data has to be passed to web service as table. The web service has a table structure.
    Hence the text in the Field 2 has to be split into 100 characters each and set into table rows.
    The Strucutre definition in the data connection is:
    - Item
            - TDFORMAT
            - TDLINE
    Since I need to split the text and load.I felt this needs to be done using code ( script ).
    I do NOT know how to do it using CODE. Please help ME!!!!!!!!
    If there any other way please let me know. I am also not sure which would be best way of doing it.
    PLEASE HELP ME!!!
    Regards,
    Aditya Deshpande.

  • Problem in data passing to backend

    Hi All ,
         I  have one problem related to passing the data from web dynpro to ABAP .
    I am using two bapis(Suppose Bapi A,and Bapi B) in one component having one model .
    Output of One bapi is the input of other ....
    like BAPI A has output in one table ,say BAPIA_OUTPUT table .
    From this node(table BAPIA_OUTPUT ) i am copying the data to the input data node(table) for other BAPI B say BAPIB_INPUT (this is through coding ), these two are of same structure.
    when i take a table UI , i can c the data came in table properly , but while executing  BAPI B, its concatenating the last two structure.
    whereas  i can clearly see the data coming in different fields  of the table . when i debug and see, at the very first step , input table has its last two fields concatenated . there is no code for concatenation on frond end side .
    Please let me know what might be the problem .
    Thanks
    Dipti

    Dipti,
    Could you be more concrete?
    <i>From this node(table BAPIA_OUTPUT ) i am copying the data to the input data node(table) for other BAPI B say BAPIB_INPUT (this is through coding ), these two are of same structure</i>
    1. Do you copy attributes manually?
    2. Do you use WDCopyService?
    3. Do you just create another node with model object from first one (the best option, I guess)?
    So what "copy" method do you use? Could you show your code?
    <i>but while executing BAPI B, its concatenating the last two structure. whereas i can clearly see the data coming in different fields of the table</i>
    Quite hard to understand. Could you provide some sample input data, and some "concatenated" erroneous result?
    Valery Silaev
    EPAM Systems
    http://www.NetWeaverTeam.com

  • Problem with checkbox on table component

    Hello i am having a problem with checkbox in table component
    i am developing something like a shopping cart app and i have a checkbox in my table component , i want users to select items from the checkbox to add to thier cart, They can select the items from cartegory combobox , my problem is when they select the items from the checkbox if they select another category the alread selected once do not display in my collection opbject please how can i maintain the state of the already selected items in my collection object

    Hi,
    Please go through the tutorial "Understanding scope and managed beans". This is available at:
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/scopes.html
    The details of the selected items need to be stored in an object that is in session scope.
    Hope this helps
    Cheers
    Girish

  • Passing TABLE NAME as parameter is possible or not?

    I want develop a small/simple report like this
    TABLE NAME :
    WHERE :
    ORDER BY :
    QUERY ROWS
    In the above model i want to pass all the three (TABLE NAME,WHERE and ORDER BY) as a parameter.
    My doubt, is that possible to pass TABLE NAME as a parameter? If so!
    When i enter any TABLE NAME it has to fetch me out the records of that table (Based on WHERE condition and ORDER BY).
    Is that possible to do?
    Need some help!
    Edited by: Muthukumar Seshadri on Aug 10, 2012 6:19 PM

    Yes, it is possible with lexical parameters. Look in the help for examples:
    SELECT Clause
    SELECT &P_ENAME NAME, &P_EMPNO ENO, &P_JOB ROLE  FROM EMP
    P_ENAME, P_EMPNO, and P_JOB can be used to change the columns selected at runtime.  For example, you could enter DEPTNO as the value for P_EMPNO on the Runtime Parameter Form. 
    Note that in this case, you should use aliases for your columns.  Otherwise, if you change the columns selected at runtime, the column names in the SELECT list will not match the Report Builder columns and the report will not run.
    FROM Clause
    SELECT ORDID, TOTAL FROM &ATABLE
    ATABLE can be used to change the table from which columns are selected at runtime.  For example, you could enter ORD for ATABLE at runtime. 
    If you dynamically change the table name in this way, you may also want to use lexical references for the SELECT clause (look at the previous example) in case the column names differ between tables.
    WHERE Clause
    SELECT ORDID, TOTAL FROM ORD WHERE &CUST
    ORDER BY Clause
    SELECT ORDID, SHIPDATE, ORDERDATE, TOTAL  FROM ORD ORDER BY &SORT You have to be really careful with this approach. Dynamic SQL may cause serious performance problems.
    Edited by: InoL on Aug 10, 2012 10:06 AM

  • Pass table name as parameter in prepared Statement

    Can I pass table name as parameter in prepared Statement
    for example
    select * from ? where name =?
    when i use setString method for passing parameters this method append single colon before and after of this parameter but table name should be send with out colon as SQL Spec.
    I have another way to make sql query in programing but i have a case where i have limitation of that thing so please tell me is it possible with prepared Statment SetXXx methods or not ?
    Thanks
    Haroon Idrees.

    haroonob wrote:
    I know ? is use for data only my question is this way to pass table name as parameterI assume you mean "how can I do it?" As I have already answered "is this the way?" with no.
    Well, I would say (ugly as it is) String concatenation, or stored procedures.

  • Problem with entity passed as argument

    Hello !
    I have this code :
    Public Class myclass
    Private cont As MyentEntities
    Public Sub New( ByRef cnx As MyentEntities)
    cont = cnx
    End Sub
    Public Sub test
    If cont.mytable1.Count=1 then
    end if
    End Sub
    End class
    'On my main form :
    Dim E1 as MyEntEntities
    Dim m1 as myclass
    Private Sub MainForm_Load(sender As System.Object, e As System.EventArgs) Handles Me.Load
    E1=New MyentEntities
    m1=new MyClass(E1)
    End Sub
    Private sub fill_entity
    E1.MyTable1.Tolist
    End sub
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    m1.test
    End Sub
    When I click the button , I get an error :
    ....the entity of type 'MyTable1'  does not exist in the context.
    But I passed E1 with ByRef ?
    What's wrong ?
    Thank you !

    Hello,
    >>Problem with entity passed as argument
    With your provided code, I tested with my database, it is ok, below is the test demo which is similar with yours except the used databse:
    Public Class Form1
    Dim E1 As DFDBEntities
    Dim m1 As TestClass
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    E1 = New DFDBEntities
    m1 = New TestClass(E1)
    End Sub
    Private Sub fill_entity()
    E1.Orders.Tolist()
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    m1.test()
    End Sub
    End Class
    Public Class TestClass
    Private cont As DFDBEntities
    Public Sub New(ByRef cnx As DFDBEntities)
    cont = cnx
    End Sub
    Public Sub test()
    If cont.Orders.Count = 1 Then
    End If
    End Sub
    End Class
    Since we do not know your exact table structure, it is hard to know why this exception is thrown in your side, one reason I know is the .edmx file is not mapped correctly, you could check this link which describes various possibilities for the
    caused reason of this exception:
    http://stackoverflow.com/questions/5634392/ef-4-1-code-first-error-the-entity-type-sometype-is-not-part-of-the-model-for
    Or you could provide information as what database you are using, the table you are working with and the Entity Framework version.
    Regards.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • PASSING TABLES AS PARAMETERS IN FOR ALL INSERT

    Hi All,
    I want to pass table as a parameter to perform update in dynamic sql....
    sample code:
    declare
    cur_tab1 is select * from tabl1;
    TYPE tables_bulk is TABLE OF table2.source_table%TYPE;
    v_tables_bulk tables_bulk;
    ls_exe varchar2(2000);
    begin
    for i in cur_tab1 loop
    select source_table bulk collect into v_tables_bulk from table2 where table_id =i.col1
    forall i in 1..v_tables_bulk.count
    ls_exe :='update '|| v_tables_bulk(i) || set bulk_col1|| =i.col2'
    end;
    code description :
    here source_table is a column in table 2..source table column contains many tables..I have to fecth that table and update it with conditions using cursor.Also for select condition , we will get more than one value (more tables)..so i used bulk collect instead of normal variable.......i get local collection error..please help me out..

    user2639048 wrote:
    I did that but still it showed invalid sql....What is version of your database ?
    Some syntax works on newer versions, and is disallowed on older.
    Here is an example that works on Oracle 11g2
    -- create base table
    CREATE TABLE TAB AS
    SELECT TAB_ID,
           EMP_ID,
           'NAME ' || TAB_ID NAME,
           ROUND( DBMS_RANDOM.VALUE( 1, 1000 ), 2 ) SALARY
    FROM (
      SELECT ROUND( DBMS_RANDOM.VALUE(1,20)) TAB_ID,
             LEVEL EMP_ID
      FROM DUAL
      CONNECT BY LEVEL <= 100
    -- create child tables
    DECLARE
      X PLS_INTEGER;
    BEGIN
      SELECT MAX( TAB_ID ) INTO X
      FROM TAB;
      FOR I IN 1 .. X LOOP
         EXECUTE IMMEDIATE
            'CREATE TABLE TAB' || I ||
           q'{ AS SELECT * FROM TAB
               WHERE 1 = 0 }';
      END LOOP;
    END;
    CREATE OR REPLACE
    PACKAGE UPDATE_TAB IS
       TYPE TAB_TAB_TYP IS TABLE OF TAB%ROWTYPE;
       PROCEDURE UPDATE_TAB( I_TAB IN TAB_TAB_TYP );
       PROCEDURE TEST_UPDATE_TAB;
    END UPDATE_TAB;
    CREATE OR REPLACE
    PACKAGE BODY UPDATE_TAB AS
      PROCEDURE UPDATE_TAB( I_TAB IN TAB_TAB_TYP ) AS
      BEGIN
        FOR I IN I_TAB.FIRST .. I_TAB.LAST
        LOOP
            EXECUTE IMMEDIATE
                ' UPDATE TAB' || I_TAB(I).TAB_ID ||
                Q'{ SET TAB_ID = :TABID, NAME = :NAM, SALARY = :SAL
                    WHERE EMP_ID = :EMPID }'
            USING I_TAB(I).TAB_ID, I_TAB(I).NAME,
                    I_TAB(I).SALARY, I_TAB(I).EMP_ID;
            IF SQL%ROWCOUNT <= 0 THEN
                EXECUTE IMMEDIATE
                  ' INSERT INTO TAB' || I_TAB(I).TAB_ID ||
                  ' ( TAB_ID, EMP_ID, NAME, SALARY ) ' ||
                  ' VALUES( :TABID,  :EMPID, :NAME , :SAL )'
                USING I_TAB(I).TAB_ID, I_TAB(I).EMP_ID,
                      I_TAB(I).NAME, I_TAB(I).SALARY;
            END IF;
        END LOOP;
      END UPDATE_TAB;
       PROCEDURE TEST_UPDATE_TAB IS
         L_TAB TAB_TAB_TYP;
       BEGIN
          SELECT * BULK COLLECT INTO L_TAB
          FROM TAB;
          UPDATE_TAB( L_TAB );
       END;
    END UPDATE_TAB;
    --- TEST
    BEGIN
      UPDATE_TAB.TEST_UPDATE_TAB;
    END;
    SELECT * FROM TAB16;
    TAB_ID                 EMP_ID                 NAME                                          SALARY                
    16                     2                      NAME 16                                       455.86                
    16                     6                      NAME 16                                       253.18                
    16                     14                     NAME 16                                       478.92                
    16                     32                     NAME 16                                       381.27                
    16                     56                     NAME 16                                       737.77                
    16                     58                     NAME 16                                       382.65                
    16                     70                     NAME 16                                       203.03                
    16                     100                    NAME 16                                       435.73                
    8 rows selected
    SELECT * FROM TAB2;
    TAB_ID                 EMP_ID                 NAME                                          SALARY                
    2                      1                      NAME 2                                        737.91                
    2                      18                     NAME 2                                        35.61                 
    2                      22                     NAME 2                                        57.76                 
    2                      33                     NAME 2                                        851.72                
    2                      73                     NAME 2                                        109.74
    5 rows selected
    UPDATE TAB SET SALARY = 100
    WHERE TAB_ID = 2;
    5 rows updated
    BEGIN
      UPDATE_TAB.TEST_UPDATE_TAB;
    END;
    SELECT * FROM TAB2;
    TAB_ID                 EMP_ID                 NAME                                          SALARY                
    2                      1                      NAME 2                                        100                   
    2                      18                     NAME 2                                        100                   
    2                      22                     NAME 2                                        100                   
    2                      33                     NAME 2                                        100                   
    2                      73                     NAME 2                                        100    
    5 rows selected 

  • Passing table record to a function in a query

    I have a procedure which calls a function in a query which has 2 input parameters as shown below -
    select a.id, a.name, a.sal, check_xyz_func(a.id, a.sal) from employees a
    The function check_xyz_func retiurns varchar2.
    Now the requirement is that few more columns from the same table are needed as input to this function. So instead of giving all the column names,. can i pass the entire row as input to this function. Something like => check_xyz_func (a.*).
    I tried creating a type --> TYPE rec IS TABLE OF employees%ROWTYPE and passing rec to this function, but this isn't working.

    >
    And what should i pass as parameter when calling the function
    >
    I showed you what to pass. You should pass a variable that is declared as
    employee_rec employees%ROWTYPESo you would populate 'employee_rec' and pass it to the function.
    See the pipelined function code below that declares a variable of %ROWTYPE and does a fetch into it.
        l_rec  emp%rowtype;
          fetch emp_cv into l_rec;You would then pass 'l_rec' to your function.
    -- type to match emp record
    create or replace type emp_scalar_type as object
      (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)
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
    -- pipelined function
    create or replace function get_emp( p_deptno in number )
      return emp_table_type
      PIPELINED
      as
       TYPE EmpCurTyp IS REF CURSOR RETURN emp%ROWTYPE;
        emp_cv EmpCurTyp;
        l_rec  emp%rowtype;
      begin
        open emp_cv for select * from emp where deptno = p_deptno;
        loop
          fetch emp_cv into l_rec;
          exit when (emp_cv%notfound);
          pipe row( emp_scalar_type( l_rec.empno, LOWER(l_rec.ename),
              l_rec.job, l_rec.mgr, l_rec.hiredate, l_rec.sal, l_rec.comm, l_rec.deptno ) );
        end loop;
        return;
      end;
    select * from table(get_emp(20))

  • How to Display IMAGE BLOB stored in a table in a html region APEX

    Need to know how to display an image stored in a table in a HTML APEX Region.
    Please

    Hi
    Please explain what you mean by it doesn't work?
    Are there errors messages, at what point, how far did you get and exactly what did you do????
    Please provide more information.
    Thanks
    Ben

  • Problems with a hash table

    hi, i have a CountryTable class which i want to implement as a hash table:
    import java.util.*;
    class CountryTable {
         static int count = 0;
         private HashMap table = new HashMap();
         public void addEntry(Colour key, Country country) {
              table.put(key, country);
              count++;
         public Country getCountry(Colour key) {
              return (Country)table.get(key);
         static int getCount() {
              return count;
    The object which are returned from this table is Country:
    class Country {
         //static variables
         static int count = 0;
         //instance variables
         private String name;
         private Colour base;
         //constructor
         Country(String name, Colour base) {
              this.name = name;
              this.base = base;
              count++;
         //return the number of objects created
         static int getCount() {
              return count;
         //return the name
         public String getName() {
              return name;
         public Colour getColour() {
              return base;
    The key for the has table is the class Colour, which includes a hashCode() method:
    class Colour {
         public int rgb;
         Colour(int rgb) {
              this.rgb = rgb;
         public int hashCode() {
              return rgb * -1;
    I implement these classes in a program as follows:
    CountryTable index = new CountryTable();
              Colour colour1 = new Colour(-3473408);
              Country argentina = new Country("Argentina", colour1);
              index.addEntry(colour1, argentina);
              Colour colour2 = new Colour(-131072);
              Country brazil = new Country("Brazil", colour2);
              index.addEntry(colour2, brazil);
                        Colour col = new Colour(or);
                        Country coun = index.getCountry(col);
                        System.out.println(coun.getName());
    I have a list of many countries which i set up, with their relevant countires with which they are associated.
    The variable 'or' contains an RGB value which has been returned elsewhere in the program. The problem that i have is that when a colour is passed into the getCountry() method, nothing is returned and a "nullPointerException" is thrown, even though a colour with which i set up a country was passed in???
    Anyone got any ideas where im going wrong?
    Many thanks Cath

    keeping the other two files same you change the CountryTable to this
    import java.util.*;
    class CountryTable {
    static int count = 0;
    private HashMap table = new HashMap();
    public void addEntry(Colour key, Country country) {
    table.put(key.rgb+"" ,country.getName());
    count++;
    public String getCountry(Colour key) {
    return (String)table.get(key.rgb+"");
    static int getCount() {
    return count;
    public static void main (String args[]){
         CountryTable index = new CountryTable();
    Colour colour1 = new Colour(-3473408);
    Country argentina = new Country("Argentina",colour1);
    index.addEntry(colour1, argentina);
    Colour colour2 = new Colour(-131072);
    Country brazil = new Country("Brazil",colour2);
    index.addEntry(colour2, brazil);
    System.out.println(index.table);
    String coun = index.getCountry(colour2);
    System.out.println(coun);
    }and now try

  • How to pass tables in Guided Procedures from VC

    Hi experts!
    I'am working in a workflow scenario, more precisely an approve-reject workflow scenario.
    I've defined all the start and the end points belonging to the respective iviews (I mean the sender and the approver iviews), following the  [Modeling Visual Composer iViews for Guided Procedures|http://help.sap.com/saphelp_nw70/helpdata/en/44/429bbd709914bce10000000a155369/frameset.htm]
    and everything works ok if I pass input fields, data fields, or boolean fields.
    But I need to pass tables (In fact, I need to pass MORE THAN ONE table)....  Is that possible?
    How do I make it?
    Any help will be apprecieated and point-rewarded.
    Thanks in advance
    Best Regards,
    Marcelo
    P.S. I'm working on EP7 VC SP15

    Hi,
    If you'll create 2 iViews:
    1. Table connected to end point (all the fields are mapped and table selection mode is multiple)
    2. Table connected to start point with same fields.
    and create GP process for it, you'll find that selecting all the fields and passing them will result with all the selected fields appear in the 2nd iView.
    But, i don't know if you can pass the entire table automatically (without the user selecting all the records).
    Hope I helped,
    Shay

  • Passing internal tables to a class

    Hi All,
    I have a problem at the moment, I need to pass an internal table to a class
    The problem is that depending on user input one of two differnet tables will be passed.
    TYPES: BEGIN OF t_destination_structure,
              matnr        TYPE mbew-matnr,   
              swerk         TYPE mbew-bwkey,  
              sverpr        TYPE mbew-verpr,   
              speinh        TYPE mbew-peinh,  
              bwkey        TYPE mbew-bwkey,
              verpr          TYPE mbew-verpr,   
              peinh          TYPE mbew-peinh,  
              lbkum         TYPE mbew-lbkum,
              salk3          TYPE mbew-salk3,  
              new_verpr  TYPE mbew-verpr,
              new_salk3  TYPE mbew-salk3,
              bwtar           TYPE mbew-bwtar,   
              it_colours    TYPE lvc_t_scol,   
           END OF t_destination_structure.
    TYPES: BEGIN OF t_pur_org_structure,
              matnr         TYPE mbew-matnr,
              bwkey       TYPE mbew-bwkey,
              verpr          TYPE mbew-verpr,
              peinh         TYPE mbew-peinh,
              lbkum         TYPE mbew-lbkum,
              salk3          TYPE mbew-salk3,
              new_verpr  TYPE mbew-verpr,
              new_salk3  TYPE mbew-salk3,
              bwtar          TYPE mbew-bwtar,
              it_colours   TYPE lvc_t_scol,
               END OF t_pur_org_structure.
    DATA:       i_destination_structure     TYPE TABLE OF t_destination_structure,
                     i_pur_org_structure         TYPE TABLE OF t_pur_org_structure.
    PERFORM Output USING i_destination_structure 1.
    OR
    PERFORM Output USING i_pur_org_structure 2.
    " Output for def
    FORM Output USING fuw_PassedTable fuw_Output_Switch
    " assignment that I want to make o_EventHandle is already created
    o_EventHandle->li_destination_structure = fuw_PassedTable.
    " Class definition
    CLASS lcl_LocalEventHandler DEFINITION.
        PUBLIC SECTION.
            DATA: li_destination_structure TYPE REF TO data, ************************************************************************
                  lw_radio_choice TYPE string.
            METHODS: OnUserCommand FOR EVENT added_function OF cl_salv_events IMPORTING e_salv_function.
            " Applies the GLEP from a souce branch to selected branch(es) GELP
             " DATA: iPassedTable TYPE passedtable.
        PROTECTED SECTION.
        PRIVATE SECTION.
            METHODS: apply_change.
            METHODS: simulate_change.
    ENDCLASS.
    When run this produces the error cannot convert type H to I
    All I need is the attribute to be a generic tabe that will become the passed table type, this sort of thing shouldnt be rocket science but I am having real trouble in my TYPE assignment
    If anyone can help or maybe have some ideas in how I can do this that would be great
    Cheers
    Ian

    Hi,
    You have to create the tables dynamic. You can do this via CREATE DATA.. Also have a look at the RTTI classes.
    I have added an example. Pass the itab via importing parameter (TYPE ANY TABLE), create data like the imported table, assign a field-symbol to the created data and, if needed, move the data from the passed itab to the dynamic itab.
    REPORT  zz_dynamic_itab.
    CLASS lcl_sample DEFINITION DEFERRED.
    DATA lt_sflight     TYPE TABLE OF sflight.
    DATA lt_spfli        TYPE TABLE OF spfli.
    DATA lcl_sample  TYPE REF TO lcl_sample.
          CLASS lcl_sample DEFINITION
    CLASS lcl_sample DEFINITION.
      PUBLIC SECTION.
        METHODS
          create_itab_from_data IMPORTING it_table TYPE ANY TABLE.
    ENDCLASS.                    "lcl_sample DEFINITION
          CLASS lcl_sample IMPLEMENTATION
    CLASS lcl_sample IMPLEMENTATION.
      METHOD create_itab_from_data.
        DATA lr_table    TYPE REF TO data.
        DATA lr_wa_table TYPE REF TO data.
        FIELD-SYMBOLS <lt_table> TYPE ANY TABLE.        "Dynamic Table
        FIELD-SYMBOLS <ls_table> TYPE ANY.              "Dynamic WA of Table
      Create data object from your table
        CREATE DATA lr_table LIKE it_table.
      Create your itab.
        ASSIGN lr_table->* TO <lt_table>.
        <lt_table> = it_table.
      Create wa
        CREATE DATA lr_wa_table LIKE LINE OF <lt_table>.
        ASSIGN lr_wa_table->* TO <ls_table>.
      ENDMETHOD.                    "create_table_from_data
    ENDCLASS.                        "lcl_sample IMPLEMENTATION
    START-OF-SELECTION.
    Creates local class
      CREATE OBJECT lcl_sample.
    First table: sflight
      SELECT *
        FROM sflight
        INTO TABLE lt_sflight.
    Pass to class with method
      lcl_sample->create_itab_from_data( lt_sflight ).
    Second table: spfli
      SELECT *
      FROM spfli
      INTO TABLE lt_spfli.
    Pass to class with same method
      lcl_sample->create_itab_from_data( lt_spfli ).
    Cheers,
    Roelof

Maybe you are looking for

  • Adobe Photoshop Elements 2 and 'Save for Web' problem

    Hi everyone, I have used Photoshop Elements 2 for some time with absolutely no problems. However when I try to use the save for the web option I get an 'export could not be completed due to a program error' message. Nothing relevant is mentioned on A

  • The music in my iTunes library are out of order...***

    This new version of iTunes doesn't allow you to resort your music. The only music i can sort out are the music in the Purchased section of mu library but that does not automatically sort out music in my "Library". How the heck do you fix this? They a

  • Lost all apps and songs...

    On the same day, my computers hard drive crashed and my iphone4 stopped working.  I did a backup and restore of my iphone on a different computer.  When the restore took place, I lost all of my music and applications.  I logged into my itunes account

  • Firefox cannot load websites like Pandora

    I was listening to music on Pandora and it randomly stopped playing the song. When I tried to reload Pandora I get an error message that says "We're sorry but the site does not appear to be loading in your browser." It provides a link to a help page,

  • Thinking to use Oracle Linux

    Hello friends, I am used to work on MS Windows. Without a doubt we get a better performance if we use DB and OS from Oracle. What are basics of Oracle Linux I have to know to be able to install Oracle DB 11g SEO on Oracle Linux ??? Is it possible to