SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Hirerical ALV



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Mon Oct 01, 2007 4:25 pm    Post subject: Hirerical ALV Reply with quote

Code:
REPORT ZALV5_OBJECTS.

TABLES : EKKO.

TYPE-POOLS : SLIS.

TYPES : BEGIN OF TY_EKKO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
STATU TYPE EKPO-STATU,
AEDAT TYPE EKPO-AEDAT,
MATNR TYPE EKPO-MATNR,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
PEINH TYPE EKPO-PEINH,
END OF TY_EKKO.

DATA: IT_EKKO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,
IT_EKPO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,
IT_EMPTYTAB TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,
WA_EKKO TYPE TY_EKKO,
WA_EKPO TYPE TY_EKKO.

DATA: OK_CODE LIKE SY-UCOMM, "OK-Code
SAVE_OK LIKE SY-UCOMM.

*ALV data declarations
DATA: FIELDCATALOG TYPE LVC_T_FCAT WITH HEADER LINE.

DATA: GD_FIELDCAT TYPE LVC_T_FCAT,
GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV.

*ALVtree data declarations
CLASS CL_GUI_COLUMN_TREE DEFINITION LOAD.
CLASS CL_GUI_CFW DEFINITION LOAD.

DATA: GD_TREE TYPE REF TO CL_GUI_ALV_TREE,
GD_HIERARCHY_HEADER TYPE TREEV_HHDR,
GD_REPORT_TITLE TYPE SLIS_T_LISTHEADER,
GD_LOGO TYPE SDYDO_VALUE,
GD_VARIANT TYPE DISVARIANT.

*Create container for alv-tree
DATA: GD_TREE_CONTAINER_NAME(30) TYPE C,
GD_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.


************************************************************************
*Includes
*INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules
*INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules
*INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)

************************************************************************
*Start-of-selection.
START-OF-SELECTION.

* ALVtree setup data
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
PERFORM BUILD_HIERARCHY_HEADER CHANGING GD_HIERARCHY_HEADER.
PERFORM BUILD_REPORT_TITLE USING GD_REPORT_TITLE GD_LOGO.
PERFORM BUILD_VARIANT.

* Display ALVtree report
* CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Form data_retrieval
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DATA_RETRIEVAL .
SELECT EBELN
UP TO 10 ROWS
FROM EKKO
INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.

LOOP AT IT_EKKO INTO WA_EKKO.
SELECT EBELN EBELP STATU AEDAT MATNR MENGE MEINS NETPR PEINH
FROM EKPO
APPENDING TABLE IT_EKPO
WHERE EBELN EQ WA_EKKO-EBELN.
ENDLOOP.

ENDFORM. " data_retrieval
*&---------------------------------------------------------------------*
*& Form build_fieldcatalog
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_FIELDCATALOG .
* Please not there are a number of differences between the structure of
* ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
* For example the field seltext_m is replace by scrtext_m in ALVtree.

FIELDCATALOG-FIELDNAME = 'EBELN'. "Field name in itab
FIELDCATALOG-SCRTEXT_M = 'Purchase Order'. "Column text
FIELDCATALOG-COL_POS = 0. "Column position
FIELDCATALOG-OUTPUTLEN = 15. "Column width
FIELDCATALOG-EMPHASIZE = 'X'. "Emphasize (X or SPACE)
FIELDCATALOG-KEY = 'X'. "Key Field? (X or SPACE)
* fieldcatalog-do_sum = 'X'. "Sum Column?
* fieldcatalog-no_zero = 'X'. "Don't display if zero
APPEND FIELDCATALOG TO GD_FIELDCAT.
CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'EBELP'.
FIELDCATALOG-SCRTEXT_M = 'PO Iten'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 1.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'STATU'.
FIELDCATALOG-SCRTEXT_M = 'Status'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 2.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'AEDAT'.
FIELDCATALOG-SCRTEXT_M = 'Item change date'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 3.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'MATNR'.
FIELDCATALOG-SCRTEXT_M = 'Material Number'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 4.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'MENGE'.
FIELDCATALOG-SCRTEXT_M = 'PO quantity'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 5.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'MEINS'.
FIELDCATALOG-SCRTEXT_M = 'Order Unit'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 6.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'NETPR'.
FIELDCATALOG-SCRTEXT_M = 'Net Price'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 7.
FIELDCATALOG-DATATYPE = 'CURR'.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.

FIELDCATALOG-FIELDNAME = 'PEINH'.
FIELDCATALOG-SCRTEXT_M = 'Price Unit'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 8.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.

ENDFORM. " build_fieldcatalog
*&---------------------------------------------------------------------*
*& Form build_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_LAYOUT .
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'
ENDFORM. " build_layout
*&---------------------------------------------------------------------*
*& Form build_hierarchy_header
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GD_HIERARCHY_HEADER text
*----------------------------------------------------------------------*
FORM BUILD_HIERARCHY_HEADER CHANGING
P_HIERARCHY_HEADER TYPE TREEV_HHDR.

P_HIERARCHY_HEADER-HEADING = 'Hierarchy Header'(013).
P_HIERARCHY_HEADER-TOOLTIP = 'This is the Hierarchy Header !'(014).
P_HIERARCHY_HEADER-WIDTH = 30.
P_HIERARCHY_HEADER-WIDTH_PIX = ''.

ENDFORM. " build_hierarchy_header
*&---------------------------------------------------------------------*
*& Form build_report_title
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GD_REPORT_TITLE text
* -->P_GD_LOGO text
*----------------------------------------------------------------------*
FORM BUILD_REPORT_TITLE USING PT_REPORT_TITLE TYPE SLIS_T_LISTHEADER
P_GD_LOGO TYPE SDYDO_VALUE.
DATA: LS_LINE TYPE SLIS_LISTHEADER,
LD_DATE(10) TYPE C.

* List Heading Line(TYPE H)
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
* ls_line-key "Not Used For This Type(H)
LS_LINE-INFO = 'PO ALVTree Display'.
APPEND LS_LINE TO PT_REPORT_TITLE.

* Status Line(TYPE S)
LD_DATE(2) = SY-DATUM+6(2).
LD_DATE+2(1) = '/'.
LD_DATE+3(2) = SY-DATUM+4(2).
LD_DATE+5(1) = '/'.
LD_DATE+6(4) = SY-DATUM(4).

LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Date'.
LS_LINE-INFO = LD_DATE.
APPEND LS_LINE TO PT_REPORT_TITLE.

* Action Line(TYPE A)
CLEAR LS_LINE.
LS_LINE-TYP = 'A'.
CONCATENATE 'Report: ' SY-REPID INTO LS_LINE-INFO SEPARATED BY SPACE.
APPEND LS_LINE TO PT_REPORT_TITLE.
ENDFORM. " build_report_title
*&---------------------------------------------------------------------*
*& Form build_variant
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_VARIANT .
* Set repid for storing variants
GD_VARIANT-REPORT = SY-REPID.

ENDFORM. " build_variant


Code:
REPORT ZSR_ALV_HIR.
TYPE-POOLS: SLIS.
*&---------------------------------------------------------------------*
TYPES: BEGIN OF TY_VBAK,
VBELN TYPE VBELN,
ERDAT TYPE ERDAT,
NETWR TYPE NETWR,
WAERK TYPE WAERK,
END OF TY_VBAK.
TYPES: BEGIN OF TY_VBAP,
VBELN TYPE VBELN,
POSNR TYPE POSNR,
ARKTX TYPE ARKTX,
NETWR TYPE NETWR,
END OF TY_VBAP.
*&---------------------------------------------------------------------*
DATA: W_VBAK TYPE TY_VBAK.
DATA: T_VBAK TYPE STANDARD TABLE OF TY_VBAK INITIAL SIZE 1.
DATA: W_VBAP TYPE TY_VBAP.
DATA: T_VBAP TYPE STANDARD TABLE OF TY_VBAP INITIAL SIZE 1.
*&---------------------------------------------------------------------*
DATA: W_FCAT TYPE SLIS_FIELDCAT_ALV.
DATA: T_FCAT TYPE SLIS_T_FIELDCAT_ALV.
*&---------------------------------------------------------------------*
CONSTANTS: C_VBAK TYPE SLIS_TABNAME VALUE 'W_VBAK'.
CONSTANTS: C_VBAP TYPE SLIS_TABNAME VALUE 'W_VBAP'.
*&---------------------------------------------------------------------*
DATA: W_KEYINFO TYPE SLIS_KEYINFO_ALV.
W_KEYINFO-HEADER01 = 'VBELN'.
W_KEYINFO-ITEM01 = 'VBELN'.
*&---------------------------------------------------------------------*
W_FCAT-COL_POS = 1.
W_FCAT-FIELDNAME = 'VBELN'.
W_FCAT-SELTEXT_M = 'ORDER NO'.
W_FCAT-TABNAME = 'W_VBAK'.
APPEND W_FCAT TO T_FCAT.
W_FCAT-COL_POS = 2.
W_FCAT-FIELDNAME = 'ERDAT'.
W_FCAT-SELTEXT_M = 'DATE'.
W_FCAT-TABNAME = 'W_VBAK'.
APPEND W_FCAT TO T_FCAT.
W_FCAT-COL_POS = 3.
W_FCAT-FIELDNAME = 'NETWR'.
W_FCAT-SELTEXT_M = 'ORDER VALUE'.
W_FCAT-TABNAME = 'W_VBAK'.
APPEND W_FCAT TO T_FCAT.
W_FCAT-COL_POS = 4.
W_FCAT-FIELDNAME = 'POSNR'.
W_FCAT-SELTEXT_M = 'ITEM NO'.
W_FCAT-TABNAME = 'W_VBAP'.
APPEND W_FCAT TO T_FCAT.
W_FCAT-COL_POS = 5.
W_FCAT-FIELDNAME = 'ARKTX'.
W_FCAT-SELTEXT_L = 'DESCRIPTION'.
W_FCAT-TABNAME = 'W_VBAP'.
APPEND W_FCAT TO T_FCAT.
W_FCAT-COL_POS = 6.
W_FCAT-FIELDNAME = 'NETWR'.
W_FCAT-SELTEXT_M = 'ITEM VALUE'.
W_FCAT-TABNAME = 'W_VBAP'.
APPEND W_FCAT TO T_FCAT.
*&---------------------------------------------------------------------*
SELECT-OPTIONS: ORDNO FOR W_VBAP-VBELN.
*&--------SELEC HEADER DATA AND SORT-------------------------------*
SELECT VBELN
ERDAT
NETWR
FROM VBAK
INTO CORRESPONDING FIELDS OF TABLE T_VBAK
WHERE VBELN IN ORDNO.
SORT T_VBAK BY VBELN.
*&--------SELEC ITEM DATA AND SORT-------------------------------*
SELECT
VBELN
POSNR
ARKTX
NETWR
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE T_VBAP.
SORT T_VBAP BY POSNR.
*&---------'REUSE_ALV_HIERSEQ_LIST_DISPLAY'----------------------*
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
IT_FIELDCAT = T_FCAT
I_TABNAME_HEADER = C_VBAK
I_TABNAME_ITEM = C_VBAP
IS_KEYINFO = W_KEYINFO
TABLES
T_OUTTAB_HEADER = T_VBAK
T_OUTTAB_ITEM = T_VBAP.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.