Skip to Content
avatar image
Former Member

ALV header with two rows?

Hi ,

I need to create ALV Grid reprot using class-method.

Issue is, header of the report should be in 2 row (one in English and ohter could be Chinese).

How do we cretae such header?

e.g.

Regards,

Monazza

Capture.PNG (3.7 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 01, 2015 at 06:12 AM

    Hi Fatima,

    you can do it by using ALV_GRID or ALV_LIST,

    let us to start wit first option, but I am not sure if it is suitable for you

    the idea, I wanted to add a new record as header but the problem is the domain of data element ( field) has 3 char, and your header name has  6 letters, so at the end it will be cut

    anyway, I have tried the first option with arabic and german langauges.


    DATA lt_scarr TYPE TABLE OF scarr.
    DATA ls_scarr TYPE scarr.
    *DATA lt_fcat TYPE slis_t_fieldcat_alv.
    *DATA ls_fcat LIKE LINE OF lt_fcat.

    FIELD-SYMBOLS <lv_field> TYPE any.

    START-OF-SELECTION.
      ls_scarr-carrid = 'رقم الخطوط الجويه'. " hier only 3 char
      ls_scarr-carrname = 'اسم الخطوط الجويه'.
      ls_scarr-currcode = 'العمله'. " hier 5 chars:(
      ls_scarr-url = 'موقع الشركه'.
      APPEND ls_scarr to lt_scarr.

      ls_scarrcarrid = 'Kurzbezeichnung der Fluggesellschaft'. " hier only 3
      ls_scarr-carrname = 'Name einer Fluggesellschaft'.
      ls_scarr-currcode = 'Hauswährung der Fluggesellschaft'.
      ls_scarr-url = 'URL einer Fluggesellschaft'.
      APPEND ls_scarr to lt_scarr.

      SELECT * FROM scarr APPENDING TABLE lt_scarr UP TO 10 ROWS.


      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_structure_name = 'SCARR'
        TABLES
          t_outtab    = lt_scarr.

    Second one with ALV-LIST

    you can refer to this post please .  Alv header in 2 lines | SCN

    I have just edited this code and the result could be with 2 langauges .

    FORM TOP_OF_PAGE.

    FORMAT COLOR COL_HEADING.

    " Language 1
    WRITE: / SY-ULINE(45).
    WRITE: / SY-VLINE,
    (8) ' فاطمه1 ' ,
    SY-VLINE,
    (8) 'فاطمه2 ' ,
    SY-VLINE,

    (8) 'فاطمه3' ,
    SY-VLINE,
    *
    (8) 'فاطمه4' ,

    sy-vline.


    " Langauge 2.
    WRITE: / SY-VLINE,
    (8) 'VBELN'(013) ,
    SY-VLINE,
    (8) 'POSNR'(014) ,
    SY-VLINE,
    (8) 'MALE'(016) ,
    sy-vline,
    (8) 'FMALE'(017) ,
    sy-vline.

    FORMAT COLOR OFF.

    Regards

    Ebrahim


    1.jpg (67.6 kB)
    2.jpg (50.7 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 02, 2015 at 06:55 AM

    Hi,

    refer the following code and link...

    http://scn.sap.com/message/8665724#8665724

    DATA:

       BEGIN OF it_data OCCURS 0,

       header1 TYPE char50,

       header2 TYPE char50,

       arbgb TYPE t100-arbgb,

       msgnr TYPE t100-msgnr,

       text TYPE t100-text,

       END OF it_data.

    *ALV Declarations

    TYPE-POOLS:slis.

    TYPES:

       ty_fieldcat   TYPE slis_fieldcat_alv,

       ty_events   TYPE slis_alv_event,

       ty_layout   TYPE slis_layout_alv.

    DATA:

       wa_fieldcat   TYPE ty_fieldcat,

       wa_events   TYPE ty_events,

       wa_layout   TYPE ty_layout.

    DATA:

       it_events   TYPE STANDARD TABLE OF ty_events,

       it_fieldcat   TYPE STANDARD TABLE OF ty_fieldcat.

    DATA:

       g_program   TYPE sy-repid.

    START-OF-SELECTION.

      SELECT * FROM t100 INTO CORRESPONDING FIELDS OF TABLE it_data

      UP TO 20 ROWS WHERE sprsl = sy-langu.

    *Fieldcatalog.

      PERFORM fieldcatalog USING:                                                                              "Field Lengths

      1 1 'HEADER1' 'IT_DATA' 'HEADER1' '30',

      1 2 'HEADER2' 'IT_DATA' 'HEADER2' '73',

      2 3 'ARBGB'   'IT_DATA' 'ARBGB'   '20',

      2 4 'MSGNR'   'IT_DATA' 'MSGNR'   '10',

      2 5 'TEXT'   'IT_DATA' 'TEXT'   '73'.

      wa_layout-info_fieldname = 'COLOR'.

      g_program = sy-repid.

      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

       EXPORTING

       i_callback_program = g_program

       is_layout   = wa_layout

       it_fieldcat   = it_fieldcat

       it_events   = it_events

       TABLES

       t_outtab   = it_data

       EXCEPTIONS

       program_error   = 1

       OTHERS   = 2.

    *&---------------------------------------------------------------------*

    *& Form FIELDCATALOG

    *&---------------------------------------------------------------------*

    FORM fieldcatalog USING row_pos col_pos field table f_txt outputlen.

      wa_fieldcat-row_pos   = row_pos.

      wa_fieldcat-col_pos   = col_pos.

      wa_fieldcat-fieldname = field.

      wa_fieldcat-tabname   = table.

      wa_fieldcat-seltext_l = f_txt.

      wa_fieldcat-outputlen = outputlen.

      APPEND wa_fieldcat TO it_fieldcat.

      CLEAR  wa_fieldcat.

    ENDFORM.   " FIELDCATALOG

    thanks!!!

    Add comment
    10|10000 characters needed characters exceeded