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

doubt regarding key value in read stmt

Former Member
0 Likes
1,721

Hi,

READ TABLE 

it_vbrp_arch  INTO wa_vbrp_arch WITH  KEY vbeln = ibil_doc_data-docno

                                                            posnr 
= ibil_doc_data-posnr.

in above stmt i am reading data into table it_vbrp_arch with key values.my doubt is ,is vbeln in key points to it_vbrp_arch-vbeln  or vbrp-vbeln

Moderator Message: Read the F1 help or the online SAP documentation before posting your question.

Message was edited by: Suhas Saha

Hi,

READ TABLE 

it_vbrp_arch  INTO wa_vbrp_arch WITH  KEY vbeln = ibil_doc_data-docno

                                                            posnr 
= ibil_doc_data-posnr.

in above stmt i am reading data into table it_vbrp_arch with key values.my doubt is ,is vbeln in key points to it_vbrp_arch-vbeln  or vbrp-vbeln

Moderator Message: Read the F1 help or the online SAP documentation before posting your question.

Message was edited by: Suhas Saha

10 REPLIES 10
Read only

Former Member
0 Likes
1,678

Hi Krishna,

You are reading values FROM table it_vbrp_arch into the work area wa_vbrp_arch and the Key vbeln refers to the vbeln of the table it_vbrp_arch.

Another point I would like to add is, in order to improve read performance on this table, you can first sort table it_vbrp_arch and then read binary search while reading as below:

SORT it_vbrp_arch by vbeln posnr. (This statement sorts it by vbeln first and then posnr within the vbelns in ascending order as default. This sort should be kept outside the loop).

READ TABLE it_vbrp_arch INTO wa_vbrp_arch WITH KEY vbeln = ibil_doc_data-docno

                                                                                     posnr = ibil_doc_data-posnr

                                                                                     BINARY SEARCH.

You can read some online documents for such queries.

Read only

Former Member
0 Likes
1,678

Hi,

It can be it_vbrp_arc-vbeln  as compared to the other value. Its always good to use it or wa. If it doesn't work, can you please send the elaborated code?

Regards

Purnand

Read only

Former Member
0 Likes
1,678

krishna sree wrote:

Hi,

READ TABLE 

it_vbrp_arch  INTO wa_vbrp_arch WITH  KEY vbeln = ibil_doc_data-docno

                                                            posnr 
= ibil_doc_data-posnr.

in above stmt i am reading data into table it_vbrp_arch with key values.my doubt is ,is vbeln in key points to it_vbrp_arch-vbeln  or vbrp-vbeln

I hope it_vbrp_arch is standard table of VBRP.So it_vbrp_arch-vbeln refers to it_vbrp_arch(i.e VRBP-VBELN).

Thanks

Katrice

Read only

Former Member
0 Likes
1,678

Hi Krishna,

       you can refer to it_vbrp_arch-vbeln instead of directly referring it as vbeln..

       and also sort the internal table before you read and delete adjacent duplicates.

      after read statement use sy-subrc check statement..

for ex..

    
SORT it2 BY lifnr.

       DELETE ADJACENT DUPLICATES FROM it2 COMPARING lifnr.

       LOOP AT it1 INTO wa1.

         READ TABLE it2 INTO wa2 WITH KEY wa1-lifnr BINARY SEARCH.

         IF sy-subrc IS INITIAL.

           MESSAGE 'There is PO for this Vendor' TYPE 'I'.

         ELSE.

           MOVE wa1 TO wa.

           APPEND wa TO it.

this is sample code..

Read only

0 Likes
1,678

hi, when i am trying to refer using it_vbrp_arch-vbeln,it s throwing an error like no component exits with the name it_vbrp_arch-vbeln.,nw my doubt is cleared by ur replies ,thank q all

Read only

0 Likes
1,678

Hi Krishna,

        if you want to refer that field means that field should present in the structure for the internal table..

     otherwise it will throw u error as unknown component..

Thanks

Pavan.

Read only

0 Likes
1,678

if it1 and it2 r same ,can we write the read stmt without loop  to read the table itab in to wa.

Read only

0 Likes
1,678

Hello Krishna,

You can also use field symbol.

For example:

   DATA : lt_vbrp TYPE STANDARD TABLE OF vbrp.
FIELD-SYMBOLS <fs_vbrp> TYPE any .

SELECT * FROM vbrp INTO TABLE lt_vbrp.

   SORT lt_vbrp BY vbeln .
DELETE ADJACENT DUPLICATES FROM lt_vbrp COMPARING ALL FIELDS.


READ TABLE lt_vbrp INTO <fs_vbrp> WITH KEY vbeln = ___.

If <fs_vbrp> is assigned.

__________________

endif.

Katrice

Read only

0 Likes
1,678

Hi Krishna,

If there is more than 1 record, you have to use loop.

Regards

Purnand

Read only

0 Likes
1,678

Hi Krishna,

One suggestion from my side, try to use wa instead of it. Its more efficient.

Regards

Purnand