‎2009 Feb 10 2:46 AM
hi experts,
my select query is like this..
SELECT pernr reinr receiptno exp_type loc_amount rec_date
FROM ptrv_srec INTO table it_ptrv_srec
FOR ALL ENTRIES IN it_ptrv_head
WHERE pernr EQ it_ptrv_head-pernr
AND reinr EQ it_ptrv_head-reinr.
SORT it_ptrv_srec BY exp_type loc_amount.here when i deburg am getting 4 line items like
pernr reinr exp_type loc_amount
30007 10003 zs01 1300
30007 10003 zs17 100
30007 10003 zs26 600
30007 10003 zs31 1500but here i want to read the line item where exp_type is zs26 and loc_amount 600.
how to do it..
regards
sunita.
‎2009 Feb 10 4:14 AM
Hi,
Test the following Sample Statement hope will help you to solve you problem,
data: it_ptrv_srec like STANDARD TABLE OF ptrv_srec WITH HEADER LINE,
it_ptrv_head like STANDARD TABLE OF ptrv_srec WITH HEADER LINE.
SELECT pernr reinr receiptno seqno exp_type loc_amount rec_date
FROM ptrv_srec INTO CORRESPONDING FIELDS OF TABLE it_ptrv_srec
FOR ALL ENTRIES IN it_ptrv_head
WHERE pernr EQ it_ptrv_head-pernr
AND reinr EQ it_ptrv_head-reinr
and exp_type eq 'ZS26'
and loc_amount eq 600.
SORT it_ptrv_srec BY exp_type loc_amount.Kind Regards,
Faisal
‎2009 Feb 10 2:58 AM
‎2009 Feb 10 3:03 AM
Hi,
SELECT pernr reinr receiptno exp_type loc_amount rec_date
FROM ptrv_srec INTO table it_ptrv_srec
FOR ALL ENTRIES IN it_ptrv_head
WHERE pernr EQ it_ptrv_head-pernr
AND reinr EQ it_ptrv_head-reinr.
AND exp_type EQ 'zs26' " If category 'zs26' only reqd
AND loc_amount eq '600' " If category '600' only reqd
SORT it_ptrv_srec BY exp_type loc_amount.
Edited by: GP on Feb 10, 2009 8:33 AM
‎2009 Feb 10 3:03 AM
Sunita,
If I understood your question correctly,
1.You can use a normal read table like the following.
read table it_ptrv_head with key exp_type = zs26
loc_amt = 600.
if sy-subrc eq 0.
<Do your custome code>.
endif.
2. Else you can use one more where condition at the time of selection query itself
WHERE pernr EQ it_ptrv_head-pernr
AND reinr EQ it_ptrv_head-reinr
and exp_type = 'ZS26'
and loc_amt = 600.
Let me understand your requirement fully.
-Shankar
‎2009 Feb 10 3:05 AM
Hi,
Your Where clause should be more specific...
Either Use Exp_type in your where clause or Put data into an internal table and use Read Table..
This will resolve the issue.
Regards,
Gurpreet.
‎2009 Feb 10 3:08 AM
Hi,
Some friends have doubt about ur requirement. Hence they suggested some methods.
Still, It's better to filter from database selecton itself. rather filtering after moving to internal table
thanks & regards,
GP
‎2009 Feb 10 3:34 AM
Hi ,
You can write the READ statement as follows ---
Read table it_ptrv_srec into field_string with key exp_type = zs26 loc_amount = 600Regards
Pinaki
‎2009 Feb 10 4:14 AM
Hi,
Test the following Sample Statement hope will help you to solve you problem,
data: it_ptrv_srec like STANDARD TABLE OF ptrv_srec WITH HEADER LINE,
it_ptrv_head like STANDARD TABLE OF ptrv_srec WITH HEADER LINE.
SELECT pernr reinr receiptno seqno exp_type loc_amount rec_date
FROM ptrv_srec INTO CORRESPONDING FIELDS OF TABLE it_ptrv_srec
FOR ALL ENTRIES IN it_ptrv_head
WHERE pernr EQ it_ptrv_head-pernr
AND reinr EQ it_ptrv_head-reinr
and exp_type eq 'ZS26'
and loc_amount eq 600.
SORT it_ptrv_srec BY exp_type loc_amount.Kind Regards,
Faisal
‎2009 Feb 10 4:47 AM
Hi
Either you can specify your select query like
SELECT pernr reinr receiptno exp_type loc_amount rec_date
FROM ptrv_srec INTO table it_ptrv_srec
FOR ALL ENTRIES IN it_ptrv_head
WHERE pernr EQ it_ptrv_head-pernr
AND reinr EQ it_ptrv_head-reinr
AND exp_type EQ zs26
AND loc_amount EQ 600.OR
You can first fetch the data to table it_ptrv_srec and
then loop through the internal table like
LOOP AT IT_PTRV_SREC INTO WA.
IF WA-exp_type = zs26
and WA-loc_amount = 600.
WRITE:/ WA-pernr ,
WA-reinr ,
WA-exp_type,
WA-loc_amount
ENDIF.
ENDLOOP.In this case you will get only this row .
30007 10003 zs26 600Try this .
This will solve your problem.
Regards
Hareesh.
‎2009 Feb 10 4:58 AM
Hi ,
You can add the two extar conditions as below.
SELECT pernr reinr receiptno exp_type loc_amount rec_date
FROM ptrv_srec INTO table it_ptrv_srec
FOR ALL ENTRIES IN it_ptrv_head
WHERE pernr EQ it_ptrv_head-pernr
AND reinr EQ it_ptrv_head-reinr.
AND exp_type EQ 'zs26' " If category 'zs26' only reqd
AND loc_amount eq '600' " If category '600' only reqd
SORT it_ptrv_srec BY exp_type loc_amount.
Regards
Rajendra