Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

Select Query

Former Member
0 Kudos

Hi all,

After spending some hours I wrote a query which is needed for my project.There are some problems in the query and Iam not 100 % sure wheather it will work.Thats why the post here.(some of the field names wont be exactly right)

data: lv_cdpos_cond type string.     
lv_cdpos_cond = 'cdpos~feldname = '.
concatenate lv_cdpos_cond  'Fmenge'
'and cdpos~chngid = ' 'I'
'OR cdpos~chngid = '  'U'
  'OR cdpos~chngid = ' 'D'
  'and cdpos~tabname = ' 'stpos' INTO lv_cdpos_cond SEPARATED BY space.
  select cdhdr~username cdhdr~udate cdpos~changeid cdpos~valuenew
         cdpos~valueold cdpos~tabname cdpos~feldname stpos~stlr
         stpos~stlr stpos~position stpos~component mast~material
          mara~mattxt into CORRESPONDING FIELDS OF TABLE gt_ditab
         from cdhdr
         INNER JOIN cdpos on cdhdr~OBJECTCLAS = cdpos~OBJECTCLAS
          and cdhdr~changenr = cdpos~changenr
        INNER JOIN stpos on cdpos~tabkey = stpos~(
        INNER join mast on stpos~stlnr = mast~stlnr
        INNER JOIN mara on mast~matnr = mara~matnr
        where cdhdr~objectclas = 'stue'
        and cdhdr~udate in so_date
        and lv_cdpos_cond and lv_stpos_cond
        and mast~matnr in so_matrange
        and mara-matnr = mast~matnr.

I have to select some data from 5 different tables(CDHDR,CDPOS,stpos.mast and mara). As Iam trying it on a test machine from home.Anyway its still not a compilable select query as there are still some holes to plug in.The purpose of this query is to get the changed BOM data.Iam using 1 string in my Select query lv_cdpos_cond to make the query readable. But the strings inside the strings like 'I','U' or 'D' is not concateneted as a string.How could it be done .Also will the "OR " condition in the string lv_cdpos_cond work(if it is used directly in the select query) in the sql query.

The innerJoin " INNER JOIN stpos on cdpostabkey = stpos( mandtbomtypebomnodetypecounter)" :Here the cdpos~tabkey is a concateneted value from the fields(mandtbomtypebomnodetypecounter) in stpos. how to make a join condition here.

Will this query work :).Will it be a performant query.Would be nice if some one could post a edited query if there are problems in my the query.(spend 2 hrs to write this,Thats why )

Thanks kOH

Edited by: Kohinoor72 on May 21, 2010 2:47 PM


Former Member
0 Kudos

Let's see:

> some of the field names wont be exactly right

> its still not a compilable select query

> there are still some holes to plug

> Would be nice if some one could post a edited query if there are problems in my the query

And you want the forum to fix it for you?

Maybe you should work on it a bit more yourself.


0 Kudos

Hi Rob,

Sorry if I have offended you with my statement.

As said I worked on this query for 2 hours...(am a beginner in abap )

I could proceed on my own only if someone could help me on the inner join and the string question.

Iam stuck there.

0 Kudos

No offense taken - but you have to realize that this is not a forum for beginners. You should provide code that has a specific problem and then ask a specific question about it.

Also, Please read and and [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers] before posting again.


0 Kudos

Hi Kohinoor72

maybe you shoult try to do more then a select.....and not only one with the inner will be more clear.

best regards


0 Kudos

Thanks Rob.Then I will close this thread as my question was a bit wierd and open another thread with my specific questions.

0 Kudos