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

Соединение таблицы с самой собой (help)



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


Age: 33
Joined: 12 Dec 2011
Posts: 47
Location: Рязань

PostPosted: Sat Jan 21, 2012 8:52 pm    Post subject: Соединение таблицы с самой собой (help) Reply with quote

Прошу прощенья, может это и легко, но все же.
Как сделать из вот этого

А Р R Z
1 1 2 3
2 1 3 2

вот это
А W
1 1
1 2
1 3
2 1
2 3
2 2

А Р1 Р2 Р3 - поля таблиы словаря.
А Р - поля внутренней таблицы.

Необходимо сделать с помощью Select.
Back to top
View user's profile Send private message Blog
ghost
Специалист
Специалист


Age: 37
Joined: 18 Jan 2008
Posts: 71
Location: Tashkent-Astana-Moscow

PostPosted: Wed Jan 25, 2012 1:52 pm    Post subject: Re: Соединение таблицы с самой собой (help) Reply with quote

Mania4e11o wrote:
Прошу прощенья, может это и легко, но все же.
Как сделать из вот этого

А Р R Z
1 1 2 3
2 1 3 2

вот это
А W
1 1
1 2
1 3
2 1
2 3
2 2

А Р1 Р2 Р3 - поля таблиы словаря.
А Р - поля внутренней таблицы.

Необходимо сделать с помощью Select.


одним select-ом нельзя. хотя сама задача очень странная Confused

_________________
Пользователь не знает, чего он хочет, пока не увидит то, что он получил. (Э. Йодан)
Back to top
View user's profile Send private message Send e-mail Blog
Mania4e11o
Участник
Участник


Age: 33
Joined: 12 Dec 2011
Posts: 47
Location: Рязань

PostPosted: Sun Jan 29, 2012 11:22 pm    Post subject: Reply with quote

Ну да,может такая задача и не встретится в жизни...просто БД криво построена была...в итоге получилась таблица:

price1 - цена материнской платы
price2 - цена видеокарты
price3 - цена памяти

IDpc price1 price2 price3

0001 2000 30000 1000
....... ........ ......... ........

и нужно было посчитать общую сумму ПК.

price1+price2+price3 as price не работает

поэтому хотел переставить эти цены в один столбец и считать сумму по полю....
Back to top
View user's profile Send private message Blog
ghost
Специалист
Специалист


Age: 37
Joined: 18 Jan 2008
Posts: 71
Location: Tashkent-Astana-Moscow

PostPosted: Mon Jan 30, 2012 8:19 am    Post subject: Reply with quote

не я сказал что одним селектом не получится. нужна доп.логика . н.п.
Code:
select * from ваша_таблица into table gt_pcprices
loop at gt_prices assigning <gfs_pcprices>.
  <gfs_pcprices>-total_price =  <gfs_pcprices>-price1 +  <gfs_pcprices>-price2 ...
endloop.


если колонок много можно и динамику реализовать

_________________
Пользователь не знает, чего он хочет, пока не увидит то, что он получил. (Э. Йодан)
Back to top
View user's profile Send private message Send e-mail Blog
Mania4e11o
Участник
Участник


Age: 33
Joined: 12 Dec 2011
Posts: 47
Location: Рязань

PostPosted: Mon Jan 30, 2012 1:11 pm    Post subject: Reply with quote

ghost wrote:
не я сказал что одним селектом не получится. нужна доп.логика . н.п.
Code:
select * from ваша_таблица into table gt_pcprices
loop at gt_prices assigning <gfs_pcprices>.
  <gfs_pcprices>-total_price =  <gfs_pcprices>-price1 +  <gfs_pcprices>-price2 ...
endloop.


если колонок много можно и динамику реализовать


Ну вот так и я реализовал) хотелось одной выборкой обойтись)
Back to top
View user's profile Send private message Blog
Удав
Гуру
Гуру


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

PostPosted: Tue Jan 31, 2012 12:49 pm    Post subject: Reply with quote

Mania4e11o wrote:
Ну вот так и я реализовал) хотелось одной выборкой обойтись)

Ну так здесь и есть одна выборка Smile
Цикл по внутренней таблице много времени не занимает Wink

_________________
С уважением,
Удав.
Back to top
View user's profile Send private message
XXX_:)
Аналитик
Аналитик


Age: 40
Joined: 01 Feb 2008
Posts: 387
Location: Воронеж

PostPosted: Tue Jan 31, 2012 4:29 pm    Post subject: Reply with quote

Code:
select * from ваша_таблица into table gt_pcprices
Мне конечно до Удава далеко, но если ваша_таблица - сильно тяжелая, а данных надо не много, то лучше 2 селекта. Т.е. зависит от конкретной задачи, ИМХО.
_________________
Hормальные люди делают вещи намного более безумные чем всё, что делают сумасшедшие (c) С.Лем
Back to top
View user's profile Send private message Blog
Mania4e11o
Участник
Участник


Age: 33
Joined: 12 Dec 2011
Posts: 47
Location: Рязань

PostPosted: Fri Feb 03, 2012 10:52 pm    Post subject: Reply with quote

Спасибо мужики!))))Такая задачка заинтересовала таких спецов,интересно даже)))
Back to top
View user's profile Send private message Blog
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.