Application Development and Automation 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: 
Read only

read lines

Former Member
0 Likes
1,579

Hi all,

How to use the read line statement to read all the lines in the output of an report

Thanks

Saravana

4 REPLIES 4
Read only

Former Member
0 Likes
952

Hi

Use a Do loop and write the read statement in the Loop.

sample code

DO.

READ LINE sy-index FIELD VALUE v_chk.

IF sy-subrc NE 0.

EXIT.

ENDIF.

READ LINE sy-index FIELD VALUE sy-lisel INTO v_lisel.

IF v_lisel+2(1) = ' ' AND sy-index GT 5.

v_lisel+2(1) = 'X'.

MODIFY LINE sy-index FIELD VALUE sy-lisel FROM v_lisel.

ENDIF.

ENDDO.

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

Former Member
0 Likes
952

CHeck this.#


READ - Reading a Line from a List 


Variants: 
1. READ LINE line. 
2. READ LINE line OF CURRENT PAGE. 
3. READ LINE line OF PAGE pag. 
4. READ CURRENT LINE. 



Variant 1 
READ LINE line. 


Additions: 
1. ... INDEX idx 
2. ... FIELD VALUE f1 INTO g1 
                      ... 
                   fn INTO gn 
3. ... LINE VALUE INTO wa 



Effect 
Reads line number line of the list, usually after a line selection ( AT LINE-SELECTION, AT PFxx, AT USER-COMMAND). 
The line is placed in the field SY-LISEL, and all 'hidden' information (HIDE) is automatically placed into its original fields. 
The output format of the line read is set for all subsequent MODIFY LINE and WRITE statements. 
You can change the contents of format of the list line using MODIFY LINE with the appropriate additinos. 


The return code is set as follows: 



SY-SUBRC = 0: 
Line exists 
SY-SUBRC <> 0: 
Line does not exist 


Addition 1 
... INDEX idx 



Effect 
Reads the line from the list with level idx (0, 1, 2...) where more than one list level exists. 


Addition 2 
... FIELD VALUE f1 INTO g1                    ... 
                fn INTO gn 



Effect 
The contents of the fields f1, f2, ... are transported from the list line to the fields g1, g2, ... . (The field contents in the list line always have type C. The system converts types as in the MOVE statement). 


Note 
All formatting characters in the list output of f1, f2, ... count as field contents. If a field is displayed more than once in a list line, only its first occurrence is copied. If the field, say f2, is not displayed at all in the line, field g2 remains unchanged. You can omit the addition INTO g2 if, for example, the field contents in the original field (f2, for example), are also to be transported back. In other words, 



... FIELD VALUE ... f2 



has the same meaning as 



... FIELD VALUE ... f2 INTO f2 



The return value SY-SUBRC is not affected by the FIELD VALUE addition. In other words, it does not depend on whether the chosen list line exists. 


Note 
The FIELD VALUE addition is specially intended to process the user's input in an input field in a list (see FORMAT, WRITE), since you cannot address input field using HIDE. 


Example 
Suppose you make a line "selectable" as follows: 



DATA MARKFIELD(1) TYPE C. 
     ... 
WRITE: / MARKFIELD INPUT, 'Text'. 



After the line selection, you can use 



CLEAR MARKFIELD. 
READ LINE SY-CUROW FIELD VALUE MARKFIELD. 



to find out in the program whether the user selected the line or not (IF MARKFIELD = SPACE ...). 



Addition 3 
... LINE VALUE INTO wa 


Effect 
The entire contents of the selected list line are transported to field wa. 


Note 
The LINE VALUE addition allows you to place the entire line contents in a user-defined work area, providing an alternative method of accessing the line that is independent of the attributes of the system field SY-LISEL (length of SY-LISEL is 255 characters). 

If you need a work area wa that can accommodate lists of any width, use the type SLIST_MAX_LISTLINE from type group SLIST. 



Variant 2 
READ LINE line OF CURRENT PAGE. 

Additions: 
As described in READ LINE. 



Effect 
Similar to the READ LINE line variant. The line number line refers to the current page (system field SY-CPAGE) at the beginning of the current event. Changing the value of SY-CPAGE in the application program has no influence on the display. 



Notes 
If the list has multiple control levels, the system always works with the control level in which the line was selected. 



When you return from the line selection, the system always returns to the last page to be displayed (if you need to scroll, use the SCROLL statement). 



Variant 3 
READ LINE line OF PAGE pag. 


Additions: 
As described in READ LINE. 



Effect 
As in variant 2, except that the system reads from page pag instead of the current page. 



Variant 4 
READ CURRENT LINE. 


Additions: 
1. ... FIELD VALUE f1 INTO g1 
                      ... 
                   fn INTO gn 
2. ... LINE VALUE INTO wa 



Effect 
Rereads the last line to be read (by line selection or READ LINE). This is useful in conjunction with the FIELD VALUE addition for retrieving field contents from the selected line in cases where it impossible to use the HIDE area. 



Additions 
1. ... FIELD VALUE f1 INTO g1                        ... 
                   fn INTO gn 

2. ... LINE VALUE INTO wa 



Effect 
See additions 2 and 3 of the READ LINE line variant. 


Additional help 
Reading Lines from Lists 

VAsanth

Read only

former_member491305
Active Contributor
0 Likes
952

AT USER-COMMAND.

CASE sy-ucomm .

WHEN 'CHANGE'.

DO.

READ LINE sy-index FIELD VALUE x_lfa1-sel x_lfa1-lifnr x_lfa1-telf1.

IF sy-subrc = 0 .

CHECK x_lfa1-sel = 'X'.

CLEAR x_lfa1-sel.

IF x_lfa1-telf1 IS INITIAL.

MESSAGE 'Please Enter Phone no in the selected coloumn' TYPE 'E'.

ELSE.

MODIFY LINE sy-index FIELD VALUE x_lfa1-sel LINE FORMAT COLOR 4 INTENSIFIED ON.

ENDIF.

ELSE.

EXIT.

ENDIF.

ENDDO.

Read only

varma_narayana
Active Contributor
0 Likes
952

Hi ..

Try this logic.

AT LINE-SELECTION.

CASE SY-LSIND.

WHEN 1.

Do.

READ LINE SY-INDEX FIELD VALUE v_field1

v_field2.

if sy-subrc ne 0.

EXIT.

endif.

WRITE:/ V_FIELD1, V_FIELD2.

ENDDO.

ENDCASE.

Reward Helpful ones.