2007 Jul 11 6:16 AM
Hi,
this is Sandeep,
I am trying to do an example on ALVs by using FIELDCATALOG and GRIDLAYOUT I am getting message as <u>program terminated, short dump is being formatted...</u>Below I mentioned that code...Please help on this how can solve that issue....
Thanks,
Sandeep.
TYPE-POOLS:SLIS.
data it_fieldcat type slis_fieldcat_alv occurs 0 with header line.
data gs_layout type slis_layout_alv.
data v_repid like sy-repid.
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
ERSDA LIKE MARA-ERSDA,
ERNAM LIKE MARA-ERNAM,
MTART LIKE MARA-MTART,
WERKS LIKE MARC-WERKS,
PSTAT LIKE MARC-PSTAT,
EKGRP LIKE MARC-EKGRP,
END OF Itab.
START-OF-SELECTION.
v_repid = sy-repid.
SELECT MARAMATNR MARAERSDA MARAERNAM MARAMTART MARCWERKS MARCPSTAT MARC~EKGRP
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM MARA INNER JOIN MARC
ON MARAMATNR = MARCMATNR.
PERFORM field_catalog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = it_fieldcat[]
IS_LAYOUT = gs_layout
TABLES
T_OUTTAB = ITAB.
&----
*& Form field_catalog
&----
text
----
--> p1 text
<-- p2 text
----
FORM field_catalog .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = v_repid
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = v_repid
CHANGING
CT_FIELDCAT = IT_FIELDCAT[].
ENDFORM. " field_catalog
2007 Jul 11 6:21 AM
Refer to this sample code
http://www.sap-img.com/abap/example-of-a-simple-alv-grid-report.htm
2007 Jul 11 6:21 AM
Refer to this sample code
http://www.sap-img.com/abap/example-of-a-simple-alv-grid-report.htm
2007 Jul 11 6:22 AM
Hi,
Go throgh this:-
Supports the creation of the field catalog for the ALV function modules based either on a structure or table defined in the ABAP Data Dictionary, or a program-internal table.
<b>The program-internal table must either be in a TOP Include or its Include must be specified explicitly in the interface.</b>
The variant based on a program-internal table should only be used for rapid prototyping since the following restrictions apply:
Performance is affected since the code of the table definition must always be read and interpreted at runtime.
Dictionary references are only considered if the keywords LIKE or INCLUDE STRUCTURE (not TYPE) are used.
If the field catalog contains more than 90 fields, the first 90 fields are output in the list by default whereas the remaining fields are only available in the field selection.
If the field catalog is passed with values, they are merged with the 'automatically' found information.
Reward if useful!
2007 Jul 11 6:22 AM
you have to create your own structure if you use the function <b>"'REUSE_ALV_FIELDCATALOG_MERGE'"</b>.
Since u don't use the field catalog, create a structure with all the fields that you want to display.
Regards
Dinesh.
Reward if helpful.
2007 Jul 11 6:23 AM
Hi sandeep,
View this code....
&----
*& Report ZSAN_ALV_TEST *
*& *
&----
*& *
*& *
&----
REPORT ZSAN_ALV_TEST .
TYPE-POOLS: SLIS.
PARAMETER: CARRID LIKE SPFLI-CARRID.
DATA: BEGIN OF T_SPFLI OCCURS 0,
CARRID LIKE SPFLI-CARRID,
CONNID LIKE SPFLI-CONNID,
CITYFROM LIKE SPFLI-CITYFROM,
CITYTO LIKE SPFLI-CITYTO,
DEPTIME LIKE SPFLI-DEPTIME,
ARRTIME LIKE SPFLI-ARRTIME,
DISTANCE LIKE SPFLI-DISTANCE,
DISTID LIKE SPFLI-DISTID,
END OF T_SPFLI.
DATA: BEGIN OF T_SFLIGHT OCCURS 0,
CARRID LIKE SFLIGHT-CARRID,
CONNID LIKE SFLIGHT-CONNID,
FLDATE LIKE SFLIGHT-FLDATE,
PRICE LIKE SFLIGHT-PRICE,
CURRENCY LIKE SFLIGHT-CURRENCY,
PLANETYPE LIKE SFLIGHT-PLANETYPE,
END OF T_SFLIGHT.
DATA: FCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
*Get Flight details
SELECT CARRID
CONNID
CITYFROM
CITYTO
DEPTIME
ARRTIME
DISTANCE
DISTID
FROM SPFLI
INTO CORRESPONDING FIELDS OF TABLE T_SPFLI
WHERE CARRID = CARRID.
IF SY-SUBRC = 0.
*Initialize values into ALV
FCAT-COL_POS = 1.
FCAT-FIELDNAME = 'CARRID'.
FCAT-TABNAME = 'T_SPFLI'.
FCAT-SELTEXT_L = 'Airline Code'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 2.
FCAT-FIELDNAME = 'CONNID'.
FCAT-TABNAME = 'T_SPFLI'.
FCAT-SELTEXT_L = 'Flight Connection Number'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 3.
FCAT-FIELDNAME = 'CITYFROM'.
FCAT-TABNAME = 'T_SPFLI'.
FCAT-SELTEXT_L = 'Departure city'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 4.
FCAT-FIELDNAME = 'CITYTO'.
FCAT-TABNAME = 'T_SPFLI'.
FCAT-SELTEXT_L = 'Country Key'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 5.
FCAT-FIELDNAME = 'DEPTIME'.
FCAT-TABNAME = 'T_SPFLI'.
FCAT-SELTEXT_L = 'Departure time'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 6.
FCAT-FIELDNAME = 'ARRTIME'.
FCAT-TABNAME = 'T_SPFLI'.
FCAT-SELTEXT_L = 'Arrival time'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 7.
FCAT-FIELDNAME = 'DISTANCE'.
FCAT-TABNAME = 'T_SPFLI'.
FCAT-SELTEXT_L = 'Distance'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 8.
FCAT-FIELDNAME = 'DISTID'.
FCAT-TABNAME = 'T_SPFLI'.
FCAT-SELTEXT_L = 'Mass unit of distance (kms, miles)'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
*Display Grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'SANKET' " Reference of second grid
IT_FIELDCAT = FCAT[]
TABLES
T_OUTTAB = T_SPFLI
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.
ELSE.
MESSAGE I036(ZPROJ).
ENDIF.
&----
*& Form SANKET
&----
text
----
-->L_UCOMM text
-->L_SELFIELD text
----
FORM SANKET USING L_UCOMM LIKE SY-UCOMM L_SELFIELD TYPE SLIS_SELFIELD.
CASE L_UCOMM.
WHEN '&IC1'. " Interactive ALV
CLEAR: FCAT,FCAT[].
*Get flight status
SELECT CARRID
CONNID
FLDATE
PRICE
CURRENCY
PLANETYPE
FROM SFLIGHT
INTO CORRESPONDING FIELDS OF TABLE T_SFLIGHT
WHERE CONNID = L_SELFIELD-VALUE. " Value for selected field of ALV
IF SY-SUBRC = 0.
*Initialize values into ALV
FCAT-COL_POS = 1.
FCAT-FIELDNAME = 'CARRID'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'Airline Code'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 2.
FCAT-FIELDNAME = 'CONNID'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'Flight Connection Number'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 3.
FCAT-FIELDNAME = 'FLDATE'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'Flight date'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 4.
FCAT-FIELDNAME = 'PRICE'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'Airfare'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 5.
FCAT-FIELDNAME = 'CURRENCY'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'Local currency of airline'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
FCAT-COL_POS = 6.
FCAT-FIELDNAME = 'PLANETYPE'.
FCAT-TABNAME = 'T_SFLIGHT'.
FCAT-SELTEXT_L = 'Plane type'.
FCAT-OUTPUTLEN = 12.
APPEND FCAT.
CLEAR FCAT.
*Display secondary Grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IT_FIELDCAT = FCAT[]
TABLES
T_OUTTAB = T_SFLIGHT.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
MESSAGE I035(ZPROJ).
ENDIF.
ENDCASE.
ENDFORM. "SANKET
If useful reward me with points.
Thanks
Sanket.
2007 Jul 11 6:23 AM
HI,
check ur code now.
TYPE-POOLS:SLIS.
<b>data it_fieldcat type slis_t_fieldcat_alv.</b>
data gs_layout type slis_layout_alv.
data v_repid like sy-repid.
DATA:BEGIN OF ITAB OCCURS 0,
MATNR LIKE MARA-MATNR,
ERSDA LIKE MARA-ERSDA,
ERNAM LIKE MARA-ERNAM,
MTART LIKE MARA-MTART,
WERKS LIKE MARC-WERKS,
PSTAT LIKE MARC-PSTAT,
EKGRP LIKE MARC-EKGRP,
END OF Itab.
START-OF-SELECTION.
v_repid = sy-repid.
SELECT MARAMATNR MARAERSDA MARAERNAM MARAMTART MARC~WERKS
MARCPSTAT MARCEKGRP INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM MARA INNER JOIN MARC
ON MARAMATNR = MARCMATNR.
PERFORM field_catalog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = v_repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
<b>IT_FIELDCAT = it_fieldcat</b>
IS_LAYOUT = gs_layout
TABLES
T_OUTTAB = ITAB.
FORM field_catalog .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = v_repid
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = v_repid
CHANGING
<b>CT_FIELDCAT = IT_FIELDCAT.</b>
ENDFORM. " field_catalog
<b>reward points if helpful</b>
rgds,
bharat.
2007 Jul 11 6:24 AM
What is the dump message that you are getting. What is the point in code where the dump is occuring?
2007 Jul 11 6:24 AM
Hi sandeep,
check your FIELDCATALOG table , i think it is creating problems
regrsd
Deepak
2007 Jul 11 6:27 AM
There is a problem in your code. You have to create a structure if you use the function "'REUSE_ALV_FIELDCATALOG_MERGE'".
As you don't use the field catalog, create a structure with all the fields that you want to display.
The structure should contain all the fields which you use..
DATA:BEGIN OF FS_ITAB,
MATNR LIKE MARA-MATNR,
ERSDA LIKE MARA-ERSDA,
ERNAM LIKE MARA-ERNAM,
MTART LIKE MARA-MTART,
WERKS LIKE MARC-WERKS,
PSTAT LIKE MARC-PSTAT,
EKGRP LIKE MARC-EKGRP,
END OF FS_ITAB.
Regards,
Pavan.
2007 Jul 11 6:34 AM
Hello Sandeep
The following sample report shows how to use self-defined fieldcatalogs based on itabs or type definitions.
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_FIELDCATALOG_1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_fieldcatalog_1.
TYPE-POOLS: slis.
include zus_sdn_slisfcat_Data. " contains the following DATA definition
*DATA: BEGIN OF ty_s_list.
*DATA: bukrs LIKE knb1-bukrs.
*DATA: kunnr LIKE knb1-kunnr.
*DATA: vkorg TYPE knvv-vkorg. " type does not work !!!
*DATA: END OF ty_s_list.
DATA:
gs_list LIKE ty_s_list,
gt_list LIKE ty_s_list OCCURS 0.
DATA:
gt_fcat TYPE slis_t_fieldcat_alv.
START-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = syst-repid
i_internal_tabname = 'TY_S_LIST'
* I_STRUCTURE_NAME =
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = 'ZUS_SDN_SLISFCAT_DATA'
I_BYPASSING_BUFFER = 'X'
* I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = gt_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE: IMPORTING parameter i_internal_tabname is provided
* with the name of the DATA definition, not the internal
* table name ( 'GT_LIST' ).
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_structure_name = 'LVC_S_FCAT'
TABLES
t_outtab = gt_fcat
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.
END-OF-SELECTION.
Regards
Uwe