SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Select with Join



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
nordlender
Участник
Участник



Joined: 28 Jul 2009
Posts: 24

PostPosted: Tue Aug 23, 2011 4:45 pm    Post subject: Select with Join Reply with quote

привет всем,

имеется следующаяю задача:

Я должен определить, по полю "Имя" (табл. REP), соответствующие Giud (из таблицы CDOC).
это моя ER модель:



понемаю что надо написать Select с несколькими Join условиями.
я начал писать , но что-то запутался, надеюсь на вашу помощ.

Code:
po_guids  (Returning Parameter)
pi_guids  (Importing Parameter)

SELECT  DISTINCT a~guid_cdoc INTO TABLE po_guids  FROM cdoc AS a
    INNER JOIN rat AS b   ON a~guid_cdoc = b~guid_cdoc
    FOR ALL ENTRIES IN pi_guids
    WHERE ( a~guid_cdoc = pi_guids-guid_cdoc
    ( SELECT DISTINCT d~giud_rat  FROM  rat AS d (
     INNER JOIN  ord  AS e  ON d~guid_ord = e~guid_ord )
       Select  DISTINCT f~guid_ord FROM ord AS f
        JOIN rep     AS g ON f~guid_rep = g~guid_rep
        JOIN order   AS h ON f~guid_order = h~guid_order
         WHERE g~name = 'Test_Name' ) ) ).
Back to top
View user's profile Send private message
FeBO-Sh
Участник
Участник


Age: 39
Joined: 25 Aug 2011
Posts: 7

PostPosted: Thu Aug 25, 2011 5:04 pm    Post subject: Reply with quote

Попробуйте так.
Code:

SELECT DISTINCT cdoc~guid_cdoc
  INTO TABLE po_guids
  FROM rep
  INNER JOIN ord ON ord~guid_rep = rep~guid_rep
  INNER JOIN rat ON rat~guid_ord = ord~guid_ord
  INNER JOIN cdoc ON cdoc~guid_cdoc = rat~guid_cdoc
  FOR ALL ENTRIES IN pi_guids
  WHERE rep~name = 'NAME'
    AND cdoc~guid_cdoc = pi_guids-guid_cdoc
  .

А вообще можно не включать табл. cdoc вытягивать только из rat.
Еще не понятна суть задачи. Вы фильтруете по тому же полю что и выбираете.
Back to top
View user's profile Send private message
Удав
Гуру
Гуру


Age: 48
Joined: 25 Jan 2008
Posts: 580
Location: Москва

PostPosted: Thu Aug 25, 2011 6:13 pm    Post subject: Reply with quote

Да, и забудьте про 3NF при работе с SAP - здесь при проектировании БД упор делается на быстродействие запросов, а не на уменьшение избыточности данных. Wink
_________________
С уважением,
Удав.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.