on 05-09-2006 2:48 AM
Hello experts,
I just have a couple of questions for my report. Below is my code to display the results of the report that I am doing. I just did this manually instead of ALV since I think this cannot be done in ALV display. Now, here are my questions:
1. I want to use collect statement rather that add. How can I do this?
2. How can I limit the size of sy-uline?
3. what are the 'standard colors' that you guys use for results?
4. in my code, I want to seperate display for every new functional location. Is my declaration of new-page right?
SORT it_finaltab BY funcloc asset_dum DESCENDING
asset DESCENDING parent DESCENDING.
DATA: v_color TYPE i VALUE 1,
v_subtot(1),
v_total(1),
subtot LIKE anlc-kansw,
total LIKE anlc-kansw,
v_old LIKE iloa-tplnr,
v_new LIKE iloa-tplnr.
LOOP AT it_finaltab.
AT END OF asset_dum.
v_subtot = 1.
ENDAT.
AT END OF funcloc.
v_total = 1.
ENDAT.
v_new = it_finaltab-funcloc.
IF v_new <> v_old AND NOT v_old IS INITIAL.
NEW-PAGE.
ENDIF.
v_old = v_new.
IF v_color = 1.
v_color = 2.
ELSE.
v_color = 1.
ENDIF.
FORMAT INTENSIFIED OFF COLOR = v_color.
WRITE: / sy-vline,
(12) it_finaltab-asset CENTERED,
(12) it_finaltab-parent CENTERED,
(40) it_finaltab-description CENTERED,
(40) it_finaltab-location CENTERED,
(20) it_finaltab-asset_book_val CENTERED, sy-vline.
ADD: it_finaltab-asset_book_val TO subtot,
it_finaltab-asset_book_val TO total.
IF v_subtot = 1.
CLEAR v_subtot.
FORMAT COLOR COL_TOTAL.
WRITE: / sy-vline,
'*Subtotal', AT 111(20) subtot CENTERED,
sy-vline.
CLEAR subtot.
FORMAT COLOR OFF.
ENDIF.
IF v_total = 1.
CLEAR v_total.
FORMAT COLOR COL_TOTAL INTENSIFIED ON.
WRITE: / sy-vline,
'**total', AT 111(20) total CENTERED,
sy-vline,
sy-uline.
CLEAR total.
FORMAT COLOR OFF.
ENDIF.
FORMAT COLOR OFF.
ENDLOOP.
Again, thank you guys and have a nice day!
2 - from the help on ULINE:
The statement ULINE AT 3(10).
corresponds to WRITE AT 3(10) SY-ULINE.
3 - from the help on COLOR:
Addition 1
... COLOR n [ON] or ...COLOR OFF
Effect
Color of line background. n can have the following values:
OFF
or COL_BACKGROUND
Background (GUI-specific)
1
or COL_HEADING
Headers (grayish blue)
2
or COL_NORMAL
List body (bright gray)
3
or COL_TOTAL
Totals (yellow)
4
or COL_KEY
Key columns (bluish green)
5
or COL_POSITIVE
Positive threshold value (green)
6
or COL_NEGATIVE
Negative threshold value (red)
7
or COL_GROUP
Control levels (violet)
Rob
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Viray,
1. I want to use collect statement rather that add. How can I do this?
Ans : Syntax of Collect statement :
<b>COLLECT <wa> INTO <itab>.</b>
The above statement allows you to summate entries in an internal table.
<itab> must have a flat line type, and all of the fields that are not part of the table key must have a numeric type (F, I, or P). You specify the line that you want to add in a work area that is compatible with the line type.
When the line is inserted, the system checks whether there is already a table entry that matches the key. If there is no corresponding entry already in the table, the COLLECT statement has the same effect as inserting the new line. If an entry with the same key already exists, the COLLECT statement does not append a new line, but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entry.
Lines are added to internal tables as follows:
Standard tables
If the COLLECT statement is the first statement to fill the standard table, the system creates a temporary hash administration that identifies existing entries in the table. The hash administration is retained until another statement changes the contents of key fields or changes the sequence of the lines in the internal table. After this, the system finds existing entries using a linear search. The runtime for this operation increases in linear relation to the number of existing table entries. The system field SY-TABIX contains the index of the line inserted or modified in the COLLECT statement.
Sorted tables
The system uses a binary search to locate existing lines. The runtime for the operation increases logarithmically with the number of existing lines. The system field SY-TABIX contains the index of the line inserted or modified in the COLLECT statement.
Hashed tables
The system finds existing lines using the hash algorithm of the internal table. After the COLLECT statement, the system field SY-TABIX has the value 0, since hashed tables have no linear index.
E.g.
Sample Prog to illustrate Collect Statement :
<b>
DATA: BEGIN OF LINE,
COL1(3) TYPE C,
COL2(2) TYPE N,
COL3 TYPE I,
END OF LINE.
DATA ITAB LIKE SORTED TABLE OF LINE
WITH NON-UNIQUE KEY COL1 COL2.
LINE-COL1 = 'abc'. LINE-COL2 = '12'. LINE-COL3 = 3.
COLLECT LINE INTO ITAB.
WRITE / SY-TABIX.
LINE-COL1 = 'def'. LINE-COL2 = '34'. LINE-COL3 = 5.
COLLECT LINE INTO ITAB.
WRITE / SY-TABIX.
LINE-COL1 = 'abc'. LINE-COL2 = '12'. LINE-COL3 = 7.
COLLECT LINE INTO ITAB.
WRITE / SY-TABIX.
LOOP AT ITAB INTO LINE.
WRITE: / LINE-COL1, LINE-COL2, LINE-COL3.
ENDLOOP.</b>
The output is :
1
2
1
abc 12 10
def 34 5
2. How can I limit the size of sy-uline?
Ans :
Horizontal lines
You can generate horizontal lines on the output screen by using the following syntax:
Syntax
<b>ULINE [AT [/][<pos>][(<len>)]].</b>
This is equivalent to
<b>WRITE [AT [/][<pos>][(<len>)]] SY-ULINE.</b>
The format specifications after AT are exactly the same as the format specifications described for the WRITE statement in Positioning WRITE Output on the Screen.
If there are no format specifications, the system starts a new line and fills it with a horizontal line. Otherwise, horizontal lines are output as specified.
Another way of generating horizontal lines is to type the appropriate number of hyphens in a WRITE statement as follows:
WRITE [AT [/][<pos>][(<len>)]] '-----...'.
3. standard Colors :
<b> <n> <c> Color Intended for</b>
OFF or COL_BACKGROUND 0 depends on GUI background
1 or COL_HEADING 1 grey-blue headers
2 or COL_NORMAL 2 light grey list bodies
3 or COL_TOTAL 3 yellow totals
4 or COL_KEY 4 blue-green key columns
5 or COL_POSITIVE 5 green positive threshold value
6 or COL_NEGATIVE 6 red negative threshold value
7 or COL_GROUP 7 violet Control levels
<b></b>
4.)Depending on your requirement , new-page is ( i think ) its correct. Still by debugging , you can better decide.
Regards,
Kunal.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI
GOOD
COLLECT =.
Example
Compressed sales figures for each company
DATA: BEGIN OF COMPANIES OCCURS 10,
NAME(20),
SALES TYPE I,
END OF COMPANIES.
COMPANIES-NAME = 'Duck'. COMPANIES-SALES = 10.
COLLECT COMPANIES.
COMPANIES-NAME = 'Tiger'. COMPANIES-SALES = 20.
COLLECT COMPANIES.
COMPANIES-NAME = 'Duck'. COMPANIES-SALES = 30.
COLLECT COMPANIES.
ADD=>
DATA: COUNTER TYPE I.
COMPUTE COUNTER = COUNTER + 1.
COUNTER = COUNTER + 1.
ADD 1 TO COUNTER.
THIRD QUESTION ANSWER=>
GO THROUGH THE FOLLOWING LINKS
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dba1ae35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/d9/4a95e351ea11d189570000e829fbbd/content.htm
THANKS
MRUTYUN
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Viray,
1. When you are using collect statement, you summarize all records having the same primary key, in this case, I guess, asset.
Suppose you have records
Asset asset_book_value
1 20
1 10
1 30
When you use the collect command, ie collect it_finaltab,
These three records will be summarized to a single record.
1 60
If this is what you require, then before writing the output, you have to add this
Loop at it_finaltab.
Collect it_finaltab.
endloop.
2. ULINE AT 0(190) NO-GAP. : Limits the horizontal line to 90 characters
3. Standard colors
... COLOR n [ON] or ...COLOR OFF
Color of line background. n can have the following values:
o OFF
or COL_BACKGROUND
Background (GUI-specific)
o or COL_HEADING
Headers (grayish blue)
o or COL_NORMAL
List body (bright gray)
o or COL_TOTAL
Totals (yellow)
o or COL_KEY
Key columns (bluish green)
o or COL_POSITIVE
Positive threshold value (green)
o or COL_NEGATIVE
Negative threshold value (red)
o or COL_GROUP
Control levels (violet)
4. Your logic used for new new page looks correct.
Thanks,
Susmitha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Viray,
<i>1. I want to use collect statement rather that add. How can I do this?</i>
DATA wa LIKE LINE OF itab.
wa-fname = 'Test'.
wa-field1 = '10'.
COLLECT wa INTO itab.
wa-fname = 'Test'.
wa-field1 = '10'.
COLLECT wa INTO itab.
<i>2. How can I limit the size of sy-uline?</i>
WRITE AT pos(len) sy-uline.
<i>OR</i>
WRITE : 10(30) sy-uline.
<i>3. what are the 'standard colors' that you guys use for results?</i>
Yellow - Subtotals
Gray - Heading
Red -Error Messages
<i>4. in my code, I want to seperate display for every new functional location. Is my declaration of new-page right?</i>
I hope it is right. However you are the better person to debug and check the results.
Regards,
Wenceslaus.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.