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

Select columns with offset from table

Former Member
0 Likes
3,954

Hi All,

Is it possible to do a select query with using offset option for column name . I have tried a code but it dint pass the syntax check.

I am eager to know because I have seen this thread with similiar requirement but that dint work for me.

LINK: []

Has it got something to do with SAP version.

Best Regards,

Dep

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,243

No you cannot atleast in open SQL. You have a lot of workarounds of using either patterns with the select statement or processing after the select statement by looping.

With native SQL, you may give a try. I don't think it is very reliable

Vikranth

10 REPLIES 10
Read only

Former Member
0 Likes
2,244

No you cannot atleast in open SQL. You have a lot of workarounds of using either patterns with the select statement or processing after the select statement by looping.

With native SQL, you may give a try. I don't think it is very reliable

Vikranth

Read only

0 Likes
2,243

Hi Vikranth,

Select with patterns I have seen examples where it has been used in WHERE condition.

But, when it comes to columns is where my concern is.

Example from the LINK I mentioned :

Select FIELD1+0(10) into L_FIELD1 where FIELD2 = L_FIELD2+2(10).

BR

Dep

Read only

0 Likes
2,243

So, what's the problem with using patterns?

Rob

Read only

0 Likes
2,243

Hi Rob,

Can I achieve below using patterns:

Select Ebeln+0(4)
          ebelp
          into table itab
          from ekpo
          up to 10 rows.

BR

Dep

Read only

0 Likes
2,243

Hi,

Select Ebeln+0(4)

ebelp

into table itab

from ekpo

up to 10 rows.

if you really only want to achieve that, then use SELECT ebeln ebelp ... and define itab with EBELN field of 4 characters only , it will copy only the 4 first characters.

Sandra

Read only

0 Likes
2,243

Hi Sandra ,

I would also like to how could we acheive:

Select Ebeln+2(4)
          ebelp
          into table itab
          from ekpo
          up to 10 rows.

I am sorry I have asked it late and moderators kindly do take approriate action if needed for marking my question as solved and changing it again.

And I wish there were more 10 pointers ))

BR

Dep

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,243

Hi Dep,

AFAIK this is not possible using Open SQL.

Actually Sandra's solution works because the values get "truncated" when they are transferred from the DB layer to the target internal table. (Since the length of the internal table field is lesser).

BR,

Suhas

PS: As a matter-of-fact at the back of my mind i knew this question was coming

Edited by: Suhas Saha on Aug 18, 2011 3:02 PM

Read only

0 Likes
2,243

How complicated does this need to get?

Select your data with a char4 field named, but empty...then loop at your internal table and compute the char4 field = ebeln+2(4)!

Read only

0 Likes
2,243

Hi Davel,

I need to fetch on single select query.

BR

Dep

Read only

sivaprasad_ml
Participant
0 Likes
2,243

Hi.

try offset and put them in another internal table or if it is a single table put into variables. After that go for fetch from standard tables,

I have faced the problem whine fetching documents with reference fields,

Rgds

Siva