Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8581

Re: Write single data within Loop

$
0
0

Hello Bikash,

 

These reason you received the output twice in this scenario is because the internal table 'itab' contained two rows of data.  If you wanted to only display the data pertaining to the first row of data, you could use the Sy-index check.  Sy-index is a system variable that indicates where you currently are in the loop. For example:

 

LOOP at itab into stab.

     if sy-index = 1.   "Only write the values out for the first loop iteration

       WRITE: / stab-text1, stab-amt .

     endif.

endloop.

 

The above would only write out the result once, as desired. Additionally, you could add a condition in the loop in order to determine the row you are interested in based on your requirement, store the values in question to variables and then write out the values outside of the loop. However, if you are doing nothing else in this loop aside from writing out the variables, you should look into replacing the loop with a read statement and then writing the value(s) out.

 

Please reward if helpful!

Sam


Viewing all articles
Browse latest Browse all 8581

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>