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: How to merge 2 columns into 1 column?

0 Kudos

Hello,

I have a list of data which I would like format the header to look as below:

-


| -


Quater 1---- | -


Quater 2 -


| -


Quater 3---- | -


Quater 4---- | <--- header 1

-


| Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec | <--- header 2

-


| -


F---- | -


S- | -


F-- | -


S- | -


F-- | -


S- | -


F-- | -


S- | <- header 3

-


xxxxxxx | xxxxxx | xxxxx | xxxxx | xxxxxx | xxxxx | xxxxxx | xxxxx | <--- data lines start here....

Is there anyway I able to achieve this layout?

I found quite a numerous of "cell_merge" information on ALV but I do not know how exactly it work and how to modify it?

Would be appreaciate if anyone of you able to guide me with sample code.

Thanks in advance,

Aish 😛

4 REPLIES 4

jj
Active Contributor
0 Kudos

you can use Write report.

ULINE.

WRITE:/1 '|', 2 '-Quater1-:', 17 '-Quater2-',

30 '-Quater3-', 43 '-Quater4-',

55 '|'.

ULINE.

similairly the rest.

Loop the internal table

and show the data below this heading.

0 Kudos

Hi John,

I need it to be in ALV report.

Former Member
0 Kudos

Hi Aish,

May i know how you are able to display 3 headings ?, then we can help easily.

I thought we can have a single header in normal ALV list or grid, one header and one item in Hierarchical ALV ..a Tree for other cases.

Cheers

Former Member
0 Kudos

Hi,

U can do this by using Row position in FIELD CATALOG.

Steps are:

u2022 First we have to declare an internal table of output type with few dummy character type fields.

u2022 Use this structure when populating field catalog.

u2022 When populating field catalog we have to change row position, column position, offset value, field length, text, reference table and field name (if required), justification etc.

u2022 Pass this field catalog as exporting parameter into function module u2018REUSE_ALV_LIST_DISPALYu2019.

Type declaration for Output table

TYPES: BEGIN OF ty_address,

add_detl(1) TYPE c, u201CDummy field

add_init(1) TYPE c, u201CDummy field

pers_detl(1) TYPE c, u201CDummy field

res_detl(1) TYPE c, u201CDummy field

off_detl(1) TYPE c, u201CDummy field

addrnumber TYPE ad_addrnum, "Address number

name1 TYPE ad_name1, "First Name

name2 TYPE ad_name2, "Middle Name

name3 TYPE ad_name3, "Last Name

home_city TYPE ad_city3, "Residential City

city2 TYPE ad_city2, "District

post_code1 TYPE ad_pstcd1, "Residential postal code

city1 TYPE ad_city1, "Office City

post_code2 TYPE ad_pstcd2, "Office postal code

tel_number TYPE ad_tlnmbr1, "First telephone no.

tel_extens TYPE ad_tlxtns1, "First Telephone No.: Extension

fax_number TYPE ad_fxnmbr1, "First fax no.

END OF ty_address.

In the above type declaration first five fields are used to populate field catalog only for the first and second line headings. These fields do not contain any data.

Main processing:

To get multiple line ALV layout we have to declare few dummy fields. When we build field catalog, then we have to put those dummy fields in proper places. In our example last 12 fields are known as valid fields with data and first 5 fields (1 at first line and 4 at second line) are knows as invalid or dummy variables containing no data.

When we build field catalog, we call a perform name CREATE_CATALOG using

Column position Row position

Field name Table name

Justification Text heading

Reference table Reference field

Output length Offset value

For the first row, we have to set row position 1, column position 1. When we call the perform we have to pass, these two values in addition with dummy field name (ADD_DETL), table name (I_ADDRESS), justification (left or right), text (Address Details), Reference table and Reference field name (we can pass SPACE, if not required), Output length and Offset value (Length from left margin or last field, for the first row it is 225. Means the text u201CAddress Detailsu201D will be printed at 225th char position).

l_off = 225. "Offset Value

l_pos = 1. "Column position

l_row = 1. "Row position

l_just = u2018Lu2019. "Allignment (u2018Lu2019 for Left)

l_outlen = 50. "Field length

                                    • Address Details *****************

PERFORM create_catalog USING

l_pos l_row 'ADD_DETL' 'I_ADDRESS' l_just text-002 space space l_outlen

l_off.

Perform CREATE_CATALOG is used to append the field catalog table with the passing parameters.

                                                                        • SUBROUTINE ***************************************

FORM create_catalog USING p_pos TYPE sycucol

p_row TYPE sycurow

p_field TYPE any

p_tab TYPE any

p_just TYPE char1

p_text TYPE reptext

p_reftab TYPE any

p_reffld TYPE any

p_outlen TYPE outputlen

p_off TYPE outputlen.

s_fieldcat-col_pos = p_pos. "Column position

s_fieldcat-row_pos = p_row. "Row position

s_fieldcat-fieldname = p_field. "Field name

s_fieldcat-tabname = p_tab. "Table name

s_fieldcat-just = p_just. "Justification

s_fieldcat-reptext_ddic = p_text. "Text heading

s_fieldcat-ref_tabname = p_reftab. "Reference table

s_fieldcat-ref_fieldname = p_reffld. "Reference field

s_fieldcat-outputlen = p_outlen. "Output length

s_fieldcat-offset = p_off. "Offset value

APPEND s_fieldcat TO i_fieldcat.

CLEAR s_fieldcat.

ENDFORM. " create_catalog

Regards,

Joy.