Output List Manipulation

New Site Address: http://abap.mirrorz.com



Home

Definitions
OK Code Values
Other Useful Tips
SAP and ABAP Links
SAP Functions
SAP Reports
SAP Tables
Source Code
Transaction Codes

Site Map (Index)

ABAP Keyword Help


Output List Manipulation

Here is an example of manipulating lists (the output of a report) in several different ways. It includes saving the list in various formats (HTML, DAT (tab delimited, good for sending to spreadsheet/database programs), ASCII, or RTF (good for sending to word processors).


Source Code Listing
*-----------------------------------------------------------------------
* Demonstrate various things that can be done with lists
* The first example shows how to have a list go to memory instead of the
* screen or a spool, and how to write out that list.
*
* The second set of examples shows how to save the screen list in
* various formats
*-----------------------------------------------------------------------
REPORT ZKBTST31.
DATA: MTAB_REPORT_LIST LIKE ABAPLIST OCCURS 0 WITH HEADER LINE.
DATA: MTAB_REPORT_HTML LIKE W3HTML OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF MTAB_REPORT_ASCII OCCURS 0,
        LINE(255) TYPE C,
      END OF MTAB_REPORT_ASCII.
START-OF-SELECTION.
*-- Submit a report.  This one is the chart of accounts
  SUBMIT RFSKPL00
    EXPORTING LIST TO MEMORY           " Save list in memory
    AND RETURN.    " Return control to this program
END-OF-SELECTION.
*-- Get the list from memory
  CALL FUNCTION 'LIST_FROM_MEMORY'
       TABLES
            LISTOBJECT = MTAB_REPORT_LIST
       EXCEPTIONS
            NOT_FOUND  = 1
            OTHERS     = 2.
*-- Write the list out
*-- This is a trivial example.  A better use would be when the
*-- requirement is to have one report print out several different
*-- reports on the same list level.
  


CALL FUNCTION 'WRITE_LIST'
       TABLES
            LISTOBJECT = MTAB_REPORT_LIST
       EXCEPTIONS
            EMPTY_LIST = 1
            OTHERS     = 2.
************************************************************************
* The examples below this line do not require that the report be       *
* submitted to memory when run.  All that they require is that the     *
* report has been written to the screen.           *
************************************************************************
*-- Take the current list that has been written to screen, and format
*-- as an HTML file.
  CALL FUNCTION 'WWW_LIST_TO_HTML'
       TABLES
            HTML   = MTAB_REPORT_HTML
       EXCEPTIONS
            OTHERS = 1.
*-- Save the list.  Same as using System->List->Save->Local File or
*-- entering %pc in the OKCODE box.  This function does not need the
*-- include <%_LIST> in a program.
*-- Method can be:
*--   NOCO - No conversion
*--   RTF  - Rich Text Format
*--   DAT  - Tab delimited Format
*-- When no method is given, a selection screen is presented for the
*-- user to choose the method.
  CALL FUNCTION 'LIST_DOWNLOAD'
     EXPORTING
          METHOD     = 'NOCO'
       EXCEPTIONS
            OTHERS     = 1.

Program Texts
R        List functions              

New Site Address: http://abap.mirrorz.com


Send any hints or tips to ABAP Hints & Tips .
All submissions will be recognized along with the tip.

Get a cool web address
Free subdomains from
ShortURL.com