‎2008 Apr 02 8:54 AM
Hi experts,
I want to change the following code. Using select-endselect is not allowed, how can I change the code? I also have to avoid of using select *.
SELECT * FROM /PTGWFI/M_PRKMTR
WHERE BELNR = RBKP-BELNR
AND GJAHR = RBKP-GJAHR
ORDER BY COUNTER DESCENDING.
LV_PARKRSN = /PTGWFI/M_PRKMTR-PARKRSN.
LV_BELNR = /PTGWFI/M_PRKMTR-BELNR.
EXIT.
ENDSELECT.
‎2008 Apr 02 9:51 AM
>
> Hi experts,
>
> I want to change the following code. Using select-endselect is not allowed, how can I change the code? I also have to avoid of using select *.
>
> SELECT * FROM /PTGWFI/M_PRKMTR
> WHERE BELNR = RBKP-BELNR
> AND GJAHR = RBKP-GJAHR
> ORDER BY COUNTER DESCENDING.
> LV_PARKRSN = /PTGWFI/M_PRKMTR-PARKRSN.
> LV_BELNR = /PTGWFI/M_PRKMTR-BELNR.
> EXIT.
> ENDSELECT.
Here's another alternative:
DATA: lv_counter TYPE /PTGWFI/M_PRKMTR-counter.
SELECT MAX( counter ) INTO lv_counter FROM /ptgwfi/m_prkmtr
WHERE belnr EQ rbkp-belnr
AND gjahr EQ rbkp-gjahr.
SELECT parkrsn belnr INTO (lv_parkrsn, lv_belnr) FROM /ptgwfi/m_prkmtr
WHERE belnr EQ rbkp-belnr
AND gjahr EQ rbkp-gjahr
AND counter EQ lv_counter.It would be interesting to compare the performance of the various alternatives, as matched against the original. SELECT... ENDSELECT should generally not be used, but there are times when it is the most appropriate construct.
matt
‎2008 Apr 02 8:58 AM
Hi,
Take one internal table which contain this 2 fields,
Like in the following way.
Data: Begin of itab occurs 1,
LV_PARKRSN type /PTGWFI/M_PRKMTR-PARKRSN,
LV_BELNR type /PTGWFI/M_PRKMTR-BELNR,
end of itab.
SELECT * FROM /PTGWFI/M_PRKMTR into corresponding fields of table itab
WHERE BELNR = RBKP-BELNR
AND GJAHR = RBKP-GJAHR
ORDER BY COUNTER DESCENDING.
‎2008 Apr 02 9:04 AM
I'm not allowed to use select *, and instead of using 'into corresponding' I'm only allowed to use simple 'into'
‎2008 Apr 02 9:02 AM
Hi
Declare an internal table and fill that table with a select query.
(Select * from Table into Corresponding fields of Table ITab).
You can sort the itab by
Sort Itab by COUNTER DESCENDING. and then execute the loop
Now make a loop at Itab (Internal Table) into wa_Itab (Work Area)
Loop at Itab into wa_Itab.
Do all the processing over here that you previously did in Select - EndSelect.
EndLoop.
Hope this works out
Regards
‎2008 Apr 02 9:04 AM
Hi,
try the below code.
Data: Begin of itab occurs 1,
LV_PARKRSN type /PTGWFI/M_PRKMTR-PARKRSN,
LV_BELNR type /PTGWFI/M_PRKMTR-BELNR,
counter type /PTGWFI/M_PRKMTR-counter,
end of itab.
Select parkrsn
belnr
counter
from /PTGWFI/M_PRKMTR
into table itab
where BELNR = RBKP-BELNR and
GJAHR = RBKP-GJAHR
order by counter descending.
if sy-subrc = 0.
if LV_PARKRSN = /PTGWFI/M_PRKMTR-PARKRSN and
LV_BELNR = /PTGWFI/M_PRKMTR-BELNR.
EXIT.
endif.
endif.
‎2008 Apr 02 9:06 AM
hi,
i am not understand /PTGWFI/M
but try this............................
SELECT * FROM /PTGWFI/M_PRKMTR into corresponding fields of itab
WHERE BELNR = RBKP-BELNR
AND GJAHR = RBKP-GJAHR
ORDER BY COUNTER DESCENDING
LV_PARKRSN = /PTGWFI/M_PRKMTR-PARKRSN.
LV_BELNR = /PTGWFI/M_PRKMTR-BELNR.
end select.
if helpful give reward points
pankaj
‎2008 Apr 02 9:58 AM
>
> hi,
> i am not understand /PTGWFI/M
Just for information, /PTGWFI/ is a namespace. It serves to seperate different applications from each other.
‎2008 Apr 02 10:14 AM
/PTGWFI/M_PRKMTR is a transparent table in SAP it is for LIX Parked Process Monitor.
‎2008 Apr 02 10:17 AM
Yes, and you use the whole thing as the table name, but technically, the /PTGWFI/ is the namespace - the table is M_PRKMTR. This allows us to, for example, have a table M_PRKMTR that is part of BI - it would be called /BIC/M_PRKMTR.
matt
‎2008 Apr 02 9:39 AM
write like this...
data: wa_/PTGWFI/M_PRKMTR type /PTGWFI/M_PRKMTR .
SELECT * FROM /PTGWFI/M_PRKMTR
into wa_/PTGWFI/M_PRKMTR
WHERE BELNR = RBKP-BELNR
AND GJAHR = RBKP-GJAHR
ORDER BY COUNTER DESCENDING.
LV_PARKRSN = /PTGWFI/M_PRKMTR-PARKRSN.
LV_BELNR = /PTGWFI/M_PRKMTR-BELNR.
EXIT.
ENDSELECT.
regards,
venkat.
‎2008 Apr 02 9:51 AM
>
> Hi experts,
>
> I want to change the following code. Using select-endselect is not allowed, how can I change the code? I also have to avoid of using select *.
>
> SELECT * FROM /PTGWFI/M_PRKMTR
> WHERE BELNR = RBKP-BELNR
> AND GJAHR = RBKP-GJAHR
> ORDER BY COUNTER DESCENDING.
> LV_PARKRSN = /PTGWFI/M_PRKMTR-PARKRSN.
> LV_BELNR = /PTGWFI/M_PRKMTR-BELNR.
> EXIT.
> ENDSELECT.
Here's another alternative:
DATA: lv_counter TYPE /PTGWFI/M_PRKMTR-counter.
SELECT MAX( counter ) INTO lv_counter FROM /ptgwfi/m_prkmtr
WHERE belnr EQ rbkp-belnr
AND gjahr EQ rbkp-gjahr.
SELECT parkrsn belnr INTO (lv_parkrsn, lv_belnr) FROM /ptgwfi/m_prkmtr
WHERE belnr EQ rbkp-belnr
AND gjahr EQ rbkp-gjahr
AND counter EQ lv_counter.It would be interesting to compare the performance of the various alternatives, as matched against the original. SELECT... ENDSELECT should generally not be used, but there are times when it is the most appropriate construct.
matt
‎2008 Apr 02 10:52 AM