2007 May 25 10:02 AM
2007 May 25 10:08 AM
Hi ,
It is not mandatory for an ALV to have a catalog , in case you are not passing feild catalog , you need to specify the structure name of te internal table to be displayed to the parameter I_STRUCTURE_NAME , ,but do keep in mind that the sturcture must be in the Data Dictionary ( DDIC) and not a structure defined in your program.
Regards
Arun
hi,
is the fieldcatalog field compulsory in alv's.
Regards,
siri
2007 May 25 10:04 AM
Hello,
Yes the fieldcatalog is a Mandatory criteria for ALV.
Check this sample code
REPORT z_alv_simple_example_with_itab .
************************************************************************
*Simple example to use ALV and to define the ALV data in an internal
*table
************************************************************************
* Martin Schlegel, BearingPoint, December 2004
*
* Thanks to Madhusudhan Sonee and Rama Krishna Kommineni for testing
* and feedback
*
************************************************************************
************************************************************************
*For a very long time, people gave me the feeling that ALV is a
*complicated tool that is difficult to understand and to use.
*Lately I had to use it and I discovered that ALV is easy to use and
*saves a lot of work:
*ALV will generate the column headings on its own, so one does not need
*to work on headlines and transalation.
*ALV allows the user to select the columns he wants to see, so the user
*does not need to contact a developer for every change he likes to have.
*ALV allows the user to create his own sums, so
*ALV has a simple way to work with internal tables.
*If you really want to save time, use ALV instead of write!
************************************************************************
*
*Please take 30 minutes to explore the following example and see how
*easy it is to use ALV!
*
************************************************************************
*data definition
INCLUDE <icon>.
TABLES:
marav. "Table MARA and table MAKT
*---------------------------------------------------------------------*
* Data to be displayed in ALV
* Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
* matically determine the fieldstructure from this source program
DATA:
BEGIN OF imat OCCURS 100,
ios(4) TYPE c,
matnr LIKE marav-matnr, "Material number
maktx LIKE marav-maktx, "Material short text
matkl LIKE marav-matkl, "Material group (so you can test to make
" intermediate sums)
ntgew LIKE marav-ntgew, "Net weight, numeric field (so you can test to
"make sums)
gewei LIKE marav-gewei, "weight unit (just to be complete)
END OF imat.
*---------------------------------------------------------------------*
* Other data needed
* field to store report name
DATA i_repid LIKE sy-repid.
* field to check table length
DATA i_lines LIKE sy-tabix.
*---------------------------------------------------------------------*
* Data for ALV display
TYPE-POOLS: slis.
DATA int_fcat TYPE slis_t_fieldcat_alv.
*---------------------------------------------------------------------*
SELECT-OPTIONS:
s_matnr FOR marav-matnr MATCHCODE OBJECT mat1.
*---------------------------------------------------------------------*
START-OF-SELECTION.
* read data into table imat
SELECT * FROM marav
INTO CORRESPONDING FIELDS OF TABLE imat
WHERE matnr IN s_matnr.
LOOP AT imat.
IF imat-matnr+0(1) = 'M'.
MOVE icon_green_light TO imat-ios.
MODIFY imat.
ENDIF.
IF imat-matnr+0(1) = 'Z'.
MOVE icon_red_light TO imat-ios.
MODIFY imat.
ENDIF.
ENDLOOP.
* Check if material was found
CLEAR i_lines.
DESCRIBE TABLE imat LINES i_lines.
IF i_lines LT 1.
* Using hardcoded write here for easy upload
WRITE: / 'No materials found.'.
EXIT.
ENDIF.
END-OF-SELECTION.
*---------------------------------------------------------------------*
* Now, we start with ALV
*---------------------------------------------------------------------*
* To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
* The fieldcatalouge can be generated by FUNCTION
* 'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
* report source, including this report.
* The only problem one might have is that the report and table names
* need to be in capital letters. (I had it :-( )
*---------------------------------------------------------------------*
* Store report name
i_repid = sy-repid.
* Create Fieldcatalogue from internal table
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'IMAT' "capital letters!
i_inclname = i_repid
CHANGING
ct_fieldcat = int_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*explanations:
* I_PROGRAM_NAME is the program which calls this function
*
* I_INTERNAL_TABNAME is the name of the internal table which you want
* to display in ALV
*
* I_INCLNAME is the ABAP-source where the internal table is defined
* (DATA....)
* CT_FIELDCAT contains the Fieldcatalouge that we need later for
* ALV display
IF sy-subrc <> 0.
WRITE: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
*This was the fieldcatlogue
*---------------------------------------------------------------------*
* And now, we are ready to display our list
*----------------------------------------------------------------------
* Call for ALV list display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'
i_callback_program = i_repid
it_fieldcat = int_fcat
i_save = 'A'
TABLES
t_outtab = imat
EXCEPTIONS
program_error = 1
OTHERS = 2.
*
*explanations:
* I_CALLBACK_PROGRAM is the program which calls this function
*
* IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains
* now the data definition needed for display
*
* I_SAVE allows the user to save his own layouts
*
* T_OUTTAB contains the data to be displayed in ALV
IF sy-subrc <> 0.
WRITE: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
ENDIF.
REgards,
VAsanth
2007 May 25 10:04 AM
2007 May 25 10:04 AM
HI,
you need a field catalogue to b able to display your table.
Regards,
Sooness
2007 May 25 10:04 AM
hi
i think it is necessary
Because it define the format in which the list needs to be generated .
thanks
mohit
2007 May 25 10:07 AM
HI,
Check this below link. U can find the use of fieldcatalog.
https://forums.sdn.sap.com/click.jspa?searchID=2800976&messageID=3052375
Thanks,
Sankar M
2007 May 25 10:08 AM
Hi ,
It is not mandatory for an ALV to have a catalog , in case you are not passing feild catalog , you need to specify the structure name of te internal table to be displayed to the parameter I_STRUCTURE_NAME , ,but do keep in mind that the sturcture must be in the Data Dictionary ( DDIC) and not a structure defined in your program.
Regards
Arun
2007 May 25 10:08 AM
hi,
it is necessary.Since we will define field properties using fieldcatalog.
Reward with points if helpful.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |