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

select statement issue

Former Member
0 Likes
810

Hi,

In the following second select statement in where condition for objid(hrp1001-sobid) value im having multiple

values(records) but as per my coding it is passing only last value(record).i want to pass all the sobid values.

can u please give me some idea on this.

select sobid from hrp1001 into wa_hrp1001 where otype = 'NC' and

sclas = 'NB' and

begda = p_start AND

endda = p_end.

append wa_hrp1001 to it_hrp1001.

endselect.

IF it_hrp1001[] IS NOT INITIAL.

SELECT branch city region FROM hrp5126 INTO wa_hrp5126 WHERE otype = 'NB' AND

objid = wa_hrp1001-sobid and

begda = p_start AND

endda = p_end .

APPEND wa_hrp5126 TO it_hrp5126.

ENDSELECT.

ENDIF.

thanks in advance.

shwetha.

Moderator message: please use a more meaningful subject line next time.

Edited by: Thomas Zloch on Apr 6, 2010 9:18 AM

7 REPLIES 7
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
768

Please use for all entries.

check the f1 help.

Read only

0 Likes
768

Hi,

for using for all entries sobid and objid are different data types..so it is not accepting.

Thx.

Read only

0 Likes
768

Check this,

TYPES:BEGIN OF ty,

sobid(8) TYPE n,

END OF ty.

DATA:wa TYPE ty,

it TYPE TABLE OF ty,

it2 TYPE TABLE OF hrp5126.

SELECT sobid FROM hrp1001 INTO TABLE it

WHERE otype = 'NC'.

IF it[] IS NOT INITIAL.

SELECT * FROM hrp5126 INTO TABLE it2

FOR ALL ENTRIES IN it

WHERE objid = it-sobid AND

otype = 'NB'.

ENDIF.

Read only

Former Member
0 Likes
768

Use the following code :

select sobid from hrp1001 into table it_hrp1001 where otype = 'NC' and
sclas = 'NB' and
begda = p_start AND
endda = p_end.
append wa_hrp1001 to it_hrp1001.


IF it_hrp1001[] IS NOT INITIAL.
SELECT branch city region 
        FROM hrp5126 INTO TABLE it_hrp5126
        FOR ALL ENTRIES IN it_hrp1001
        WHERE otype = 'NB' AND
objid = it_hrp1001-objid and
begda = p_start AND
endda = p_end .
ENDIF.

Read only

Former Member
0 Likes
768

Check the below points.

1. Fetch all the primary key fields.

2. Make use of for all entries.

3. Sort and delete adjacent duplicates if any.

Read only

0 Likes
768

hi,

solved by myself..

thx for all..

Read only

Former Member
0 Likes
768

Hi,

Please check the below logic.

You can create a new work area and internal table as shown below.

Better to avoid select/endselect statement.

Please check and let me know if any further issues.

select sobid from hrp1001 into wa_hrp1001 where otype = 'NC' and

sclas = 'NB' and

begda = p_start AND

endda = p_end.

append wa_hrp1001 to it_hrp1001.

*--Create a new work area and internal table

*--with correct field type which matches the hrp5126-objid

*--add additional fields which ever required for further processing in the new table and work area

wa_hrp-objid = wa_hrp1001-sobid.

append wa_hrp to i_objid.

clear: wa_hrp.

endselect.

IF i_objid.[] IS NOT INITIAL.

SELECT branch city region

FROM hrp5126 INTO TABLE it_hrp5126

FOR ALL ENTRIES IN i_objid.

WHERE otype = 'NB' AND

objid = i_objid-objid and

begda = p_start AND

endda = p_end .

ENDIF.

Regards

Shibino