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

Date field initial; Select clause.

Former Member
0 Likes
9,809

Hi All,

I have a requirement where I need to select all the records where the data field (AUFK- IDAT2) is INITIAL.

I have given the query:

SELECT

A~AUFNR

A~AUFPL

INTO TABLE IT_ITAB

FROM AFKO AS A INNER JOIN AUFK AS U

ON AAUFNR = UAUFNR

WHERE

U~AUART = 'ZCPM' AND

U~IDAT2 = '00000000' AND

U~WERKS BETWEEN PLANT-LOW AND PLANT-HIGH AND

A~GSTRP BETWEEN CREATEDT-LOW AND CREATEDT-HIGH.

however, it gives an error on this line: U~IDAT2 = '00000000' .

Please reply urgently.

Thanks....

1 ACCEPTED SOLUTION
Read only

vinod_vemuru2
Active Contributor
0 Likes
4,066

Hi Vishal,

There should not be any problem. But still u can replace ur select like this.

I think last two conditions causing problem. Try commenting those and check. U may have to place proper brackets for those conditions.

DATA: l_initial TYPE aufk-idat2 VALUE IS INITIAL.

SELECT

A~AUFNR

A~AUFPL

INTO TABLE IT_ITAB

FROM AFKO AS A INNER JOIN AUFK AS U

ON AAUFNR = UAUFNR

WHERE

U~AUART = 'ZCPM' AND

U~IDAT2 = l_initial AND

U~WERKS BETWEEN PLANT-LOW AND PLANT-HIGH AND

A~GSTRP BETWEEN CREATEDT-LOW AND CREATEDT-HIGH.

Edited by: Vinod Reddy Vemuru on Jul 7, 2008 3:44 PM

7 REPLIES 7
Read only

vinod_vemuru2
Active Contributor
0 Likes
4,067

Hi Vishal,

There should not be any problem. But still u can replace ur select like this.

I think last two conditions causing problem. Try commenting those and check. U may have to place proper brackets for those conditions.

DATA: l_initial TYPE aufk-idat2 VALUE IS INITIAL.

SELECT

A~AUFNR

A~AUFPL

INTO TABLE IT_ITAB

FROM AFKO AS A INNER JOIN AUFK AS U

ON AAUFNR = UAUFNR

WHERE

U~AUART = 'ZCPM' AND

U~IDAT2 = l_initial AND

U~WERKS BETWEEN PLANT-LOW AND PLANT-HIGH AND

A~GSTRP BETWEEN CREATEDT-LOW AND CREATEDT-HIGH.

Edited by: Vinod Reddy Vemuru on Jul 7, 2008 3:44 PM

Read only

Former Member
0 Likes
4,066

Use like this:

SELECT

A~AUFNR

A~AUFPL

INTO TABLE IT_ITAB

FROM AFKO AS A INNER JOIN AUFK AS U

ON AAUFNR = UAUFNR

WHERE

U~AUART = 'ZCPM' AND

U~IDAT2 = ' ' AND

U~WERKS BETWEEN PLANT-LOW AND PLANT-HIGH AND

A~GSTRP BETWEEN CREATEDT-LOW AND CREATEDT-HIGH.

Amit.

Read only

Former Member
0 Likes
4,066

hi,

You cannot check the IS INITIAL condition in a SELECT statement so, you can assign the initial value to any other variable of that type and Assign INITIAL value to that. In the SELECT statement sue the VAriable instead of '00000000' value.

Hope this will help.

regards

Sumit Agarwal

Read only

Former Member
0 Likes
4,065

U can do this as shown below:

data: l_date like sy-datum.

clear l_date.

SELECT

A~AUFNR

A~AUFPL

INTO TABLE IT_ITAB

FROM AFKO AS A INNER JOIN AUFK AS U

ON AAUFNR = UAUFNR

WHERE

U~AUART = 'ZCPM' AND

U~IDAT2 = l_date AND

U~WERKS BETWEEN PLANT-LOW AND PLANT-HIGH AND

A~GSTRP BETWEEN CREATEDT-LOW AND CREATEDT-HIGH.

Regards,

Joy.

Read only

Former Member
0 Likes
4,065

Hi Vishal,

According to ur query I have written the code as this :

tables :
  afko,
  aufk.
  
select-options:
  plant for aufk-werks,
  CREATEDT for afko-gstrp.
  
data :
  begin of it_itab   occurs 0,
    aufnr like afko-aufnr,
    aufpl like afko-aufpl,
    auart like aufk-auart,
    IDAT2 like aufk-idat2,
    WERKS like aufk-werks,
    GSTRP like afko-gstrp,
  end of it_itab.
    
    
SELECT
A~AUFNR
A~AUFPL
INTO TABLE IT_ITAB
FROM AFKO AS A INNER JOIN AUFK AS U
ON A~AUFNR = U~AUFNR
WHERE
U~AUART = 'ZCPM' AND
U~IDAT2 = '00000000' AND
U~WERKS BETWEEN PLANT-LOW AND PLANT-HIGH AND
A~GSTRP BETWEEN CREATEDT-LOW AND CREATEDT-HIGH.

It was not giving me any error.

But just change and try with the following select query.

SELECT
A~AUFNR
A~AUFPL
INTO TABLE IT_ITAB
FROM AFKO AS A INNER JOIN AUFK AS U
ON A~AUFNR = U~AUFNR
WHERE
U~AUART = 'ZCPM' AND
U~IDAT2 is null AND
U~WERKS BETWEEN PLANT-LOW AND PLANT-HIGH AND
A~GSTRP BETWEEN CREATEDT-LOW AND CREATEDT-HIGH.

Regards,

Swapna.

Read only

Former Member
0 Likes
4,065

Hi,

i have tried it in this way and don't get any problems.

TABLES: AFKO, AUFK.

*

SELECT-OPTIONS: PLANT FOR AUFK-WERKS.

SELECT-OPTIONS: CREATEDT FOR AFKO-GSTRP.

TYPES: BEGIN OF TY_ITAB,

AUFNR LIKE AUFK-AUFNR,

AUFPL LIKE AFKO-AUFPL,

END OF TY_ITAB.

*

DATA: IT_ITAB TYPE TABLE OF TY_ITAB.

*

SELECT AAUFNR AAUFPL INTO TABLE IT_ITAB

FROM AFKO AS A INNER JOIN AUFK AS U

ON AAUFNR = UAUFNR

WHERE U~AUART = 'PP01' AND "You use ZCPM

U~IDAT2 = '00000000' AND

U~WERKS IN PLANT AND

A~GSTRP IN CREATEDT.

*

Try my example or show a little bit more of your Report.

Regards, Dieter

Read only

Former Member
0 Likes
4,065

types :  begin of y_anla,

            bukrs type anla-bukrs,

            anln1 type anla-anln1,

            end of y_anla.   

data :   t_anla type standard table of y_anla,

           i_initial type anla-abgdt value is initial,

select-options : s_bukrs for anla-bukrs.

select bukrs anln1

   from anla

   into table t_anla

   where bukrs in s_bukrs

      and abgdt = i_initial.