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

Please tell me the Three table INNER JOIN Sql statement

Former Member
0 Likes
909

Hi experts,

  I got requirement like by using INNER JOIN i have to write the code in MY program i.e using 3 tables VBAK VBAP and VBUK.And the common field is VBELN .SO please give the  INNER JOIN SQL statement for above three tables...

vbak-vbeln,erdat

vbap-vbeln,posnr

vbuk-vbeln,RFSTK

Thanks in Advance

5 REPLIES 5
Read only

Former Member
0 Likes
868

Hi,

select a~erdat b~posnr c~rfstk

  from vbak as a  join vbap as b on  a~vbeln = b~vbeln

                           join  vbuk as c on a~vbeln = c~vbeln

                  into corresponding fields of table itab

                  where vbeln in s_vbeln .

Read only

Former Member
0 Likes
868

select a~vbeln a~erdat b~posnr c~rfstk

from vbak as a inner join vpab as b on a~vbeln = b~vbeln

inner join vbuk as c on a~vbeln = c~vbeln

into table i_tab

where vbeln eq p_vbeln.

Read only

0 Likes
868

hi guglani  please see my total code b.caus DATA is not extracting...once see the code  correct error.

DATA:V_VBELN TYPE VBAK-VBELN.      "VBAK,VBAP AND VBUK

SELECT-OPTIONS SORDER FOR V_VBELN.

TYPES:BEGIN OF T_VBAK,

     VBELN TYPE VBELN_VA,

     ERDAT TYPE ERDAT,

  END OF T_VBAK.

TYPES:BEGIN OF T_VBAP,

       VBELN TYPE VBELN_VA,

        POSNR TYPE POSNR_VA,

  END OF T_VBAP.

TYPES:BEGIN OF T_VBUK,

    VBELN TYPE VBELN,

  RFSTK TYPE RFSTK,

  END OF T_VBUK.

TYPES:BEGIN OF FS,

   VBELN TYPE VBELN_VA,

     ERDAT TYPE ERDAT,

POSNR TYPE POSNR_VA,

  RFSTK TYPE RFSTK,

  END OF FS.

DATA:WA1 TYPE T_VBAK,

     WA2 TYPE T_VBAP,

     WA3 TYPE T_VBUK,

     WA TYPE FS.

DATA:ITAB1 TYPE TABLE OF T_VBAK,

      ITAB2 TYPE TABLE OF T_VBAP,

      ITAB3 TYPE TABLE OF T_VBUK,

      ITAB TYPE TABLE OF FS.

select a~vbeln a~erdat b~posnr c~rfstk

       from vbak as a inner join vbAP as b on a~vbeln = b~vbeln

                      inner join vbuk as c on a~vbeln = c~vbeln

into table itab

where A~vbeln eq SORDER.

IF NOT ITAB IS INITIAL.

  SORT ITAB BY VBELN.

ENDIF.

LOOP AT ITAB INTO WA.

   WRITE:/ WA-VBELN,WA-ERDAT,WA-rfstk.

   ENDLOOP.

   CLEAR WA.

   REFRESH ITAB.

Read only

0 Likes
868

can you tell what is there in SORDER?

Thanks

Gaurav

Read only

former_member199670
Participant
0 Likes
868

Hi Vamshi,

                      Try below code,

SELECT A~VBELN

               A~ERDAT

               B~POSNR

               C~RFSTK

  INTO TABLE ITAB FROM VBAK AS A INNER JOIN VBAP AS B ON A~VBELN = B~VBELN

  INNER JOIN VBUK AS C ON A~VBELN = C~VBELN

  WHERE A~VBELN IN S_VBELN.

Thanks,