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

Dynamic Join SAP TABLES

Former Member
0 Likes
1,390

Hi guys !! is it possible to join SAP tables dynamically.

I explain : a user chose some tables FOR EXAMPLE EKKO EKPO EKET.

Then some FIELDS from those tables.

And here comes my question how can i join tables dynamically then show contents.

Regards.

Mehdi.

Hi guys !! is it possible to join SAP tables dynamically.

I explain : a user chose some tables FOR EXAMPLE EKKO EKPO EKET.

Then some FIELDS from those tables.

And here comes my question how can i join tables dynamically then show contents.

Regards.

Mehdi.

6 REPLIES 6
Read only

royolav_johansen
Explorer
0 Likes
976

why not just let them use SQVI - Quickviewer. If they don't know how to find the tables you could

create info sets for them.

Regards

Roy

Read only

Former Member
0 Likes
976

maybe you can dinamically generate the select as a text ant then use this text generating and runing a temporary subroutine you can se how here ( http://help.sap.com/saphelp_nw04/helpdata/en/9f/db999535c111d1829f0000e829fbfe/content.htm )

I think you must generate all the subroutine as a code before this but it will work fine if you use the correct parameters.

Read only

0 Likes
976

to explain more i'm working on an SAP EXTRACTOR and this is the scenario :

the user X chose TABLES and Tables FIELDS.

but i dont know how to join those TABLES to get DATA.

Read only

Former Member
0 Likes
976

1. Get all the fields of the tables using FM DDIF_FIELDINFO_GET.

2. There must be some relation beetween the tables. According to that create a dynamic internal table using the common key fields only and all non key fields.

3. Create a list of fields to be used in the select query with all non key fields and common key fields. Create join condition string and WHERE conditions string using concatenate statement.

4. Create a generic select querie as decribed

SELECT ([FIELD LIST])

INTO TABLE [dynamic internal table]

FROM ([JOIN CONDITION])

WHERE (CONDITIONS).

I think, it will work......But needs some time for analysis.......

Read only

Former Member
0 Likes
976

Hi,

it is possible using a generated subroutine pool. I used this technic to implement a document search. Here are some relevant lines ...

append 'select distinct ts~tsnummer into table pt_tsnum'        to lt_top.
append '    from /rand/ts_erfasst as ts'                        to lt_top.
append '    where ts~tsnummer in <tsnum>'                       to lt_mid.
append '    and   ts~gescannt in <scadt>'                       to lt_mid.
append '    and   ts~pernr    in <pernr>'                       to lt_mid.
append '    and   ts~tsweek   >= l_week'                        to lt_mid.
l_hex = i_flag.
if  l_hex o l_hx2.
  append '    inner join PA0002 as pa on ts~pernr = pa~pernr'     to lt_top.
  append '                           and pa~endda = ''99991231''' to lt_top.
  append '    and pa~nachn in <nachn>'                            to lt_mid.
  append '    and pa~vorna in <vorna>'                            to lt_mid.
endif.
[...]

GENERATE SUBROUTINE POOL lt_top name m_prog MESSAGE l_top.

Regards

Nick

Read only

0 Likes
976

Still have no solution to my problem :s

I just linked 2 tables dynamically Header Tables & Item Tables should lik an other Table

For example :

Header table (EKKO) Item table (EKPO) and an other Table (X) that contain a discription of a field in the item Table

Like MAKT .....