06-08-2007 2:03 PM
hi all,
In alv reports which r done using object oriented concepts, im able to print all the fields
of a table by passing LFA1 table to the parameter I_STRUCTUE_NAME of method
SET TABLEFOR_FIRST_DISPLAY and IT_OUTTAB as ITAB.
I declared ITAB as...DATA:ITAB TYPE TABLE OF VBAK .
Now, the problem is...if i want to declare my ITAB with only few fields then wat is the method i have to use to display and wat r the parameters i have to pass...so that my output will have only the columns i declared and not the whole structure of LFA1.
06-08-2007 2:08 PM
You have to define a filed catalog and remove the entries from the field catalog:
http://help.sap.com/saphelp_webas630/helpdata/en/22/a3f5fed2fe11d2b467006094192fe3/frameset.htm
Best regards,
Peter
06-08-2007 2:08 PM
You have to define a filed catalog and remove the entries from the field catalog:
http://help.sap.com/saphelp_webas630/helpdata/en/22/a3f5fed2fe11d2b467006094192fe3/frameset.htm
Best regards,
Peter
06-08-2007 2:11 PM
Hello Aturi
Do not create the fieldcatalog manually but use the function module LVC_FIELDCATALOG_MERGE.
If you need only a few fields out of a structure you could use the following coding:
DATA:
gs_fcat TYPE lvc_s_fcat,
gt_fcat TYPE lvc_t_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'LFA1'
CHANGING
ct_fieldcat = gt_fcat.
gs_fcat-no_out = 'X'. " column is visible neither on ALV list nor in the layout
MODIFY gt_fcat FROM gs_fcat
TRANSPORTING FIELD no_out
WHERE ( no_out ne 'X' ).
" Make all required columns visible again...
LOOP AT gt_fcat INTO gs_fcat
WHERE ( fieldname = 'required column' AND
fieldname = ... ).
gs_fcat-no_out = ' '.
MODIFY gt_fcat FROM gs_fcat.
ENDLOOP.
If you need fields from different tables you can repeatedly call the function module and use the logic above. To distinguish between fields of different tables simply add:
LOOP AT gt_fcat INTO gs_fcat
WHERE ( ref_table = 'LFA1' )
AND ( fieldname = ... ).
...
ENDLOOP.
Regards
Zwe
06-08-2007 2:19 PM
Hi,
You need to create which are the fields your want to display and pass it in set_table_for_first_display and remove the parameter I_STRUCTUE_NAME
ls_fcat-fieldname = 'MATNR' .
ls_fcat-ref_table = 'MARA' .
ls_fcat-outputlen = '16'.
ls_fcat-col_opt = 'X'.
append ls_fcat to i_fieldcat.
clear ls_fcat.
*
ls_fcat-fieldname = 'WERKS' .
ls_fcat-ref_table = 'T001W' .
append ls_fcat to pt_fieldcat.
clear ls_fcat.
call method grid1->set_table_for_first_display
exporting
is_layout = gs_layout
changing
it_outtab = i_output[]
it_fieldcatalog = i_fieldcat[]
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
aRs