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: 

Regarding Offset usage in Select statement

Former Member
0 Kudos
1,382

Hi All,

I have written one select stmt.

SELECT objectid

changenr

udate

FROM CDHDR

INTO TABLE t_cdhdr

FOR ALL ENTRIES IN t_material

WHERE OBJECTCLAS EQ c_material AND

OBJECTID+0(18) EQ t_material-matnr AND

UDATE EQ P_PLCHDT.

But this is giving syntax error because of Offeset i have used for OBJECTID field.

I have to use this as matnr & cdhdr-objectid lengths are diffrent.

Please clarify wether there is any direct way i can modify select statement so that it works.

Instead of above select as it is not working i have written below code:

SELECT objectid

changenr

udate

FROM CDHDR

INTO TABLE t_cdhdr

WHERE OBJECTCLAS EQ c_material AND

UDATE EQ P_PLCHDT.

IF SY-SUBRC EQ 0.

LOOP AT T_MATERIAL INTO WA_MATERIAL.

READ TABLE t_cdhdr INTO wa_cdhdr WITH KEY

OBJECTID+0(18) = WA_MATERIAL-MATNR.

IF SY-SUBRC EQ 0.

MOVE wa_cdhdr-objectid TO wa_cdhdr_f-objectid.

MOVE wa_cdhdr-changenr TO wa_cdhdr_f-changenr.

MOVE wa_cdhdr-udate TO wa_cdhdr_f-udate.

APPEND wa_cdhdr_f TO t_cdhdr_f.

ENDIF.

ENDLOOP.

Is this code correct replacement for above, Please clarify!

Can anybody give solutions for above issues!

Thanks,

Deep.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
146

Hi

Since CDHDR consumes lot of time, it is better to pass OBJECTID also in the where condition.

So better declare another field equivalent to objectID length in T_MATERIAL and modify it first.

then use for all entries of this int table T_MATERIAL to fetch the data from CDHDR

if not T_MATERIAL [] is initial.

SELECT objectid

changenr

udate

FROM CDHDR

INTO TABLE t_cdhdr

FOR ALL ENTRIES IN t_material

WHERE OBJECTCLAS EQ c_material AND

OBJECTID EQ t_material-new_material AND

UDATE EQ P_PLCHDT.

endif.

Reward points for useful Answers

Regards

Anji

4 REPLIES 4

Former Member
0 Kudos
146

declare: t_material-matnr like objid

Abd then use ur folowing codes..

Former Member
0 Kudos
146

Hello,

Change the code like this..


concatenate  t_material-matnr '%' into  t_material-matnr. " Check here
SELECT objectid
changenr
udate
FROM CDHDR
INTO TABLE t_cdhdr
FOR ALL ENTRIES IN t_material
WHERE OBJECTCLAS EQ c_material AND
OBJECTID+0(18) LIKE t_material-matnr AND " Check here
UDATE EQ P_PLCHDT.

Vasanth

Former Member
0 Kudos
147

Hi

Since CDHDR consumes lot of time, it is better to pass OBJECTID also in the where condition.

So better declare another field equivalent to objectID length in T_MATERIAL and modify it first.

then use for all entries of this int table T_MATERIAL to fetch the data from CDHDR

if not T_MATERIAL [] is initial.

SELECT objectid

changenr

udate

FROM CDHDR

INTO TABLE t_cdhdr

FOR ALL ENTRIES IN t_material

WHERE OBJECTCLAS EQ c_material AND

OBJECTID EQ t_material-new_material AND

UDATE EQ P_PLCHDT.

endif.

Reward points for useful Answers

Regards

Anji

former_member378318
Contributor
0 Kudos
146

If OBJECTID contains only the 18 digit material number and nothing after then you can change the type of t_material-matnr to match cdhdr-objectid. If you do not want to change the type of t_material-matnr then have another intermediate table.