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: 

Reg loops

Former Member
0 Kudos

I have a internal table with various fields... like

SO SO line item Matnr Date Diff Result

1452261 10 NXP1010 2 Yes

1452261 10 NXP1010 2 Yes

1452261 10 NXP1010 3 Yes

1452261 10 NXP1010 1 No

1452261 10 NXP1010 0 No

Now i want to find the no of records only with result 'YES'. and also i want to find the total no of records.

<removed_by_moderator> <= read [the rules|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/rulesofEngagement] here!

Edited by: Julius Bussche on Jul 16, 2008 2:57 PM

Points removed from everyone who answered

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos

loop through. if result equals yes, then add 1 to counter. get total number of lines using lines( ).

matt

6 REPLIES 6

matt
Active Contributor
0 Kudos

loop through. if result equals yes, then add 1 to counter. get total number of lines using lines( ).

matt

Former Member
0 Kudos

hi,

You can find Total No of Records using

DESCRIBE <table> lines <line-var>.

That will Give You Total No of lines ie No of Records.

Regards

Sumit Agarwal

former_member70391
Contributor
0 Kudos

Hi ,

data: counter type i value 0.

Looat at table.

if table-result eq 'Yes'.

counter = counter + 1.

endif.

endloop.

Hope it helps.

Thanks & Regards,

Nagaraj Kalbavi

Former Member
0 Kudos

Copy the intenale table 1(original) to internal table 2.

Describe the 1nd internal table to find the total no of records.

delete the records which has NO.

and Describe the 2nd internal table to find the no of records only with result 'YES'.

Regards,

Rajasekhar Reddy.

Former Member
0 Kudos

Hi,

For finding total number of records use the following logic.


DATA: N1    TYPE I, 
          N2 type i.

 DESCRIBE TABLE ITAB LINES N1. 

*N contains the total number of records.

*for finding number of records with Yes try this way

itab1 = itab. * Itab1 same structure of itab.

delete itab1 where result = 'YES'.

DESCRIBE TABLE ITAB1 LINES N2. 

*number of records with result = Yes is N1 - N2.

I think this will be performance efficient(without loop) for your case of just knowing number of records

//Kothand

Former Member
0 Kudos

Hi

Use the fields that you want in the below select statement

TABLES xxxx.

SELECT * FROM xxxx

WHERE

Diff Result = 'YES' .

WRITE: / Diff Result.

ENDSELECT.

Regards

Divya