11-29-2007 10:50 AM
An internal table ICODE contains the following entries:
field1 field2
-
John 12345
Alice 23478
Sam 54321
Bob 10000
IF NOT ICODE[] IS INITIAL.
SORT ICODE BY FIELD1 DESCENDING.
READ TABLE ICODE WITH KEY FIELD1 = 'Sam'.
WRITE: / SY-TABIX.
ENDIF.
What is the output of the above code after execution?
a) 1
b) 2
c) 3
d) 4
e) Sam
11-29-2007 10:51 AM
11-29-2007 10:51 AM
11-29-2007 10:51 AM
11-29-2007 10:53 AM
11-29-2007 11:46 AM
a) 1
In the descending order 'Sam' will be the first entry.
The internal table will look like this:
field1 field2
------ -------
Sam 54321
John 12345
Bob 10000
Alice 23478
The code:
DATA: BEGIN OF icode occurs 4,
field1(5) TYPE c,
field2(5) TYPE n,
END OF icode.
icode-field1 = 'John'.
icode-field2 = '12345'.
APPEND icode.
icode-field1 = 'Alice'.
icode-field2 = '23478'.
APPEND icode.
icode-field1 = 'Sam'.
icode-field2 = '54321'.
APPEND icode.
icode-field1 = 'Bob'.
icode-field2 = '10000'.
APPEND icode.
IF NOT icode[] IS INITIAL.
SORT icode BY field1 DESCENDING.
READ TABLE icode WITH KEY field1 = 'Sam'.
WRITE: / sy-tabix.
ENDIF.
produces this output:
1