Visit the SAP Forum

Languages : English | Dutch | French | Portugese | Italian



INTERVIEW EBOOK
Get 30,000 Interview Questions & Answers in an eBook.

Interview Success Kit - Get Success in Job Interviews



Send your Resume to 6000 Companies
START YOUR WEBSITE
India's Best Web Hosting Company

Reporting Tree in ABAP


Home »ABAP Programming » Reporting Tree in ABAP


"General - Reporting Tree in ABAP

"


* An ABAP reporting tree program that allows the user to press enter or double click on * any line. The report is updated with new internal table data and re-written. The cursor * and paging returns to the exact same line the user was on, even though the report was * re-written from the internal table. Input fields are filled with data based on ENTER of * DOUBLE CLICK. [+] and [-] is displayed on each line and changes if user selects to * expand/collapse.


* * Create a gui status (8000) with Functions Keys * ENTER = ENTE * BACK = BACK * EXIT = %EX * CANCEL = RW * PICK = F2 * EXPAND ALL = EXPA * COLLAPSE ALL = COLA * *

REPORT ZTREE NO STANDARD PAGE HEADING
LINE-COUNT 65
LINE-SIZE 80.


DATA: BEGIN OF IT_DATA OCCURS 0, EXP(1) TYPE C,
WERKS LIKE T001W-WERKS,
MATNR LIKE MARA-MATNR,
VALUE1(13) TYPE C,
VALUE2(13) TYPE C,
END OF IT_DATA.

DATA: W_MATNR LIKE MARA-MATNR, W_COUNT TYPE I,
G_FIELD(40) TYPE C.


DATA: BEGIN OF PAGE, SCRLLINE LIKE SYST-LILLI, "scroll line to top of screen
CURSLINE LIKE SYST-LILLI, "line to put cursor on
HDRLINES TYPE I, "lines in header + 1 TWOHDRS TYPE I, "two headers on screen
CPOSTOP TYPE I, "position of cursor from top
CPOSBOT TYPE I, "position of cursor from bottom
CPOSIT TYPE I, "position on the screen
PAGNO TYPE I, "pageno of line
PGELINES TYPE I, "lines used so far END OF PAGE.
START-OF-SELECTION. PERFORM BUILD_IT_DATA.
END-OF-SELECTION. PERFORM WRITE_REPORT.
TOP-OF-PAGE. PERFORM TOP_OF_PAGE.
TOP-OF-PAGE DURING LINE-SELECTION. PERFORM TOP_OF_PAGE.
AT LINE-SELECTION. G_FIELD = SPACE. GET CURSOR FIELD G_FIELD. PERFORM LINE_SELECTION.
AT USER-COMMAND. G_FIELD = SPACE. GET CURSOR FIELD G_FIELD. PERFORM USER_COMMAND.
*---------------------------------------------------------------------* * FORM BUILD_IT_DATA * *---------------------------------------------------------------------*

FORM BUILD_IT_DATA. IT_DATA-WERKS = '0000'. WHILE IT_DATA-WERKS < '0100'. ADD '10' TO IT_DATA-WERKS. W_MATNR = 0. WHILE W_MATNR < 10. ADD 1 TO W_MATNR. IT_DATA-EXP = '+'. WRITE W_MATNR TO IT_DATA-MATNR. IF IT_DATA-WERKS = 10 AND W_MATNR = 1. WRITE 'ZTEST2' TO IT_DATA-VALUE1. WRITE 'Testing program 2' TO IT_DATA-VALUE2. ELSE. CLEAR: IT_DATA-VALUE1, IT_DATA-VALUE2. ENDIF. APPEND IT_DATA. ENDWHILE. ENDWHILE. ENDFORM.

*---------------------------------------------------------------------* * FORM WRITE_REPORT * *---------------------------------------------------------------------*

FORM WRITE_REPORT. SET PF-STATUS '8000'. SYST-LSIND = '0'. LOOP AT IT_DATA. AT NEW WERKS. FORMAT COLOR COL_HEADING INTENSIFIED OFF. WRITE: /1 SYST-VLINE NO-GAP, '[' NO-GAP, IT_DATA-EXP NO-GAP HOTSPOT ON, ']'. FORMAT COLOR COL_NORMAL INTENSIFIED ON. WRITE: IT_DATA-WERKS, AT SYST-LINSZ SYST-VLINE. PAGE-PAGNO = SYST-PAGNO. HIDE: IT_DATA-WERKS, PAGE-PAGNO. ENDAT. IF IT_DATA-EXP = '-'. FORMAT COLOR COL_NORMAL INTENSIFIED OFF. WRITE: /1 SYST-VLINE, 8 IT_DATA-MATNR, IT_DATA-VALUE1 INPUT ON, IT_DATA-VALUE2 INPUT ON, AT SYST-LINSZ SYST-VLINE. HIDE: IT_DATA, PAGE-PAGNO. ENDIF. ENDLOOP. ULINE. ENDFORM.

*---------------------------------------------------------------------* * FORM USER_COMMAND * *---------------------------------------------------------------------*

FORM USER_COMMAND. PERFORM SET_SCROLL_LINE. CASE SY-UCOMM. WHEN 'ENTE'. READ TABLE IT_DATA WITH KEY WERKS = IT_DATA-WERKS MATNR = IT_DATA-MATNR. IF SYST-SUBRC = 0. CASE G_FIELD. WHEN 'IT_DATA-VALUE1'. IF IT_DATA-VALUE1 <> SPACE. SUBMIT (IT_DATA-VALUE1) VIA SELECTION-SCREEN AND RETURN. ELSE. IT_DATA-VALUE1 = 'Enter 1 Press'(001). ENDIF. WHEN 'IT_DATA-VALUE2'. IT_DATA-VALUE2 = 'Enter 2 Press'(001). ENDCASE. MODIFY IT_DATA INDEX SYST-TABIX. ENDIF. PERFORM WRITE_REPORT. PERFORM POSITION_LIST. CASE G_FIELD. WHEN 'IT_DATA-EXP'. ADD 1 TO PAGE-CURSLINE. SET CURSOR FIELD 'IT_DATA-VALUE1' LINE PAGE-CURSLINE. WHEN 'IT_DATA-VALUE1'. SET CURSOR FIELD 'IT_DATA-VALUE1' LINE PAGE-CURSLINE. WHEN 'IT_DATA-VALUE2'. SET CURSOR FIELD 'IT_DATA-VALUE2' LINE PAGE-CURSLINE. ENDCASE. WHEN 'EXPA'. PERFORM SET_EXPAND USING '-'. PERFORM WRITE_REPORT. WHEN 'COLA'. PERFORM SET_EXPAND USING '+'. PERFORM WRITE_REPORT. ENDCASE. ENDFORM. *---------------------------------------------------------------------*

* FORM SET_EXPAND * *---------------------------------------------------------------------*

FORM SET_EXPAND USING W_EXP. LOOP AT IT_DATA. IT_DATA-EXP = W_EXP. MODIFY IT_DATA INDEX SYST-TABIX. ENDLOOP. ENDFORM. *---------------------------------------------------------------------*

* FORM LINE_SELECTION * *---------------------------------------------------------------------*

FORM LINE_SELECTION. PERFORM SET_SCROLL_LINE. READ TABLE IT_DATA WITH KEY WERKS = IT_DATA-WERKS MATNR = IT_DATA-MATNR. CASE G_FIELD. WHEN 'IT_DATA-EXP'. LOOP AT IT_DATA WHERE WERKS = IT_DATA-WERKS. IF IT_DATA-EXP = '-'. IT_DATA-EXP = '+'. ELSE. IT_DATA-EXP = '-'. ENDIF. MODIFY IT_DATA INDEX SYST-TABIX. ENDLOOP. WHEN 'IT_DATA-VALUE1'. IT_DATA-VALUE1 = 'Double Click'(004). MODIFY IT_DATA INDEX SYST-TABIX. WHEN 'IT_DATA-VALUE2'. IT_DATA-VALUE2 = 'Double Click'(004). MODIFY IT_DATA INDEX SYST-TABIX. ENDCASE. PERFORM WRITE_REPORT. PERFORM POSITION_LIST. CASE G_FIELD. WHEN 'IT_DATA-EXP'. ADD 1 TO PAGE-CURSLINE. SET CURSOR FIELD 'IT_DATA-VALUE1' LINE PAGE-CURSLINE. WHEN 'IT_DATA-VALUE1'. SET CURSOR FIELD 'IT_DATA-VALUE1' LINE PAGE-CURSLINE. WHEN 'IT_DATA-VALUE2'. SET CURSOR FIELD 'IT_DATA-VALUE2' LINE PAGE-CURSLINE. ENDCASE. ENDFORM. *---------------------------------------------------------------------*

* FORM SET_SCROLL_LINE * * determine the correct line to scroll the re-written report to, so * * that the user is returned to the same spot on the screen * * if user is mid way between pages, ie two headers are visable on the * * screen, check if they are on the secondary page and adjust the * * scroll variable accordingly so as not to jump up lines because the * * scroll variable will be out by the number of lines in the extra hdr * *---------------------------------------------------------------------*

FORM SET_SCROLL_LINE. PAGE-CURSLINE = SYST-LILLI. PAGE-SCRLLINE = SYST-LILLI - ( SYST-CUROW - PAGE-HDRLINES ). PAGE-PGELINES = ( PAGE-PAGNO - 1 ) * SYST-LINCT. PAGE-CPOSTOP = ( PAGE-SCRLLINE + SYST-CUROW ) - PAGE-PGELINES. PAGE-CPOSBOT = ( PAGE-SCRLLINE - SYST-CUROW ) - PAGE-PGELINES. PAGE-CPOSIT = PAGE-CPOSTOP + PAGE-CPOSBOT. PAGE-TWOHDRS = PAGE-HDRLINES * 2. IF PAGE-CPOSIT LT PAGE-TWOHDRS. PAGE-SCRLLINE = PAGE-SCRLLINE + 1. ENDIF. ENDFORM. *---------------------------------------------------------------------*

* FORM POSITION_LIST * *---------------------------------------------------------------------*

FORM POSITION_LIST. CALL FUNCTION 'LIST_SCROLL_LINE_TOPMOST' EXPORTING LIST_INDEX = 1 LIST_LINE = PAGE-SCRLLINE EXCEPTIONS OTHERS = 1. CHECK SYST-SUBRC = 0. ENDFORM. *---------------------------------------------------------------------*

* FORM TOP_OF_PAGE * *---------------------------------------------------------------------*

FORM TOP_OF_PAGE. * set page-hdrlines = lines in header + 1 system generated blank line PAGE-HDRLINES = 5. ULINE. WRITE : /1 SYST-VLINE, 'Header'(002), AT SYST-LINSZ SYST-VLINE. WRITE : /1 SYST-VLINE, 'Lines'(003), AT SYST-LINSZ SYST-VLINE. ULINE. ENDFORM.

A D V E R T I S E M E N T

.

A D V E R T I S E M E N T

S A P - R E S O U R C E S


Get Free SAP Resources:

Are you looking for:
  • SAP Jobs
  • Free SAP eBooks
  • SAP Softwares
  • SAP Tutorials
  • ERP Implementation Examples
Enter Email Address:
(Enter your email address above and we will instantly send you the download link to you, when you confirm your email.)
Search SAP Resources:
discussionDiscussion Center
Discuss
Discuss

Query

Feedback
Yahoo Groups
Y! Group
Sirfdosti Groups
Sirfdosti
Contact Us
Contact
Sign in

User Name:
Password:
Forget password? | Register


INTERVIEW EBOOK

Get 30,000 Interview Questions & Answers in an eBook.

Interview Success Kit - Get Success in Job Interviews


Send your Resume to 6000 Companies

SAP Resources

  • SAP Articles
  • SAP Books
  • SAP Certifications
  • SAP Companies
  • SAP Study Materials
  • SAP Events
  • SAP Faqs
  • SAP Jobs
  • SAP Job Consultants
  • SAP Links
  • SAP News
  • SAP Sample Papers
  • SAP Interview Questions
  • SAP Training Institutes
  •  
    SAP Tutorial

  • Introduction
  • SAP History
  • SAP Facts
  • SAP Tables
  • SAP Function
  • SAP Report
  • Reasons To Use SAP
  • SAP Landscape
  • SAP Transaction Code
  • SAP Lotus Notes Integration
  • Business Connector and XML
  • Enterprise Release 4.7

  • SAP Training Institutes

  • SAP Training Institutes
  • Job Consultants Address
  • SAP Companies Address

  • Business Process Cycle

  • Analyze
  • Design
  • Implement
  • Operate
  • Optimize
  • Skills And Education

  • Logistics Module

  • Sales and Distribution
  • Quality Management
  • Materail Management
  • Plant Maintenance
  • Financial Modules (FI/CO)
  • Project system
  • Production Planning
  • Service Management

  • SAP NetWeaver

  • Introduction
  • Object Model
  • Interoperability
  • Creating Web Apps
  • Java Connector
  • Advantages & Conclusion
  • Life Cycle Management
  • Composite Application Framework

  • SAP Tools

  • SQL Trace Tool
  • SAP CRM
  • SAP SRM
  • SAP SCM
  • SAP ERP
  • SAP BW

  • SAP Modules

  • SAP FI Module
  • SAP CO Module

  • SAP Technical

  • SAP ITS Architecture
  • Financial Management
  • Manufacturing Planning and Execution
  • Customer Order Management
  • Lackbox Processing
  • SD and Financial Accounting Integration
  • SAP - HR (Human Resource)

  • SAP Miscellanous

  • Web Application Server(WAS)
  • Data Archiving
  • Mobile Engine
  • SAP Script
  • SAP Transactions
  • SAP Business Warehouse(BW)

  • SAP Reference

  • SAP Facts
  • SAP Tables
  • SAP Function
  • SAP Report
  • SAP Landscape

  • SAP Others

  • SAP Treasury
  • SAP Finance
  • SAP WAS
  • SAP Data Archiving
  • SAP ALE
  • SAP EDI
  • SAP Exchange
  • SAP X-APPS
  • SAP Applications Components
  • SAP Software
  • Dunning
  • SAP IDES
  • SAP Payroll Basics
  • SAP BASIS and Security Authorization
  • SAP Backup
  • SAP Router

  • ABAP Tutorials

  • Introduction
  • ABAP Transaction
  • ABAP Function
  • ABAP File Processing
  • ABAP Objects
  • ABAP Syntax
  • ABAP Queries
  • SAPMail Using ABAP
  • ABAP Programming Hints

  • SAP Projects & Codes

  • Finding the user-exits
  • Purchase Order Display
  • Batch Input
  • Dynamic Open SQL
  • Creating Extract Dataset
  • Reading database tables
  • Load table from a UNIX file
  • Create subscreen

  • SAP Resources

  • SAP Books
  • SAP Links

  • Interview Question



  • Common Interview Que.
  • ABAP Interview Que.
  • ERP Interview Que.
  • HR Interview Que.
  • MM Interview Que.
  • PP Interview Que.
  • ALE Interview Que.
  • EDI Interview Que.
  • Basis Interview Questions
  • SAP-SD Interview Questions
  • FI&CO Interview Questions
  • BW Interview Questions
  • CRM Interview Questions
  • Interview Questions

  • Careers at SAP

  • Careers in SAP (SAP Jobs)
  • Advertise
  •