Skip to main content

Develop Abap reports quickly and easily

Here is a piece of code to write ABAP reports and format them easily and quickly. The following code can be created as an include and used whenever required. This code uses the ABAP objects and created as local class. This include can be used for printing Internal tables, either by passing the whole table or by passing individual lines. Using the following steps the report output can be easily formatted.
  1. Create object with referance to lcl_report.
  2. Create column formats for individual columns by building the t_format structure and calling the method add_column as follows call method x->add_column exporting l_format = comp_print = 'K' (to print the column with key color) comp_print = 'H' (to print the column as hotspot)
  3. Call method write_table for listing the whole internal table. call method x->write_table exporting p_table =
  4. Call method write_line for listing one line at a time. May be used in cases where loop control is with the main program. call method x->write_line exporting p_line =
  5. Call method write_header to print the page header. Will be used in the top-of-page event. The report title is picked up as follows. for basic list - from the report title in the attributes for drilldown lists - from text symbol TTN where N is the drill down level. For example drill down level 2 will look for TT2.
  6. call method X->format_line exporting p_line = importing out_line =
DOWNLOAD Include code Also you can download the sample report created using this include from here. DOWNLOAD Sample Report

Comments

Anonymous said…
Hi Ravi,

We have tried your code and it's working perfectly. Thanks for the great information and for sharing it with others.

Amani

Popular posts from this blog

Vendor Consignment Business Process

Wikipedia offers a very simple definition for consignment . It is a process of placing a thing in the hand of another, but retaining the ownership until the goods are sold or used. In SAP consignment business process can be implemented very easily using the following steps. Activate Consignment inforecords using tcode OMEV. This activates the consignment prices to be picked up using the consignment info records. configure a special procurement type using IMG->Production->MRP->Master Data->Define special procurement type. In OBYC configure the consignment payables account (transaction KON). Assign the special procurement type created in step 2 to all the materials that are to use the consignment process. This is done in the MRP2 view of the material master maintenance transaction Create Consignment info record using tcode ME11. Select info category as consignment. Create general data, Purchase Org data and conditions. Conditions allow you to create time dependent prices. Cre...

Rounding off of Amount fields in SAP

I remember, when I learnt COBOL, our instructor used to give us problems to solve. One of the problems often repeated in all programming classes was to write the code for rounding off numbers, without using built in functions. In SAP it is a bit tricky, as SAP stores amout fields as currency types. These fields are stored internally with 2 decimals, irrespective of the currency used. It can be easily done using write statement if you want to round the amount field in the report. How to do it if you want to round it store it as a currency amount field itself. This is a problem in SAP query reports. In my case the user wanted to amount fields to appear rounded to nearest integer. SAP has some built-in-functions like ceil, floor but they can not be used as it is, due to the fact that the amount is stored internally with 2 decimals. Most of the currencies are with 2 decimals and it is still not a problem. This can be easily achieved by the following operation. A constant need to be defin...

LSMW Tip

This tip is very useful for Master Data LSMWs that updates many fields. Usually it happens that during a specific project we realise a need to update specific fields. We design these LSMWs in such a way that these values supplied in the input file is updated in the master file. Later on we try to reuse the LSMW for updating a subset if these fields. If we leave the values of other fields blank in the input file, depending on how the LSMW conversion rules were designed, the the master data will be updated with initial values. Common practice in many organisations is to create a new LSMW for the new set of fields. This is not required if the LSMW uses Direct Input. Direct input uses a special character to denote no value. The default is "/". This allows us to reuse the LSMW. Reformat the input text file and fill fields that are not to be disturbed with this character. For example if the LSMW is for updating the following fields 1. storage bin 2. picking area 3. reord...