2006 Jan 19 5:18 AM
2006 Jan 19 5:30 AM
Hi Harikishore,
Try this sample code :
REPORT yalv .
TABLES : mara.
TYPE-POOLS : slis.
DATA: gs_layout TYPE slis_layout_alv,
ct_fieldcat TYPE slis_t_fieldcat_alv,
g_repid LIKE sy-repid,
temp_cat TYPE slis_fieldcat_alv,
header_alv TYPE slis_t_listheader,
header_alv_wa TYPE slis_listheader.
DATA : BEGIN OF it OCCURS 0,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
mbrsh LIKE mara-mbrsh,
matkl LIKE mara-matkl,
END OF it.
SELECT-OPTIONS: p_matnr FOR mara-matnr.
INITIALIZATION.
g_repid = sy-repid.
START-OF-SELECTION.
SELECT
amatnr amtart ambrsh amatkl b~maktx
FROM mara AS a
JOIN makt AS b ON amatnr = bmatnr
INTO CORRESPONDING FIELDS OF TABLE it
WHERE a~matnr IN p_matnr.
END-OF-SELECTION.
PERFORM field_catalog.
PERFORM change_catalog.
PERFORM alv_display.
*&----
*& Form field_catalog
*&----
FORM field_catalog .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = g_repid
i_internal_tabname = 'IT'
i_inclname = g_repid
CHANGING
ct_fieldcat = ct_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
ENDFORM. " field_catalog
*&----
*& Form change_catalog
*&----
FORM change_catalog .
LOOP AT ct_fieldcat INTO temp_cat.
temp_cat-key = ' '.
CASE temp_cat-fieldname.
WHEN 'MATNR'.
temp_cat-seltext_m = 'Material #'.
temp_cat-ddictxt = 'M'.
temp_cat-outputlen = 10.
WHEN 'MAKTX'.
temp_cat-seltext_m = 'Material Desc'.
temp_cat-ddictxt = 'M'.
temp_cat-outputlen = 40.
WHEN OTHERS.
CONTINUE.
ENDCASE.
MODIFY ct_fieldcat FROM temp_cat.
ENDLOOP.
gs_layout-zebra = 'X'.
ENDFORM. " change_catalog
*&----
*& Form alv_display
*&----
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = gs_layout
it_fieldcat = ct_fieldcat
i_save = 'A'
TABLES
t_outtab = it
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " alv_display
Regards,
Digesh Panchal
Note : Please Reward points, if it solve ur problem
HI
how to add a alv grid and assign a database table.
2006 Jan 19 5:23 AM
use reuse_alv_grid_display
pass i_structure = structure of dbtab
2006 Jan 19 5:24 AM
Hi,
can you make it clear.
you want to add alv functionality to dbtable created by you.
regards
vijay
Message was edited by: Vijay Babu Dudla
2006 Jan 19 5:35 AM
select * from vbap into it_vbap where vbeln = p_vbeln.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_STRUCTURE_NAME = vbap
TABLES
T_OUTTAB = it_vbap.
2006 Jan 19 5:29 AM
Hi vijay
i want to show the vbap table for the selected vbeln in the alv.
give me sample code
2006 Jan 19 5:32 AM
<deleted>
check this link
http://www.sap-img.com/abap-function.htm
Message was edited by: chandrasekhar jagarlamudi
2006 Jan 19 5:39 AM
REPORT ZTEST.
type-pools:slis.
tables: vbak,vbap.
select-options : s_vbeln for VBAK-VBELN.
data: it_vbap like vbap occurs 0 with header line.
select *
from vbap
into table it_vbap
where vbeln in s_vbeln.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_STRUCTURE_NAME = 'VBAP'
TABLES
T_OUTTAB = it_vbap[]
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.
2006 Jan 19 5:42 AM
Hi,
Check this link.Kindly reward points by clicking the star on the left of reply,if it helps.
2006 Jan 19 5:30 AM
Hi Harikishore,
Try this sample code :
REPORT yalv .
TABLES : mara.
TYPE-POOLS : slis.
DATA: gs_layout TYPE slis_layout_alv,
ct_fieldcat TYPE slis_t_fieldcat_alv,
g_repid LIKE sy-repid,
temp_cat TYPE slis_fieldcat_alv,
header_alv TYPE slis_t_listheader,
header_alv_wa TYPE slis_listheader.
DATA : BEGIN OF it OCCURS 0,
matnr LIKE mara-matnr,
mtart LIKE mara-mtart,
maktx LIKE makt-maktx,
mbrsh LIKE mara-mbrsh,
matkl LIKE mara-matkl,
END OF it.
SELECT-OPTIONS: p_matnr FOR mara-matnr.
INITIALIZATION.
g_repid = sy-repid.
START-OF-SELECTION.
SELECT
amatnr amtart ambrsh amatkl b~maktx
FROM mara AS a
JOIN makt AS b ON amatnr = bmatnr
INTO CORRESPONDING FIELDS OF TABLE it
WHERE a~matnr IN p_matnr.
END-OF-SELECTION.
PERFORM field_catalog.
PERFORM change_catalog.
PERFORM alv_display.
*&----
*& Form field_catalog
*&----
FORM field_catalog .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = g_repid
i_internal_tabname = 'IT'
i_inclname = g_repid
CHANGING
ct_fieldcat = ct_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
ENDFORM. " field_catalog
*&----
*& Form change_catalog
*&----
FORM change_catalog .
LOOP AT ct_fieldcat INTO temp_cat.
temp_cat-key = ' '.
CASE temp_cat-fieldname.
WHEN 'MATNR'.
temp_cat-seltext_m = 'Material #'.
temp_cat-ddictxt = 'M'.
temp_cat-outputlen = 10.
WHEN 'MAKTX'.
temp_cat-seltext_m = 'Material Desc'.
temp_cat-ddictxt = 'M'.
temp_cat-outputlen = 40.
WHEN OTHERS.
CONTINUE.
ENDCASE.
MODIFY ct_fieldcat FROM temp_cat.
ENDLOOP.
gs_layout-zebra = 'X'.
ENDFORM. " change_catalog
*&----
*& Form alv_display
*&----
FORM alv_display .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
is_layout = gs_layout
it_fieldcat = ct_fieldcat
i_save = 'A'
TABLES
t_outtab = it
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. " alv_display
Regards,
Digesh Panchal
Note : Please Reward points, if it solve ur problem
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |