07-02-2007 9:15 AM
Dear all,
I have a report format :
Field 1 Field 2 Field 3
XXX XXXXX XXXX
XXX XXXXX XXXX
XXX XXXXX XXXX
I want to change this format to :
Field 1 Field 2 Field 3
XXX XXXXX XXXX
XXXXX XXXX
XXXXX XXXX
Field1 is be display one times and I want that I can read the field 1 value with READ LINE
I try to use HIDE: Field 1 in a loop ,but It can not hide the field 1 value.
why?
thanks you
John
07-02-2007 9:19 AM
Hi,
Use the statements READ LINE and READ CURRENT LINE to read data from the lines of existing list levels. These statements are closely connected to the HIDE technique.
All of the lists generated by a single program are stored internally in the system. You can therefore access any list in a program that was created for the same screen and that has not yet been deleted by returning to a lower list level. To read lines, use the statements READ LINE and READ CURRENT LINE.
To read a line from a list after an interactive list event, use the READ LINE statement:
READ LINE <lin> [INDEX <idx>]
[FIELD VALUE <f1> [INTO <g 1>] ... <f n> [INTO <g n>]]
[OF CURRENT PAGE|OF PAGE <p>].
The statement without any options stores the contents of line <lin> from the list on which the event was triggered (index SY-LILLI) in the SY-LISEL system field and fills all HIDE information stored for this line back into the corresponding fields. As far as SY-LISEL and the HIDE area are concerned, READ LINE has the same effect as an interactive line selection.
<b>Here is the Demo Program</b>
REPORT demo_list_read_line NO STANDARD PAGE HEADING.
TABLES: sflight.
DATA: box(1) TYPE c, lines TYPE i, free TYPE i.
START-OF-SELECTION.
SET PF-STATUS 'CHECK'.
GET sflight.
WRITE: box AS CHECKBOX, sflight-fldate.
HIDE: sflight-fldate, sflight-carrid, sflight-connid,
sflight-seatsmax, sflight-seatsocc.
END-OF-SELECTION.
lines = sy-linno - 1.
TOP-OF-PAGE.
WRITE: 'List of flight dates'.
ULINE.
TOP-OF-PAGE DURING LINE-SELECTION.
WRITE: 'Date:', sflight-fldate.
ULINE.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'READ'.
box = space.
SET PF-STATUS 'CHECK' EXCLUDING 'READ'.
DO lines TIMES.
READ LINE sy-index FIELD VALUE box.
IF box = 'X'.
free = sflight-seatsmax - sflight-seatsocc.
IF free > 0.
NEW-PAGE.
WRITE: 'Company:', sflight-carrid,
'Connection: ',sflight-connid,
/ 'Number of free seats:', free.
ENDIF.
ENDIF.
ENDDO.
ENDCASE.
Regards
Sudheer
07-02-2007 9:28 AM
Hi
The command HIDE is for the fields written on the list only, if you wan to print the field FIELD1 once you can use a code like this:
DATA: _FIELD1.
LOOP AT ITAB
AT FIRST.
WRITE: / ITAB-FIELD1.
_FIELD1 = 'X'.
ENDAT.
IF _FIELD1 = SPACE
WRITE: / ITAB-FIELD2, ITAB-FIELD3.
ELSE.
_FIELD1 = SPACE.
WRITE: ITAB-FIELD2, ITAB-FIELD3.
ENDIF.
ENDLOOP.
Now you can know the value of FIELD1 for the first row only by READ LINE command. If you need to know the value for the other lines you need to know a link between the line and record index.
For example if the first record is written on the 3 line, the link will be:
TABLE INDEX = PAGE LINE - 2.
So:
_LINE = 3.
DO.
READ LINE _LINE.
IF SY-SUBRC <> 0. EXIT. ENDIF.
TABINDEX = _LINE - 2.
READ TABLE ITAB INDEX TABINDEX.
IF SY-SUBRC <> 0. EXIT. ENDIF.
WRITE: / ITAB-FIELD1.
_LINE = _LINE + 1.
ENDDO.
Max
Message was edited by:
max bianchi