*
* 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
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
* http://www.sap-img.com
*
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.
Friday, November 23, 2007
General - Reporting Tree in ABAP
Labels:
Reporting Tree in ABAP
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2007
(952)
-
▼
November
(716)
- SAP Paper Documents
- SAP Repository
- SAP R/3 Implementation and Maintenance Tips
- ABAP/4 programming language overview
- The interactive eLearning system for ABAP™
- Helpful System Administration ABAPS
- free download abap programmin pdf book
- examples of real time objects in sap abap(1)
- examples of real time objects in sap abap
- work flow example2
- Workflow tips
- Miscellaneous sap abap faq
- BDC , LSMW, Conversions faq in abap
- Sap Scripts & Smart forms faqs in abap
- performance tuning in abap faqs
- Real Time BDC & LSMW faqs
- Real Time ABAP Internal Tables faqs
- Real Time ABAP Reports faqs
- Real Time questions ..in sap ABAP
- SAP ABAP FAQ (Technical)
- ABAP and Unicode
- ABAP and JavaScript
- ABAP Objects
- ABAP Database Access
- Running ABAP Programs
- ABAP User Dialogs
- The ABAP Programming Language
- Creating and Changing ABAP Programs
- Overview of the Components of Application Programs
- Introduction to ABAP
- ABAP Programming Documentation
- FREE DOWNLOAD ALE, EDI & IDOCS
- Conversion of IDOCs to XML.pdf
- FREE DOWNLOAD IDOC Interface Technology
- FREE DOWNLOAD EDI, IDOC Interface
- FREE DOWNLOAD IDOC BOOK
- FREE DOWNLOAD LSMW - Idoc Inbound Processing
- FREE DOWNLOAD SAP ABAP Idoc Interface
- FREE DOWNLOAD Java for SAP
- FREE DOWNLOAD Java for ABAP Programmers
- FREE DOWNLOAD Java and BAPI technology for EP
- free download Building Web Services with Java and ...
- free download Enable SAP with the power of Javascript
- FREE DOWNLOAD ABAP Training Simulator
- FREE DOWNLOAD SAP Accounting Training Simulators
- free download SAPScripts Made Easy
- CONDENSE
- CONSTANTS
- ABAP Quick Viewer
- sap abap XXL (EXtended Export of Lists)
- Some ABAP/4 Query header line variable
- Understanding SAP Query
- ABAP/4 Query
- ABAP/4 Query Hints and Tips
- SAP Website Links Exchange for ABAP, Basis or Cons...
- sap abap Program for Generate IDoc
- sap abap program for Reads an existing Idoc and di...
- List of ABAP Function modules
- sap abap FTP programming
- sap abap program for Issuing an Unix Command from ...
- sap abap program for RFC call to get Server List
- sap abap program for A SAP Pop-out Calculator
- sap ABAP program for Timers and Auto-refresh
- sap abap program for WS_EXECUTE to called External...
- sap abap programming Execute DOS Command from ABAP...
- To execute a dos command from ABAP
- sap abap program for Make your SAPGUI Disappear an...
- sap abap program for Using Function Modules F4_FIL...
- abp program for How to Restrict the Select Options
- sap abap program for Take Values from Selection-Sc...
- sap abap program for Change Text Into Password
- sap abap program for Function Module for Encryptio...
- sap abap program for FM VRM_SET_VALUE To List Box
- sap abap program for Value Request For Parameter
- sap abap program for Pop a Message to specific SAP...
- ABAP Pop-out box for user confirmation
- sap ABAP program for POP-UP Window
- sap abap program Sample XML Source Code For SAP
- sap abap XML file to word document through SAP
- sap abap program for How to Write Web Reports in SAP
- sap abap conversion Program to Test Line Selection...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for String Handling in ABAP - Rem...
- sap abap program for Split String into two parts a...
- sap abap conversion Program For Printing Prime Number
- sap abap program for How can I get Ascii value of ...
- sap abap program for Figure to Words for India but...
- sap abap conversion program for Print Number Value...
- sap abap conversion program for Insert a special T...
- sap abap program for Convert SAP Spool List to HTML
- sap program for Convert Month to Word in ABAP
- ABAP function to convert Number to Words
- sap abap program for How to Create Tree Control
- sap abap A sample Tree Programming
-
▼
November
(716)
No comments:
Post a Comment