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: 

Regarding For All Entries Statement

Former Member
0 Kudos

Hi Experts,

I have simple problem,

I want to retrieve plnnr number from mapl table like this

SELECT SINGLE plnnr

matnr

FROM mapl

INTO CORRESPONDING FIELDS OF wa_mapl

WHERE matnr = wa_qals-selmatnr AND

plnty = '2'.

By using this 'plnnr' number, i want to retrieve data from another table using for all entries. like

SELECT verwmerkm

plnnr

plnkn

merknr

FROM plmk

INTO CORRESPONDING FIELDS OF TABLE it_plmk

FOR ALL ENTRIES IN it_qasr

WHERE plnkn = it_qasr-vorglfnr AND

merknr = it_qasr-merknr AND

plnnr = wa_mapl-plnnr.

My question is, Can i use this where condition (plnnr = wa_mapl-plnnr) in this statement. If i used like this, Is it retrieve data or not?

Otherwise, please give me suggession in this regard and give some coding also......

Advance thanks to all.........

Regards

Ravindra

11 REPLIES 11

valter_oliveira
Active Contributor
0 Kudos

Yes you can. When you use for all entries you don't have to be restricted on itab fields. Also, don't forget to check if it_qasr has entries before select.

Regards,

Valter Oliveira.

0 Kudos

If iam using like this, it doest retrieve the date. Just jump from the select statement. I think, because of that wa_mapl-plnnr field.

Please help me.............

Any Experts.......................

Edited by: Sai Babu on Sep 11, 2008 3:40 PM

0 Kudos

Hello Sai,

Sure you can do this, in the debugging mode before select statement check whether you are getting data into work area.

Regards,

Naresh

Former Member
0 Kudos

Sure you can use the field PLNNR as a condition and indeed you should do that since it is a key field.

My question is where do you get the value of wa_mapl-plnnr because I don't see it in the coding you posted here?

Former Member
0 Kudos

Hi Sai,

If you are using the SELECT statement within the LOOP of

T_MAPL then it is ok.

Regards,

Rajitha.

0 Kudos

In debug, verify two thing: the number of record you have in your itab, and then the value of that field wa_mapl-plnnr. For your info, this coding works (take your conclusions).


TYPES: BEGIN OF ty_vbrk,
         vbeln TYPE vbeln,
       END OF ty_vbrk,
       BEGIN OF ty_vbrp,
         vbeln TYPE vbeln,
         posnr TYPE posnr,
       END OF ty_vbrp.

DATA: ti_vbrk TYPE STANDARD TABLE OF ty_vbrk,
      wa_vbrk TYPE ty_vbrk,
      ti_vbrp TYPE STANDARD TABLE OF ty_vbrp,
      wa_vbrp TYPE ty_vbrp,
      wa_posnr TYPE posnr.

SELECT vbeln FROM vbrk INTO TABLE ti_vbrk WHERE fkart = 'ZZOT'.
CHECK sy-subrc EQ 0.
wa_posnr = '000020'.

SELECT vbeln posnr FROM vbrp
  INTO TABLE ti_vbrp
   FOR ALL ENTRIES IN ti_vbrk
 WHERE vbeln = ti_vbrk-vbeln
   AND posnr = wa_posnr.

Regards.

Valter Oliveira.

Former Member
0 Kudos

Hi Sai,

There wont be any difference between the two Select Statements.

You will get the same output for the two as the Primary key will be compared, any how, in the Statements For All Entries.

You can execute the below code and check.

REPORT ZAMIT101754.

data: wa_mapl type mapl,

wa_qals type qals,

it_plmk type plmk occurs 0 with header line,

it_qasr type qasr occurs 0 with header line .

SELECT SINGLE plnnr

matnr

FROM mapl

INTO CORRESPONDING FIELDS OF wa_mapl

WHERE matnr = wa_qals-selmatnr AND

plnty = '2'.

SELECT verwmerkm

plnnr

plnkn

merknr

FROM plmk

INTO CORRESPONDING FIELDS OF TABLE it_plmk

FOR ALL ENTRIES IN it_qasr

WHERE plnkn = it_qasr-vorglfnr AND

merknr = it_qasr-merknr.

AND

plnnr = wa_mapl-plnnr.

loop at it_plmk.

write it_plmk-plnnr.

endloop.

Former Member
0 Kudos

Hi Sai,

Yes you can use plnnr = wa_mapl-plnnr in where condition.

Regards,

Rajitha.

Former Member
0 Kudos

Hi all, Thank you very much

i understand problem

Former Member
0 Kudos

Hi,

As per the query you can follow in the below way.

-


REPORT ysdn_sp .

DATA:wa_mapl LIKE mapl.

DATA:wa_qals LIKE qals.

DATA:it_plmk LIKE plmk OCCURS 0 WITH HEADER LINE.

DATA:it_qasr LIKE qasr OCCURS 0 WITH HEADER LINE.

SELECT SINGLE selmatnr

FROM qals

INTO CORRESPONDING FIELDS OF wa_qals.

*WHERE matnr =

SELECT SINGLE plnnr matnr

FROM mapl

INTO CORRESPONDING FIELDS OF wa_mapl

WHERE matnr = wa_qals-selmatnr AND

plnty = '2'.

SELECT vorglfnr merknr

FROM qasr

INTO CORRESPONDING FIELDS OF TABLE it_qasr

UP TO 500 ROWS.

IF NOT it_qasr[] IS INITIAL.

SELECT verwmerkm plnnr plnkn merknr

FROM plmk

INTO CORRESPONDING FIELDS OF TABLE it_plmk

FOR ALL ENTRIES IN it_qasr

WHERE plnkn = it_qasr-vorglfnr AND

merknr = it_qasr-merknr AND

plnnr = wa_mapl-plnnr.

ENDIF.

-


Regds

Parvathi

Former Member
0 Kudos

This message was moderated.