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

Read internal Table

Former Member
0 Likes
901

Hi,

I declared intrnal table with 4 fields and I filled the internal table with the data. I wnat to read the internal table using with 2 key fields. How can I do it thies.

If I am writing like below, its giving error.

'Read table i_vbrp WITH TABLE KEY

vbeln = i_sub_table-vbeln

posnr = i_sub_table-posnr.'

It is giving error like below

The declaration for the key field "VKBUR" is incomplete. However,"VKBUR" is is contained in the key of table "I_VBRP". and must be filled.

here VKBUR is also a internal table field.

Please give Idea, How can I resolve this problem.

Thanks & Regards

Venkat

9 REPLIES 9
Read only

Former Member
0 Likes
867

Hi Venkat,

Can you post the declaration of the internal table I_VBRP ?

Regards,

Anand Mandalika.

Read only

0 Likes
867

May be you can try this -

READ TABLE I_VBRP WITH KEY
VBELN = I_SUB_TABLE-VBELN
POSNR = I_SUB_TABLE-POSN.

Regards,

Anand Mandalika.

Read only

0 Likes
867

HI Anand Mandalika,

Its working fine.

If I want to chek non blank value like below

READ TABLE I_VBRP WITH KEY VBELN = I_SUB_TABLE-VBELN

POSNR = I_SUB_TABLE-posnr

VKGRP <> ''

VKBUR <> ''.

How can I do it this.

Thanks & Regards

Venkat

Read only

0 Likes
867

Hi Venkata,

You cannot do that in READ statement. But you can use that in your select statement so when you read your internal table, you are sure that you will not get any VKGRP and VKBUR that are blank.

Hope this helps...

P.S. Please award points if found useful.

Read only

Former Member
0 Likes
867

If you use TABLE kEY statment all fields of KEY must be used with the same order as declaration of the key!!

Read table i_vbrp WITH TABLE KEY

Vkbur = something

vbeln = i_sub_table-vbeln

posnr = i_sub_table-posnr.'

BR< JAcek

Read only

Former Member
0 Likes
867

hi venkat,

if u are using table key in reading that internal table,

then u need to pass all the keys of table.

if u want to read with only 2 keys then try this

'Read table i_vbrp WITH KEY

vbeln = i_sub_table-vbeln

posnr = i_sub_table-posnr.

u can use binary search also to improve performance but by sorting the table .

Read only

Former Member
0 Likes
867

Hi Venkat,

I am assuming you declared your table as sorted table, then it should be like this.


TYPES:Begin of type_vbrp,
      vbeln type vbeln_vf,
      posnr type posnr,
      vkbur type vkbur,
      meins type meins_d,
      End of type_vbrp.


TYPES : TYPE_VBRP_TBL  TYPE SORTED TABLE OF TYPE_VBRP
                             WITH UNIQUE KEY VBELN POSNR.

....
Read table i_vbrp WITH TABLE KEY
vbeln = i_sub_table-vbeln
posnr = i_sub_table-posnr 
    binary search.

Regards,

Raghav

Read only

aris_hidalgo
Contributor
0 Likes
867

Hi,

Change your READ statement as:

READ TABLE I_VBRP WITH KEY VBELN = I_SUB_TABLE-VBELN

POSNR = I_SUB_TABLE-POSNR.

You can use WITH TABLE KEY if you declared your itab as HASHED.

Regards!

P.S> Please award points for useful answers

Read only

Former Member
0 Likes
867

Instead of this 'Read table i_vbrp WITH TABLE KEY

you have to use 'Read table i_vbrp WITH KEY .

Regards

Abhishek