‎2010 Mar 18 10:50 AM
hi,
I did a alv report. now client has add 5 fields in the report. so again report has chaged. and add the frields to feild catalog. but in the report the feilds not showing.
MODULE pbo1 OUTPUT.
IF g_custom_container IS INITIAL.
SET PF-STATUS 'PF-2000'.
CREATE OBJECT g_custom_container
EXPORTING
container_name = 'ALV_GRID_CONTAINER'.
CREATE OBJECT grid
EXPORTING
i_parent = g_custom_container.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'zworksorder'
CHANGING
ct_fieldcat = lt_fieldcat.
LOOP AT lt_fieldcat INTO ls_fieldcat.
CASE ls_fieldcat-fieldname.
WHEN 'OBJNR'.
ls_fieldcat-no_out = 'X'.
WHEN 'AUFNR'.
ls_fieldcat-coltext = 'Order Number'.
ls_fieldcat-hotspot = 'X'.
ls_fieldcat-col_pos = '1'.
WHEN 'GSTRP'.
ls_fieldcat-col_pos = '2'.
WHEN 'IDAT'.
ls_fieldcat-col_pos = '3'.
WHEN 'AUART'.
ls_fieldcat-col_pos = '4'.
WHEN 'ILART'.
ls_fieldcat-col_pos = '5'.
WHEN 'WERKS'.
ls_fieldcat-col_pos = '6'.
WHEN 'KTEXT'.
ls_fieldcat-col_pos = '7'.
WHEN 'KUNUM'.
ls_fieldcat-col_pos = '8'.
WHEN 'SERMAT'.
ls_fieldcat-col_pos = '9'.
WHEN 'SERIALNR'.
ls_fieldcat-col_pos = '10'.
WHEN 'ZZHMRG'.
ls_fieldcat-col_pos = '11'.
WHEN 'BSTKD'.
ls_fieldcat-col_pos = '12'.
WHEN 'ZZWREF'.
ls_fieldcat-col_pos = '13'.
WHEN 'STTXT'.
ls_fieldcat-coltext = 'System status'. "From here new fields add
ls_fieldcat-col_pos = '14'.
WHEN 'GKSTP'.
ls_fieldcat-coltext = 'Tot Planed Cost'.
ls_fieldcat-col_pos = '15'.
WHEN 'GKSTI'.
ls_fieldcat-coltext = 'Tot act cost'.
ls_fieldcat-col_pos = '16'.
WHEN 'GERTI'.
ls_fieldcat-coltext = 'Tot Rev'.
ls_fieldcat-col_pos = '17'.
WHEN 'GESIST'.
ls_fieldcat-coltext = 'Tot act Sum'.
ls_fieldcat-col_pos = '18'.
WHEN OTHERS.
ls_fieldcat-no_out = 'X'.
ENDCASE.
MODIFY lt_fieldcat FROM ls_fieldcat INDEX sy-tabix.
ENDLOOP.
ls_layout-grid_title = lv_title_text.
ls_variant-report = sy-repid.
CREATE OBJECT g_handler.
SET HANDLER g_handler->handle_hotspot_click FOR grid.
CALL METHOD grid->set_table_for_first_display
EXPORTING
i_structure_name = 'itab3'
is_layout = ls_layout
i_save = 'A'
is_variant = ls_variant
CHANGING
it_outtab = itab3
it_fieldcatalog = lt_fieldcat.
ENDIF.
ENDMODULE.
Regards
‎2010 Mar 18 2:39 PM
Let the system generate the fieldcatalog for you. That is better than do it by yourself, or not? use the following example to guide you. ZMYSTRUCTURE is the DDIC structure used as a template for a fieldcat.Regards Otto
FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_bypassing_buffer = 'X'
i_structure_name = 'ZMYSTRUCTURE'
is_layout = ls_layout
is_variant = ls_variant
i_save = 'A'
TABLES
t_outtab = lt_result
EXCEPTIONS
program_error = 1
OTHERS = 2.
‎2010 Mar 18 10:52 AM
‎2010 Mar 18 11:33 AM
Hi,
Goto Change layout Option in Gird and add ur new Columns to the column set.
If you are not able to see ur columns in in columns list,just logout from sap and relogin once again.Then automatically all the columns will be added to the ALV list.
Regards,
Ravinder.
‎2010 Mar 18 2:39 PM
Let the system generate the fieldcatalog for you. That is better than do it by yourself, or not? use the following example to guide you. ZMYSTRUCTURE is the DDIC structure used as a template for a fieldcat.Regards Otto
FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_bypassing_buffer = 'X'
i_structure_name = 'ZMYSTRUCTURE'
is_layout = ls_layout
is_variant = ls_variant
i_save = 'A'
TABLES
t_outtab = lt_result
EXCEPTIONS
program_error = 1
OTHERS = 2.
‎2010 Mar 18 2:51 PM
Hi Otto,
But in this case you do not have control over your fieldcatlog
It will be better to pass the DDIC structure to REUSE_ALV_FIELDCATALOG_MERGE & let the system generate the fieldcatalog for you. This you can manipulate before passing to the ALV display FM.
What do you say ?
BR,
Suhas
‎2010 Mar 18 3:07 PM
You can do that too. I like this one because it is quite simple. I thought it would be exemplificative:)) Regards Otto