‎2008 May 29 6:20 AM
if v_zfnpio = 'X'.
select COUNT(*) from zme2o_vendors
where werks = v_werks
and lifnr = v_lifnr
and ZFNPIO = 'X'
and ZFOSGR = 'X'.
else.
Hi,
what does the above code do can any one explain me.
‎2008 May 29 6:21 AM
Hi
The above code is explained as follows.
1.The if condition checks whether v_zfnpio is not empty or not .
If it contains any value the code will be executed.
2. The select statement fetches number of records from the customized table zme2o_vendors with
key werks = v_werks
and the other conditions and lifnr = v_lifnr
and ZFNPIO = 'X'
and ZFOSGR = 'X'.
Regards,
Jagadish
‎2008 May 29 6:22 AM
Hi,
.
It gives the number i.e count of the records in the table matching the where condition.
... COUNT( * ).
Effect
Returns the number of lines selected. If the SELECT command contains a GROUP-BY clause, the system returns the number of lines for each group. You can use COUNT( * ) instead of COUNT(*).
Example
Displays a list of all the customers on all the Lufthansa 0400 flights in the year 2001, with the number of bookings for each flight, ordered by customer name:
DATA: name TYPE scustom-name,
postcode TYPE scustom-postcode,
city TYPE scustom-city,
count TYPE I.
SELECT scustomname scustompostcode scustom~city COUNT( * )
INTO (name, postcode, city, count)
FROM scustom INNER JOIN sbook
ON scustomid = sbookcustomid
WHERE sbook~fldate BETWEEN '20010101' AND '20011231' AND
sbook~carrid = 'LH ' AND
sbook~connid = '0400'
GROUP BY scustomname scustompostcode scustom~city
ORDER BY scustom~name.
WRITE: / name, postcode, city, count.
ENDSELECT.
Exceptions
Non-Catchable Exceptions
Cause: The database column whose values are to be aggregated has the type STRING or RAWSTRING.
Runtime Error: SAPSQL_AGGREGATE_LOB
Cause: The database column for which the mean is to be calculated does not have a numeric type.
Runtime Error: SAPSQL_FIELDLIST_AVG_TYPE
Cause: DThe database column whose values are to be totalled does not have a numeric type.
Runtime Error: SAPSQL_FIELDLIST_SUM_TYPE
Regards,
Raj.
‎2008 May 29 7:29 AM
You are code is checking for v_zfnpio ,if it has any value then
you are fetching number of rows present in your table zme20_vendors which satisfy the following conditions
werks = v_werks
and lifnr = v_lifnr
and ZFNPIO = 'X'
and ZFOSGR = 'X'.
reward if useful.