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

what is wrong with the select statement?

Former Member
0 Likes
1,087

Hi,

I have a Z table ZTAB with PSPID,PSTRT & POSKI as Primary keys.

I have 6 entries for a record PSPID= 251194004 & PSTRT =08/24/2009.


PSPID,            PSTART,          POSKI
251194004,	08/24/2009,	1010-02
251194004,	08/24/2009,	1010-03
251194004,	08/24/2009,	1010-05
251194004,	08/24/2009,	1010-10
251194004,	08/24/2009,	1010-11
251194004,	08/24/2009,	1010-14

REPORT x.

TABLES: ztab.

DATA: it_itab TYPE STANDARD TABLE OF ztab,
     wa_itab TYPE ztab.

PARAMETERS:

p_pspid LIKE ztab-pspid,
p_pstrt LIKE ztab-pstart.

SELECT * FROM ztab INTO CORRESPONDING FIELDS OF TABLE it_itab
WHERE pspid = p_pspid
AND pstart = p_pstrt.


LOOP AT it_itab INTO wa_itab.

  WRITE:/10 wa_itab-pspid , wa_itab-poski.
ENDLOOP.

When I execute this report I am getting only 5 records .What could be the mistake? I definetlly need these 2 where conditions.

If I comment S_PSPRT it brings up all 6 entries..

rgds

Vara

Edited by: Vara K on Aug 31, 2009 8:58 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,056

Hi Vara,

This seems to problems of data, review records are stored as column PSTART, record can be followed by a space or character or another date format that is not taken in the condition pstart = p_pstrt.

Hope this information is help to you.

Regards,

José

Hi,

I have a Z table ZTAB with PSPID,PSTRT & POSKI as Primary keys.

I have 6 entries for a record PSPID= 251194004 & PSTRT =08/24/2009.


PSPID,            PSTART,          POSKI
251194004,	08/24/2009,	1010-02
251194004,	08/24/2009,	1010-03
251194004,	08/24/2009,	1010-05
251194004,	08/24/2009,	1010-10
251194004,	08/24/2009,	1010-11
251194004,	08/24/2009,	1010-14

REPORT x.

TABLES: ztab.

DATA: it_itab TYPE STANDARD TABLE OF ztab,
     wa_itab TYPE ztab.

PARAMETERS:

p_pspid LIKE ztab-pspid,
p_pstrt LIKE ztab-pstart.

SELECT * FROM ztab INTO CORRESPONDING FIELDS OF TABLE it_itab
WHERE pspid = p_pspid
AND pstart = p_pstrt.


LOOP AT it_itab INTO wa_itab.

  WRITE:/10 wa_itab-pspid , wa_itab-poski.
ENDLOOP.

When I execute this report I am getting only 5 records .What could be the mistake? I definetlly need these 2 where conditions.

If I comment S_PSPRT it brings up all 6 entries..

rgds

Vara

Edited by: Vara K on Aug 31, 2009 8:58 PM

7 REPLIES 7
Read only

Former Member
0 Likes
1,056

try this

select PSPID
            PSTART          
            POSKI
            from zitab 
            into table gt_itab
            where  WHERE pspid = p_pspid
                          AND pstart = p_pstrt.

Read only

0 Likes
1,056

Nop! it did not work

I am still getting only 5 entries as output instead of 6.

rgds

Vara

Read only

0 Likes
1,056

then try this.

select PSPID
            PSTART          
            POSKI
            from zitab 
            into table gt_itab
            where  WHERE pspid = p_pspid.

delete gt_itab where pstart NE p_pstrt.

Read only

0 Likes
1,056

I want to do that only if we don't have any other options.

because why to select unnecessary data first and delete the same.. As I will have lot of entries..

rgds

Vara

Read only

FabioPagoti
Active Contributor
0 Likes
1,056

what i'd do:

- check if the problem is in the select statement or at the loop at statement.. debug it if you won't

- i do not use corresponding fields.. and as i don't know how the others fields in your table are... i'd remove the * from your select statement and specify the fields you want.


select PSPID  PSTART POSKI
into ...

- and i didn't understand what you comment to get the right result.. where is S_PSPRT ?

at the first look, i cannot see any problem.. and this kind of problem, for me, are the worst ones.

Good luck!

Read only

Former Member
0 Likes
1,057

Hi Vara,

This seems to problems of data, review records are stored as column PSTART, record can be followed by a space or character or another date format that is not taken in the condition pstart = p_pstrt.

Hope this information is help to you.

Regards,

José

Read only

0 Likes
1,056

Perfect jose.

that's what it.I have awarded you full points.

rgds

Vara