Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

regarding output format

Former Member
0 Likes
970

hi frends,

i have a report with this output format.

tonum item itemDesc quantity site

12 1 hhuuh 5 h001

12 2 fdefe 6 h001

14 1 fsdfsd 8 d001

14 2 efer 4 d001

16 1 efe 6 w001

16 2 feff 2 w001.

but now i want to diaplay the output like this

item itemDesc site1 site2 site3 site4

1 dfdf 5(q) 6(q) 8(q) 5(q)

2 ggff 5(q) 5(q) 5(q) 5(q)

3 fdfd 5(q) 5(q) 5(q) 5(q)

4 fdfd 5(q) 5(q)

this is the final output format i need.ie i need to creat a column for site .for that all the sites available for my delivery number that amny columns should b created.and for each site column i should disply the quantity available for each item number.i created site column but now i was stuck up with how to display quantity for the site column for each item available.pls help..

hi frends,

i have a report with this output format.

tonum item itemDesc quantity site

12 1 hhuuh 5 h001

12 2 fdefe 6 h001

14 1 fsdfsd 8 d001

14 2 efer 4 d001

16 1 efe 6 w001

16 2 feff 2 w001.

but now i want to diaplay the output like this

item itemDesc site1 site2 site3 site4

1 dfdf 5(q) 6(q) 8(q) 5(q)

2 ggff 5(q) 5(q) 5(q) 5(q)

3 fdfd 5(q) 5(q) 5(q) 5(q)

4 fdfd 5(q) 5(q)

this is the final output format i need.ie i need to creat a column for site .for that all the sites available for my delivery number that amny columns should b created.and for each site column i should disply the quantity available for each item number.i created site column but now i was stuck up with how to display quantity for the site column for each item available.pls help..

3 REPLIES 3
Read only

Former Member
0 Likes
665

It is difficult to define an internal table with dynamic number of colns...but you can use the below logic.

itab

item

itemdescr

site

qty.

sort itab by site.

isite[] = itab[]

delete adjacent duplicate from isite.

*For headings

write : / 'Item','ItemDescr',

loop at isite.

write isite-site.

endloop.

sort itab.

loop at itab.

at new itemdescr.

write : / itab-item, itab-itemdescr

endat.

read table isite with key site = itab-site.

lcnt = sy-tabix * 10. "10 is the field length for qty.

write : (lcnt) itab-qty.

endloop.

<i>I am not sure about your tonum field but as defined in your requirement you wish to show the output based on item hence the definition of table itab is that accordance.</i>

Message was edited by: Anurag Bankley

Read only

0 Likes
665

thanx for the reply .i will try it and let u now..

Read only

Former Member
0 Likes
665

Hi,

Go thru this docu it may help you.

WRITE - int_format_options

Syntax

... [LEFT-JUSTIFIED|CENTERED|RIGHT-JUSTIFIED]

[NO-GAP]

[UNDER other_dobj]

{ { [EXPONENT exp]

[NO-GROUPING]

[NO-SIGN]

[NO-ZERO]

[CURRENCY cur]

{ { [DECIMALS dec]

[ROUND scale] }

| [UNIT unit] } }

| [TIME ZONE tz] }

[USING { {NO EDIT MASK}|{EDIT MASK mask} }]

[ DD/MM/YY | MM/DD/YY

| DD/MM/YYYY | MM/DD/YYYY

| DDMMYY | MMDDYY | YYMMDD ] ... .

Extras:

1. ... LEFT-JUSTIFIED|CENTERED|RIGHT-JUSTIFIED

2. ... NO-GAP

3. ... UNDER other_dobj

4. ... EXPONENT exp

5. ... NO-GROUPING

6. ... NO-SIGN

7. ... NO-ZERO

8. ... CURRENCY cur

9. ... DECIMALS dec

10. ... ROUND scale

11. ... UNIT unit

12. ... TIME ZONE tz

13. ... USING { {NO EDIT MASK}|{EDIT MASK mask} }

14. ... DD/MM/YY | MM/DD/YY

| DD/MM/YYYY | MM/DD/YYYY

| DDMMYY | MMDDYY | YYMMDD

Effect

These format options override the predefined settings. Without the specification of these additions, the output format depends implicitly on the data type. The result of formatting is adjusted to match the output length. If, during output, a conversion routine is executed, all the formatting optins - except for NO-GAP and UNDER - are ignored.

The additions can be used together with the following limitations:

The addition UNIT cannot be used together with the additions DECIMALS and ROUND.

The addition TIME ZONE cannot be used together with the additions CURRENCY, DECIMALS, EXPONENT, NO-GROUPING, NO-SIGN, NO-ZERO, ROUND, or UNIT.

Addition 1

... LEFT-JUSTIFIED|CENTERED|RIGHT-JUSTIFIED

Effect

This addition defines whether the output formatted according to the other options is aligned left-justified, centered, or right-justified outside the current output length in the list buffer. Closing blaniks are ignored in the case of fields of the type c and they are treated like the other characters in the case of fields of type string.

The alignment takes place in that the superfluous positions in the list buffer are filled up either right-justified, or left-justified, or alternating right and left. If the output length is not sufficient, the characters are cut off to the right for left-justified and centered, and to the left for right-justified alignment.

If the output length in the list display is not sufficient in Unicode systems, characters are cut off during transfer of data from the list buffer into the list. They are cut off to the right for left-justified, and to the left for right- justified output. In the case of centered output, blanks are removed in alternating fashion on both sides, whereby the cut-off starts on the side with more blanks, and then the other characters on the right side. If, during data transfer from the list buffer into the list, characters are cut off, this is made visible on the left side with the character < and on the right side with the character >.

Example

Output of three literals left, in the middle, and to the right of an output area 60 characters in length.

WRITE: /(60) 'Left' LEFT-JUSTIFIED,

/(60) 'Center' CENTERED,

/(60) 'Right' RIGHT-JUSTIFIED.

Addition 2

... NO-GAP

Effect

The list cursor is positioned directly after the output and not in the position in the list buffer after the next one.

Example

The output for both WRITE statements is " NoGap".

WRITE: 'No' NO-GAP, 'Gap'.

Addition 3

... UNDER other_dobj

Effect

The output takes place in the current line at the position where, in a previous WRITE statement, the data object other_dobj was output. The data object other_dobj must be written in the same way as in the respective WRITE statement - that is, including possible offset/length specifiations, and so on. if the data object other_dobj was not specified beforehand, the addition is ignored.

The addition UNDER cannot be used together with a position specification pos after AT.

Note

Vertical positioning must be taken care of. If the list cursor is at the same position as the output of other_dobj, this will be overwritten.

Example

Table-type output of flight connections.

DATA: carrid TYPE spfli-carrid,

connid TYPE spfli-connid.

WRITE: 10 'Carrier', 40 'Connection'.

ULINE.

SELECT carrid connid

FROM spfli

INTO (carrid,connid).

WRITE: / carrid UNDER 'Carrier',

connid UNDER 'Connection'.

ENDSELECT.

Addition 4

... EXPONENT exp

This addition cannot be used together with the addition TIME ZONE.

Effect

This addition defines the exponent for output of data objects of the data type f. For all other data types, the addition is ignored. For exp, a data object of the type i is expected that contains the required exponent. The mantissa is adjusted by moving the decimal point and inserting zeroes to the exponent. If exp contains the value 0, no exponent is output. If the value of exp is larger than the exponent in dobj plus 16, only zeroes are displayed in the mantissa. If the value of exp is less than the exponent in dobj and the output length is not sufficient for the required positions bfore the decimal separator, the addition is ignored. If the value in exp is positive and more than three digits, only the first three positions of the exponent are displayed.

Example

The output of the WRITE statement is "1,414". The standard output for an output length of 6 would be "1E+00".

DATA float TYPE f.

float = sqrt( 2 ).

WRITE (6) float EXPONENT 0.

Addition 5

... NO-GROUPING

This addition cannot be used together with the addition TIME ZONE.

Effect

This addition suppresses the thousands separator in the output of data objects of data types i or p. In all other data types, the addition is ignored.

Addition 6

... NO-SIGN

This addition cannot be used together with the addition TIME ZONE.

Effect

This addition suppresses the plus/minus sign in the output of data objects of data types i, p, or f. In all the other data types, the addition is ignored.

If the addition NO-SIGN is used with the length specification * or ** after AT, it is used first and the output length is determined from the result.

Example

Output with red background color instead of with a plus/minus sign.

DATA number TYPE i.

DO 10 TIMES.

number = sy-index - 5.

IF number < 0.

WRITE number NO-SIGN COLOR = 6.

ENDIF.

ENDDO.

Addition 7

... NO-ZERO

This addition cannot be used together with the addition TIME ZONE.

Effect

If dobj has a numeric data type and contains the value 0, blanks are output for the length of the output. If dobj has the data type c, n, or string, leading zeroes are displayed by blanks.

Example

Output of 22 blanks with red background color instead of the standard output "0,0000000000000000E+00".

DATA float TYPE f.

SET BLANK LINES ON.

IF float = 0.

WRITE float NO-ZERO COLOR = 6.

ENDIF.

Addition 8

... CURRENCY cur

This addition cannot be used together with the addition TIME ZONE.

Effect

This addition defines currency-dependent decimal places for the output of data objects of data types i or p. For all other data types, except for f, the addition is ignored. For cur, a three-digit, character-type field is expected that contains a currency key from the column CURRKEY of the database table TCURX in uppercase letters. The system determines the number of decimal places from the column CURRDEC of the respective row in the database table TCURX. If the content of cur is not found in TCURX, two decimal places are used. The following applies for numeric data types:

In the case of data types of type i, a decimal separator is inserted at the position determined by cur and the thousands separators are moved accordingly.

In the case of data objects of type p, the decimal places defined in the definition of the data type are ignored completely. Irrespective of the actual value and without rounding actions, the decimal separators and the thousand separators are inserted at the positions in the numbers determined by cur.

In the case of data objects of type f, the addition CURRENCY has the same effect as the addition DECIMALS (see below). Here, the number of decimal places is determined by cur.

If the addition CURRENCY with length specification * or ** is used after AT, it is used first and the output length is determined from the result.

Note

The addition CURRENCY is appropriate for the display of data objects of type i or p without decimal places, whose contents are currency amounts in the smallest unit of the currency.

Example

The output of the WRITE statement is "123456,78".

DATA int TYPE i VALUE 12345678.

WRITE int NO-GROUPING CURRENCY 'EUR'.

Addition 9

... DECIMALS dec

This addition cannot be used together with the addition TIME ZONE.

Effect

This addition defines the number of displayed decimal places for the output of data objects of data types i, p, or f. For all other data types, the addition is ignored. For dec, a data object of type i is expected that contains the number of required decimal places. If the content of dec is less than 0, it is treated as 0, whereby the content of data objects of data types i or p is previously multiplied by 10 to the power of dec. For the individual numeric data types, the following applies:

In the case of data objects of type i, a decimal separator and as many zeroes as are specified in dec are added on. The content of dec can be maximum 14. Otherwise, an exception that cannot be handled will be triggered. If the content of dec is 0, the output is unchanged.

In the case of data objects of type p, as many decimal places as are specified in dec are displayed - irrespective of the number of decimal places defined in the data type. The content of dec can be maximum 14. Otherwise, an exception that cannot be handled will be triggered. If dobj has more decimal places, it is rounded to the decimal places in dec. If dobj has less decimal places, a corresponding number of zeroes are inserted.

In the case of data objects of type f, the content of dec determines the number of decimal places in scientific notation. If the content of dec is greater than 16, it will be treated like 16. If the content of dec is greater than the number of decimal places in dobj, a corresponding number of zeroes will be inserted. If the content of dec is less than the number of decimal places in dobj, it is rounded to the decimal places defined in dec.

If the addition DECIMALS is used with length specification * or ** after AT, it is used first and then the output length is determined from the result.

If the addition CURRENCY is specified as well, this is executed first in the case of data types i and p, and then the addition DECIMALS is applied. In the case of data type f, the addition CURRENCY is ignored if it is specified together with DECIMALS.

Example

The output for the WRITE statement is "1234,57".

DATA pack TYPE p DECIMALS 4 VALUE '1234.5678'.

WRITE pack NO-GROUPING DECIMALS 2.

Addition 10

... ROUND scale

This addition cannot be used together with the addition TIME ZONE.

Effect

If dobj has the data type p, this addition multiplies the value of the data object, before output, by 10 to the power of scale. In all other data types, the addition is ignored. For scale, a data object of type i is expected that contains the value of the required scale.

If the value of scale is greater than 0 and the addition DECIMALS is not specified, the interim result is rounded to the number of decimal places defined in the data type. If the addition DECIMALS is specified, it is rounded to the number of decimal places specified in dec and these are then output.

If the addition ROUND is used with the length specification * or ** after AT, it is used first and the output length is determined from the result.

If the addition CURRENCY is specified, this is used, before multiplication, for the content of dobj. If the addition DECIMALS is not specified, the number of decimal places specified through cur is used for rounding off and for the output. If the addition DECIMALS is specified, the value in dec is used.

Example

The output of the WRITE statement is "123456,7800".

DATA pack TYPE p VALUE '12345678'.

WRITE pack NO-GROUPING ROUND 2 DECIMALS 4.

Addition 11

... UNIT unit

This addition cannot be used together with the addition TIME ZONE.

Effect

This addition cuts off decimal places that have the value 0 and are outside the exactness of a unit of measure during output of data objects of data type p. For all other data types, except f, this addition is ignored. For unit, a three-digit, character-type field is expected that contains a unit key from the column MSEHI in the database table T006 in uppercase letters. The system determines the number of decimal places from the column DECAN in the corresponding row in the database table T006. If the content of unit is not found in T006, the addition is ignored.

If the data type of dobj is p and has at least as many decimal places as specified by unit, and if no positions are thus cut off that are not equal to 0, then dobj is output with this number of decimal places.

In the case of data objects of type f, the addition UNIT will be treated like the addition DECIMALS (see above). Here, the number of decimal places is determined by unit.

If the addition UNIT is used with the length specification * or ** after AT, it is used forst, and the output length is determined from the result.

If the addition CURRENCY is used at the same time, this is used first for data type p and then the addition UNIT is used. In the case of data type f, the addition UNIT is ignored.

Example

If no decimal places are specified for the number "PC" in T006, the output of the WRITE statement is "1234".

DATA pack TYPE p DECIMALS 4 VALUE '1234.0000'.

WRITE pack NO-GROUPING UNIT 'PC'.

Addition 12

... TIME ZONE tz

Effect

This addition edits a time stamp in relation to a time zone. The data object dobj must be of type p of length 0 without decimal places, or of type p of length 11 with seven decimal places. The content of dobj is interpreted in such a way as if it contained the long or the short form of a time stamp in UTC reference time.

For tz, a data object of type TIMEZONE from the ABAP Dictionary must be specified. It must contain a time zone from the column TZONE of the database table TTZZ in uppercase letters. If tz is initial, the UTC reference time is output.

The time stamp in dobj is converted to the time zone given in tz, and edited as follows from the left:

First of all, the date is output. The format depends on the settings in the user master record or on any data mask date_mask specified concurrently. After the date, a blank is output.

Secondly, the time is output in the format predefined for type t. Colons ":" are inserted here as separators between hours, minutes, and seconds.

If the time stamp is in the long form, a comma "," is output directly after the time, and after that the milliseconds.

If the value of tz is not contained in the database table TTZZ or if dobj does not contain any valid time stamp, the content of dobj is output without conversion. Before the date, an asterisk "*" is entered, and the last position of the time is cut off.

The editing takes place in an interim result of length 19 if the time stamp is in its short form or of length 27, or if the time stamp is in the long form. If the output length is shorter than 19 or 27, respectively, first all the separators in date and time are removed in the interim result, then the blanks between date and time, and only then characters are cut off at the right. If, at the same time, a date mask date_mask is specified, the separators in the date are not removed.

Note

The data objects dobj and tz can be declared in relation to data types TIMESTAMP, TIMESTAMPL, and TIMEZONE in the ABAP Dictionary.

Example

Output of a UTC time stamp in Tasmanian time. In daylight-saving time, the output is "28.06.2002 04:00:00".

DATA: time_stamp TYPE timestamp,

tzone TYPE timezone.

time_stamp = 20020627180000.

tzone = 'AUSTAS'.

WRITE / time_stamp TIME ZONE tzone.

Addition 13

... USING { {NO EDIT MASK}|{EDIT MASK mask} }

Effect

This addition overrides a conversion routine defined through reference to the ABAP Dictionary. The addition NO EDIT MASK only switches off the execution of an assigned conversion routine. The addition EDIT MASK calls either another conversion routine or defines an edit mask. For mask, a data object of the same name is expected.

In order to call an arbitrary conversion routine CONV, mask must contain two equals signs, followed directly by the name of the conversion routine: "==CONV". During output, the content of dobj is passed to the function module CONVERSION_EXIT_CONV_OUTPUT, converted there, and then the result is displayed. If the function module is not found, an exception that can be handled is triggered (as of Release 6.10). The statement DESCRIBE FIELD contains an addition in order to fill mask accordingly.

If the output length is specified explicitly with len, the conversion routine is executed for the specified length; otherwise for the implicit output length. If * or ** is specified for the output length, the appropriate rules are used for the converted result.

If the first two characters in mask are not equals signs, the content is interpreted as an edit mask in which some characters have a particular meaning. The WRITE statement does not then output the content of dobj directly, but the character string in mask as follows:

If the first two characters in mask are "LL" or "RR ", these are not output, They control whether the edit mask is left-justified or right-justified. If the first two characters are other characters, the edit mask is left-justified.

All "_" characters are replaced from the left (in the case of "LL") or fromn the right (in the case of "RR") with characters for character-type types or numbers for the types p or i from dobj. In the case of fields of type c, closing blanks are ignored. Data objects of type f or x are converted into type c before editing. Superfluous characters "_" in mask are replaced by blanks. Characters from dobj for which there are no characters "_" in mask are not displayed.

If dobj is of type i or p, the first chyaracter from the left "V" in mask is replaced with "-" in the case of a negative number and by blank in the case of a positive number.

All the other characters of the edit mask are displayed unchanged.

If no output length is specified, the implicit output length of dobj is used. If len is specified for the output length, the value of len is used. If * is specified for the output length, exactly that length that is required for the list display is set. If, in Unicode systemsn, characters of the edit mask are replaced by characters that take up more than one column on the list, the output length is increased accordingly and the output is filled with blanks in the list buffer. If ** is specified for the output length, double the length of the edit mask mask is used.

If other formatting options are specified concurrently for an edit mask, these are used first and then the special characters in the edit mask are replaced by the interin result. The date masks date_mask are an exception to this. If these are specified, the edit mask is ignored.

Notes

In Unicode systems, you must remember that a character "_"in the edit mask does not necessarily correspond to a column in the list display since the space required in the display depends on the character to be replaced.

The minus sign for a negative number is not displayed if no edit character "V" is specified. The decimal separator of a packed number with decimal places must be specified at the required position in the edit mask.

Example

Edited output of time duration. In the first output, the function module CONVERSION_EXIT_DURA_OUTPUT is executed. This converts the duration specified in seconds into minutes. In the second output, the edit mask is output according to the above rules. However, the uncerscore characters "_" are replaced by the characters from time.

DATA: dura TYPE i,

time TYPE t VALUE '080000'.

dura = sy-uzeit - time.

time = dura.

WRITE /(30) dura USING EDIT MASK '==SDURA'.

WRITE /(30) time USING EDIT MASK

'RRThe duration is __:__:__'.

Addition 14

... DD/MM/YY | MM/DD/YY

| DD/MM/YYYY | MM/DD/YYYY

| DDMMYY | MMDDYY | YYMMDD

Effect

These additions have the same effect as edit masks for the output of data ojects of data type d. For all other data types, this addition is ignored.

The content of a data object of type d is interpreted according to the specified masks. Here, YYYY stands for the year, MM for the month, and DD for the day. The individual additions assign the content of dobj accordingly. Here, the two last year numbers are used for YY, and all the year numbers are used for YYYY. For the character /, the separator that is defined in the user master record for date output is inserted.

If the output length is defined implicitly or specified using len, this is used. If it is too short, the edited output is cut off to the right. If the output length is specified using * or **, it is set to the length of the specified edit mask (6, 8, or 10).

Note

The behavior for abbreviation differs from the output of a data in accordance with the user master record - that is, with regard to the position where the separator is removed first and then cut off.

Example

The output of the WRITE statement is, for example, "230402".

WRITE sy-datum DDMMYY.

Exceptions

Non-Catchable Exceptions

Cause: CURRENCY parameter for WRITE not of the type C

Runtime Error: WRITE_CURRENCY_ILLEGAL_TYPE

Cause: Rounding parameter less than -14

Runtime Error: WRITE_ROUND_TOO_SMALL

Cause: UNIT parameter for WRITE not of the tye type C

Runtime Error: WRITE_UNIT_ILLEGAL_TYPE

Thanks

Sunil