Application Development and Automation 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: 
Read only

ALV Data horizontally?

Former Member
0 Likes
636

Hi All,

I have to display some data in ALV format.

Data contains only 1 row.

So, instead of displaying them as columns, I want to display them horizontally as rows.

I want in this format

Name:

EE Number:

instead of this format

Name EE Number

Is there any way we can do this?

Any help will be greatly appreciated.

Thanks,

Haritha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
607

You can use Hierarchy ALV...Not my code...I copied from SDN and do some modifications...


TYPE-POOLS: slis.
 
DATA: BEGIN OF itab OCCURS 0,
        vbeln TYPE vbeln,
        expand,
      END OF itab.
 
DATA: BEGIN OF itab1 OCCURS 0,
        vbeln TYPE vbeln,
        posnr TYPE posnr,
        matnr TYPE matnr,
        netpr TYPE netpr,
      END OF itab1.
 
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
 
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname   = 'ITAB'.
s_fieldcatalog-rollname  = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
 
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
 
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'POSNR'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'POSNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
 
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'MATNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
 
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'NETPR'.
s_fieldcatalog-do_sum    = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
 
DATA: s_layout TYPE slis_layout_alv.
 
s_layout-subtotals_text            = 'SUBTOTAL TEXT'.
s_layout-key_hotspot = 'X'.
s_layout-expand_fieldname = 'EXPAND'.
 
 
SELECT vbeln UP TO 100 ROWS
       FROM
       vbak
       INTO TABLE itab.
 
 
IF NOT itab[] IS INITIAL.
 
  SELECT vbeln posnr matnr netpr
         FROM vbap
         INTO TABLE itab1
         FOR ALL ENTRIES IN itab
         WHERE vbeln = itab-vbeln.
 
ENDIF.
 
DATA: v_repid TYPE syrepid.
 
v_repid = sy-repid.
 
DATA: s_keyinfo TYPE slis_keyinfo_alv.
s_keyinfo-header01 = 'VBELN'.
s_keyinfo-item01   = 'VBELN'.
 
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
     EXPORTING
          i_callback_program = v_repid
          is_layout          = s_layout
          it_fieldcat        = t_fieldcatalog
          i_tabname_header   = 'ITAB'
          i_tabname_item     = 'ITAB1'
          is_keyinfo         = s_keyinfo
     TABLES
          t_outtab_header    = itab
          t_outtab_item      = itab1
     EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Greetings,

Blag.

Hi All,

I have to display some data in ALV format.

Data contains only 1 row.

So, instead of displaying them as columns, I want to display them horizontally as rows.

I want in this format

Name:

EE Number:

instead of this format

Name EE Number

Is there any way we can do this?

Any help will be greatly appreciated.

Thanks,

Haritha

3 REPLIES 3
Read only

Former Member
0 Likes
608

You can use Hierarchy ALV...Not my code...I copied from SDN and do some modifications...


TYPE-POOLS: slis.
 
DATA: BEGIN OF itab OCCURS 0,
        vbeln TYPE vbeln,
        expand,
      END OF itab.
 
DATA: BEGIN OF itab1 OCCURS 0,
        vbeln TYPE vbeln,
        posnr TYPE posnr,
        matnr TYPE matnr,
        netpr TYPE netpr,
      END OF itab1.
 
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
 
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname   = 'ITAB'.
s_fieldcatalog-rollname  = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
 
s_fieldcatalog-col_pos = '1'.
s_fieldcatalog-fieldname = 'VBELN'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'VBELN'.
s_fieldcatalog-outputlen = '12'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
 
s_fieldcatalog-col_pos = '2'.
s_fieldcatalog-fieldname = 'POSNR'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'POSNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
 
s_fieldcatalog-col_pos = '3'.
s_fieldcatalog-fieldname = 'MATNR'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'MATNR'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
 
s_fieldcatalog-col_pos = '4'.
s_fieldcatalog-fieldname = 'NETPR'.
s_fieldcatalog-tabname   = 'ITAB1'.
s_fieldcatalog-rollname  = 'NETPR'.
s_fieldcatalog-do_sum    = 'X'.
APPEND s_fieldcatalog TO t_fieldcatalog.
CLEAR: s_fieldcatalog.
 
DATA: s_layout TYPE slis_layout_alv.
 
s_layout-subtotals_text            = 'SUBTOTAL TEXT'.
s_layout-key_hotspot = 'X'.
s_layout-expand_fieldname = 'EXPAND'.
 
 
SELECT vbeln UP TO 100 ROWS
       FROM
       vbak
       INTO TABLE itab.
 
 
IF NOT itab[] IS INITIAL.
 
  SELECT vbeln posnr matnr netpr
         FROM vbap
         INTO TABLE itab1
         FOR ALL ENTRIES IN itab
         WHERE vbeln = itab-vbeln.
 
ENDIF.
 
DATA: v_repid TYPE syrepid.
 
v_repid = sy-repid.
 
DATA: s_keyinfo TYPE slis_keyinfo_alv.
s_keyinfo-header01 = 'VBELN'.
s_keyinfo-item01   = 'VBELN'.
 
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
     EXPORTING
          i_callback_program = v_repid
          is_layout          = s_layout
          it_fieldcat        = t_fieldcatalog
          i_tabname_header   = 'ITAB'
          i_tabname_item     = 'ITAB1'
          is_keyinfo         = s_keyinfo
     TABLES
          t_outtab_header    = itab
          t_outtab_item      = itab1
     EXCEPTIONS
          program_error      = 1
          OTHERS             = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Greetings,

Blag.

Read only

0 Likes
607

Thanks for the reply.

I have about 13 fields to display horizontally.

I dont think it is efficient to use 13 internal tables for hierarchial display.

Any other possibility?

Please help.

Thanks,

Haritha

Message was edited by:

Haritha

Read only

0 Likes
607

> I have about 13 fields to display horizontally.

>

> I dont think it is efficient to use 13 internal

> tables for hierarchial display.

Of course not....The report would look like a mess....Sorry...I'm not aware of any other method...

Greetings,

Blag.