‎2008 Jul 02 4:32 PM
I have written the following logic but get the error:
E:Field "OBJVERS" unknown.
Code
DATA: lt_tab1 LIKE /BI0/Ptable OCCURS 0,
ls_tab1 LIKE LINE OF lt_tab1.
REFRESH lt_tab1.
SELECT field1
FROM /BI0/Ptable
INTO CORRESPONDING FIELDS OF TABLE lt_tab1
FOR ALL ENTRIES IN lt_another_table
WHERE field1 EQ lt_another_table-field1
AND OBJVERS EQ 'A'.
SORT lt_tab1 BY field1 ASCENDING.
OBJVER is a field in the table which stores the version of the record i.e. modified, active
Can someone advise on what I have done wrong? Thanks
‎2008 Jul 02 6:04 PM
Check out this code:
DATA: lt_tab1 type standard table of /BI0/Ptable initial size 0,
ls_tab1 type /BI0/Ptable.
REFRESH lt_tab1.
SELECT *
FROM /BI0/Ptable
INTO TABLE lt_tab1
FOR ALL ENTRIES IN lt_another_table
WHERE field1 EQ lt_another_table-field1
AND OBJVERS = 'A'.
if sy-subrc = 0.
SORT lt_tab1 BY field1 ASCENDING.
endif.
‎2008 Jul 02 4:34 PM
Check this:
SELECT field1
FROM /BI0/Ptable
INTO CORRESPONDING FIELDS OF TABLE lt_tab1
FOR ALL ENTRIES IN lt_another_table
WHERE field1 EQ lt_another_table-field1
AND /BI0/Ptable-OBJVER EQ 'A'
SORT lt_tab1 BY field1 ASCENDING.
Or, simply check the table /BI0/Ptable whether the field exists/misspelled?
Assign points, if this helps.
rgds,
Raghu.
Edited by: Raghuram Saripalli on Jul 2, 2008 9:07 PM
‎2008 Jul 02 4:36 PM
‎2008 Jul 02 4:59 PM
Thanks for this. I thought changing to /BI0/Ptable-OBJVERS EQ 'A' may have done the trick but still the same error.
You were write it was OBJVERS but I still get the error.
Is there anything wrong with the way I have defined:
DATA: lt_tab1 LIKE /BI0/Ptable OCCURS 0,
ls_tab1 LIKE LINE OF lt_tab1.
‎2008 Jul 02 5:04 PM
can U try declaring with occcurs 0 OR
types: xxx type /BI0/Ptable.
data: yyy type standard table of xxx..
Rgds,
Raghu.
‎2008 Jul 02 5:54 PM
Thanks I changed the logic and still get the same error. The changes that I made are
DATA: BEGIN OF ls_tab1,
field1 TYPE /BI0/Fireld1,
objvers TYPE RSOBJVERS,
END OF ls_tab1,
lt_tab1 LIKE TABLE OF ls_tab1.
‎2008 Jul 02 6:04 PM
Check out this code:
DATA: lt_tab1 type standard table of /BI0/Ptable initial size 0,
ls_tab1 type /BI0/Ptable.
REFRESH lt_tab1.
SELECT *
FROM /BI0/Ptable
INTO TABLE lt_tab1
FOR ALL ENTRIES IN lt_another_table
WHERE field1 EQ lt_another_table-field1
AND OBJVERS = 'A'.
if sy-subrc = 0.
SORT lt_tab1 BY field1 ASCENDING.
endif.
‎2008 Jul 02 6:54 PM
Thanks very much for this the code worked I made a slight modification in the SELECT to get the specific field that I was looking for.
In general:
1. What was I doing wrong?
2. When I declare the variable:
DATA: lt_tab1 type standard table of /BI0/Ptable initial size 0,
ls_tab1 type /BI0/Ptable.
Is there a way that I can reduce it so that it is only the one or two fields that I am interested in?
‎2008 Jul 02 7:41 PM
Hi Niten,
Please check this code...
DATA: BEGIN OF ls_tab1,
<fieldname1> LIKE /bi0/ptable-<fieldname>,
<fieldname2> LIKE /bi0/ptable-<fieldname>,
<fieldname3> LIKE /bi0/ptable-<fieldname>,
END OF ls_tab1,
lt_tab1 TYPE TABLE OF ls_tab1.
SELECT <fieldname1>
<fieldname2>
<fieldname3>
FROM /BI0/ptable
INTO TABLE lt_tab1
FOR ALL ENTRIES IN lt_another_table
WHERE field1 EQ lt_another_table-field1
AND objvers = 'A'.reward if helpful...
Best regards,
raam
‎2008 Jul 02 8:01 PM
Thanks for this. Is the advantage of this approach that I am only getting my 3 specific fields whereas with the original data declaration I am getting all the columns of each row of data?
‎2008 Jul 02 8:08 PM
Hi Niten,
Generally it is always advantageous to fetch the data which we require.
As you require only three fields so declare the table with only three fields as i declaired and also select the fields which are required.
By doing this u are decreasing the database access. As the database access decreases the performance of the program increases.
DATA: lt_tab1 type standard table of /BI0/Ptable initial size 0,
ls_tab1 type /BI0/Ptable.In the above table declaration all the fields of the table /BI0/Ptable are considered.
DATA: BEGIN OF ls_tab1,
<fieldname1> LIKE /bi0/ptable-<fieldname>,
<fieldname2> LIKE /bi0/ptable-<fieldname>,
<fieldname3> LIKE /bi0/ptable-<fieldname>,
END OF ls_tab1,
lt_tab1 TYPE TABLE OF ls_tab1.where as in this table declaration u are only considering the fields which you require.
Best regards,
raam