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

Error in Select query

Former Member
0 Likes
1,077

Hi ,

In my select query

SELECT BELNR

           VBELN

           FKDAT

           NETWR

           BUKRS

           WAERK

           GJAHR

     from vbrk

          INTO TABLE it_vbrk

          where  vbeln in s_vbeln

           and gjahr in s_gjahr

           and fkdat in s_fkdat

           and bukrs = p_bukrs.

   IF not it_vbrk[] is INITIAL.

     SELECT vbeln

            volum

            voleh

            matnr

            arktx from vbrp

            INTO TABLE it_vbrp

       FOR ALL ENTRIES IN it_vbrk

        where vbeln = it_vbrk-vbeln.

   endif.

   IF NOT it_vbrk[] is INITIAL.

     SELECT BUKRS

           BELNR

           GJAHR

           BLART

           BLDAT

           XBLNR 

       from bkpf

       INTO TABLE it_bkpf

       FOR ALL ENTRIES IN it_vbrk

       where bukrs = it_vbrk-bukrs

       AND xblnr = it_vbrk-vbeln

       and bstat <> 'A'.

   ENDIF.


Getting error 'When you use the additional 'FOR ALL ENTRIES IN itab' the fields 'XBLNR'. and the 'IT_VBRK-VBELN' must have same type and same length'.


7 REPLIES 7
Read only

Arun_Prabhu_K
Active Contributor
0 Likes
980

Hello Meenakshi.

     I guess the error message is very clear.

     The data and data types should match.


IF NOT it_vbrk[] is INITIAL.

     SELECT BUKRS

           BELNR

           GJAHR

           BLART

           BLDAT

           XBLNR

       from bkpf

       INTO TABLE it_bkpf

       FOR ALL ENTRIES IN it_vbrk

       where bukrs = it_vbrk-bukrs

       AND xblnr = it_vbrk-vbeln

       and bstat <> 'A'.

ENDIF.

Regards.

Read only

0 Likes
980

Thanks for your reply......i find the length length of vbrk-vbeln is 20 and bkpf-xblnr is 16 only....may this might be the problem.....

Read only

0 Likes
980

Exactly.

Read only

0 Likes
980

But in my req they specified...

a.       Select BKPF based on VBRK like detailed below:

  • BKPF-BUKRS eq VBRK-BUKRS
  • BKPF-BSTAT NOT EQUAL ‘A’
  • BKPF-XBLNR eq VBRK-VBELN
Read only

0 Likes
980

Hi Meenakshi,

In the internal table it_vbrk, define an extra field like xblnr_t type bkpf-xblnr. After accessing the data through your first select statement, loop at that internal table with field symbol and copy the value of vbeln into xblnr_t upto 16 characters.

Now in third select statement, use like this,

     SELECT BUKRS

           BELNR

           GJAHR

           BLART

           BLDAT

           XBLNR

       from bkpf

       INTO TABLE it_bkpf

       FOR ALL ENTRIES IN it_vbrk

       where bukrs = it_vbrk-bukrs

       AND xblnr = it_vbrk-xblnr_t

       and bstat <> 'A'.

If you still get any problem, feel free to ask... I  also once got this situation but this is not your fault as this is sometimes the functional needs..

Regards

Dhananjay

Read only

matt
Active Contributor
0 Likes
980

It probably will work, but still suffers from the big flaw that it is using FOR ALL ENTRIES.

Read only

matt
Active Contributor
0 Likes
980

The really big problem with your program, and which would get it a fail if I were your reviewer, is that you are using FOR ALL ENTRIES. Please rewrite your select using INNER JOIN.