08-21-2007 12:38 PM
Hi,
I am a BASIS person.
I need to create an ABAP program which willl return the <b>count</b> of rows returned by the following query.Pls help me in this
<b>SELECT AGR_NAME FROM AGR_1250 where OBJECT IN (select OBJCT from
TOBJ where OCLSS IN ('RS','RSR','RSBC')) AND
AGR_NAME LIKE 'Z%'</b>
Message was edited by:
Balaji R
08-21-2007 12:40 PM
Hi
use sy-dbcnt variable...
reward points to all helpful answers
kiran.M
08-21-2007 12:40 PM
Hi
use sy-dbcnt variable...
reward points to all helpful answers
kiran.M
08-21-2007 12:44 PM
Hi Balaji,
Use <b>sy-dbcnt</b> its used to get the total no of rows from the select query
<b>
Regards,
Azhar</b>
08-21-2007 12:44 PM
In Abap
write like this
select OBJCT from
TOBJ into table itab1 where OCLSS IN ('RS','RSR','RSBC').
if itab1[] is not initial.
SELECT AGR_NAME FROM AGR_1250 into table itab2 for all entries in itab1 where object = itab1-object and AGR_NAME LIKE 'Z%'
endif.
describe table ITAB2 lines ld_lines.
now ld_lines contains count of records
reward points to all helpful answers
kiran.M
08-21-2007 12:45 PM
hi,
After this query use sy-dbcnt system variable which holds the number of rec/rows.
<b>Reward points if useful</b>
Cheers,
Chandra
08-21-2007 12:53 PM
since i am very new to ABAP , i wouldbe very thankful if you could send me the complete code for the same
08-21-2007 12:58 PM
hi, Balaji,
TABLES: ekpo, ekko.
DATA: BEGIN OF itab1 OCCURS 0,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
END OF itab1.
DATA: BEGIN OF itab2 OCCURS 0,
ebeln LIKE ekko-ebeln,
lifnr LIKE ekko-lifnr,
bukrs LIKE ekko-ebeln,
END OF itab2.
DATA: count LIKE sy-dbcnt.
DATA: BEGIN OF itab3 OCCURS 0,
ebeln LIKE ekpo-ebeln,
ebelp LIKE ekpo-ebelp,
matnr LIKE ekpo-matnr,
lifnr LIKE ekko-lifnr,
bukrs LIKE ekko-bukrs,
END OF itab3.
SELECT-OPTIONS: s_ebeln FOR ekpo-ebeln.
SELECT ebeln ebelp matnr INTO TABLE itab1 FROM ekpo
WHERE ebeln IN s_ebeln.
IF NOT itab1[] IS INITIAL.
SELECT ebeln lifnr bukrs INTO TABLE itab2 FROM ekko
FOR ALL ENTRIES IN itab1
WHERE ebeln = itab1-ebeln.
count = sy-dbcnt.
ENDIF.
LOOP AT itab1.
READ TABLE itab2 WITH KEY
ebeln = itab1-ebeln.
itab3-ebeln = itab1-ebeln.
itab3-ebelp = itab1-ebelp.
itab3-matnr = itab1-matnr.
itab3-lifnr = itab2-lifnr.
itab3-bukrs = itab2-bukrs.
APPEND itab3.
ENDLOOP.
LOOP AT itab3.
WRITE : / sy-vline,
itab3-ebeln, sy-vline,
itab3-ebelp, sy-vline,
itab3-matnr, sy-vline,
itab3-lifnr, sy-vline,
itab3-bukrs, sy-vline.
ENDLOOP.
write : count.
<b>
Regards,
Azhar</b>
08-21-2007 1:08 PM
SELECT AGR_NAME FROM AGR_1250 where OBJECT IN (select OBJCT from
TOBJ where OCLSS IN ('RS','RSR','RSBC')) AND
AGR_NAME LIKE 'Z%'.
write: sy-dbcnt.