2006 Dec 28 8:01 AM
Hi,
i am dealing with the table s703.
i have created an internal table t_s703 whose structure is similar to S703.
now i want to display data in t_s703 using ALV.
Now my quetion is how to fill the fieldcatalog.
i think there are two ways to fill it by mentioning each and every field of the internal table and call the REUSE_ALV_GRID_DISPLAY.
Next method is we did not mention the each and every of the internal table .we just give the table name in a function module.Please tell what is that function module.
if my explanation above is wrong please tell me methods to fill the field catalog.
regards,
shoban
2006 Dec 28 8:04 AM
Hi Shweta,
Check this link: http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
Hope this helps you.
Regards,
Ruthra
Hi,
i am dealing with the table s703.
i have created an internal table t_s703 whose structure is similar to S703.
now i want to display data in t_s703 using ALV.
Now my quetion is how to fill the fieldcatalog.
i think there are two ways to fill it by mentioning each and every field of the internal table and call the REUSE_ALV_GRID_DISPLAY.
Next method is we did not mention the each and every of the internal table .we just give the table name in a function module.Please tell what is that function module.
if my explanation above is wrong please tell me methods to fill the field catalog.
regards,
shoban
2006 Dec 28 8:04 AM
Hi Shweta,
Check this link: http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
Hope this helps you.
Regards,
Ruthra
2006 Dec 28 8:05 AM
Hi Shweta,
Use this FM REUSE_ALV_FIELDCATALOG_MERGE for populating the catalog.
Most important point is that if you are using this FM all the fields of the internal table that you are passing to FM should contain all the DDIC fields only if you are using any icon like items in the internal table you cannot use this FM.
Refer this program
REPORT ztest_merge.
TYPE-POOLS : slis.
TABLES : qals.
DATA : BEGIN OF t_out OCCURS 0,
matnr LIKE qals-matnr, "MATERIAL
werk LIKE qals-werk, "PLANT
art like qals-art, "Inspaction Lot Type
objnr like qals-objnr, "Object Number
END OF t_out.
DATA : i_fieldcat TYPE slis_t_fieldcat_alv,
i_layout TYPE slis_layout_alv,
gs_layout TYPE lvc_s_layo,
g_repid TYPE sy-repid,
ls_fieldcat TYPE slis_fieldcat_alv.
SELECT-OPTIONS:s_prflos FOR qals-prueflos.
INITIALIZATION.
g_repid = sy-repid.
i_layout-zebra = 'X'.
i_layout-colwidth_optimize = 'X'.
START-OF-SELECTION.
PERFORM fetch_data.
END-OF-SELECTION.
PERFORM fill_fieldcat.
PERFORM display_alv.
&----
*& Form FETCH_DATA
&----
text
----
--> p1 text
<-- p2 text
----
FORM fetch_data .
SELECT matnr werk art objnr
FROM qals
INTO TABLE t_out
WHERE prueflos IN s_prflos.
ENDFORM. " FETCH_DATA
&----
*& Form FILL_FIELDCAT
&----
text
----
FORM fill_fieldcat .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = g_repid
i_internal_tabname = 'T_OUT'
i_inclname = g_repid
CHANGING
ct_fieldcat = i_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
ENDFORM. " FILL_FIELDCAT
&----
*& Form display_alv
&----
text
----
FORM display_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = i_layout
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = t_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " display_alv
Regards,
Mukesh Kumar
2006 Dec 28 8:06 AM
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = ' '
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
<b> I_STRUCTURE_NAME = 'S703'</b>
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
IS_LAYOUT =
IT_FIELDCAT =
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT =
IT_EVENTS =
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = ITAB
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
GIVE TABLE AT THE PARAMETER
REGARDS
SHIBA DUTTA
2006 Dec 28 8:19 AM
data: lt_fieldcat type slis_t_fieldcat_alv.
*to prepare the field catalog same as dictionary table is REUSE_ALV_FIELDCATALOG_MERGE'
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = sy-repid
i_structure_name = 'VBAK'
i_inclname = sy-repid
changing
ct_fieldcat = lt_fieldcat.
you can use the lt_fieldcat in
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_background_id = 'ALV_BACKGROUND'
i_grid_title = l_title
is_layout = g_layout
it_fieldcat = lt_flcat
i_default = 'X'
TABLES
t_outtab = ITAB
EXCEPTIONS
program_error = 1
others = 2.
if sy-subrc <> 0.
message e001 with 'Error in displaying the report'.
endif.
2006 Dec 28 8:33 AM
Hi Shewtha,
<b>Field Catalog:</b> We use another internal table to define specifications on how the fields of our ALV list will be displayed. This internal table is called the field catalog. The field catalog must comprise some technical and additional information about display options for each column to be displayed. There are three procedures to generate the field catalog as Automatic generation, Semi-automatic generation, and Manual generation. The internal table for the field catalog must be referenced to the dictionary type LVC_T_FCAT.
<b>Building Field Catalog</b>
Since there are three procedures to build a field catalog. The simplest way applies if our list structure is similar to a dictionary table. To do this, we simply eliminate the form call and pass the name of dictionary structure (for example, SFLIGHT) to the parameter I_STRUCTURE_NAME. The row structure of a field catalog is of dictionary type LVC_S_FCAT.
<b>Building Field Catalog Manually</b>
The work in this procedure is just filling the internal table for the field catalog. We have seen the structure of a field catalog above. To achieve filling the field catalog correctly, one must at least fill the following fields of the field catalog structure for each column of the list:(for example)
<i>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 .</i>
<b>Building Field Catalog Semi-Automatically</b>
It is a boring work to fill and append rows for all columns of our list. And it is not flexible to proceed with automatically generating of the field catalog. Fortunately, there is a middle ground as generating the field catalog semi-automatically.
This procedure requires a function module to call. We pass the name of the structure to be the template and the function module generates a field catalog for us. After getting the generated field catalog, we loop at it and change whatever we want.
For Example:
<i>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 .</i>
In the sample code above, firstly a field catalog is generated. It is filled with respect to <structure_name> (e.g. SFLIGHT). After filling, we have changed the output length and column text for a column (here CARRID) and make another column (PAYMENTSUM) not to be displayed.
Now that, I can hear the question What would happen if I both pass a structure name to the parameter I_STRUCTURE_NAME and a table to the parameter IT_FIELDCATALOG?. Of course, the method gives a priority to one and it is the name of the structure passed to the parameter I_STRUCTURE_NAME which has the priority.
Regards,
Balaji Reddy G
***Rewards if answers are helpful.
2006 Dec 28 8:50 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |