Application Development 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: 

Error in joining 3 internal tables

Former Member
0 Kudos

Hi,

Getting error while joing 3 internal tables

START-OF-SELECTION.

            SELECT belnr

                   vbeln

                   fkdat

                   netwr

                   bukrs from vbrk

                   INTO TABLE it_vbrk

*                  where bukrs in p_bukrs

                    where vbeln in s_vbeln

                    and gjahr in s_gjahr

                    and fkdat in s_fkdat.

             

              IF it_vbrk[] is INITIAL.

                SELECT vbeln

                       volum

*                      vloeh

                       matnr

                       arktx from vbrp

                       INTO TABLE it_vbrp

                  FOR ALL ENTRIES IN it_vbrk

                   where vbeln = it_vbrk-vbeln.

                  SELECT belnr

                         bschl

                         hkont from bseg

                      FOR ALL ENTRIES IN it_vbrk

                    WHERE belnr = it_vbrk-belnr.

              ENDIF.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos
  • Had you a good reason to not actually JOIN VBRK and VBRP in a single SELECT statement
  • Are you sure you want to extract items only if no header was read
  • Are you sure of the key used to access FI items BSEG (miss 2 important primary keys) so look at BKPF and fields AWTYP and AWREF (Look at source of FM AC_DOCUMENT_SENDER_VBRK to guess exact relation, you could also look at table TTYP for information between FI and original documents)

Regards,

Raymond

6 REPLIES 6

ThomasZloch
Active Contributor
0 Kudos

Try correcting the logic, so that it returns the expected result.

Thomas

anubhab
Active Participant
0 Kudos

Hello Meenakshi,

         I guess the code should be IF it_vbrk[] IS NOT INITIAL(Just before the 2nd SELECT statement).

And also you forgot to get the data into an internal table in the 3rd SELECT statement.

Regards,

Anubhab

narendar_naidu
Active Participant
0 Kudos

Hi,

1.first check your field sequence, the fields in the DB table and in

select query should be same.

2. check the where clause, try to use the indexes and also maintain sequences.

3. when using for all entries check ,whether ur driver table is empty or not.

eg: if it_vbrk is not initial.

     delete adjacent duplicates from it_vbrk.

now use for all entries.

endif.


regards,

ksourabh
Explorer
0 Kudos

Anubhab is correct.. you should either use IF NOT it_vbrk[] IS INITIAL or IF it_vbrk[] IS NOT INITIAL.

You are trying to fetch data for empty it_vbrk

raymond_giuseppi
Active Contributor
0 Kudos
  • Had you a good reason to not actually JOIN VBRK and VBRP in a single SELECT statement
  • Are you sure you want to extract items only if no header was read
  • Are you sure of the key used to access FI items BSEG (miss 2 important primary keys) so look at BKPF and fields AWTYP and AWREF (Look at source of FM AC_DOCUMENT_SENDER_VBRK to guess exact relation, you could also look at table TTYP for information between FI and original documents)

Regards,

Raymond

0 Kudos

Quite right. You should use inner join.