11-12-2007 12:26 PM
hi all
program is working fine but alv report is not displayed pls check it
&----
*& Report Z_ALV1 *
*& *
&----
*& *
*& *
&----
REPORT z_alv1 .
----
Tables *
----
TABLES : kna1. "General Data in Customer Master
TYPE-POOLS : slis.
----
Internal data *
----
types : BEGIN OF t_alv,
kunnr LIKE kna1-kunnr, "Customer Number 1
land1 LIKE kna1-land1, "Country key
name1 LIKE kna1-name1, "Name 1
name2 LIKE kna1-name2, "Name 2
stras LIKE kna1-stras, "House number and street
pstlz LIKE kna1-pstlz, "Postal Code
ort01 LIKE kna1-ort01, "City
umsa1 LIKE kna1-umsa1, "Annual sales
ktokd LIKE kna1-ktokd, "Customer Account Group
END OF t_alv.
data : i_alv type standard table of t_alv,
wa_alv type t_alv.
data-statements that are necessary for the use of the ALV-grid
DATA: gt_xevents TYPE slis_t_event,
xs_event TYPE slis_alv_event,
repid TYPE sy-repid,
zta_print TYPE slis_t_fieldcat_alv WITH HEADER LINE,
lo_layout TYPE slis_layout_alv,
lo_itabname TYPE slis_tabname,
ls_variant TYPE disvariant.
----
Initialization *
----
INITIALIZATION.
----
Parameters and select-options *
----
SELECT-OPTIONS so_kunnr FOR kna1-kunnr DEFAULT '2000' TO '2300'.
SELECT-OPTIONS so_name FOR kna1-name1.
PARAMETERS: pa_pstcd AS CHECKBOX DEFAULT 'X'.
PARAMETERS: pa_var AS CHECKBOX DEFAULT 'X'.
----
Start of main program *
----
START-OF-SELECTION.
PERFORM select_records.
PERFORM print_alvlist.
END-OF-SELECTION.
&----
*& Form SELECT_RECORDS
&----
text
----
--> p1 text
<-- p2 text
----
FORM select_records .
SELECT * FROM kna1 INTO CORRESPONDING FIELDS OF table i_alv
WHERE kunnr IN so_kunnr
AND name1 IN so_name.
loop at i_alv into wa_alv.
endloop.
ENDSELECT.
ENDFORM. " SELECT_RECORDS
&----
*& Form PRINT_ALVLIST
&----
text
----
--> p1 text
<-- p2 text
----
FORM print_alvlist .
repid = sy-repid.
lo_itabname = 'LT_ALVTABLE'. "NB: ONLY USE CAPITALS HERE!
Fill the variables of the ALV-grid.
PERFORM set_layout USING lo_layout. "Change layout-settings
PERFORM set_events USING gt_xevents."Set the events (top-page etc)
PERFORM fill_structure. "Read the structure of the itab
PERFORM modify_structure. "Modify itab's field-properties
Sort the table
SORT i_alv BY kunnr.
Present the table using the ALV-grid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = repid
it_fieldcat = ZTA_PRINT[]
is_layout = lo_layout
it_events = gt_xevents
i_save = 'A'
is_variant = ls_variant
TABLES
t_outtab = i_alv.
ENDFORM. " PRINT_ALVLIST
&----
*& Form SET_LAYOUT
&----
text
----
-->P_LO_LAYOUT text
----
FORM set_layout USING pa_layout TYPE slis_layout_alv.
Minimize the columnwidth
pa_layout-colwidth_optimize = 'X'.
Give the table a striped pattern
pa_layout-zebra = 'X'.
Set the text of the line with totals
pa_layout-totals_text = 'Total:'.
Set the text of the line with subtotals
pa_layout-subtotals_text = 'Subtotal:'.
Set the variant, as requested via the checkbox
IF pa_var = 'X'.
ls_variant-variant = '/ZLAYOUT'.
ELSE.
CLEAR ls_variant-variant.
ENDIF.
ENDFORM. " SET_LAYOUT
&----
*& Form FILL_STRUCTURE
&----
text
----
--> p1 text
<-- p2 text
----
FORM fill_structure .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = REPID
I_INTERNAL_TABNAME = LO_ITABNAME
I_INCLNAME = 'ZALV_SAM'
CHANGING
CT_FIELDCAT = ZTA_PRINT[].
ENDFORM. " FILL_STRUCTURE
&----
*& Form MODIFY_STRUCTURE
&----
text
----
--> p1 text
<-- p2 text
----
FORM modify_structure .
LOOP AT ZTA_PRINT.
CLEAR ZTA_PRINT-KEY.
CASE ZTA_PRINT-FIELDNAME.
WHEN 'KUNNR'. "Klantnummer
ZTA_PRINT-COL_POS = 0.
ZTA_PRINT-SELTEXT_S = 'Cstm'(H01).
ZTA_PRINT-SELTEXT_M = 'Customer'(H01).
ZTA_PRINT-SELTEXT_L = 'Customer is king'(H01).
WHEN 'NAME1'. "Name1
ZTA_PRINT-COL_POS = 1.
WHEN 'NAME2'. "Name 2 (now set to invisible)
ZTA_PRINT-COL_POS = 2.
ZTA_PRINT-NO_OUT = 'X'.
WHEN 'STRAS'. "Month
ZTA_PRINT-COL_POS = 3.
WHEN 'PSTLZ'. "Postcode
ZTA_PRINT-COL_POS = 4.
IF PA_PSTCD = ''.
ZTA_PRINT-NO_OUT = 'X'.
ELSE.
CLEAR ZTA_PRINT-NO_OUT.
ENDIF.
WHEN 'ORT01'. "Stad
ZTA_PRINT-COL_POS = 5.
WHEN 'UMSA1'. "Annual sales
ZTA_PRINT-COL_POS = 6.
WHEN 'KTOKD'. "
ZTA_PRINT-COL_POS = 7.
when others. "set all other fields to invisible
zta_print-no_out = 'X'.
ENDCASE.
MODIFY ZTA_PRINT.
ENDLOOP.
ENDFORM. " MODIFY_STRUCTURE
&----
*& Form SET_EVENTS
&----
text
----
-->P_GT_XEVENTS text
----
FORM set_events USING PA_EVENTS TYPE SLIS_T_EVENT.
XS_EVENT-NAME = SLIS_EV_TOP_OF_LIST.
XS_EVENT-FORM = 'XTOP_OF_LIST'.
APPEND XS_EVENT TO PA_EVENTS.
XS_EVENT-NAME = SLIS_EV_END_OF_LIST.
XS_EVENT-FORM = 'XEND_OF_LIST'.
APPEND XS_EVENT TO PA_EVENTS.
XS_EVENT-NAME = SLIS_EV_TOP_OF_PAGE.
XS_EVENT-FORM = 'XTOP_OF_PAGE'.
APPEND XS_EVENT TO PA_EVENTS.
XS_EVENT-NAME = SLIS_EV_END_OF_PAGE.
XS_EVENT-FORM = 'XEND_OF_PAGE'.
APPEND XS_EVENT TO PA_EVENTS.
ENDFORM. " SET_EVENTS
&----
*& Form XTOP_OF_LIST
&----
FORM XTOP_OF_LIST.
DATA LO_DATE(8).
CONCATENATE SY-DATUM+6(2) '.'
SY-DATUM+4(2) '.'
SY-DATUM+2(2)
INTO LO_DATE.
WRITE: AT 1 'Report:'(T01), 20 'Reportname'(T02).
WRITE: AT 50 'Date:'(T03), LO_DATE.
NEW-LINE.
WRITE: AT 1 'Abap-name report: '(T04), SY-REPID.
WRITE: AT 50 'Page:'(T05), SY-CPAGE.
ENDFORM. "xtop_of_list
&----
*& Form XEND_OF_LIST
&----
FORM XEND_OF_LIST.
WRITE: 'Footer of the list'(002).
ENDFORM. "xend_of_list
&----
*& Form XTOP_OF_PAGE
&----
FORM XTOP_OF_PAGE.
WRITE:/ 'Top of the page.'(003).
()Here your selection-criteria can be printed
ENDFORM. "xtop-of-page
&----
*& Form XEND_OF_PAGE
&----
FORM XEND_OF_PAGE.
WRITE:/ 'End of the page.'(004).
ENDFORM. "xtop-of-page
11-12-2007 12:31 PM
11-12-2007 12:33 PM
i check the i_alv also its working properly . it i think perform modify_structure
11-12-2007 12:37 PM
check the repid
give it as sy-repid
<i><u><b>Reward points if usefull</b></u></i>
11-12-2007 12:43 PM
11-12-2007 12:38 PM
and also give i_alv as
i_alv[]
<u><b>reward points if usefull.</b></u>
11-12-2007 12:42 PM
Hello Kuamr
You are using an internal table definition for generating the fieldcatalog.
...
lo_itabname = 'LT_ALVTABLE'. "NB: ONLY USE CAPITALS HERE!
...
...
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = REPID
I_INTERNAL_TABNAME = LO_ITABNAME " <== value = 'LT_ALVTABLE'
I_INCLNAME = 'ZALV_SAM'
CHANGING
CT_FIELDCAT = ZTA_PRINT[].
...
However, there is nowhere any DATA type definition for LT_ALVTABLE.
Regards
Uwe