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: 

select statement.

Former Member
0 Kudos

Hi friends,

Lat me know how to write the select query to get the fields PLANS and ENAME from table PA0001 by checking the field PERNR = IHPA-PARNR .

Because pernr and parnr are not same type and same length.

Thanks in advancce.

12 REPLIES 12

pavel_parshenkov2
Participant
0 Kudos

Hi, try like this:

DATA: BEGIN OF lt_ihpa OCCURS 0

, parnr LIKE pa0001-pernr

  • if need other fields

, END OF lt_ihpa.

DATA lt_pa0001 LIKE pa0001 OCCURS 0.

REFRESH lt_ihpa[].

REFRESH lt_pa0001[].

SELECT parnr

  • if need other fields

INTO TABLE lt_ihpa

FROM ihpa.

CHECK NOT lt_ihpa[] IS INITIAL.

SELECT *

INTO TABLE lt_pa0001

FROM pa0001

FOR ALL ENTRIES IN lt_ihpa

WHERE pernr = lt_ihpa-parnr

  • if need other fields conditions

.

0 Kudos

It is giving the dump.

in select query what should i mention in where condition to get teh field parnr FROM table ihpa table.

0 Kudos

Thanks for your reply.

But i am getting the dump.

Let me know what should i mention in WHERE condition in the following query.

SELECT parnr

  • if need other fields

INTO TABLE lt_ihpa

FROM ihpa.

0 Kudos

DATA: BEGIN OF lt_ihpa OCCURS 0

, parnr LIKE ihpa-parnr

, parnr_2 LIKE pa0001-pernr

, END OF lt_ihpa.

DATA lt_pa0001 LIKE pa0001 OCCURS 0.

FIELD-SYMBOLS <fs> LIKE LINE OF lt_ihpa.

REFRESH lt_ihpa[].

REFRESH lt_pa0001[].

SELECT parnr

INTO CORRESPONDING FIELDS OF TABLE lt_ihpa

FROM ihpa.

LOOP AT lt_ihpa ASSIGNING <fs>.

<fs>-parnr_2 = <fs>-parnr(8).

ENDLOOP.

CHECK NOT lt_ihpa[] IS INITIAL.

SELECT *

INTO TABLE lt_pa0001

FROM pa0001

FOR ALL ENTRIES IN lt_ihpa

WHERE pernr = lt_ihpa-parnr_2.

0 Kudos

Thank you...itw working fine now..

0 Kudos

mark thread as answered

0 Kudos

Thanks, a lot! it worked.

Former Member
0 Kudos

Hi

you need to get the PARNR number from IHPA

select PARNR from IHPA into itab1 where some condition

if itab1 is not initial

select data from PA0001 into itab2 for allentries in itab1 where pernr = itab1-PARNR

endif.

<b>Reward if usefull</b>

Former Member
0 Kudos

in the itab declaration put

parnr LIKE pa0001-pernr

Former Member
0 Kudos

Hi Praveen,

I think PERNR is for Partner name and PARNR is for personal number.So you can't check with this condition.Better clarify with functionals for the checking of these two fields really needed or not.

If is it so..please take an internal table and declare both the fields with type C and fetch the corresponding values and check in your select statement.

Reward if helpful.

Former Member
0 Kudos

Hi Praveen,

you can try this.

Make a table say 'it_ihpa' only field PARNR but of type PERNR .

Now loop at IHPA and get all PARNR in your table 'it_ihpa' .

Now select PLANS and ENAME from table PA0001 by checking the field PERNR = IT_IHPA-PARNR .

Rewards pts if helpful

Regards,

Manish

Former Member
0 Kudos

answered