+ -

Pages

Saturday, July 26, 2014

Reading mulitiple selected lines in a list

Scenario: List with checkboxes. You want to read all lines in the list where the checkboxes are cheked into an internal table.


* Define checkbox
data: markfield(1) type c value space. 

* Write list

loop at itab.
  write: /  markfield as checkbox, itab1-myfield.
endloop.


When you are ready to read the list igain:


* Holds the number of the current line
 lineno type i.


 lineno = 0.                                                 

*Read the report line by line
 do.                                                         
   lineno = lineno + 1.                                      

*  Read markfield 
   read line lineno field value markfield.                   
   
 * Check that you haven't reached the end of the report  
   if sy-subrc ne 0. 
        exit. 
   endif.                            

* If markfield = X then read the report line again and append it to another internal

* table  
  if markfield = 'X'.
*       read the line igain to retrieve all  fields of the line                                     
        read current line                                    
           field value itab1-myfield                    
                             into itab2-myfield.  
         append itab2.                             
    endif.                                                    
                                                                 

  enddo.                
5 ABAP Tips: Reading mulitiple selected lines in a list Scenario: List with checkboxes. You want to read all lines in the list where the checkboxes are cheked into an internal table. * Define ch...

No comments:

Post a Comment

< >