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

Re: ALV colour problem

Former Member
0 Likes
737

Hi Friends,

I have a problem in ALV report while dispalying the fields in Different colours,i just want to Display Purchase order no,Material no in yellow and green colours.

Can you guide me,i have sent the code along with this.

Report YSDBALV.

tables: ekko , ekpo .

type-pools: slis .

  • Table for Display Header

data:i_header type slis_t_listheader with header line.

*Fieldcat Declaration

data:fieldcatalog type slis_T_fieldcat_alv WITH HEADER LINE.

*Table of Events

data:i_event type slis_t_event with header line .

  • For Layout

data:i_layout type slis_layout_alv .

data: text(30) .

*Internal Table Declaration

data: begin of it_final occurs 0 ,

ebeln like ekko-ebeln , "Purchasing Document No.

bedat like ekko-bedat , "Purchasing Document Date

matnr like ekpo-matnr , "Material No.

netwr like ekpo-netwr , "Net Order Value in PO Currancy

meins like ekpo-meins , "UOM

chk(1) ,

light(1) ,

change like ekpo-menge ,

end of it_final .

**select option Declaration

selection-screen begin of block block.

select-options: s_ebeln for ekko-ebeln .

selection-screen end of block block .

selection-screen begin of block block1 .

parameters:grid radiobutton group r .

parameters:list radiobutton group r .

selection-screen end of block block1 .

    • at selection screen

at selection-screen .

select single * from ekko where ebeln in s_ebeln .

if sy-subrc <> 0 .

message e000(8I) WITH 'No Data Exists' .

endif .

start-of-selection .

if grid = 'X' .

perform get_data .

perform event using i_event[] .

perform field using fieldcatalog[] .

perform layout using i_layout .

perform grid_display .

endif .

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data .

*DATA Retrieval from tables

SELECT EKKO~EBELN

EKKO~BEDAT

EKPO~EBELP

EKPO~MATNR

EKPO~NETWR

EKPO~MEINS

EKPO~MENGE

EKPO~BPRME

INTO CORRESPONDING FIELDS OF table IT_FINAL

FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN

WHERE EKKO~EBELN IN S_EBELN.

APPEND IT_FINAL.

endform. " get_data

*Getting the Event for Top of Page display.

&----


*& Form event

&----


  • text

----


  • -->P_I_event[] text

----


form event using p_i_event type slis_t_event.

clear p_i_event .

refresh p_i_event .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

  • EXPORTING

  • I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = p_i_event

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 1

  • OTHERS = 2

read table p_i_event with key name = slis_ev_top_of_page into i_event.

if sy-subrc = 0.

move 'TOP_OF_PAGE_PO' to i_event-form.

modify p_i_event from i_event index sy-tabix transporting form.

endif.

clear i_event.

endform. " event

*Display Top-of –Page Details and Logo

form top_of_page_po .

clear i_header .

refresh i_header .

write sy-datum to text.

i_header-typ = 'H'.

i_header-info = 'PURCHASE OREDER DETAILS'.

append i_header.

*Logo Display

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_header[]

I_LOGO = 'ENJOYSAPLOGO'.

endform .

*Field Catalog Append

&----


*& Form field

&----


  • text

----


  • -->P_fieldCATALOG[] text

----


form field using p_fieldcatalog type slis_t_fieldcat_alv.

  • clear fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order No'.

fieldcatalog-col_pos = 1.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'BEDAT'.

fieldcatalog-seltext_m = 'PO Date'.

fieldcatalog-col_pos = 2.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material No'.

fieldcatalog-col_pos = 4.

fieldcatalog-outputlen = 20.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'NETWR'.

fieldcatalog-seltext_m = 'Net Value '.

fieldcatalog-col_pos = 5.

fieldcatalog-outputlen = 20.

fieldcatalog-do_sum = 'X'.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Units'.

fieldcatalog-col_pos = 6.

fieldcatalog-outputlen = 4.

append fieldcatalog .

clear fieldcatalog.

endform. " field

&----


*& Form layout

&----


  • text

form layout using p_i_layout TYPE SLIS_LAYOUT_ALV .

i_layout-zebra = 'X'.

i_layout-lights_fieldname = 'LIGHT'.

i_layout-lights_tabname = 'IT_FINAL'.

i_layout-box_fieldname = 'CHK'.

i_layout-box_tabname = 'IT_FINAL'.

i_layout-edit = ' '.

endform.

*To display Buttons in the MENU BAR if needed

FORM SET_PO_PF_STATUS USING P_I_EXTAB TYPE

SLIS_T_EXTAB.

SET PF-STATUS 'MENUPO'.

ENDFORM.

*Event for Interactive display of ALV report

form USER_COMMAND using r_ucomm like sy-ucomm

rs_selfield type slis_selfield .

if r_ucomm = '&IC1'.

READ TABLE IT_FINAL index rs_selfield-tabindex.

write:/ IT_FINAL-ebeln.

endif.

endform .

*Parameters of FM REUSE_ALV_GRID_DISPLAY

&----


*& Form grid_display

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form grid_display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = 'SET_PO_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IS_LAYOUT = I_LAYOUT

IT_FIELDCAT = FIELDCATALOG[]

IT_EVENTS = I_EVENT[]

TABLES

t_outtab = IT_FINAL.

endform. " grid_display

sreekanth reddy

Posts: 733

Questions: 0

Registered: 9/4/06

Forum points: 1,094

Solved problem (10)

Very helpful answer (6)

Helpful answer (2)

Re: Problem in ALV report

Posted: Jan 31, 2007 6:26 PM in response to: Dinesh Babu Reply E-mail this post

Hi Dinesh,

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_header[]

I_LOGO = 'ENJOYSAPLOGO'.

change it to

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_header[]

I_LOGO = 'ENJOYSAP_LOGO'.

Rusidar Subramani

Posts: 67

Questions: 1

Registered: 9/5/05

Forum points: 90

Unassign

Solved problem (10)

Very helpful answer (6)

Helpful answer (2)

Re: Problem in ALV report

Posted: Jan 31, 2007 7:35 PM in response to: Dinesh Babu Reply E-mail this post

&----


*& Report YSDBALV1

*&

&----


*&

*&

&----


REPORT YSDBALV1.

tables: ekko , ekpo .

type-pools: slis .

  • Table for Display Header

data:i_header type slis_t_listheader with header line.

*Fieldcat Declaration

data:fieldcatalog type slis_T_fieldcat_alv WITH HEADER LINE.

*Table of Events

data:i_event type slis_t_event with header line ,

wa_event type line of slis_t_event.

  • For Layout

data:i_layout type slis_layout_alv .

data: text(30) .

*Internal Table Declaration

data: begin of it_final occurs 0 ,

ebeln like ekko-ebeln , "Purchasing Document No.

bedat like ekko-bedat , "Purchasing Document Date

matnr like ekpo-matnr , "Material No.

netwr like ekpo-netwr , "Net Order Value in PO Currancy

meins like ekpo-meins , "UOM

chk(1) ,

light(1) ,

change like ekpo-menge ,

end of it_final .

**select option Declaration

selection-screen begin of block block.

select-options: s_ebeln for ekko-ebeln .

selection-screen end of block block .

selection-screen begin of block block1 .

parameters:grid radiobutton group r .

parameters:list radiobutton group r .

selection-screen end of block block1 .

    • at selection screen

at selection-screen .

select single * from ekko where ebeln in s_ebeln .

if sy-subrc <> 0 .

message e000(8I) WITH 'No Data Exists' .

endif .

start-of-selection .

if grid = 'X' .

perform get_data .

perform event using i_event[] .

perform field using fieldcatalog[] .

perform layout using i_layout .

perform grid_display .

endif .

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data .

*DATA Retrieval from tables

SELECT EKKO~EBELN

EKKO~BEDAT

EKPO~EBELP

EKPO~MATNR

EKPO~NETWR

EKPO~MEINS

EKPO~MENGE

EKPO~BPRME

INTO CORRESPONDING FIELDS OF table IT_FINAL

FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN

WHERE EKKO~EBELN IN S_EBELN.

APPEND IT_FINAL.

endform. " get_data

*Getting the Event for Top of Page display.

&----


*& Form event

&----


  • text

----


  • -->P_I_event[] text

----


form event using p_i_event type slis_t_event.

clear p_i_event .

refresh p_i_event .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

  • EXPORTING

  • I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = p_i_event.

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 1

  • OTHERS = 2.

read table p_i_event with key name = slis_ev_top_of_page into wa_event.

if sy-subrc = 0.

move 'TOP_OF_PAGE_PO' to i_event-form.

modify p_i_event from i_event index sy-tabix transporting form.

endif.

clear i_event.

endform. " event

*Display Top-of –Page Details and Logo

form top_of_page_po .

clear i_header .

refresh i_header .

write sy-datum to text.

i_header-typ = 'H'.

i_header-info = 'PURCHASE OREDER DETAILS'.

append i_header.

*Logo Display

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_header[]

I_LOGO = 'ENJOYSAP_LOGO'.

endform .

*Field Catalog Append

&----


*& Form field

&----


  • text

----


  • -->P_fieldCATALOG[] text

----


form field using p_fieldcatalog type slis_t_fieldcat_alv.

  • clear fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order No'.

fieldcatalog-col_pos = 1.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'BEDAT'.

fieldcatalog-seltext_m = 'PO Date'.

fieldcatalog-col_pos = 2.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material No'.

fieldcatalog-col_pos = 4.

fieldcatalog-outputlen = 20.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'NETWR'.

fieldcatalog-seltext_m = 'Net Value '.

fieldcatalog-col_pos = 5.

fieldcatalog-outputlen = 20.

fieldcatalog-do_sum = 'X'.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Units'.

fieldcatalog-col_pos = 6.

fieldcatalog-outputlen = 4.

append fieldcatalog .

clear fieldcatalog.

endform. " field

&----


*& Form layout

&----


  • text

form layout using p_i_layout TYPE SLIS_LAYOUT_ALV .

i_layout-zebra = 'X'.

i_layout-lights_fieldname = 'LIGHT'.

i_layout-lights_tabname = 'IT_FINAL'.

i_layout-box_fieldname = 'CHK'.

i_layout-box_tabname = 'IT_FINAL'.

i_layout-edit = ' '.

endform.

*To display Buttons in the MENU BAR if needed

FORM SET_PO_PF_STATUS USING P_I_EXTAB TYPE

SLIS_T_EXTAB.

SET PF-STATUS 'MENUPO'.

ENDFORM.

*Event for Interactive display of ALV report

form USER_COMMAND using r_ucomm like sy-ucomm

rs_selfield type slis_selfield .

if r_ucomm = '&IC1'.

READ TABLE IT_FINAL index rs_selfield-tabindex.

set parameter id 'VL1' field it_final-ebeln.

call transaction 'ME23N'.

endif.

endform .

*Parameters of FM REUSE_ALV_GRID_DISPLAY

&----


*& Form grid_display

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form grid_display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = 'SET_PO_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IS_LAYOUT = I_LAYOUT

IT_FIELDCAT = FIELDCATALOG[]

IT_EVENTS = I_EVENT[]

TABLES

t_outtab = IT_FINAL.

endform. " grid_display

Regards,

Dinesh

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
714

Hello Dinesh

Simply add the following line of coding:

fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order No'.
fieldcatalog-col_pos = 1.
fieldcatalog-emphasize = 'C310'.  " intensive yellow, 'C510' = intensive green
append fieldcatalog .
clear fieldcatalog.

Regards

Uwe

5 REPLIES 5
Read only

Former Member
0 Likes
714

Try to use emphasie in your Fieldcatalog... please look at type pool : slis for more help....

i.e. when you are writing the code for populating the fieldcatalog table use a field emphasize .. along with it... it has got diffrent numbers for diff. colors....

Please look at this...

  • 0 = background color *

  • 1 = blue *

  • 2 = gray *

  • 3 = yellow *

  • 4 = blue/gray *

  • 5 = green *

  • 6 = red *

  • 7 = orange *

Message was edited by:

JAYANT KUMAR

Read only

uwe_schieferstein
Active Contributor
0 Likes
715

Hello Dinesh

Simply add the following line of coding:

fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order No'.
fieldcatalog-col_pos = 1.
fieldcatalog-emphasize = 'C310'.  " intensive yellow, 'C510' = intensive green
append fieldcatalog .
clear fieldcatalog.

Regards

Uwe

Read only

Former Member
0 Likes
714

hi Dinesh,

Please follow the instructions mentioned below:

step1: your ALV internal table should have a field (say,COLORCELL)of structure LVC_T_SCOL.

step2: in the layout structure, set the coltab. for eg: is_layout-coltab_fieldname = 'COLORCELL'.

step3: hide the column field 'COLORCELL' in fieldcatalog. for eg,


loop at it_fieldcatalog into wa_fieldcatalog.
       if wa_fieldcatalog-fieldname = 'COLORCELL'.
             wa_fieldcatalog-no_out  = 'X'.
             modify it_fieldcatalog from wa_fieldcatalog. <b>(index sy-tabix</b> optional here)
       endif.
endloop.

step4: loop through the ALV internal table and check the condition where you need to color the cell.

step5: write the following code:


perform set_column_color tables ls_alv_display-colorcell
                                   using  'DOCUMENT'             " field name
                                             '6'                             "column number is red
                                             '0'                             "inverse     
                                             '0'.                            "intensity
 
 
form set_column_color  tables et_color type lvc_t_scol
                                   using  p_fname  type lvc_fname
                                             p_col    type lvc_col
                                             p_inv    type lvc_inv
                                             p_int    type lvc_int.
data:
    ls_color type lvc_s_scol. 
    ls_color-fname     = p_fname.
    ls_color-color-col = p_col.
    ls_color-color-inv = p_inv.
    ls_color-color-int = p_int.
    append ls_color to et_color.
endform.                                                  " set_column_color

Hope this helps,

Sajan Joseph.

Read only

Former Member
0 Likes
714

Hi,

Take alook at the program given below

TABLES:LFA1.

SELECT-OPTIONS:C_LIFNR FOR LFA1-LIFNR. " FOR GRID ONLY

PARAMETERS:LIST RADIOBUTTON GROUP ALV DEFAULT 'X',

GRID RADIOBUTTON GROUP ALV.

DATA:BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

NAME1 LIKE LFA1-NAME1,

LAND1 LIKE LFA1-LAND1,

ORT01 LIKE LFA1-ORT01,

SORTL LIKE LFA1-SORTL,

REGIO LIKE LFA1-REGIO,

COL TYPE LVC_T_SCOL,

END OF ITAB.

DATA:COLR TYPE LVC_S_SCOL.

SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB.

LOOP AT ITAB.

IF ITAB-LIFNR IN C_LIFNR.

COLR-FNAME = 'NAME1'.

COLR-COLOR-COL = '5'.

COLR-COLOR-INT = '1'.

COLR-COLOR-INV = '0'.

COLR-NOKEYCOL = 'X'.

APPEND COLR TO ITAB-COL.

COLR-FNAME = 'LIFNR'.

APPEND COLR TO ITAB-COL.

MODIFY ITAB.

ENDIF.

ENDLOOP.

TYPE-POOLS:SLIS.

DATA:FCAT TYPE SLIS_T_FIELDCAT_ALV.

DATA:LAYOUT TYPE SLIS_LAYOUT_ALV.

LAYOUT-ZEBRA = 'X'.

layout-coltab_fieldname = 'COL'.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = SY-REPID

I_INTERNAL_TABNAME = 'ITAB'

  • I_STRUCTURE_NAME =

  • I_CLIENT_NEVER_DISPLAY = 'X'

I_INCLNAME = SY-REPID

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = FCAT

  • EXCEPTIONS

  • INCONSISTENT_INTERFACE = 1

  • PROGRAM_ERROR = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

IF LIST = 'X'.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = ITAB

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ELSEIF GRID = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

IS_LAYOUT = LAYOUT

IT_FIELDCAT = FCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = ITAB

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDIF.

Rgds,

Prajith

Read only

Former Member
0 Likes
714

Hi Dinesh,

Just copy and paste your code......I added two statements in fieldcatalog for the two fields that you have asked to color that fields with yellow and green....

<b>

I have bolded the that two statements which I added...</b>

Report YSDBALV.

tables: ekko , ekpo .

type-pools: slis .

  • Table for Display Header

data:i_header type slis_t_listheader with header line.

*Fieldcat Declaration

data:fieldcatalog type slis_T_fieldcat_alv WITH HEADER LINE.

*Table of Events

data:i_event type slis_t_event with header line .

  • For Layout

data:i_layout type slis_layout_alv .

data: text(30) .

*Internal Table Declaration

data: begin of it_final occurs 0 ,

ebeln like ekko-ebeln , "Purchasing Document No.

bedat like ekko-bedat , "Purchasing Document Date

matnr like ekpo-matnr , "Material No.

netwr like ekpo-netwr , "Net Order Value in PO Currancy

meins like ekpo-meins , "UOM

chk(1) ,

light(1) ,

change like ekpo-menge ,

end of it_final .

**select option Declaration

selection-screen begin of block block.

select-options: s_ebeln for ekko-ebeln .

selection-screen end of block block .

selection-screen begin of block block1 .

parameters:grid radiobutton group r .

parameters:list radiobutton group r .

selection-screen end of block block1 .

    • at selection screen

at selection-screen .

select single * from ekko where ebeln in s_ebeln .

if sy-subrc <> 0 .

message e000(8I) WITH 'No Data Exists' .

endif .

start-of-selection .

if grid = 'X' .

perform get_data .

perform event using i_event[] .

perform field using fieldcatalog[] .

perform layout using i_layout .

perform grid_display .

endif .

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data .

*DATA Retrieval from tables

SELECT EKKO~EBELN

EKKO~BEDAT

EKPO~EBELP

EKPO~MATNR

EKPO~NETWR

EKPO~MEINS

EKPO~MENGE

EKPO~BPRME

INTO CORRESPONDING FIELDS OF table IT_FINAL

FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN

WHERE EKKO~EBELN IN S_EBELN.

APPEND IT_FINAL.

endform. " get_data

*Getting the Event for Top of Page display.

&----


*& Form event

&----


  • text

----


  • -->P_I_event[] text

----


form event using p_i_event type slis_t_event.

clear p_i_event .

refresh p_i_event .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

  • EXPORTING

  • I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = p_i_event

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 1

  • OTHERS = 2

read table p_i_event with key name = slis_ev_top_of_page into i_event.

if sy-subrc = 0.

move 'TOP_OF_PAGE_PO' to i_event-form.

modify p_i_event from i_event index sy-tabix transporting form.

endif.

clear i_event.

endform. " event

*Display Top-of –Page Details and Logo

form top_of_page_po .

clear i_header .

refresh i_header .

write sy-datum to text.

i_header-typ = 'H'.

i_header-info = 'PURCHASE OREDER DETAILS'.

append i_header.

*Logo Display

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_header[]

I_LOGO = 'ENJOYSAPLOGO'.

endform .

*Field Catalog Append

&----


*& Form field

&----


  • text

----


  • -->P_fieldCATALOG[] text

----


form field using p_fieldcatalog type slis_t_fieldcat_alv.

  • clear fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.

<b>fieldcatalog-emphasize = 'C311'.</b>

fieldcatalog-seltext_m = 'Purchase Order No'.

fieldcatalog-col_pos = 1.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'BEDAT'.

fieldcatalog-seltext_m = 'PO Date'.

fieldcatalog-col_pos = 2.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material No'.

<b>fieldcatalog-emphasize = 'C511'.</b>

fieldcatalog-col_pos = 4.

fieldcatalog-outputlen = 20.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'NETWR'.

fieldcatalog-seltext_m = 'Net Value '.

fieldcatalog-col_pos = 5.

fieldcatalog-outputlen = 20.

fieldcatalog-do_sum = 'X'.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Units'.

fieldcatalog-col_pos = 6.

fieldcatalog-outputlen = 4.

append fieldcatalog .

clear fieldcatalog.

endform. " field

&----


*& Form layout

&----


  • text

form layout using p_i_layout TYPE SLIS_LAYOUT_ALV .

i_layout-zebra = 'X'.

i_layout-lights_fieldname = 'LIGHT'.

i_layout-lights_tabname = 'IT_FINAL'.

i_layout-box_fieldname = 'CHK'.

i_layout-box_tabname = 'IT_FINAL'.

i_layout-edit = ' '.

endform.

*To display Buttons in the MENU BAR if needed

FORM SET_PO_PF_STATUS USING P_I_EXTAB TYPE

SLIS_T_EXTAB.

SET PF-STATUS 'MENUPO'.

ENDFORM.

*Event for Interactive display of ALV report

form USER_COMMAND using r_ucomm like sy-ucomm

rs_selfield type slis_selfield .

if r_ucomm = '&IC1'.

READ TABLE IT_FINAL index rs_selfield-tabindex.

write:/ IT_FINAL-ebeln.

endif.

endform .

*Parameters of FM REUSE_ALV_GRID_DISPLAY

&----


*& Form grid_display

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form grid_display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = 'SET_PO_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IS_LAYOUT = I_LAYOUT

IT_FIELDCAT = FIELDCATALOG[]

IT_EVENTS = I_EVENT[]

TABLES

t_outtab = IT_FINAL.

endform. " grid_display

sreekanth reddy

Posts: 733

Questions: 0

Registered: 9/4/06

Forum points: 1,094

Solved problem (10)

Very helpful answer (6)

Helpful answer (2)

Re: Problem in ALV report

Posted: Jan 31, 2007 6:26 PM in response to: Dinesh Babu Reply E-mail this post

Hi Dinesh,

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_header[]

I_LOGO = 'ENJOYSAPLOGO'.

change it to

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_header[]

I_LOGO = 'ENJOYSAP_LOGO'.

Rusidar Subramani

Posts: 67

Questions: 1

Registered: 9/5/05

Forum points: 90

Unassign

Solved problem (10)

Very helpful answer (6)

Helpful answer (2)

Re: Problem in ALV report

Posted: Jan 31, 2007 7:35 PM in response to: Dinesh Babu Reply E-mail this post

&----


*& Report YSDBALV1

*&

&----


*&

*&

&----


REPORT YSDBALV1.

tables: ekko , ekpo .

type-pools: slis .

  • Table for Display Header

data:i_header type slis_t_listheader with header line.

*Fieldcat Declaration

data:fieldcatalog type slis_T_fieldcat_alv WITH HEADER LINE.

*Table of Events

data:i_event type slis_t_event with header line ,

wa_event type line of slis_t_event.

  • For Layout

data:i_layout type slis_layout_alv .

data: text(30) .

*Internal Table Declaration

data: begin of it_final occurs 0 ,

ebeln like ekko-ebeln , "Purchasing Document No.

bedat like ekko-bedat , "Purchasing Document Date

matnr like ekpo-matnr , "Material No.

netwr like ekpo-netwr , "Net Order Value in PO Currancy

meins like ekpo-meins , "UOM

chk(1) ,

light(1) ,

change like ekpo-menge ,

end of it_final .

**select option Declaration

selection-screen begin of block block.

select-options: s_ebeln for ekko-ebeln .

selection-screen end of block block .

selection-screen begin of block block1 .

parameters:grid radiobutton group r .

parameters:list radiobutton group r .

selection-screen end of block block1 .

    • at selection screen

at selection-screen .

select single * from ekko where ebeln in s_ebeln .

if sy-subrc <> 0 .

message e000(8I) WITH 'No Data Exists' .

endif .

start-of-selection .

if grid = 'X' .

perform get_data .

perform event using i_event[] .

perform field using fieldcatalog[] .

perform layout using i_layout .

perform grid_display .

endif .

&----


*& Form get_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_data .

*DATA Retrieval from tables

SELECT EKKO~EBELN

EKKO~BEDAT

EKPO~EBELP

EKPO~MATNR

EKPO~NETWR

EKPO~MEINS

EKPO~MENGE

EKPO~BPRME

INTO CORRESPONDING FIELDS OF table IT_FINAL

FROM EKKO INNER JOIN EKPO ON EKKOEBELN = EKPOEBELN

WHERE EKKO~EBELN IN S_EBELN.

APPEND IT_FINAL.

endform. " get_data

*Getting the Event for Top of Page display.

&----


*& Form event

&----


  • text

----


  • -->P_I_event[] text

----


form event using p_i_event type slis_t_event.

clear p_i_event .

refresh p_i_event .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

  • EXPORTING

  • I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = p_i_event.

  • EXCEPTIONS

  • LIST_TYPE_WRONG = 1

  • OTHERS = 2.

read table p_i_event with key name = slis_ev_top_of_page into wa_event.

if sy-subrc = 0.

move 'TOP_OF_PAGE_PO' to i_event-form.

modify p_i_event from i_event index sy-tabix transporting form.

endif.

clear i_event.

endform. " event

*Display Top-of –Page Details and Logo

form top_of_page_po .

clear i_header .

refresh i_header .

write sy-datum to text.

i_header-typ = 'H'.

i_header-info = 'PURCHASE OREDER DETAILS'.

append i_header.

*Logo Display

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = i_header[]

I_LOGO = 'ENJOYSAP_LOGO'.

endform .

*Field Catalog Append

&----


*& Form field

&----


  • text

----


  • -->P_fieldCATALOG[] text

----


form field using p_fieldcatalog type slis_t_fieldcat_alv.

  • clear fieldcatalog.

fieldcatalog-fieldname = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order No'.

fieldcatalog-col_pos = 1.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'BEDAT'.

fieldcatalog-seltext_m = 'PO Date'.

fieldcatalog-col_pos = 2.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material No'.

fieldcatalog-col_pos = 4.

fieldcatalog-outputlen = 20.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'NETWR'.

fieldcatalog-seltext_m = 'Net Value '.

fieldcatalog-col_pos = 5.

fieldcatalog-outputlen = 20.

fieldcatalog-do_sum = 'X'.

append fieldcatalog .

clear fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Units'.

fieldcatalog-col_pos = 6.

fieldcatalog-outputlen = 4.

append fieldcatalog .

clear fieldcatalog.

endform. " field

&----


*& Form layout

&----


  • text

form layout using p_i_layout TYPE SLIS_LAYOUT_ALV .

i_layout-zebra = 'X'.

i_layout-lights_fieldname = 'LIGHT'.

i_layout-lights_tabname = 'IT_FINAL'.

i_layout-box_fieldname = 'CHK'.

i_layout-box_tabname = 'IT_FINAL'.

i_layout-edit = ' '.

endform.

*To display Buttons in the MENU BAR if needed

FORM SET_PO_PF_STATUS USING P_I_EXTAB TYPE

SLIS_T_EXTAB.

SET PF-STATUS 'MENUPO'.

ENDFORM.

*Event for Interactive display of ALV report

form USER_COMMAND using r_ucomm like sy-ucomm

rs_selfield type slis_selfield .

if r_ucomm = '&IC1'.

READ TABLE IT_FINAL index rs_selfield-tabindex.

set parameter id 'VL1' field it_final-ebeln.

call transaction 'ME23N'.

endif.

endform .

*Parameters of FM REUSE_ALV_GRID_DISPLAY

&----


*& Form grid_display

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form grid_display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = SY-REPID

  • I_CALLBACK_PF_STATUS_SET = 'SET_PO_PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

IS_LAYOUT = I_LAYOUT

IT_FIELDCAT = FIELDCATALOG[]

IT_EVENTS = I_EVENT[]

TABLES

t_outtab = IT_FINAL.

endform. " grid_display

<b>

Reward all helpful answers</b>

Regards,

V.Raghavender.