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: 

ALV report - Dsiplay Issue

aasim_khan
Participant
0 Kudos

Hi Experts,

I am making an ALV report. Is there any way/setting which allows me to display the column headings and its corresponding data from the left side of the page rather than from the top?

e.g.

Standard ALV Display

SNo. VesselName BOE Date

-


1 ABC 12.3.2008

2 LMN 15.3.2008

-


To be displayed:

SNo. 1 2

Vessel Name ABC LMN

BOE Date 12.3.2008 15.3.2008

I know it's a bit wierd, but just wanted to know if it's possible. I don't to waste time making a classical report for it.

Thanks in advance

Points will be rewarded if useful.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

May be this prog will give u an overview of the same.

REPORT Z_TRANSPOSEALV .

  • Type pools declaration for ALV

TYPE-POOLS: slis.

*Declarations for ALV, dynamic table and col no for transpose

DATA: l_col TYPE sy-tabix,

l_structure TYPE REF TO data,

l_dyntable TYPE REF TO data,

wa_lvc_cat TYPE lvc_s_fcat,

lt_lvc_cat TYPE lvc_t_fcat,

lt_fieldcatalogue TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv,

lt_fieldcat TYPE slis_t_fieldcat_alv,

lt_layout TYPE slis_layout_alv.

*Field symbols declarations

FIELD-SYMBOLS :

<header> TYPE ANY,

<dynheader> TYPE ANY,

<dyndata> TYPE ANY,

<ls_table> TYPE ANY,

<dynamictable> TYPE STANDARD TABLE,

<it_table> TYPE STANDARD TABLE.

*Input the name of the table

PARAMETERS p_table TYPE dd02l-tabname OBLIGATORY.

*Initialization event

INITIALIZATION.

*Start of selection event

START-OF-SELECTION.

  • Create internal table of dynamic type

CREATE DATA l_dyntable TYPE STANDARD TABLE OF (p_table)

WITH NON-UNIQUE DEFAULT KEY.

ASSIGN l_dyntable->* TO <it_table>.

*select statement to select data from the table as input into

*our dynamic internal table.

*Here i have restricted only till 5 rows.

*You can set a variable and give no of rows to be fetched

*The variable can be set in your select statement

SELECT * INTO CORRESPONDING FIELDS OF TABLE <it_table>

FROM (p_table) up to 5 rows.

*Fieldcatalogue definitions

wa_lvc_cat-fieldname = 'COLUMNTEXT'.

wa_lvc_cat-ref_table = 'LVC_S_DETA'.

APPEND wa_lvc_cat TO lt_lvc_cat.

wa_fieldcat-fieldname = 'COLUMNTEXT'.

wa_fieldcat-ref_tabname = 'LVC_S_DETA'.

wa_fieldcat-key = 'X'..

APPEND wa_fieldcat TO lt_fieldcat.

DESCRIBE TABLE <it_table>.

DO sy-tfill TIMES.

  • For each line, a column 'VALUEx' is created in the fieldcatalog

  • Build Fieldcatalog

WRITE sy-index TO wa_lvc_cat-fieldname LEFT-JUSTIFIED.

CONCATENATE 'VALUE' wa_lvc_cat-fieldname

INTO wa_lvc_cat-fieldname.

wa_lvc_cat-ref_field = 'VALUE'.

wa_lvc_cat-ref_table = 'LVC_S_DETA'.

APPEND wa_lvc_cat TO lt_lvc_cat.

  • Build Fieldcatalog

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = wa_lvc_cat-fieldname.

wa_fieldcat-ref_fieldname = 'VALUE'.

wa_fieldcat-ref_tabname = 'LVC_S_DETA'.

APPEND wa_fieldcat TO lt_fieldcat.

ENDDO.

  • Create dynamic internal table

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = lt_lvc_cat

IMPORTING

ep_table = l_dyntable.

ASSIGN l_dyntable->* TO <dynamictable>.

  • Create structure as structure of the internal table

CREATE DATA l_structure LIKE LINE OF <dynamictable>.

ASSIGN l_structure->* TO <header>.

  • Create structure = structure of the internal table

CREATE DATA l_structure LIKE LINE OF <it_table>.

ASSIGN l_structure->* TO <ls_table>.

  • Create field catalog from our table structure

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = p_table

CHANGING

ct_fieldcat = lt_fieldcatalogue

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

DESCRIBE TABLE lt_fieldcatalogue.

  • Fill the internal to display <dynamictable>

DO sy-tfill TIMES.

IF sy-index = 1.

READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX 1.

ENDIF.

  • For each field of it_table

ASSIGN COMPONENT 1 OF STRUCTURE <header> TO <dynheader>.

IF sy-subrc NE 0. EXIT .ENDIF.

READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX sy-index.

  • Fill 1st column

<dynheader> = wa_fieldcat-seltext_m.

IF <dynheader> IS INITIAL.

<dynheader> = wa_fieldcat-fieldname.

ENDIF.

*Filling the other columns

LOOP AT <it_table> INTO <ls_table>.

l_col = sy-tabix + 1.

ASSIGN COMPONENT sy-index OF STRUCTURE <ls_table> TO <dyndata>.

IF sy-subrc NE 0. EXIT .ENDIF.

ASSIGN COMPONENT l_col OF STRUCTURE <header> TO

<dynheader>.

IF sy-subrc NE 0. EXIT .ENDIF.

WRITE <dyndata> TO <dynheader> LEFT-JUSTIFIED.

ENDLOOP.

APPEND <header> TO <dynamictable>.

ENDDO.

*Layout for ALV output

lt_layout-zebra = 'X'.

lt_layout-no_colhead = 'X'..

lt_layout-colwidth_optimize ='X'.

lt_layout-window_titlebar = 'ALV GRID TRANSPOSED'.

*ALV Grid output for display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

is_layout = lt_layout

it_fieldcat = lt_fieldcat

TABLES

t_outtab = <dynamictable>.

5 REPLIES 5

Former Member
0 Kudos

Hi,

You can archive this by using the dynamic internal table.

Append the table with records fetched as columns so that u can display as u specified.

For help on Dynamic internal table search in SDN.

0 Kudos

Can you please tell me how can I fetch the records column wise?

Former Member
0 Kudos

through grid display it is not possible.

use method set_text_as_r3table in class cl_gui_textedit.

this method is used to display long text or abap editor.

CALL METHOD g_text_grid->set_text_as_r3table

EXPORTING

table = it_abcd

  • EXCEPTIONS

  • ERROR_DP = 1

  • ERROR_DP_CREATE = 2

  • others = 3

.

you need to build ur one it_abcd table.

Former Member
0 Kudos

May be this prog will give u an overview of the same.

REPORT Z_TRANSPOSEALV .

  • Type pools declaration for ALV

TYPE-POOLS: slis.

*Declarations for ALV, dynamic table and col no for transpose

DATA: l_col TYPE sy-tabix,

l_structure TYPE REF TO data,

l_dyntable TYPE REF TO data,

wa_lvc_cat TYPE lvc_s_fcat,

lt_lvc_cat TYPE lvc_t_fcat,

lt_fieldcatalogue TYPE slis_t_fieldcat_alv,

wa_fieldcat TYPE slis_fieldcat_alv,

lt_fieldcat TYPE slis_t_fieldcat_alv,

lt_layout TYPE slis_layout_alv.

*Field symbols declarations

FIELD-SYMBOLS :

<header> TYPE ANY,

<dynheader> TYPE ANY,

<dyndata> TYPE ANY,

<ls_table> TYPE ANY,

<dynamictable> TYPE STANDARD TABLE,

<it_table> TYPE STANDARD TABLE.

*Input the name of the table

PARAMETERS p_table TYPE dd02l-tabname OBLIGATORY.

*Initialization event

INITIALIZATION.

*Start of selection event

START-OF-SELECTION.

  • Create internal table of dynamic type

CREATE DATA l_dyntable TYPE STANDARD TABLE OF (p_table)

WITH NON-UNIQUE DEFAULT KEY.

ASSIGN l_dyntable->* TO <it_table>.

*select statement to select data from the table as input into

*our dynamic internal table.

*Here i have restricted only till 5 rows.

*You can set a variable and give no of rows to be fetched

*The variable can be set in your select statement

SELECT * INTO CORRESPONDING FIELDS OF TABLE <it_table>

FROM (p_table) up to 5 rows.

*Fieldcatalogue definitions

wa_lvc_cat-fieldname = 'COLUMNTEXT'.

wa_lvc_cat-ref_table = 'LVC_S_DETA'.

APPEND wa_lvc_cat TO lt_lvc_cat.

wa_fieldcat-fieldname = 'COLUMNTEXT'.

wa_fieldcat-ref_tabname = 'LVC_S_DETA'.

wa_fieldcat-key = 'X'..

APPEND wa_fieldcat TO lt_fieldcat.

DESCRIBE TABLE <it_table>.

DO sy-tfill TIMES.

  • For each line, a column 'VALUEx' is created in the fieldcatalog

  • Build Fieldcatalog

WRITE sy-index TO wa_lvc_cat-fieldname LEFT-JUSTIFIED.

CONCATENATE 'VALUE' wa_lvc_cat-fieldname

INTO wa_lvc_cat-fieldname.

wa_lvc_cat-ref_field = 'VALUE'.

wa_lvc_cat-ref_table = 'LVC_S_DETA'.

APPEND wa_lvc_cat TO lt_lvc_cat.

  • Build Fieldcatalog

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = wa_lvc_cat-fieldname.

wa_fieldcat-ref_fieldname = 'VALUE'.

wa_fieldcat-ref_tabname = 'LVC_S_DETA'.

APPEND wa_fieldcat TO lt_fieldcat.

ENDDO.

  • Create dynamic internal table

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = lt_lvc_cat

IMPORTING

ep_table = l_dyntable.

ASSIGN l_dyntable->* TO <dynamictable>.

  • Create structure as structure of the internal table

CREATE DATA l_structure LIKE LINE OF <dynamictable>.

ASSIGN l_structure->* TO <header>.

  • Create structure = structure of the internal table

CREATE DATA l_structure LIKE LINE OF <it_table>.

ASSIGN l_structure->* TO <ls_table>.

  • Create field catalog from our table structure

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = p_table

CHANGING

ct_fieldcat = lt_fieldcatalogue

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

DESCRIBE TABLE lt_fieldcatalogue.

  • Fill the internal to display <dynamictable>

DO sy-tfill TIMES.

IF sy-index = 1.

READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX 1.

ENDIF.

  • For each field of it_table

ASSIGN COMPONENT 1 OF STRUCTURE <header> TO <dynheader>.

IF sy-subrc NE 0. EXIT .ENDIF.

READ TABLE lt_fieldcatalogue INTO wa_fieldcat INDEX sy-index.

  • Fill 1st column

<dynheader> = wa_fieldcat-seltext_m.

IF <dynheader> IS INITIAL.

<dynheader> = wa_fieldcat-fieldname.

ENDIF.

*Filling the other columns

LOOP AT <it_table> INTO <ls_table>.

l_col = sy-tabix + 1.

ASSIGN COMPONENT sy-index OF STRUCTURE <ls_table> TO <dyndata>.

IF sy-subrc NE 0. EXIT .ENDIF.

ASSIGN COMPONENT l_col OF STRUCTURE <header> TO

<dynheader>.

IF sy-subrc NE 0. EXIT .ENDIF.

WRITE <dyndata> TO <dynheader> LEFT-JUSTIFIED.

ENDLOOP.

APPEND <header> TO <dynamictable>.

ENDDO.

*Layout for ALV output

lt_layout-zebra = 'X'.

lt_layout-no_colhead = 'X'..

lt_layout-colwidth_optimize ='X'.

lt_layout-window_titlebar = 'ALV GRID TRANSPOSED'.

*ALV Grid output for display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

is_layout = lt_layout

it_fieldcat = lt_fieldcat

TABLES

t_outtab = <dynamictable>.

0 Kudos

Hey Joyjit,

Thanks buddy. That's exactly what I was lookin' for, though it's not printing all the records.

But thanks a TON

If you could explain me why it's not displaying all the records, then I would be able to make some changes in it accordingly.

Thanks once again pal, I really appreciate it.

Hence I gave you a perfect 10ner