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.
cancel
Showing results for 
Search instead for 
Did you mean: 

TRYING TO USE AN OFFSET STATEMENT IN MY SELECT

Former Member
0 Kudos
223

I am trying to use an offset in my select but it says the offset is the same length of the field. Basically what I want to do is remove the 1st 3 characters form the one field and have the last 3 be moved into the field. They are of different length but I thought the offset would take care of that. here is the code

LOOP AT DATA_PACKAGE.

SELECT AC_DOC_NO

DOC_ITEM

PROFIT_CTR

INTO TABLE T_AZFIG

FROM /BIC/AZFIG_O5100

WHERE

AC_DOC_NO = DATA_PACKAGE-AC_DOC_NO AND

DOC_ITEM = DATA_PACKAGE-ITEM_NUM+3(3).

ENDLOOP.

7 REPLIES 7

Former Member
0 Kudos
184

Hi Mike,

This should work, but make sure that the DOC_ITEM type and the DATA_PACKAGE-ITEM_NUM type should be same

Regards

Sudheer

0 Kudos
184

Well taht is the issue. they are both characters but one is of lenth 3 and the other 6. Do I need to first move it inot a working area and then set them equal?

Former Member
0 Kudos
184

Hello Mick,#

The problem is the field DOC_ITEM from the table should be of length 3. Since u r offsetting for lenght 3.

Regards,

Vasanth

0 Kudos
184

but isn't it still jsut moving in 3 characters?

rajasekhar_matukumalli3
Active Participant
0 Kudos
184

Hi Mick,

Try this option

DATA: l_tempvar(3) type c.

LOOP AT DATA_PACKAGE.

l_tempvar = DATA_PACKAGE-ITEM_NUM+3(3).

SELECT AC_DOC_NO

DOC_ITEM

PROFIT_CTR

INTO TABLE T_AZFIG

FROM /BIC/AZFIG_O5100

WHERE

AC_DOC_NO = DATA_PACKAGE-AC_DOC_NO AND

DOC_ITEM = l_tempvar.

clear l_tempvar.

ENDLOOP.

Hope this solves ur problem.

Enjoy SAP and award points if the reply was useful.

Rajasekhar

0 Kudos
184

thanks this worked. I will assign points.

Former Member
0 Kudos
184

Hi ,

If the field length is 6 then u have to use

DOC_ITEM = DATA_PACKAGE-ITEM_NUM+2(3).

since the position starts from i got this problem earlier u have to change the position to position-1 since position starts from 0.

so the qusery is now changed to

LOOP AT DATA_PACKAGE.

SELECT AC_DOC_NO

DOC_ITEM

PROFIT_CTR

INTO TABLE T_AZFIG

FROM /BIC/AZFIG_O5100

WHERE

AC_DOC_NO = DATA_PACKAGE-AC_DOC_NO AND

DOC_ITEM = DATA_PACKAGE-ITEM_NUM+2(3).

ENDLOOP.

Check the types of DOC_ITEM and DATA_PACKAGE-ITEM_NUM are same or not.

Reward points if u found it useful

Regards,

Ravi Kumar