2010 Jun 09 10:40 AM
Hi Friends,
I face a issue with the displaying the Header details in OOPS based on ALV,I have sent the sample code that i have writtten.Can anyone help me.
Regards
VK
REPORT YSDB_ALV_ECC NO STANDARD PAGE HEADING LINE-SIZE 260 LINE-COUNT 58.
*----
CLASS lcl_event_receiver DEFINITION
*----
**
*----
CLASS LCL_EVENT_RECEIVER DEFINITION.
PUBLIC SECTION.
METHODS:
HANDLE_TOOLBAR
FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
IMPORTING E_OBJECT E_INTERACTIVE,
HANDLE_USER_COMMAND
FOR EVENT USER_COMMAND OF CL_GUI_ALV_GRID
IMPORTING E_UCOMM.
PRIVATE SECTION.
ENDCLASS. "lcl_event_receiver DEFINITION
****************************************************************
LOCAL CLASSES: Implementation
****************************************************************
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_TOOLBAR.
DATA: WA_TOOLBAR TYPE STB_BUTTON.
*....................................................................
E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
This class has got one attribute, namly MT_TOOLBAR, which
is a table of type TTB_BUTTON. One line of this table is
defined by the Structure STB_BUTTON
A remark to the flag E_INTERACTIVE:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'e_interactive' is set, if this event is raised due to
the call of 'set_toolbar_interactive' by the user.
You can distinguish this way if the event was raised
by yourself or by ALV
append a separator to normal toolbar
CLEAR WA_TOOLBAR.
MOVE 3 TO WA_TOOLBAR-BUTN_TYPE.
APPEND WA_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
append an icon "Header Data"
CLEAR WA_TOOLBAR.
WA_TOOLBAR-FUNCTION = 'HEAD'.
WA_TOOLBAR-ICON = 'ICON_HEADER'.
WA_TOOLBAR-QUICKINFO = 'Billing details'.
WA_TOOLBAR-TEXT = 'Order Header Data'.
APPEND WA_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
append an icon "Item Data"
CLEAR WA_TOOLBAR.
WA_TOOLBAR-FUNCTION = 'ITEM'.
WA_TOOLBAR-ICON = 'ICON_HEADER'.
WA_TOOLBAR-QUICKINFO = 'Order Item Data From AFPO'.
WA_TOOLBAR-TEXT = 'Order Item Data'.
APPEND WA_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
ENDMETHOD. "handle_toolbar
METHOD HANDLE_USER_COMMAND.
CASE e_ucomm.
WHEN 'HEAD'.
PERFORM show_header_details.
*
WHEN 'ITEM'.
PERFORM show_item_details.
*
ENDCASE.
*
ENDMETHOD. "handle_user_command
**----
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
TABLES:
VBRK,
VBRP.
TYPE-POOLS: SLIS.
TYPES:
BEGIN OF Y_VBRK_STRUCT ,
VBELN TYPE VBRK-VBELN,
FKART TYPE VBRK-FKART,
FKDAT TYPE VBRK-FKDAT,
BUKRS TYPE VBRK-BUKRS,
NETWR TYPE VBRK-NETWR,
END OF Y_VBRK_STRUCT.
TYPES:
BEGIN OF Y_VBRP_STRUCT,
VBELN TYPE VBRP-VBELN,
POSNR TYPE VBRP-POSNR,
MATNR TYPE VBRP-MATNR,
FKIMG TYPE VBRP-FKIMG,
AUBEL TYPE VBRP-AUBEL,
KOSTL TYPE VBRP-KOSTL,
PS_PSP_PNR TYPE VBRP-PS_PSP_PNR,
ARKTX TYPE VBRP-ARKTX,
END OF Y_VBRP_STRUCT.
TYPES:
BEGIN OF Y_DISPLAY_STRUCT,
VBELN TYPE VBRK-VBELN,
FKART TYPE VBRK-FKART,
FKDAT TYPE VBRK-FKDAT,
BUKRS TYPE VBRK-BUKRS,
NETWR TYPE VBRK-NETWR,
POSNR TYPE VBRP-POSNR,
MATNR TYPE VBRP-MATNR,
FKIMG TYPE VBRP-FKIMG,
AUBEL TYPE VBRP-AUBEL,
KOSTL TYPE VBRP-KOSTL,
PS_PSP_PNR TYPE VBRP-PS_PSP_PNR,
ARKTX TYPE VBRP-ARKTX,
END OF Y_DISPLAY_STRUCT .
DATA: W_INDEX LIKE SY-TABIX.
DATA: W_FIELDCATALOG TYPE SLIS_FIELDCAT_ALV.
DATA: T_FIELDCATALOG1 TYPE SLIS_T_FIELDCAT_ALV.
DATA: W_REPID TYPE SY-REPID.
DATA: T_VBRK_ITAB TYPE STANDARD TABLE OF Y_VBRK_STRUCT .
DATA: T_VBRP_ITAB TYPE STANDARD TABLE OF Y_VBRP_STRUCT .
DATA: T_DISPLAY_ITAB TYPE STANDARD TABLE OF Y_DISPLAY_STRUCT.
DATA: E_DISPLAY TYPE Y_DISPLAY_STRUCT.
FIELD-SYMBOLS: <FS_STRUCT1> TYPE Y_VBRK_STRUCT,
<FS_STRUCT2> TYPE Y_VBRP_STRUCT,
<FS_STR> TYPE Y_VBRP_STRUCT.
SELECT-OPTIONS S_VBELN FOR VBRK-VBELN.
SELECT-OPTIONS S_BUKRS FOR VBRK-BUKRS.
SELECT-OPTIONS S_FKDAT FOR VBRK-FKDAT.
CONSTANTS: C_STRUCT TYPE DD02L-TABNAME VALUE 'Y_DISPLAY_STRUCT',
C_CONTAINER TYPE SCRFNAME VALUE 'CL_CUSTOM_CONTAINER'.
DATA: OB_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
CONSTANTS: C_A TYPE DD07T-AS4LOCAL VALUE 'A',
C_X(1) TYPE C VALUE 'X'.
DATA: E_VARIANT TYPE DISVARIANT,
E_LAYOUT TYPE LVC_S_LAYO,
I_FIELDCAT_LVC TYPE STANDARD TABLE OF LVC_S_FCAT.
DATA: T_FIELDCAT_LVC TYPE LVC_S_FCAT.
DATA : GR_ALVGRID TYPE REF TO CL_GUI_ALV_GRID,
GC_CUSTOM_CONTROL_NAME TYPE SCRFNAME VALUE 'CC_ALV',
GR_CCONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
GT_SORT TYPE LVC_T_SORT.
INITIALIZATION.
W_REPID = SY-REPID.
START-OF-SELECTION.
PERFORM F_GET_DATA1.
PERFORM F_PROCESS_DATA.
PERFORM F_FIELDCATALOG.
CALL SCREEN '100'.
&----
*& Module STATUS_0100 OUTPUT
&----
text
----
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS '123'.
SET TITLEBAR 'xxx'.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = C_STRUCT
I_CLIENT_NEVER_DISPLAY = C_X
CHANGING
CT_FIELDCAT = I_FIELDCAT_LVC[]
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
IF GR_ALVGRID IS INITIAL.
CREATE OBJECT GR_CCONTAINER
EXPORTING
CONTAINER_NAME = GC_CUSTOM_CONTROL_NAME.
IF SY-SUBRC <> 0.
ENDIF.
CREATE OBJECT GR_ALVGRID
EXPORTING
I_PARENT = GR_CCONTAINER.
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_VARIANT = E_VARIANT
I_SAVE = C_A
I_DEFAULT = C_X
IS_LAYOUT = E_LAYOUT
CHANGING
IT_OUTTAB = T_DISPLAY_ITAB[]
IT_FIELDCATALOG = I_FIELDCAT_LVC
IT_SORT = GT_SORT[].
**Call method 'set_toolbar_interactive' to raise event TOOLBAR.
CALL METHOD wo_alv_main->set_toolbar_interactive.
*
CALL METHOD wo_alv_main->register_f4_for_fields
EXPORTING
it_f4 = t_f4[].
*
Register trigger for data changed after the field is modified
CALL METHOD wo_alv_main->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
*
Register editability
CALL METHOD wo_alv_main->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
*
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
END-OF-SELECTION.
&----
*& Form get_data1
&----
text
----
FORM F_GET_DATA1 .
SELECT VBELN FKART FKDAT BUKRS NETWR
FROM VBRK
INTO TABLE T_VBRK_ITAB
WHERE BUKRS IN S_BUKRS
AND FKDAT IN S_FKDAT
AND VBELN IN S_VBELN.
IF SY-SUBRC NE 0.
FREE: T_VBRK_ITAB.
ENDIF.
IF NOT T_VBRK_ITAB IS INITIAL.
SELECT VBELN POSNR MATNR FKIMG AUBEL
KOSTL PS_PSP_PNR ARKTX
FROM VBRP
INTO TABLE T_VBRP_ITAB
FOR ALL ENTRIES IN T_VBRK_ITAB
WHERE VBELN EQ T_VBRK_ITAB-VBELN.
IF SY-SUBRC NE 0.
FREE: T_VBRK_ITAB.
ENDIF.
ENDIF.
ENDFORM. " GET_DATA1
&----
text
----
--> p1 text
<-- p2 text
----
FORM F_PROCESS_DATA .
SORT T_VBRK_ITAB BY VBELN.
SORT T_VBRP_ITAB BY VBELN.
CLEAR: W_INDEX.
UNASSIGN <FS_STRUCT1>.
UNASSIGN <FS_STRUCT2>.
LOOP AT T_VBRK_ITAB ASSIGNING <FS_STRUCT1>.
READ TABLE T_VBRP_ITAB ASSIGNING <FS_STRUCT2> WITH KEY VBELN = <FS_STRUCT1>-VBELN BINARY SEARCH.
IF SY-SUBRC EQ 0.
MOVE SY-TABIX TO W_INDEX.
WHILE SY-SUBRC IS INITIAL AND <FS_STRUCT1>-VBELN = <FS_STRUCT2>-VBELN.
*Header Items Moving
MOVE:
<FS_STRUCT1>-FKART TO E_DISPLAY-FKART,
<FS_STRUCT1>-FKDAT TO E_DISPLAY-FKDAT,
<FS_STRUCT1>-BUKRS TO E_DISPLAY-BUKRS,
<FS_STRUCT1>-NETWR TO E_DISPLAY-NETWR.
*Line items Moving
MOVE: <FS_STRUCT2>-VBELN TO E_DISPLAY-VBELN,
<FS_STRUCT2>-POSNR TO E_DISPLAY-POSNR,
<FS_STRUCT2>-MATNR TO E_DISPLAY-MATNR,
<FS_STRUCT2>-FKIMG TO E_DISPLAY-FKIMG,
<FS_STRUCT2>-AUBEL TO E_DISPLAY-AUBEL,
<FS_STRUCT2>-KOSTL TO E_DISPLAY-KOSTL,
<FS_STRUCT2>-PS_PSP_PNR TO E_DISPLAY-PS_PSP_PNR,
<FS_STRUCT2>-ARKTX TO E_DISPLAY-ARKTX.
APPEND E_DISPLAY TO T_DISPLAY_ITAB.
CLEAR E_DISPLAY.
ADD 1 TO W_INDEX.
READ TABLE T_VBRP_ITAB ASSIGNING <FS_STRUCT2> INDEX W_INDEX.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
ENDWHILE.
ENDIF.
ENDLOOP.
ENDFORM. " GET_DATA3
&----
*& Module USER_COMMAND_0100 INPUT
&----
text
----
MODULE USER_COMMAND_0100 INPUT.
LEAVE TO SCREEN 0.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Form F_FIELDCATALOG
&----
text
----
--> p1 text
<-- p2 text
----
FORM F_FIELDCATALOG .
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '1'.
T_FIELDCAT_LVC-TABNAME = 'VBRK'.
T_FIELDCAT_LVC-FIELDNAME = 'VBELN'.
T_FIELDCAT_LVC-COLTEXT = TEXT-002.
MOVE: 20 TO T_FIELDCAT_LVC-OUTPUTLEN.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '2'.
T_FIELDCAT_LVC-TABNAME = 'VBRK'.
T_FIELDCAT_LVC-FIELDNAME = 'FKART'.
T_FIELDCAT_LVC-COLTEXT = TEXT-004.
MOVE: 20 TO T_FIELDCAT_LVC-OUTPUTLEN.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '3'.
T_FIELDCAT_LVC-TABNAME = 'VBRK'.
T_FIELDCAT_LVC-FIELDNAME = 'FKDAT'.
T_FIELDCAT_LVC-COLTEXT = TEXT-006.
MOVE: 20 TO T_FIELDCAT_LVC-OUTPUTLEN.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '4'.
T_FIELDCAT_LVC-TABNAME = 'VBRK'.
T_FIELDCAT_LVC-FIELDNAME = 'BUKRS'.
T_FIELDCAT_LVC-COLTEXT = TEXT-008.
MOVE: 20 TO T_FIELDCAT_LVC-OUTPUTLEN.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '5'.
T_FIELDCAT_LVC-TABNAME = 'VBRK'.
T_FIELDCAT_LVC-FIELDNAME = 'NETWR'.
T_FIELDCAT_LVC-COLTEXT = TEXT-010.
MOVE: 20 TO T_FIELDCAT_LVC-OUTPUTLEN.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '6'.
T_FIELDCAT_LVC-TABNAME = 'VBRP'.
T_FIELDCAT_LVC-FIELDNAME = 'POSNR'.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
*
*
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '7'.
T_FIELDCAT_LVC-TABNAME = 'VBRP'.
T_FIELDCAT_LVC-FIELDNAME = 'MATNR'.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
*
*
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '8'.
T_FIELDCAT_LVC-TABNAME = 'VBRP'.
T_FIELDCAT_LVC-FIELDNAME = 'FKIMG'.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
*
*
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '9'.
T_FIELDCAT_LVC-TABNAME = 'VBRP'.
T_FIELDCAT_LVC-FIELDNAME = 'AUBEL'.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
*
*
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '10'.
T_FIELDCAT_LVC-TABNAME = 'VBRP'.
T_FIELDCAT_LVC-FIELDNAME = 'KOSTL'.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
*
*
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '11'.
T_FIELDCAT_LVC-TABNAME = 'VBRP'.
T_FIELDCAT_LVC-FIELDNAME = 'PS_PSP_PNR'.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
*
*
T_FIELDCAT_LVC-ROW_POS = '1'.
T_FIELDCAT_LVC-COL_POS = '12'.
T_FIELDCAT_LVC-TABNAME = 'VBRP'.
T_FIELDCAT_LVC-FIELDNAME = 'ARKTX'.
APPEND T_FIELDCAT_LVC TO I_FIELDCAT_LVC.
ENDFORM. " F_FIELDCATALOG
Edited by: VINAYAK1 on Jun 9, 2010 11:43 AM
2010 Jun 09 10:47 AM
Hi,
For this u have to create a method with the event PRINT_TOP_OF_PAGE...while implementing this method u have to write what ever the out put u wnat to display...after that u have to handle this event thru SET HANDLER...Still ur confusing ask me i will send u coding.....
I hope u can understud..
2010 Jun 09 10:47 AM
Hi,
For this u have to create a method with the event PRINT_TOP_OF_PAGE...while implementing this method u have to write what ever the out put u wnat to display...after that u have to handle this event thru SET HANDLER...Still ur confusing ask me i will send u coding.....
I hope u can understud..
2010 Jun 09 10:53 AM
2010 Jun 09 11:02 AM
HI vinay,
for grid heading
WA_LAYOUT-GRID_TITLE = W_TEXT.
for heading in the columns of the grid we fill catalog field as
WA_FIELDCAT-ROW_POS = 1.
WA_FIELDCAT-COL_POS = 3.
WA_FIELDCAT-FIELDNAME = 'EMPID'.
WA_FIELDCAT-TABNAME = 'IT_OUTPUT'.
WA_FIELDCAT-COLTEXT = 'EMP.ID'. * for column header
WA_FIELDCAT-OUTPUTLEN = 07.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
revert for further help
2010 Jun 09 11:11 AM
Hi Gurav,
it is not working,please find the cod below.
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.
METHOD HANDLE_TOOLBAR.
DATA: WA_TOOLBAR TYPE STB_BUTTON.
*....................................................................
append a separator to normal toolbar
CLEAR WA_TOOLBAR.
MOVE 3 TO WA_TOOLBAR-BUTN_TYPE.
APPEND WA_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
append an icon "Header Data"
CLEAR WA_TOOLBAR.
WA_TOOLBAR-FUNCTION = 'HEAD'.
WA_TOOLBAR-ICON = 'ICON_HEADER'.
WA_TOOLBAR-QUICKINFO = 'Billing details'.
WA_TOOLBAR-TEXT = 'Order Header Data'.
APPEND WA_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
ENDMETHOD. "handle_toolbar
2010 Jun 09 10:57 AM