cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic ALV columns REPORT

Former Member
0 Kudos

Hi,

I have a requirement like in select-option i have to give dates. and click on sbmit buttion .In alv report i have to show the number of months in alv

like if i give 20.10.2010    and 01.12.2010   

then in alv it will show columns like   oct2010 nov2010  dec2010   with 3 fields i have to show in alv.

eg:2 i give 20.8.2010    and 01.12.2010

then in alv it will show columns like  aug2010 sept2010 oct201 .......dec2010   with 4 fields ihave to show

Here i have to show dynamic alv columns...

I know how to use alv with static structure, But I dont no how to proceed it dynamically.....Pls help me.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I have a question for you.

eg:2 i give 20.11.2010and 01.2.2011

Is this test case value in your case, In case do you want to show Nov 2010, dec 2010, jan 2011, feb 2011 columns.

I can guide you further if this is cleared.

Former Member
0 Kudos

Hi lekha,

Thank u for u r replay...

Exactly that is the reuirement...

Former Member
0 Kudos

Refer to this link for more information

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80a3de18-ee00-2d10-bfb3-946d7e00f...

In the above link they have populated a field catalog with 2 columns.

You have to determine the number of columns to be generated first and modify the code accordingly.

data lv_col_id  type string.

DO LV_COUNT TIMES.  "LVcount for number of columns calculation

concatenate 'FLD' sytabix into lv_col_id.   "you can give oct,nov as per your requriement

condense lv_col_id no-gaps.

lw_fieldcat-fieldname = lv_col_id.

lw_fieldcat-datatype = 'string'.  "or 'C' if you know the length

lw_fieldcat-outputlen = '24'.

lw_fieldcat-coltext = lv_col_id.

lw_fieldcat-seltext = lw_fieldcat-coltext.

append lw_fieldcat to lt_fieldcat.

ENDDO.

Rest of the logic refer to the link.

There is a FM that reruns the names of the month "MONTH_NAMES_GET" you can use for column Id change code accordingly.

Hope this helps.