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 display ?

Former Member
0 Likes
487

Hi experts,

I have a requirement wher i have to display a amount value for each week from the date mentioned. How do i dynamically decide the number of columns in ALV. if for example user enters todays date and enters 2 weeks i shud display the amount for 2 weeks only . Also how do i display two headers for one alv dipslay .For example my first header will hv week1 week2 ...and second header(below the first one) will have amount and receipts for the week1 and then week2 so on. Any sample code will be very helpful.

Kindly help,

Thanks in advance,

regards

Ashwin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
462

Do a get_column for the column you wish to display. It will return you a column reference. On this, if you do a set_technical( ), then the column will not be displayed.

You can set the header of the column at run time by calling lr_column->set_short_text. Thereby each time, the same column will have different headers. Hope this helps.

Do a get_column for the column you wish to display. It will return you a column reference. On this, if you do a set_technical( ), then the column will not be displayed.

You can set the header of the column at run time by calling lr_column->set_short_text. Thereby each time, the same column will have different headers. Hope this helps.

3 REPLIES 3
Read only

Former Member
0 Likes
463

Do a get_column for the column you wish to display. It will return you a column reference. On this, if you do a set_technical( ), then the column will not be displayed.

You can set the header of the column at run time by calling lr_column->set_short_text. Thereby each time, the same column will have different headers. Hope this helps.

Read only

Former Member
0 Likes
462

hi ..

for this u need to build the internal table dynamically ..

and then populate the vauels also in that table.

after populating the values in the interanl table pass that to the ALV function module.

i hve one document about building the internal table dynamically

if u want send me u r mail id i wil send that document to u ..

my mail id is

[email protected]

thanks and regards

JK

Read only

Former Member
0 Likes
462

hi

This can be achieved using ALV using classes.

1. use the container class CL_GUI_CUSTOM_CONTAINER , create a screen with custom control.

2. create a reference variable of class cl_gui_alv_grid

3. call the methods of the class set_table_for_first_display and pass the itab contents.

sample code.

*-- Global data definitions for ALV

*--- ALV Grid instance reference

DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid .

*--- Name of the custom control added on the screen

DATA gc_custom_control_name TYPE scrfname VALUE ‘CC_ALV’ .

*--- Custom container instance reference

DATA gr_ccontainer TYPE REF TO cl_gui_custom_container .

*--- Field catalog table

DATA gt_fieldcat TYPE lvc_t_fcat .

*--- Layout structure

DATA gs_layout TYPE lvc_s_layo .

IF gr_alvgrid IS INITIAL .

*----Creating custom container instance

CREATE OBJECT gr_ccontainer

EXPORTING

container_name = gc_custom_control_name

*----Creating ALV Grid instance

CREATE OBJECT gr_alvgrid

EXPORTING

i_parent = gr_ccontainer

*----Preparing field catalog.

PERFORM prepare_field_catalog CHANGING gt_fieldcat .

*----Preparing layout structure

PERFORM prepare_layout CHANGING gs_layout .

*----Here will be additional preparations

*--e.g. initial sorting criteria, initial filtering criteria, excluding

*--functions

CALL METHOD gr_alvgrid->set_table_for_first_display

EXPORTING

is_layout = gs_layout

CHANGING

it_outtab = gt_list[]

it_fieldcatalog = gt_fieldcat

ENDIF .

ENDFORM .

FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat .

DATA ls_fcat type lvc_s_fcat .

ls_fcat-fieldname = 'CARRID' .

ls_fcat-inttype = 'C' .

ls_fcat-outputlen = '3' .

ls_fcat-coltext = 'Carrier ID' .

ls_fcat-seltext = 'Carrier ID' .

APPEND ls_fcat to pt_fieldcat .

CLEAR ls_fcat .

ls_fcat-fieldname = 'CONNID' .

ls_fcat-ref_table = 'SFLIGHT' .

ls_fcat-ref_table = 'CONNID' .

ls_fcat-outputlen = '3' .

ls_fcat-coltext = 'Connection ID' .

ls_fcat-seltext = 'Connection ID' .

APPEND ls_fcat to pt_fieldcat .

ENDFORM .

**********changing the columns of the fieldcatalog

FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat .

DATA ls_fcat type lvc_s_fcat .

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'SFLIGHT'

CHANGING

ct_fieldcat = pt_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

*--Exception handling

ENDIF.

LOOP AT pt_fieldcat INTO ls_fcat .

CASE pt_fieldcat-fieldname .

WHEN 'CARRID' .

ls_fcat-outpulen = '10' .

ls_fcat-coltext = 'Airline Carrier ID' .

MODIFY pt_fieldcat FROM ls_fcat .

WHEN 'PAYMENTSUM' .

ls_fcat-no_out = 'X' .

MODIFY pt_fieldcat FROM ls_fcat .

ENDCASE .

ENDLOOP .

ENDFORM .

Hope this solves ur problem....

<b>do reward if useful....</b>

regards

dinesh