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

Classical vs ALV report allignment

Former Member
0 Likes
1,396

Hi Friends,

In classical report 'm getting the output as follows.


PROGRAM ID:  Z2S0K123         Canada-Singapore Corp            PAGE :     1
18.06.2009 14:41:28            Production Materials           USERNAME: RSKUM 

How can I display the same allignment using ALV display?

Thanks in advance.

Regards,

Viji.

12 REPLIES 12
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,345

Hi,

Refer the wiki for displaying data in ALV Grid:-

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/learn%252bto%252bdisplay%252bdata%252bin...

Now if you want the text to be JUSTIFIED the use the field catalog properties to middle align the text.

Hope this helps you.

Regards,

Tarun Gambhir

Read only

Former Member
0 Likes
1,345

Hello,

As per my understanding, the text you have given in post is the part of the header of your report.

You can have the same header in ALV list output. Just write the same code in the form for top of page.

You need to use the events for ALV.

Please try the below code.


DATA: f_event   TYPE slis_alv_event,
          t_events  TYPE slis_t_event,
          w_repid   TYPE repid.
TYPE-POOLS: slis.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
     EXPORTING
          i_list_type     = 0
     IMPORTING
          et_events       = t_events
     EXCEPTIONS
          list_type_wrong = 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.
SORT t_events BY name.
READ TABLE t_events WITH KEY name = slis_ev_top_of_page
                         INTO f_event BINARY SEARCH.
IF sy-subrc = 0.
  MOVE  <slis_ev_top_of_page>   "<-- Form name for top of page (TOP_OF_PAGE)
    TO  f_event-form.
  APPEND f_event TO t_events.
ENDIF.
DELETE t_events WHERE form IS initial.
w_repid = sy-repid.

CALL FUNCTION reuse_alv_list_display
     EXPORTING
          is_layout                  = gf_layout
          it_fieldcat                = gt_fieldcat
          it_events                  = t_events
     TABLES
          t_outtab                   = gt_disp
     EXCEPTIONS
          program_error              = 1
          maximum_of_appends_reached = 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.

*---------------------------------------------------------------------*
*       FORM <TOP_OF_PAGE>                                            *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM <top_of_page>.
WRITE: /'PROGRAM ID:',  <z2s0k123>, 28 'Canada-Singapore Corp', 58 'PAGE:',  <     1>
<18.06.2009>, <14:41:28>,  28 ' Production Materials ',   57 'USERNAME:', <rskum>.
ENDFORM.

When the ALV display FM is called, it internally call the TOP_OF_PAGE subroutine.

Thus you can get the top of page as you want.

Hope this helps you.

Regards,

Sachinkumar Mehta

Read only

Former Member
0 Likes
1,345

Hi Viji,

You can achieve this by using the Field catalog parameters/properties

FIELDCATALOG-JUST = 'L' / 'R' / 'C'.

Thanks & regards,

Dileep .C

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,345

Hello Viji,

Two things to remember:

1. If you are using an ALV list, then it is easy ) You can use WRITE stmts and use the formatting options.

2. If you are using ALV Grid, it is a bit cumbersome. But still you have Tarun's wiki for your reference )

All the best !!!

BR,

Suhas

Read only

former_member212005
Active Contributor
0 Likes
1,345

Please ignore this!

Edited by: Vin on Jun 18, 2009 9:51 AM

Read only

former_member212005
Active Contributor
0 Likes
1,345

Please ignore this!

Edited by: Vin on Jun 18, 2009 9:51 AM

Read only

former_member212005
Active Contributor
0 Likes
1,345

Viji....you have to create an itnernal table which will hold all these details...i.e. should have one column..in the internal table


*      Types declaration to hold header details, displayed in ALV.
       BEGIN OF ty_header,
         col1(500)  TYPE c,
       END OF ty_header,

DATA: gt_header          TYPE STANDARD TABLE OF ty_header,
          gv_gap1(25)              TYPE c VALUE '                        '.

*       Concatenate Program ID, Comp Name and Page number.
        CONCATENATE gv_text1
                                 gv_text2
                                 sy-pageno
                            INTO gv_text
         SEPARATED BY gv_gap1.

        gs_header-col1 = gv_text.
        APPEND gs_header TO gt_header.

* Similarly do it for other fields also...and then
    APPEND gs_header TO gt_header.

*   Display first header 
    CALL METHOD gv_grid_control2->set_table_for_first_display
      EXPORTING
            is_layout                     = gs_layout1
      CHANGING
            it_outtab                     = gt_header
            it_fieldcatalog               = gt_fieldcat2
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.

You may get better answers than these

Read only

Former Member
0 Likes
1,345

Hi,

You can display the same in the TOP -OF -PAGE.... or use

'JUST' property, " (R)ight (L)eft (C)ent.

Read only

Former Member
0 Likes
1,345

Hi Viji,

You can achieve this by using the Field catalog parameters/properties

FIELDCATALOG-JUST = 'L' / 'R' / 'C'.

Thanks & regards,

Dileep .C

Read only

Former Member
0 Likes
1,345

I wonder How I could post three same messages at a time...! Luckyly one more person also seem to be had troubled.

@Fun

---Dileep .C

Edited by: Dileep Kumar Chinnaiah on Jun 18, 2009 3:54 PM

Read only

venkat_o
Active Contributor
0 Likes
1,345

Hi Vijaya Lakshmi,

If you are using REUSE_LAV_LIST_DISPLAY function module, just use WRITE statement to design top of page just like in TOP-OF-PAGE event.

Try this way

*---------------------------------------------------------------------*
*       FORM top_of_page                                              *
*---------------------------------------------------------------------*
FORM top_of_page.
  DATA:
      l_date_1 TYPE char10,
      l_date_2 TYPE char10,
      l_string TYPE string.

  WRITE  AT 50  'Report for Medifund Payments'.
  WRITE: AT /1   'Company code', 25 ':',26 p_bukrs,
             100 'Date:', sy-datum.
  IF NOT s_kunnr-high IS INITIAL.
    WRITE: AT /1   'Customer account', 25 ':',26 s_kunnr-low,'-to-',
                                               s_kunnr-high,
               100 'Time:', sy-uzeit.
  ELSE.
    WRITE: AT /1   'Customer account', 25 ':',26 s_kunnr-low,
               100  'Time:', sy-uzeit.
  ENDIF.
  IF NOT s_blart-high IS INITIAL.
    WRITE: AT /1  'Payment related doc type', 25 ':',26 s_blart-low,'-to-',s_blart-high,
               100 'User:', sy-uname.
  ELSE.
    WRITE: AT /1  'Payment related doc type', 25 ':',26 s_blart-low,
               100 'User:', sy-uname.
  ENDIF.
  IF NOT s_extrdt-high IS INITIAL.
    WRITE: AT /1 'Extraction period', 25 ':',26 s_extrdt-low,'-to-',
                                          s_extrdt-high.
  ELSE.
    WRITE: AT /1 'Extraction period', 25 ':',26 s_extrdt-low.
  ENDIF.
  SKIP 1.
  WRITE AT /1 'Records with errors' .

ENDFORM.                    "top_of_page

Thanks

Venkat.O

Read only

Former Member
0 Likes
1,345

Thanks a lot.