Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

alv sequential report..

Former Member
0 Likes
524

Hi,

Anyone can send me the ALV sequential report.

Regards,

Thanuskodi T.

4 REPLIES 4
Read only

Former Member
0 Likes
504

hi,

Check the sample code

*-----tables declaration

TABLES:EKKO.

TYPE-POOLS:SLIS.

*-----data declaration

TYPES:BEGIN OF X_EKKO,

EBELN type EKKO-EBELN, "PO Number

BUKRS type EKKO-BUKRS, "Company code

BSART type EKKO-BSART, "Purchasing Document type

LIFNR type EKKO-LIFNR, "Vendor

SPRAS type EKKO-SPRAS, "Language Key

ZTERM type EKKO-ZTERM, "Terms of payment key

END OF X_EKKO,

BEGIN OF X_EKPO,

EBELN type EKPO-EBELN,

EBELP type EKPO-EBELP, "Item number

WERKS type EKPO-WERKS, "Plant

MATNR type EKPO-MATNR, "Material Number

MATKL type EKPO-MATKL, "Material Group

END OF X_EKPO.

DATA:IT_EKKO TYPE STANDARD TABLE OF X_EKKO,

IT_EKPO TYPE STANDARD TABLE OF X_EKPO,

WA_EKKO TYPE X_EKKO,

WA_EKPO TYPE X_EKPO, "#EC *

IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,

IT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,

WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,

WA_FIELDCAT1 TYPE SLIS_FIELDCAT_ALV.

*-----Selection-screen design

SELECTION-SCREEN BEGIN OF BLOCK B1.

SELECT-OPTIONS:S_EBELN FOR EKKO-EBELN.

SELECTION-SCREEN END OF BLOCK B1.

*-----SELECTION-SCREEN VALIDATION

AT SELECTION-SCREEN.

SELECT EBELN

FROM EKKO

INTO TABLE IT_EKKO

WHERE EBELN IN S_EBELN.

*-----if there are no values display an error

IF SY-SUBRC NE 0.

MESSAGE E009.

ENDIF.

*-----Data retrieval

START-OF-SELECTION.

*-----retrieving data from the PO header

SELECT EBELN BUKRS BSART LIFNR SPRAS ZTERM

FROM EKKO

INTO TABLE IT_EKKO

WHERE EBELN IN S_EBELN.

*-----if there are no records display an error

IF SY-SUBRC NE 0.

MESSAGE E003.

ENDIF.

*-----Field catalog for the PO Header

REFRESH IT_FIELDCAT[].

WA_FIELDCAT-COL_POS = '1'.

WA_FIELDCAT-FIELDNAME = 'EBELN'.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-KEY = 'X'.

WA_FIELDCAT-HOTSPOT = 'X'.

WA_FIELDCAT-REF_FIELDNAME = 'EBELN'.

WA_FIELDCAT-REF_TABNAME = 'EKKO'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = '2'.

WA_FIELDCAT-FIELDNAME = 'BUKRS'.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-REF_FIELDNAME = 'BUKRS'.

WA_FIELDCAT-REF_TABNAME = 'EKKO'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = '3'.

WA_FIELDCAT-FIELDNAME = 'BSART'.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-REF_FIELDNAME = 'BSART'.

WA_FIELDCAT-REF_TABNAME = 'EKKO'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = '4'.

WA_FIELDCAT-FIELDNAME = 'LIFNR'.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-REF_FIELDNAME = 'LIFNR'.

WA_FIELDCAT-REF_TABNAME = 'EKKO'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = '5'.

WA_FIELDCAT-FIELDNAME = 'SPRAS'.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-REF_FIELDNAME = 'SPRAS'.

WA_FIELDCAT-REF_TABNAME = 'EKKO'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-COL_POS = '6'.

WA_FIELDCAT-FIELDNAME = 'ZTERM'.

WA_FIELDCAT-TABNAME = 'IT_EKKO'.

WA_FIELDCAT-REF_FIELDNAME = 'ZTERM'.

WA_FIELDCAT-REF_TABNAME = 'EKKO'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

*-----to display the header details

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IT_FIELDCAT = IT_FIELDCAT[]

TABLES

T_OUTTAB = IT_EKKO[].

&----


*& Form USER_COMMAND

&----


  • text

----


  • -->UCOMM text

  • -->FIELD1 text

----


FORM USER_COMMAND USING UCOMM LIKE SY-UCOMM FIELD1 TYPE "#EC CALLED

SLIS_SELFIELD. "#EC *

READ TABLE IT_EKKO INTO WA_EKKO INDEX FIELD1-TABINDEX.

*-----retrieving item details from the PO Item table

SELECT EBELN EBELP WERKS MATNR MATKL

FROM EKPO

INTO TABLE IT_EKPO

WHERE EBELN = WA_EKKO-EBELN.

*-----to display an error if other than PO Number is clicked

IF SY-SUBRC NE 0.

MESSAGE E001.

ENDIF.

*-----Fieldcatalog for the PO item details

REFRESH IT_FIELDCAT1[].

WA_FIELDCAT1-COL_POS = '1'.

WA_FIELDCAT1-FIELDNAME = 'EBELN'.

WA_FIELDCAT1-TABNAME = 'IT_EKPO'.

WA_FIELDCAT1-REF_FIELDNAME = 'EBELN'.

WA_FIELDCAT1-REF_TABNAME = 'EKPO'.

APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

CLEAR WA_FIELDCAT1.

WA_FIELDCAT1-COL_POS = '2'.

WA_FIELDCAT1-FIELDNAME = 'EBELP'.

WA_FIELDCAT1-TABNAME = 'IT_EKPO'.

WA_FIELDCAT1-REF_FIELDNAME = 'EBELP'.

WA_FIELDCAT1-REF_TABNAME = 'EKPO'.

APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

CLEAR WA_FIELDCAT1.

WA_FIELDCAT1-COL_POS = '3'.

WA_FIELDCAT1-FIELDNAME = 'WERKS'.

WA_FIELDCAT1-TABNAME = 'IT_EKPO'.

WA_FIELDCAT1-REF_FIELDNAME = 'WERKS'.

WA_FIELDCAT1-REF_TABNAME = 'EKPO'.

APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

CLEAR WA_FIELDCAT1.

WA_FIELDCAT1-COL_POS = '4'.

WA_FIELDCAT1-FIELDNAME = 'MATNR'.

WA_FIELDCAT1-TABNAME = 'IT_EKPO'.

WA_FIELDCAT1-REF_FIELDNAME = 'MATNR'.

WA_FIELDCAT1-REF_TABNAME = 'EKPO'.

APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

CLEAR WA_FIELDCAT1.

WA_FIELDCAT1-COL_POS = '5'.

WA_FIELDCAT1-FIELDNAME = 'MATKL'.

WA_FIELDCAT1-TABNAME = 'IT_EKPO'.

WA_FIELDCAT1-REF_FIELDNAME = 'MATKL'.

WA_FIELDCAT1-REF_TABNAME = 'EKPO'.

APPEND WA_FIELDCAT1 TO IT_FIELDCAT1.

CLEAR WA_FIELDCAT1.

*-----to display the item details

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

IT_FIELDCAT = IT_FIELDCAT1[]

TABLES

T_OUTTAB = IT_EKPO[].

ENDFORM. "user_command_form

Read only

0 Likes
504

Hi friend,

Thanks for replay. This is not a ALV sequential report, its a sample alv report only.

My req is, I have to calculate the sub total, finally I ahve to add in Total.

Read only

Former Member
0 Likes
504

Hi.

Totals :

while populating the fieldcat add one more field(DO_SUM) for which field u want total.

WA-FIELDNAME = ' '.

WA-SELTEXT_M = ' ' .

WA-DO_SUM = 'X'.

APPEND WA TO I_FIELDCAT.

CLEAR WA.

Subtotals.

Create internal table and wa type SLIS_T_SORTINFO_ALV.

and populate this internal table like this.

WA-FIELDNAME = ' '.(for which field u want subtotal)

WA-UP = 'X' (sorting)

WA-SUBTOTAL = 'X'.

APPEND WA TO I_SORT.

CLEAR WA.

and pass this internal table to I_SORT of REUSE_ALV_GRID_DISPLAY function module.

Check the Demo code for total and subtotal.




REPORT  zmy_alv.
 
TABLES : vbak.
 
TYPE-POOLS: slis.  " ALV Global types
 
 
SELECT-OPTIONS :
 
  s_vkorg FOR vbak-vkorg,  " Sales organization
  s_kunnr FOR vbak-kunnr,  " Sold-to party
  s_vbeln FOR vbak-vbeln.  " Sales document
 
 
SELECTION-SCREEN :
  SKIP, BEGIN OF LINE,COMMENT 5(27) v_1 FOR FIELD p_max.
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
 
DATA:
 
  ls_fieldcat TYPE slis_fieldcat_alv,
 
  lt_fieldcat TYPE slis_t_fieldcat_alv,
 
  lt_sort TYPE slis_t_sortinfo_alv,
 
  ls_sort TYPE slis_sortinfo_alv,
 
  ls_layout TYPE slis_layout_alv.
 
DATA:
 
  BEGIN OF gt_vbak OCCURS 0,
 
  vkorg LIKE vbak-vkorg, " Sales organization
 
  kunnr LIKE vbak-kunnr, " Sold-to party
 
  vbeln LIKE vbak-vbeln, " Sales document
 
  netwr LIKE vbak-netwr, " Net Value of the Sales Order
 
  waerk LIKE vbak-waerk, " Document currency
 
  END OF gt_vbak.
 
TYPES:
 
  BEGIN OF t_vbak,
 
  vkorg LIKE vbak-vkorg, " Sales organization
 
  kunnr LIKE vbak-kunnr, " Sold-to party
 
  vbeln LIKE vbak-vbeln, " Sales document
 
  netwr LIKE vbak-netwr, " Net Value of the Sales Order
 
  waerk LIKE vbak-waerk, " Document currency
 
  END OF t_vbak.
 
DATA: it_vbak TYPE t_vbak OCCURS 0 WITH HEADER LINE.
 
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
     EXPORTING
          i_program_name         = sy-repid
          i_internal_tabname     = 'IT_VBAK'
          i_inclname             = sy-repid
     CHANGING
          ct_fieldcat            = lt_fieldcat
     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.
 
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
     EXPORTING
          i_program_name         = sy-repid
          i_internal_tabname     = 'GT_VBAK'
          i_inclname             = sy-repid
     CHANGING
          ct_fieldcat            = lt_fieldcat
     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.
 
*---------------------------------------------------------------------*
 
INITIALIZATION.
 
 
 
  v_1 = 'Maximum of records to read'.
 
 
 
*---------------------------------------------------------------------*
 
START-OF-SELECTION.
 
 
 
  PERFORM f_read_data.
 
 
 
  PERFORM f_display_data.
 
 
 
*---------------------------------------------------------------------*
 
*  Form  f_read_data
 
*---------------------------------------------------------------------*
 
FORM f_read_data.
 
 
 
  SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
 
 FROM vbak
 
 UP TO p_max ROWS
 
  WHERE kunnr IN s_kunnr
 
  AND vbeln IN s_vbeln
 
  AND vkorg IN s_vkorg.
 
 
 
ENDFORM. " F_READ_DATA
 
*---------------------------------------------------------------------*
 
*  Form  f_display_data
 
*---------------------------------------------------------------------*
 
FORM f_display_data.
 
 
 
  DEFINE m_fieldcat.
 
    add 1 to ls_fieldcat-col_pos.
 
    ls_fieldcat-fieldname = &1.
 
    ls_fieldcat-ref_tabname = 'VBAK'.
 
    ls_fieldcat-do_sum  = &2.
 
    ls_fieldcat-cfieldname  = &3.
 
    append ls_fieldcat to lt_fieldcat.
 
  END-OF-DEFINITION.
 
 
 
  DEFINE m_sort.
 
    add 1 to ls_sort-spos.
 
    ls_sort-fieldname = &1.
 
    ls_sort-up  = 'X'.
 
    ls_sort-subtot  = &2.
 
    ls_sort-group = '*'.
 
    append ls_sort to lt_sort.
 
  END-OF-DEFINITION.
 
 
 
  DATA:
 
  ls_fieldcat TYPE slis_fieldcat_alv,
 
  lt_fieldcat TYPE slis_t_fieldcat_alv,
 
  lt_sort TYPE slis_t_sortinfo_alv,
 
  ls_sort TYPE slis_sortinfo_alv,
 
  ls_layout TYPE slis_layout_alv.
 
 
 
  m_fieldcat 'VKORG' ''  ''.
 
  m_fieldcat 'KUNNR' ''  ''.
 
  m_fieldcat 'VBELN' ''  ''.
 
  m_fieldcat 'NETWR' 'C' 'WAERK'.
 
  m_fieldcat 'WAERK' ''  ''.
 
 
 
  m_sort 'VKORG' 'X'.  " Sort by vkorg and subtotal
 
  m_sort 'KUNNR' 'X'.  " Sort by kunnr and subtotal
 
  m_sort 'VBELN' ''. " Sort by vbeln
 
 
 
*  ls_layout-cell_merge = 'X'.
 
  ls_layout-window_titlebar = 'test window'.
 
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            is_layout   = ls_layout
            it_fieldcat = lt_fieldcat
            it_sort     = lt_sort
       TABLES
            t_outtab    = gt_vbak.
 
ENDFORM. " F_DISPLAY_DATA
 

regards

ravish

<b>plz dont forget to reward points if helpful</b>

Read only

Former Member
0 Likes
504

The SAP List Viewer can be used to view both single-level lists and multilevel sequential lists.



·

Single-level lists

contain any number of lines that have no hierarchical relationship to each other.

·

Multilevel sequential

lists consist of any number of lines that have two hierarchical levels. Multilevel lists have header rows and item rows; the item rows are subordinate to the header rows. For each header row there can be any number of subordinate item rows.

You can view subtotals and totals rows in both single-level lists and multilevel sequential lists.



The SAP List Viewer is used in Controlling for reports such as the following:

· Reports from cost centers and business processes
· Actual line item reports from cost centers and business processes
· Commitment line item reports
· Plan line item reports from cost centers, orders, business processes, cost objects
· Budget reports
· Cycle reports
· Order selection (CO-PC)
· Flexible itemization (CO-PC)

Features


Not all lists in the SAP components use the full range of functions available in the SAP List Viewer. Some lists in the SAP system components offer special functions that extend beyond the normal range of the SAP List Viewer.

This documentation covers all the functions of the SAP List Viewer. The description of the lists in the applications includes all of the functions available in the SAP List Viewer as well as the additional functions.

Navigation



Navigating Within the List

Detail



Choosing Detail

Sort



Sorting in Ascending/Descending Order

ABC Analysis

Select



Selecting and Deselecting Rows

Setting Exceptions

Filters



Setting and Deleting Filters

Totaling



Displaying and Deleting Sums

Creating Subtotals

Choosing Summation Levels

Defining the Breakdown of the Summation Levels

Status Display



Displaying the list status

Columns



Optimizing the Column Width

Freezing to Columns and Unfreezing Columns

Layouts



Selecting Layouts

Changing Layouts

Saving Layouts

Layout Management


Basic List



Displaying the Basic List


Find



Finding Terms

Printing



Printing Lists


Sending



Sending Lists as Documents


Export



Spreadsheets

Word Processing

Transferring Lists to Local Files



So . for Creating the Heiarachy Report Please see the link ..

in this 6 to 7 steps are there to Create all like

For the following example it will have the name 'SCREEN_CONTAINER'.


1.Creation of Main Program code, Data declaration and screen call
2.Creation of 'INCLUDES' to store ALVtree code
3.Create Screen along with PBO and PAI modules for screen
4.Define OK CODE(SY-UCOMM) variable
5.Add screen control to PAI module(INCLUDE Z......I01)
6.Create pf-status


Create the following objects step by step

1.Create Container

2.Create Object in Container

3.Set ALVtree table for first display

4.Create ALV Tree Hierarchy

5.Add 'does tree already exist?' check

1.ABAP code listing of PBO(..O01) and FORM(..F01) includes should now look like this

http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_basic.htm

reward points if it is usefull ....

Girish