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

Code help

Former Member
0 Likes
1,022

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
996

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.

10 REPLIES 10
Read only

Former Member
0 Likes
996

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

Read only

Former Member
0 Likes
996

is it OBJVER or OBJVERS

Read only

0 Likes
996

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.

Read only

0 Likes
996

can U try declaring with occcurs 0 OR

types: xxx type /BI0/Ptable.

data: yyy type standard table of xxx..

Rgds,

Raghu.

Read only

0 Likes
996

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.

Read only

Former Member
0 Likes
997

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.

Read only

0 Likes
996

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?

Read only

0 Likes
996

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

Read only

0 Likes
996

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?

Read only

0 Likes
996

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