Multi-line ALV using ROW_POS in field catalog

VN:F [1.9.3_1094]
Rating: 6.0/10 (1 vote cast)

Does you business requirement needs single line item in ALV to be displayed in multiple rows/lines for better readability? You then surely need a multi-line ALV, which can be implemented by just a simple tweaking in your ALV field catalog.

You can achieve this objective using property ROW_POS of Field catalog. Just assign a value between 1 to 3 to each of the records (denoting output internal table’s columns/fields) in field catalog. That’s it. Value is restricted between 1 and 3 since ALV can handle maximum of 3 rows for 1 ALV line item.
The example followed will completely clear the usage.

Here is the code to build the field catalog of an ALV.

FORM e01_fieldcat_init USING e01_lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA: ls_fieldcat TYPE slis_fieldcat_alv.
ls_fieldcat-fieldname = ‘CARRID’.
ls_fieldcat-key       = ‘X’.
ls_fieldcat-ref_fieldname = ‘CARRID’.
ls_fieldcat-ref_tabname = ‘SFLIGHT’.
ls_fieldcat-row_pos = 1.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CONNID’.
ls_fieldcat-key       = ‘X’.
ls_fieldcat-ref_fieldname = ‘CONNID’.
ls_fieldcat-ref_tabname = ‘SFLIGHT’.
ls_fieldcat-row_pos = 1.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘FLDATE’.
ls_fieldcat-key       = ‘X’.
ls_fieldcat-ref_fieldname = ‘FLDATE’.
ls_fieldcat-ref_tabname = ‘SFLIGHT’.
ls_fieldcat-row_pos = 1.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘PRICE’.
ls_fieldcat-ref_fieldname = ‘PRICE’.
ls_fieldcat-ref_tabname = ‘SFLIGHT’.
ls_fieldcat-row_pos = 2.
APPEND ls_fieldcat TO e01_lt_fieldcat.
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = ‘CURRENCY’.
ls_fieldcat-ref_fieldname = ‘CURRENCY’.
ls_fieldcat-ref_tabname = ‘SFLIGHT’.
ls_fieldcat-row_pos = 2.
APPEND ls_fieldcat TO e01_lt_fieldcat.
ENDFORM.

FORM e01_fieldcat_init USING e01_lt_fieldcat TYPE slis_t_fieldcat_alv.

DATA: ls_fieldcat TYPE slis_fieldcat_alv.

ls_fieldcat-fieldname = ‘CARRID’.

ls_fieldcat-key       = ‘X’.

ls_fieldcat-ref_fieldname = ‘CARRID’.

ls_fieldcat-ref_tabname = ‘SFLIGHT’.

ls_fieldcat-row_pos = 1.

APPEND ls_fieldcat TO e01_lt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = ‘CONNID’.

ls_fieldcat-key       = ‘X’.

ls_fieldcat-ref_fieldname = ‘CONNID’.

ls_fieldcat-ref_tabname = ‘SFLIGHT’.

ls_fieldcat-row_pos = 1.

APPEND ls_fieldcat TO e01_lt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = ‘FLDATE’.

ls_fieldcat-key       = ‘X’.

ls_fieldcat-ref_fieldname = ‘FLDATE’.

ls_fieldcat-ref_tabname = ‘SFLIGHT’.

ls_fieldcat-row_pos = 1.

APPEND ls_fieldcat TO e01_lt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = ‘PRICE’.

ls_fieldcat-ref_fieldname = ‘PRICE’.

ls_fieldcat-ref_tabname = ‘SFLIGHT’.

ls_fieldcat-row_pos = 2.

APPEND ls_fieldcat TO e01_lt_fieldcat.

CLEAR ls_fieldcat.

ls_fieldcat-fieldname = ‘CURRENCY’.

ls_fieldcat-ref_fieldname = ‘CURRENCY’.

ls_fieldcat-ref_tabname = ‘SFLIGHT’.

ls_fieldcat-row_pos = 2.

APPEND ls_fieldcat TO e01_lt_fieldcat.

ENDFORM.

The ALV with the above field catalog gives the following multi-lined ALV output.
Multi-lined ALV using ROW_POS specified in Field catalog

Multi-lined ALV using ROW_POS specified in Field catalog

All the columns with row_pos as 1 in the field catalog are appearing in 1st row where as the ones with row_pos as 2 are appearing in the 2nd row, even though they are one single line item in the ALV output internal table.
VN:F [1.9.3_1094]
Rating: 6.0/10 (1 vote cast)
Multi-line ALV using ROW_POS in field catalog, 6.0 out of 10 based on 1 rating
Hey friends!!! Don't forget to promote the post by pressing the buttons below, if you liked it...
  • Digg
  • del.icio.us
  • StumbleUpon
  • Twitthis
  • Yahoo! Buzz
  • Facebook
  • Technorati
  • LinkedIn

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>