Skip to content

Line color in ALV

May 18, 2009

Using colors in ALV List or ALV Grid has it’s advantages, it could be very useful to increase readability of report and it is very easy to implement if you are already familiar with programming ALV.

There are only two specific codes to add and the rest are your usual ALV codes. First, add a character field to internal table structure that is going to be displayed in the ALV for storing color attribute.

DATA: BEGIN OF it_alv OCCURS 0,
        color(4),        "color line
        field1,
        field2,
      END OF it_alv.

The color is represented in four characters with following details:

  • 1st char = ‘C’
  • 2nd char = Color code (1-7)
  • 3rd char = Intensified on/off (1 or 0)
  • 4th char = Inverse on/off (1 or 0)

See ABAP Keyword Documentation for color code reference.

And the second one, add following to your ALV layout attributes

DATA: v_layout TYPE slis_layout_alv.

v_layout-INFO_FIELDNAME       = 'COLOR'.
v_layout-F2CODE               = '&ETA'.

Read more to see a complete example of how to set line color in ALV.  In this example we will use ALV to output list of reservations and highlight open reservations, finished items, and deleted items with different colors.

Read more…

Get Last Day of The Month

March 31, 2009

Any chance that you need to get the latest date of this month or any month in particular? Easy, just use function LAST_DAY_OF_MONTHS. Here’s an example of how to do it.

DATA: start_date LIKE sy_datum,
      end_date LIKE sy_datum.

* Get first day of current month
  CONCATENATE sy-datum(6) '01' INTO start_date.

* Get last day of current month
  CALL FUNCTION 'LAST_DAY_OF_MONTHS'
       EXPORTING
            day_in            = start_date
       IMPORTING
            last_day_of_month = end_date.
  IF sy-subrc  0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

and voila! you got your last day of the month 🙂

Force your ABAP Report to Run in Background

September 8, 2008

Despite of any performance tuning you made, some reports may still take forever to execute. One of my last report did, and when i tried to execute it in foreground it gets a TIME_OUT runtime error, apparently the report hits the maximum run time parameter defined in the system.

One solution to this is by running your report in background, since there are no run time limitations of background jobs you can execute any report in any amount of time needed.

Read more…

Uploading data using lsmw

August 21, 2008
tags: ,

Imagine that you have thousands of material data and you need to change the storage location field on each of them or you have tons and tons of cost center to be allocated. To manually do it one by one is, of course, out of the question. How much time and energy would be needed to accomplish it?

There are a couple of options to take. First, you could make an abap program to upload the data simultaneously through a file, this is of course if there is an abap programmer availabe or you are willing to hire one.

The second option is to use one of SAP functionality called Legacy System Migration Workbench with transaction code lsmw. LSMW is easy to use and you don’t need to have any knowledge on programing, though basic understanding on data structures would be an advantage.

Read more…

Get Cost Center & Profit Center Hierarchy

July 23, 2008

Some reports may need to use Profit Center or Cost Center hierarchy defined in the SAP Master Data. Rather than define a table to provide the same information, you could use function module provided by SAP.

Lets say that we have Cost Center hierarchy like below and we want to get all cost center below the CTR group.

snap

Read more…

Internal Table: With or Without Header Line

July 23, 2008

If you are familiar with programming, you might find that array is a powerful tool provided by various programming languages. ABAP offers Internal Table to fulfill the functionality of array.

The obvious difference between general array concept in other various programming language and internal table lies in the way of accessing it. Direct access to internal table content is not provided, instead we use work area that hold a single line of the internal table.

There are two types of Internal Table declaration that differ the way of processing it.

  • Internal Table With Header Line
  • Internal Table without Header Line

Read more…

Connecting to FTP Server using ABAP

July 23, 2008

There are several ways can be used to interact your SAP system with other application. If you specifically need an ABAP program to connect to an FTP server, then you are lucky, SAP provides a function module for FTP connection.

Using SAP function module, you can execute any FTP Command. Furthermore you can directly send your internal table content to FTP server as file, and vice versa.
Read more…