REPORT Y9030014 LINE-SIZE 250. "Release 3.1G, 4.5A ************************************************************************ * Copyright (c) 1999 by CT-Team, 33415 Verl, http://www.ct-software.com * only use for CT-DEBUG_Simulator * You can use or modify this report for your own work as long * as you don't try to sell or republish it. * In no event will the author be liable for indirect, special, * Incidental, or consequental damages (if any) arising out of * the use of this report. ************************************************************************ * Important: - The definition of the internal table must be directly * - Comments in the definition are allowed * - This report does not allow definition with "structure xx" ************************************************************************ *BREAK-POINT. *//////////////////////////////////////////////////////////////////////* WRITE: 'Work with an internal table and WRITE variable headline, data' TO SY-TITLE. *//////////////////////////////////////////////////////////////////////* *************** Parameters ********************** PARAMETERS: P_PTEST(1) TYPE C DEFAULT 'J'. "output fieldnames * *************** External tables ********************** TABLES: YT100. "only use for CT-DEBUG_Simulator * *************** Variables ********************** DATA: OFF TYPE I. DATA: WORK(256) TYPE C. DATA: ANZ TYPE I. DATA: LEN1 TYPE I. * *************** internal tables ********************** * ................. your internal table ................................ DATA: BEGIN OF IT100 OCCURS 200, ZNUMBER1(6) TYPE N, "not append in struct. ZLAENG1(05) TYPE N, " this also * ZSPRSL(1) TYPE C, ZARBGB(20) TYPE C, ZMSGNR(03) TYPE C, ZTEXT1(63) TYPE C, ZTEXT2(63) TYPE C, END OF IT100. * DATA: BEGIN OF ITREP OCCURS 500, "Report source F1(72) TYPE C, END OF ITREP. * DATA: BEGIN OF I_FNAMES OCCURS 50, F1(72) TYPE C, END OF I_FNAMES. * *************** Field symbols ********************** FIELD-SYMBOLS: , . *//////////////////////////////////////////////////////////////////////* ************* Main Section ******************* *//////////////////////////////////////////////////////////////////////* * PERFORM READ-YT100. PERFORM DISPLAY-HEAD-DATA TABLES IT100 USING 'IT100'. * |-> ITAB | * |-> itab name * *//////////////////////////////////////////////////////////////////////* ************* Subroutines ******************* *//////////////////////////////////////////////////////////////////////* ************************************************************************ * Read and display a few rows of DD01L ************************************************************************ FORM READ-YT100. * ULINE. SKIP 2. WRITE: /5 'Step 1: Read YT100 and fill IT100 ' COLOR 5. SKIP 2. *....................................................................... DATA: ZLEN1 TYPE I. *....................................................................... SELECT * FROM YT100 UP TO 40 ROWS WHERE ZSPRSL EQ 'E'. * MOVE-CORRESPONDING YT100 TO IT100. MOVE SY-DBCNT TO IT100-ZNUMBER1. ZLEN1 = STRLEN( YT100-ZTEXT1 ). IF SY-SUBRC EQ 0. IT100-ZLAENG1 = ZLEN1. ELSE. WRITE: /1 'Error= STRLEN', ZLEN1, YT100 COLOR 5. ENDIF. * APPEND IT100. * ENDSELECT. * ENDFORM. ************************************************************************ * Display header and data ************************************************************************ FORM DISPLAY-HEAD-DATA TABLES ITAB STRUCTURE IT100 USING TABL1. * ULINE. SKIP 2. WRITE: /5 'Step 2: Display the headline and data of IT100 ' COLOR 5. WRITE: /5 ' this can also be used with other internal tables' COLOR 7. SKIP 2. *.................Information about field names of internal tables...... PERFORM READ-FIELDNAMES USING TABL1. *................. here the headline of (any) internal table ........... LOOP AT ITAB. IF SY-TABIX EQ 1. DO 200 TIMES. "max 200 fields ASSIGN COMPONENT SY-INDEX OF STRUCTURE ITAB TO . IF SY-SUBRC NE 0. EXIT. ENDIF. DESCRIBE FIELD LENGTH LEN1. READ TABLE I_FNAMES INDEX SY-INDEX. IF SY-SUBRC EQ 0. IF SY-INDEX EQ 1. MOVE '|' TO WORK+OFF(1). ADD 1 TO OFF. ENDIF. MOVE I_FNAMES TO WORK+OFF(LEN1). ADD LEN1 TO OFF. MOVE '|' TO WORK+OFF(1). ADD 1 TO OFF. ELSE. MOVE 'NN' TO WORK+OFF(LEN1). ADD LEN1 TO OFF. MOVE '|' TO WORK+OFF(1). ADD 1 TO OFF. ENDIF. ENDDO. ULINE. WRITE: /1 WORK COLOR 3. ULINE. CLEAR: WORK, LEN1, OFF. ENDIF. ENDLOOP. * *************** here the data of (any) internal table ***************** * LOOP AT ITAB. DO 200 TIMES. "max 200 fields ASSIGN COMPONENT SY-INDEX OF STRUCTURE ITAB TO . IF SY-SUBRC NE 0. EXIT. ENDIF. DESCRIBE FIELD LENGTH LEN1. IF SY-INDEX EQ 1. MOVE '|' TO WORK+OFF(1). ADD 1 TO OFF. ENDIF. MOVE TO WORK+OFF(LEN1). ADD LEN1 TO OFF. MOVE '|' TO WORK+OFF(1). ADD 1 TO OFF. ENDDO. WRITE: /1 WORK. CLEAR: WORK, LEN1, OFF. ENDLOOP. * ENDFORM. ************************************************************************ * Read fieldnames of internal table ************************************************************************ FORM READ-FIELDNAMES USING TABL1. * One probably can read out the desired information directly from the * memory or other sources. We choosed a more official way by reading * the report source with the command READ REPORT ... *....................................................................... DATA: FIELDS1 TYPE I. *....................................................................... READ REPORT 'Y9030014' INTO ITREP. "only for debug-simulation * READ REPORT SY-REPID INTO ITREP. "... in the real world IF SY-SUBRC EQ 0. LOOP AT ITREP. IF ITREP-F1 CS 'END OF'. EXIT. ENDIF. IF ITREP-F1 CS 'OCCURS'. IF ITREP-F1 CS TABL1. MOVE 1 TO FIELDS1. CONTINUE. ENDIF. ENDIF. IF FIELDS1 EQ 1. IF ITREP-F1+0(1) EQ '*'. CONTINUE. ENDIF. MOVE ITREP-F1 TO I_FNAMES. CONDENSE I_FNAMES. APPEND I_FNAMES. ENDIF. ENDLOOP. ELSE. WRITE: /1 'No headline possible'. ENDIF. *....................................................................... IF P_PTEST EQ 'J'. WRITE: /1 'The fieldnames of the internal table:' COLOR 3, TABL1. SKIP. ULINE. LOOP AT I_FNAMES. WRITE: /1 I_FNAMES. ENDLOOP. SKIP 2. ULINE. * ENDIF. * ENDFORM. ************************************************************************ ************************************************************************ ******************* END OF PROGRAM *************************************