Application Development 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: 

related to internal table

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

ans is a

4 REPLIES 4

Former Member
0 Kudos

A

Former Member
0 Kudos

ans is a

former_member386202
Active Contributor
0 Kudos

Hi,

1 only

Regards,

Prashant

Former Member
0 Kudos

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