*
* 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
*
*
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 < exp =" '+'." werks =" 10" w_matnr =" 1." lsind =" '0'." pagno =" SYST-PAGNO." exp =" '-'." werks =" IT_DATA-WERKS" matnr =" IT_DATA-MATNR." subrc =" 0."> 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.
Tuesday, April 22, 2008
General - Reporting Tree in ABAP Interview Questions
Posted by Anonymous at 1:39 AM
Labels: ABAP Interview Questions
Subscribe to:
Post Comments (Atom)
Content
-
►
2009
(2)
- ► 09/06 - 09/13 (1)
- ► 03/01 - 03/08 (1)
-
▼
2008
(207)
- ► 11/23 - 11/30 (1)
-
▼
04/20 - 04/27
(70)
- The Other 50 ABAP Interview Faq's ABAP Interview Q...
- ABAP Certification Sample Questions for Abapers AB...
- Important ABAP FAQ's ABAP Interview Questions
- SAP ABAP Interview Questions And Answers ABAP Inte...
- ABAP Frequently Asked Question ABAP Interview Ques...
- Answers to some ABAP Interview Questions ABAP Inte...
- General - Number Range Generation ABAP Interview Q...
- Extract the smtp email address ABAP Interview Ques...
- How to Get the Version Value When I Print the PO A...
- Attach T-Codes to Area Menu ABAP Interview Questions
- What is the use of Authorization Checks? ABAP Inte...
- Difference Between BADI and User Exits ABAP Interv...
- BAPI Conventions ABAP Interview Questions
- BDC ABAP Interview Questions
- SAP BDC Interview Questions And Answers ABAP Inter...
- BDC & LSMW ABAP Interview Questions
- ABAP Clipboard Utilities for Beautiful Commented C...
- Using Fonts command in ABAP ABAP Interview Questions
- Using Different Color in ABAP ABAP Interview Quest...
- ABAP Questions Commonly Asked 1 ABAP Interview Que...
- Create Push Buttons in Application Tool Bar ABAP I...
- A demo program to create subscreen in your ABAP Pr...
- Display Active Exits in a ABAP System ABAP Intervi...
- Displaying Graphics using an ABAP Program ABAP Int...
- Doubt in Unicode Enabling ABAP Interview Questions
- Example Code For Drill Down Report ABAP Interview ...
- SAP ABAP FAQ (Technical) ABAP Interview Questions
- Faq Miscellaneous ABAP Interview Questions
- Field exits (SMOD/CMOD) Questions and Answers ABAP...
- Inserting Website Links in ABAP ABAP Interview Que...
- Blocking Searchhelp and Create New Searchhelp ABAP...
- Attach a Search Help to the Screen Field ABAP Inte...
- Splash Screen in ABAP ABAP Interview Questions
- SY-UCOMM and OK_CODE in Dialog Program ABAP Interv...
- Change the Input Fields Dynamically in a Screen AB...
- A Sample Hide & Get Cursor in Interactive Programm...
- Scrolling in Table Control ABAP Interview Questions
- Common used of Dialog Screen for Display, Change, ...
- Internal Tables ABAP Interview Questions
- ABAP Interview Questions 1
- Interview Question on BAPI, RFC, ABAP Objects, Tab...
- Making a Java Editor in ABAP and compiling it ABAP...
- Will ABAP be Obsolete? Will JAVA Replace ABAP? ABA...
- Learning ABAP or SAP Application ABAP Interview Qu...
- List Box in ABAP Report ABAP Interview Questions
- List Of User Exit Related to VL01N ABAP Interview ...
- LOGICAL DATABASE ABAP Interview Questions
- Recursion with Loop Checking in SAP ABAP Interview...
- Maintaining Translations for Work item texts and A...
- MODULARIZATION Technique 2. ABAP Interview Questions
- Q. What is a function module? ABAP Interview Quest...
- What are ABAP Objects? ABAP Interview Questions
- Splash Screen in ABAP using OO ABAP Interview Ques...
- Passing data from one ABAP program to another ABAP...
- Performance tuning ABAP Interview Questions
- Performance Tuning ABAP Interview Questions
- Real Time questions ABAP Interview Questions
- How to find out Total No of Pages of a Report Outp...
- General - Reporting Tree in ABAP Interview Questions
- REPORTS ABAP Interview Questions
- Sample Test Questions on ABAP Programming
- ABAP Frequently Asked Question 45
- ABAP Frequently Asked Question locks
- ABAP Frequently Asked Question BDC
- ABAP Frequently Asked Question RFC
- SAP ABAP Interview Questions And Answers 1
- SAP ABAP Interview Questions And Answers free ABAP...
- Sap Scripts & Smart forms
- Different Types of Selection Screens
- SQL Tool for ABAP Yes4SQL -- Both Native & Open SQL
- ► 04/13 - 04/20 (51)
- ► 03/16 - 03/23 (44)
- ► 02/24 - 03/02 (9)
- ► 02/17 - 02/24 (32)
No comments:
Post a Comment