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

ABAP code error

vrgembali1979
Participant
0 Likes
655

HI Guys,

Can you please check the code error?

Select MBLNR MJAHR CPUDT CPUTM

into gt_mkpf

from mkpf

where werks = p_werks

and cpudt = sy-datum

and ( ( cputm > sy-uzeit ) and ( cputm < ( sy-uzeit - p_hours ) ) ).

Edited by: deva gembali on Aug 26, 2009 7:12 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
609

Hi,

Change the select query like this,



data: temp like sy-uzeit.

temp =  sy-uzeit - p_hours.

Select MBLNR MJAHR CPUDT CPUTM
into gt_mkpf
from mkpf
where werks = p_werks
and cpudt = sy-datum
and cputm > sy-uzeit 
and cputm < temp.

Regards,

Vik

5 REPLIES 5
Read only

Former Member
0 Likes
609

Hi,

Check your Where condition.

Read only

gaursri
Active Contributor
0 Likes
609

Hi ,

Check the syntax

select statement> ::= <query> ( <order by clause> )?.

<query> ::= <query specification>

| <query expression>

Have a look on this page.

Link:[SELECT|http://help.sap.com/saphelp_nw04/helpdata/en/62/10a423384746e8bf5f15ccdd36e8b1/content.htm]

Have a best day ahead.

Edited by: Srivastava.G on Aug 26, 2009 7:18 AM

Read only

Former Member
0 Likes
610

Hi,

Change the select query like this,



data: temp like sy-uzeit.

temp =  sy-uzeit - p_hours.

Select MBLNR MJAHR CPUDT CPUTM
into gt_mkpf
from mkpf
where werks = p_werks
and cpudt = sy-datum
and cputm > sy-uzeit 
and cputm < temp.

Regards,

Vik

Read only

Former Member
0 Likes
609

Hello

Table MKPF does not contain field WERKS.

Check conditions.

Read only

Former Member
0 Likes
609

Hi,

First of all MKPF table doesnt have WERKS(Plant).

So if you want to run this query using Plant as a parameter, you need to join MKPF & MSEG on Material Doc(MBLNR) and Material Year(MJAHR).

Calculate sy-uzeit - p_hours and store it in a variable say q_hours and then write select as follows:

Select aMBLNR aMJAHR aCPUDT aCPUTM

into table t_mkpf

from mkpf as a inner join mseg as b

on amblnr = bmblnr

and amjahr = bmjahr

where b~werks = p_werks

and a~cpudt = sy-datum

and ( ( cputm > sy-uzeit ) and ( cputm < q_hours ) ).

DECLARE q_hours as syst-uzeit which is same as data element CPUTM.

It works.

Regards,

Amit

Edited by: Amit Iyer on Aug 26, 2009 10:59 AM