Quantcast
Channel: SCN : Blog List - ABAP Development
Viewing all articles
Browse latest Browse all 943

Dynamic Inner Joins

$
0
0

Hi Guys, we write select with dynamic table names and dynamic where clause, but i had never written a dynamic inner join.

I tried it with some help from google and all and then got so many dumps but finally i have a working code and i would like to share with

you all:

 

   REPORT  ztest_prbist01.
* Program written by Prasenjit Singh Bist
* Prototype for dynamic inner joins.
TABLES:mara.

DATA: l_col TYPE string,
      l_db  TYPE string,
      lt    TYPE STANDARD TABLE OF mara,
      l_tab_1 TYPE string,
      l_tab_2 TYPE string.

l_tab_1 = 'MARA'.
l_tab_2 = 'MAKT'.

l_col = `M~MATNR T~MAKTX`.

CONCATENATE l_tab_1
            'AS M'
            'INNER JOIN'
            l_tab_2
            'AS T ON'
            'M~MATNR = T~MATNR'
            INTO l_db SEPARATED BY space.


SELECT (l_col) FROM (l_db) INTO CORRESPONDING FIELDS OF TABLE lt.

WRITE sy-dbcnt.


Viewing all articles
Browse latest Browse all 943

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>