Problem solve Get help with specific problems with your technologies, process and projects.

Report output formatting tips using the write statement

This tip outlines a couple of methods that can be used to display your report output.

If you are not using the ALV grid to display your report output there is usually some frustration involved with the positioning of columns and the data underneath them. This tip outlines a couple of methods that can be used to reduce this stressful activity so that amendments become very simple indeed.


Fed up with specifiying the exact position of columns? Can't be bothered with the 'oh, I must move that heading one character left and that one two characters right'? Cringe with fear at the nightmare that is realigning the first column because the field size has changed? Try the following:

write: /(10) wa_it_kna1-kunnr,
(25) wa_it_kna1-name1,
(8) wa_it_kna1-pstlz.

The value in brackets defines how long each output field should be. Therefore the column titles will be:

write: /(10) 'Customer',
(25) 'Name',
(8) 'Postcode'.

If the values are set to the field sizes from the dictionary, then all of their contents will be displayed.

This is also a handy way of cutting down on the size of some fields such as descriptions without having to move it to a different sized field. In this case, 4.6 has a useful addition called 'quickinfo'. If you want to cut down, for instance, kna1-name1 (which is 35 characters long) to display as 25 characters you can still have the 35 character field display when the user moves their mouse over the field on the screen as follows:

write: /(25) wa_it_kna1-name1 quickinfo wa_it_kna1-name1 .

And if the customer number changes to 20 characters, just update the field size in both the column header and the field output. No more having to rejig the other positions.

Also, using:

write: / sy-vline no-gap,
(10) wa_it_kna1-kunnr no-gap,
sy-vline no-gap,
(25) wa_it_kna1-name1 no-gap,
sy-vline no-gap,
(8) wa_it_kna1-pstlz no-gap,
sy-vline no-gap.

- each column will be separated with a pretty vertical line.

Another method that can be employed is as follows. The WRITE command has an extension called UNDER whereby you designate the column headings and then on the subsequent write statements you use:
WRITE field UNDER column_heading.

This means that you only have to specify the column heading positions (possibly using the method outlined previously).

Dig Deeper on SAP Basis

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

Hello,
I read your blog and i really liked it and it is very useful for me and, I hope you will post these types of posts.
Thank you.
Cancel

-ADS BY GOOGLE

SearchERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchContentManagement

SearchHRSoftware

Close