Application Development 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: 

standard output formats

Former Member
0 Kudos
232

How to display the output data in reports as a table format with background coloring and table coloring.

10 REPLIES 10

Former Member
0 Kudos
71

Hi,

You can use ALV List that's very easy to use and format. Else you can use the classical reporting method where you'll have to specify the color and other options explicitely. This is a tedious process ofcourse.

I'd suggest you to use ALV List.

If you are ok I'll send the codes for that.

Cheers,

Sam

0 Kudos
71

Thanks for giving rply

sure you can send the code now

thanks

neelima

Lakshmant1
Active Contributor
0 Kudos
71

Hi Neelima,

For standard list, have a look at ERGP2000 program.

Thanks

Lakshman

0 Kudos
71

i am fresher to abap so plz give me detailed information regarding to that, if possible along with code.plz give reply how to navigate that program also

thanks

neelima

0 Kudos
71

Hi,

Here is the simple example.

format color 1.

write : 'hello' .

Check the documentation for FORMAT.

http://www.geocities.com/SiliconValley/Campus/6345/abapindx.htm

Kindly reward points for useful answers by clicking yellow star(2 points),green star(6 points),blue star(10 points-if your problem is solved] against replies.

Message was edited by: Jayanthi Jayaraman

Message was edited by: Jayanthi Jayaraman

0 Kudos
71

Hi,

U can go to SE38, give program name as: ERGP2000 and click on Display to see the coding!!!. Its explained very neatly.

*---------------------------------------------------------------------*
*       FORM HEADING                                                  *
*---------------------------------------------------------------------*
*       Writes the heading of the list                                *
*---------------------------------------------------------------------*
FORM HEADING.
  FORMAT INTENSIFIED OFF.              " Remove any INTENSIFIED
  ULINE AT (WIDTH).                    " Upper frame border
  FORMAT COLOR COL_HEADING INTENSIFIED." Title color
  WRITE: / SY-VLINE.                   " Left border
  WRITE: 'No |Colour        |intensified    |intensified off|',
         'inverse' NO-GAP.             "#EC NOTEXT
  WRITE: AT WIDTH SY-VLINE.            " Right border
  ULINE AT (WIDTH).                    " Line below titles
  FORMAT COLOR OFF.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM OUTPUT_BODY                                              *
*---------------------------------------------------------------------*
*       Writes the list body                                          *
*---------------------------------------------------------------------*
FORM OUTPUT_BODY.

  DO LENGTH TIMES.
    PERFORM WRITE_LINE USING SY-INDEX.
  ENDDO.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM WRITE_LINE                                               *
*---------------------------------------------------------------------*
*       Writes one line of the list                                   *
*---------------------------------------------------------------------*
FORM WRITE_LINE USING COUNT TYPE I.
  DATA: HELP(14) TYPE C,
        COUNT1 TYPE I.

  COUNT1 = SY-INDEX - 1.
  WRITE: / SY-VLINE NO-GAP.
  WRITE: (4) COUNT1 COLOR COL_KEY INTENSIFIED NO-GAP.
  WRITE: SY-VLINE NO-GAP.
  CASE COUNT1.
    WHEN '0'.
      HELP = 'COL_BACKGROUND'.
    WHEN '1'.
      HELP = 'COL_HEADING'.
    WHEN '2'.
      HELP = 'COL_NORMAL'.
    WHEN '3'.
      HELP = 'COL_TOTAL'.
    WHEN '4'.
      HELP = 'COL_KEY'.
    WHEN '5'.
      HELP = 'COL_POSITIVE'.
    WHEN '6'.
      HELP = 'COL_NEGATIVE'.
    WHEN '7'.
      HELP = 'COL_GROUP'.
  ENDCASE.
  WRITE: HELP COLOR COL_KEY INTENSIFIED NO-GAP.
  WRITE: SY-VLINE NO-GAP.
  WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED NO-GAP.
  WRITE: SY-VLINE NO-GAP.
  WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED OFF NO-GAP.
  WRITE: SY-VLINE NO-GAP.
  WRITE: TESTSTRING COLOR = COUNT1 INVERSE NO-GAP.
  WRITE AT WIDTH SY-VLINE NO-GAP.
ENDFORM.

Best Regards,

Anjali

Former Member
0 Kudos
71

Hi Neelima,

Use the FORMAT ABAP command.

It has the option for COLOR as well as many other options.

Regards,

Gaurav

0 Kudos
71

i am fresher to abap so plz give me detailed information regarding to that, if possible along with code.

thanks

neelima

jayanthi_jayaraman
Active Contributor
0 Kudos
71

Hi,

Here is the sample code for colouring lines in ALV.

1. Include a 4-character field in the internal data table that is being passed to REUSE_ALV_GRID_DISPLAY.

Eg:  
      DATA: BEGIN OF i_data OCCURS 10,
      qmnum      LIKE viqmel-qmnum,
      qmart      LIKE viqmel-qmart,
      zzvalstat  LIKE viqmel-zzvalstat,
      valstattxt LIKE zawprcode-valstattxt,
      kunum      LIKE viqmel-kunum,
      bstnk      LIKE viqmel-bstnk,
      qmtxt      LIKE viqmel-qmtxt,
      ws_color(4)TYPE c,  
      END OF i_data.

2. In the code, loop through the lines of the internal table and assign values to this field. The 4-character value will be of the format - Cxyz.

Char 1            – is always C indicating that it’s a color property.
Char 2    (x)    – color code, which can be any value from (1 – 7). 
Char 3    (y)    – Intensity on/off.         (1 = on, 0 = off).
Char 4    (z)    – Inverse display on/off.   (1 = on, 0 = off).

(From the above, it is clear that we can have only 28 different coloring options)
	Eg: C401.

LOOP AT i_data.
IF (expression 1).
	i_data-ws_color = ‘C510’.
ELSEIF(expression 2).
	i_data-ws_color = ‘C200’.
ELSE.
	i_data-ws_color = ‘C711’.
ENDIF.
MODIFY i_data.
ENDLOOP.

3. When specifying the layout properties, specify the name of this field (ws_color) as the color field.

FORM f1200_define_layout CHANGING p_i_layout TYPE slis_layout_alv.

  CLEAR p_i_layout.
  p_i_layout-zebra = 'X'.
  p_i_layout-colwidth_optimize = 'X'.
  p_i_layout-info_fieldname = 'WS_COLOR'.

ENDFORM.                    " F1200_define_layout

Former Member
0 Kudos
71