You are on page 1of 13

REPORT Y_UNAPPROVED_POS_REPORT.

TYPE-POOLS : SLIS.

" SLIS is the type library for ALV grid

Tables: EKPO, EKKN, EKKO, t16fd, t16fc.


Types : BEGIN OF itab,
EBELN
PS_PSP_PNR
NPLNR
PROJN
TXZ01
WERKS
SAKTO
KOSTL
FIPOS
AUFNR
BEDAT
FRGGR
FRGSX
FRGC1
FRGC2
FRGC3
FRGC4
FRGC5
FRGC6
FRGC7
FRGC8

LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE
LIKE

EKPO-EBELN
, " PO No
EKKN-PS_PSP_PNR
, " WBSE
EKKN-NPLNR
, " Network Activity
EKKN-PROJN
, " Porject No
EKPO-TXZ01
, " Item Description
EKPO-WERKS
, " Plant Code
EKKN-SAKTO
, " GL Account
EKKN-KOSTL
, " Cost Center
EKKN-FIPOS
, " Commitment Item
EKKN-AUFNR
, " Maintenance Order
EKKO-BEDAT
, " PO DATE
T16FS-FRGGR
, " Release group
T16FS-FRGSX
, " Release strategy
T16FS-FRGC1
, " Release code 1
T16FS-FRGC2
, " Release code 2
T16FS-FRGC3
, " Release code 3
T16FS-FRGC4
, " Release code 4
T16FS-FRGC5
, " Release code 5
T16FS-FRGC6
, " Release code 6
T16FS-FRGC7
, " Release code 7
T16FS-FRGC8
, " Release code 8

FRGCO

LIKE

T16FC-FRGCO

REL_CODE
TYPE
REL_CODE_DESC
IPTIONS
AGE1
AGE2
AGE3
AGE4

LIKE
LIKE
LIKE
LIKE

, " Release Strategy Code

STRING
, " CONCATENATED Release code
TYPE
STRING
, " CONCATENATED Release code DESCR
VTBBEWE-ATAGE,
VTBBEWE-ATAGE,
VTBBEWE-ATAGE,
VTBBEWE-ATAGE,

END OF itab.
data: it_itab TYPE STANDARD TABLE of itab INITIAL SIZE 0 ,
wa_itab type itab.
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout
type slis_layout_alv,
gd_repid
like sy-repid,
gt_events
type slis_t_event,
gd_prntparams type slis_print_alv.
Selection-screen begin of block B3 with frame title text-001.
SELECT-OPTIONS:
EBELN
FOR EKPO-EBELN,

PS_PNR
NPLNR
PROJN
TXZ01
WERKS
SAKTO
KOSTL
FIPOS
AUFNR
BEDAT

FOR
FOR
FOR
FOR
FOR
FOR
FOR
FOR
FOR
FOR

EKKN-PS_PSP_PNR,
EKKN-NPLNR,
EKKN-PROJN,
EKPO-TXZ01,
EKPO-WERKS,
EKKN-SAKTO,
EKKN-KOSTL,
EKKN-FIPOS,
EKKN-AUFNR,
EKKO-BEDAT.

Selection-screen end of block B3.


Select: distinct
EKPO~EBELN
EKKN~PS_PSP_PNR
EKKN~NPLNR
EKKN~PROJN
EKPO~TXZ01
EKPO~WERKS
EKKN~SAKTO
EKKN~KOSTL
EKKN~FIPOS
EKKN~AUFNR
EKKO~BEDAT
T16FS~FRGGR
T16FS~FRGC1
T16FS~FRGC2
T16FS~FRGC3
T16FS~FRGC4
T16FS~FRGC5
T16FS~FRGC6
T16FS~FRGC7
T16FS~FRGC8
T16FC~FRGCO

"
"
"
"
"
"
"
"
"
"

Release
Release
Release
Release
Release
Release
Release
Release
Release
Release

code 1
code 1
code 2
code 3
code 4
code 5
code 6
code 7
code 8
Strategy Code

INTO CORRESPONDING FIELDS OF wa_itab


from EKPO
INNER join
INNER join
INNER join
INNER join

EKKN on EKPO~EBELN = EKKN~EBELN


EKKO on EKPO~EBELN = EKKO~EBELN
T16FS on EKKO~FRGGR = T16FS~FRGGR AND EKKO~FRGSX = T16FS~FRGSX
T16FC on EKKO~FRGGR = T16FC~FRGGR

**UP TO 500 ROWS


WHERE
EKPO~EBELN
EKKN~PS_PSP_PNR
EKKN~NPLNR
EKKN~PROJN
EKPO~TXZ01
EKPO~WERKS
EKKN~SAKTO
EKKN~KOSTL
EKKN~FIPOS
EKKN~AUFNR

IN
IN
IN
IN
IN
IN
IN
IN
IN
IN

EBELN AND
PS_PNR AND
NPLNR AND
PROJN AND
TXZ01 AND
WERKS AND
SAKTO AND
KOSTL AND
FIPOS AND
AUFNR AND

EKKO~BEDAT
IN BEDAT AND
EKKO~frgke Not IN ('Y','R') .
APPEND WA_ITAB TO IT_ITAB.
Endselect.
*&---------------------------------------------------------------------*
*&
Data fields to store number of days, months and years from specified dat
e to current date
*&---------------------------------------------------------------------*
DATA: EDAYS LIKE VTBBEWE-ATAGE,
EMONTHS LIKE VTBBEWE-ATAGE,
EYEARS LIKE VTBBEWE-ATAGE,
DESC_TEMP
type
String,
" Release code 8.
FRGC1_TEMP
LIKE
T16FS-FRGC1
, " Release code 1
FRGC2_TEMP
LIKE
T16FS-FRGC2
, " Release code 2
FRGC3_TEMP
LIKE
T16FS-FRGC3
, " Release code 3
FRGC4_TEMP
LIKE
T16FS-FRGC4
, " Release code 4
FRGC5_TEMP
LIKE
T16FS-FRGC5
, " Release code 5
FRGC6_TEMP
LIKE
T16FS-FRGC6
, " Release code 6
FRGC7_TEMP
LIKE
T16FS-FRGC7
, " Release code 7
FRGC8_TEMP
LIKE
T16FS-FRGC8.
" Release code 8.
data: FROMDATE LIKE VTBBEWE-DBERVON.
*&---------------------------------------------------------------------*
*&
Looping at internal table to process the Document Date in Document
*&
inorder to calculate total number of days, months and years from specifi
ed date to current date
*&---------------------------------------------------------------------*
LOOP AT IT_ITAB INTO WA_ITAB.

FROMDATE = wa_itab-BEDAT.
IF wa_itab-FRGC1 ne ''.
SELECT T16FD~FRGCT into DESC_TEMP from T16FD
where T16FD~FRGGR = wa_itab-FRGGR
and T16FD~FRGCO = wa_itab-FRGC1.
endselect.
CONCATENATE
CONCATENATE
CONCATENATE
CONCATENATE
SPACE .
endif.

wa_itab-REL_CODE wa_itab-FRGC1 ',' INTO wa_itab-REL_CODE.


wa_itab-REL_CODE '' INTO wa_itab-REL_CODE SEPARATED BY SPACE.
wa_itab-REL_CODE_DESC DESC_TEMP ' , ' INTO wa_itab-REL_CODE_DESC.
wa_itab-REL_CODE_DESC '' INTO wa_itab-REL_CODE_DESC SEPARATED BY

IF wa_itab-FRGC2 ne ''.
SELECT T16FD~FRGCT into DESC_TEMP from T16FD
where T16FD~FRGGR = wa_itab-FRGGR
and T16FD~FRGCO = wa_itab-FRGC2.
endselect.
CONCATENATE wa_itab-REL_CODE wa_itab-FRGC2 ', ' space INTO wa_itab-REL_CODE .
CONCATENATE wa_itab-REL_CODE '' INTO wa_itab-REL_CODE SEPARATED BY SPACE.
CONCATENATE wa_itab-REL_CODE_DESC DESC_TEMP ', ' space INTO wa_itab-REL_CODE_D
ESC .
CONCATENATE wa_itab-REL_CODE_DESC '' INTO wa_itab-REL_CODE_DESC SEPARATED BY

SPACE .
endif.
IF wa_itab-FRGC3 ne ''.
SELECT T16FD~FRGCT into DESC_TEMP from T16FD
where T16FD~FRGGR = wa_itab-FRGGR
and T16FD~FRGCO = wa_itab-FRGC3.
endselect.
CONCATENATE wa_itab-REL_CODE wa_itab-FRGC3 ', ' INTO wa_itab-REL_CODE .
CONCATENATE wa_itab-REL_CODE '' INTO wa_itab-REL_CODE SEPARATED BY SPACE.
CONCATENATE wa_itab-REL_CODE_DESC DESC_TEMP ', ' INTO wa_itab-REL_CODE_DESC .
CONCATENATE wa_itab-REL_CODE_DESC '' INTO wa_itab-REL_CODE_DESC SEPARATED BY
SPACE .
endif.
IF wa_itab-FRGC4 ne ''.
SELECT T16FD~FRGCT into DESC_TEMP from T16FD
where T16FD~FRGGR = wa_itab-FRGGR
and T16FD~FRGCO = wa_itab-FRGC4.
endselect.
CONCATENATE wa_itab-REL_CODE wa_itab-FRGC4 ', ' INTO wa_itab-REL_CODE .
CONCATENATE wa_itab-REL_CODE '' INTO wa_itab-REL_CODE SEPARATED BY SPACE.
CONCATENATE wa_itab-REL_CODE_DESC DESC_TEMP ', ' INTO wa_itab-REL_CODE_DESC .
CONCATENATE wa_itab-REL_CODE_DESC '' INTO wa_itab-REL_CODE_DESC SEPARATED BY
SPACE .
endif.
IF wa_itab-FRGC5 ne ''.
SELECT T16FD~FRGCT into DESC_TEMP from T16FD
where T16FD~FRGGR = wa_itab-FRGGR
and T16FD~FRGCO = wa_itab-FRGC5.
endselect.
CONCATENATE wa_itab-REL_CODE wa_itab-FRGC5 ', ' INTO wa_itab-REL_CODE .
CONCATENATE wa_itab-REL_CODE '' INTO wa_itab-REL_CODE SEPARATED BY SPACE.
CONCATENATE wa_itab-REL_CODE_DESC DESC_TEMP ', ' INTO wa_itab-REL_CODE_DESC .
CONCATENATE wa_itab-REL_CODE_DESC '' INTO wa_itab-REL_CODE_DESC SEPARATED BY
SPACE .
endif.
IF wa_itab-FRGC6 ne ''.
SELECT T16FD~FRGCT into DESC_TEMP from T16FD
where T16FD~FRGGR = wa_itab-FRGGR
and T16FD~FRGCO = wa_itab-FRGC6.
endselect.
CONCATENATE wa_itab-REL_CODE wa_itab-FRGC6 ', ' INTO wa_itab-REL_CODE .
CONCATENATE wa_itab-REL_CODE '' INTO wa_itab-REL_CODE SEPARATED BY SPACE.
CONCATENATE wa_itab-REL_CODE_DESC DESC_TEMP ', ' INTO wa_itab-REL_CODE_DESC .
CONCATENATE wa_itab-REL_CODE_DESC '' INTO wa_itab-REL_CODE_DESC SEPARATED BY
SPACE .
endif.
IF wa_itab-FRGC7 ne ''.
SELECT T16FD~FRGCT into DESC_TEMP from T16FD
where T16FD~FRGGR = wa_itab-FRGGR
and T16FD~FRGCO = wa_itab-FRGC7.
endselect.
CONCATENATE wa_itab-REL_CODE wa_itab-FRGC7 ', ' INTO wa_itab-REL_CODE .
CONCATENATE wa_itab-REL_CODE '' INTO wa_itab-REL_CODE SEPARATED BY SPACE.
CONCATENATE wa_itab-REL_CODE_DESC DESC_TEMP ', ' INTO wa_itab-REL_CODE_DESC .
CONCATENATE wa_itab-REL_CODE_DESC '' INTO wa_itab-REL_CODE_DESC SEPARATED BY
SPACE .
endif.
IF wa_itab-FRGC8 ne ''.
SELECT T16FD~FRGCT into DESC_TEMP from T16FD

where T16FD~FRGGR = wa_itab-FRGGR


and T16FD~FRGCO = wa_itab-FRGC8.
endselect.
CONCATENATE wa_itab-REL_CODE wa_itab-FRGC8 ', ' INTO wa_itab-REL_CODE .
CONCATENATE wa_itab-REL_CODE '' INTO wa_itab-REL_CODE SEPARATED BY SPACE.
CONCATENATE wa_itab-REL_CODE_DESC DESC_TEMP ', ' INTO wa_itab-REL_CODE_DESC .
CONCATENATE wa_itab-REL_CODE_DESC '' INTO wa_itab-REL_CODE_DESC SEPARATED BY
SPACE .
endif.
call function 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
exporting
i_date_from
= FROMDATE
i_date_to
= sy-datum
IMPORTING
E_DAYS
= EDAYS
E_MONTHS
= EMONTHS
E_YEARS
= EYEARS.
if EDAYS < 31.
wa_itab-age1 = EDAYS.
ELSEIF EDAYS < 61.
wa_itab-age2 = EDAYS.
ELSEIF EDAYS < 91.
wa_itab-age3 = EDAYS.
ELSE.
wa_itab-age4 = EDAYS.
endif.
MODIFY it_itab INDEX sy-tabix FROM wa_itab.
ENDLOOP.
**perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
*perform build_print_params.
perform display_alv_report.

*&---------------------------------------------------------------------*
*&
Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*
Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.
*
*
*
*
*

There are a number of ways to create a fieldcat.


For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.

* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were

* simply displaying the result


*
I.e. Field type may be required in-order for
*
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'PO No'.
fieldcatalog-col_pos
= 0.
fieldcatalog-outputlen = 10.
fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght

fieldcatalog-fieldname = 'PS_PSP_PNR'.
" field Name
fieldcatalog-seltext_m = 'WBSE'.
" Field heading
fieldcatalog-col_pos
= 0.
" col position
fieldcatalog-outputlen = 10.
" output Lenght
fieldcatalog-emphasize = 'X'.
" Emphasize (highlight columns
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NPLNR'.
fieldcatalog-seltext_m = 'Network Activity'.
fieldcatalog-col_pos
= 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PROJN'.
fieldcatalog-seltext_m = 'Project No'.
fieldcatalog-col_pos
= 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

fieldcatalog-fieldname = 'TXZ01'.
fieldcatalog-seltext_m = 'Item Description'.
fieldcatalog-col_pos
= 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname
fieldcatalog-seltext_m
fieldcatalog-col_pos
fieldcatalog-outputlen
fieldcatalog-emphasize

=
=
=
=
=

'WERKS'.
'Plant Code'.
0.
10.
'X'.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'SAKTO'.
fieldcatalog-seltext_m = 'GL Account'.
fieldcatalog-col_pos
= 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

fieldcatalog-fieldname = 'KOSTL'.
fieldcatalog-seltext_m = 'Cost Center'.
fieldcatalog-col_pos
= 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

fieldcatalog-fieldname = 'FIPOS'.
fieldcatalog-seltext_m = 'Commitment Item'.
fieldcatalog-col_pos
= 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

"
"
"
"
"

field Name
Field heading
col position
output Lenght
Emphasize (highlight columns

fieldcatalog-fieldname = 'AUFNR'.
" field Name
fieldcatalog-seltext_m = 'Maintenance Order'.
" Field heading
fieldcatalog-col_pos
= 0.
" col position
fieldcatalog-outputlen = 10.
" output Lenght
fieldcatalog-emphasize = 'X'.
" Emphasize (highlight columns
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'BEDAT'.
" field Name
fieldcatalog-seltext_m = 'Document Creation Date'.
" Field heading
fieldcatalog-col_pos
= 0.
" col position
fieldcatalog-outputlen = 10.
" output Lenght
fieldcatalog-emphasize = 'X'.
" Emphasize (highlight columns
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.

"fieldcatalog-fieldname = 'FRGC1'.
"fieldcatalog-seltext_m = 'RC 1'.
"fieldcatalog-col_pos
= 0.
"fieldcatalog-outputlen = 10.
"fieldcatalog-emphasize = 'X'.
in color)
"*fieldcatalog-key
= 'X'.
"append fieldcatalog to fieldcatalog.
"clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

"fieldcatalog-fieldname = 'FRGC2'.
"fieldcatalog-seltext_m = 'RC 2'.
"fieldcatalog-col_pos
= 0.
"fieldcatalog-outputlen = 10.
"fieldcatalog-emphasize = 'X'.
in color)
"*fieldcatalog-key
= 'X'.
"append fieldcatalog to fieldcatalog.
"clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

"fieldcatalog-fieldname = 'FRGC3'.
"fieldcatalog-seltext_m = 'RC 3'.
"fieldcatalog-col_pos
= 0.
"fieldcatalog-outputlen = 10.
"fieldcatalog-emphasize = 'X'.
in color)
"*fieldcatalog-key
= 'X'.
"append fieldcatalog to fieldcatalog.
"clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

"fieldcatalog-fieldname = 'FRGC4'.
"fieldcatalog-seltext_m = 'RC 4'.
"fieldcatalog-col_pos
= 0.
"fieldcatalog-outputlen = 10.
"fieldcatalog-emphasize = 'X'.
in color)
"*fieldcatalog-key
= 'X'.
"append fieldcatalog to fieldcatalog.
"clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

"fieldcatalog-fieldname = 'FRGC5'.
"fieldcatalog-seltext_m = 'RC 5'.
"fieldcatalog-col_pos
= 0.
"fieldcatalog-outputlen = 10.
"fieldcatalog-emphasize = 'X'.
in color)
"*fieldcatalog-key
= 'X'.
"append fieldcatalog to fieldcatalog.
"clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

"fieldcatalog-fieldname

= 'FRGC6'.

" field Name

"fieldcatalog-seltext_m = 'RC 6'.


"fieldcatalog-col_pos
= 0.
"fieldcatalog-outputlen = 10.
"fieldcatalog-emphasize = 'X'.
in color)
"*fieldcatalog-key
= 'X'.
"append fieldcatalog to fieldcatalog.
"clear fieldcatalog.

" Field heading


" col position
" output Lenght
" Emphasize (highlight columns

"fieldcatalog-fieldname = 'FRGC7'.
"fieldcatalog-seltext_m = 'RC 7'.
"fieldcatalog-col_pos
= 0.
"fieldcatalog-outputlen = 10.
"fieldcatalog-emphasize = 'X'.
in color)
"*fieldcatalog-key
= 'X'.
"append fieldcatalog to fieldcatalog.
"clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

"fieldcatalog-fieldname = 'FRGC8'.
"fieldcatalog-seltext_m = 'RC 8'.
"fieldcatalog-col_pos
= 0.
"fieldcatalog-outputlen = 10.
"fieldcatalog-emphasize = 'X'.
in color)
"*fieldcatalog-key
= 'X'.
"append fieldcatalog to fieldcatalog.
"clear fieldcatalog.

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

"fieldcatalog-fieldname = 'FRGCO'.
" field Name
"fieldcatalog-seltext_m = 'Release Strategy Code'.
" Field heading
"fieldcatalog-col_pos
= 0.
" col position
"fieldcatalog-outputlen = 10.
" output Lenght
"fieldcatalog-emphasize = 'X'.
" Emphasize (highlight columns
in color)
"*fieldcatalog-key
= 'X'.
"append fieldcatalog to fieldcatalog.
"clear fieldcatalog.

fieldcatalog-fieldname = 'REL_CODE'.
fieldcatalog-seltext_m = 'Release Code'.
fieldcatalog-col_pos
= 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname
fieldcatalog-seltext_m
fieldcatalog-col_pos
fieldcatalog-outputlen
fieldcatalog-emphasize
in color)

=
=
=
=
=

" field Name


" Field heading
" col position
" output Lenght
" Emphasize (highlight columns

'REL_CODE_DESC'.
" field Name
'Release Code Description'.
" Field heading
0.
" col position
10.
" output Lenght
'X'.
" Emphasize (highlight columns

*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AGE1'.
" field Name
fieldcatalog-seltext_m = 'Pending since 0-30 Days'.
" Field heading
fieldcatalog-col_pos
= 0.
" col position
fieldcatalog-outputlen = 10.
" output Lenght
fieldcatalog-emphasize = 'X'.
" Emphasize (highlight columns
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AGE2'.
" field Name
fieldcatalog-seltext_m = 'Pending since 31-60 Days'.
" Field heading
fieldcatalog-col_pos
= 0.
" col position
fieldcatalog-outputlen = 10.
" output Lenght
fieldcatalog-emphasize = 'X'.
" Emphasize (highlight columns
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AGE3'.
" field Name
fieldcatalog-seltext_m = 'Pending since 61-90 Days'.
" Field heading
fieldcatalog-col_pos
= 0.
" col position
fieldcatalog-outputlen = 10.
" output Lenght
fieldcatalog-emphasize = 'X'.
" Emphasize (highlight columns
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AGE4'.
" field Name
fieldcatalog-seltext_m = 'Pending since More than 90 Days'.
" Field heading
fieldcatalog-col_pos
= 0.
" col position
fieldcatalog-outputlen = 10.
" output Lenght
fieldcatalog-emphasize = 'X'.
" Emphasize (highlight columns
in color)
*fieldcatalog-key
= 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform.

" BUILD_FIELDCATALOG

*&---------------------------------------------------------------------*
*&
Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
*
Build layout for ALV grid report
*----------------------------------------------------------------------*
form build_layout.
gd_layout-no_input
= 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text
= 'Totals'(201).
* gd_layout-totals_only
= 'X'.
* gd_layout-f2code
= 'DISP'. "Sets fcode for when double
*
"click(press f2)

* gd_layout-zebra
= 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text
= 'helllllo'.
endform.
" BUILD_LAYOUT
*&---------------------------------------------------------------------*
*&
Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*
Display report using ALV grid
*----------------------------------------------------------------------*
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program
= gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
*
i_callback_user_command = 'USER_COMMAND'
*
i_grid_title
= outtext
is_layout
= gd_layout
it_fieldcat
= fieldcatalog[]
*
it_special_groups
= gd_tabgroup
it_events
= gt_events
is_print
= gd_prntparams
i_save
= 'X'
*
is_variant
= z_template
tables
t_outtab
= it_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.
endform.
" DISPLAY_ALV_REPORT
*-------------------------------------------------------------------*
* Form TOP-OF-PAGE
*
*-------------------------------------------------------------------*
* ALV Report Header
*
*-------------------------------------------------------------------*
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'Review of Unapproved POs Report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'

sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info.
append wa_header to t_header.
clear: wa_header.

"todays date

* Total No. of Records Selected


describe table it_itab lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = t_header.
*
i_logo
= 'Z_LOGO'.
endform.
*------------------------------------------------------------------*
*
FORM USER_COMMAND
*
*------------------------------------------------------------------*
*
--> R_UCOMM
*
*
--> RS_SELFIELD
*
*------------------------------------------------------------------*
*FORM user_command USING r_ucomm LIKE sy-ucomm
*
rs_selfield TYPE slis_selfield.
*
** Check function code
* CASE r_ucomm.
*
WHEN '&IC1'.
** Check field clicked on within ALVgrid report
*
IF rs_selfield-fieldname = 'EBELN'.
**
Read data table, using index of row user clicked on
*
READ TABLE itab INTO wa_EKPO INDEX rs_selfield-tabindex.
**
Set parameter ID for transaction screen field
*
SET PARAMETER ID 'BES' FIELD wa_EKPO-EBELN.
**
Sxecute transaction ME23N, and skip initial data entry screen
*
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
*
ENDIF.
* ENDCASE.
*ENDFORM.
*&---------------------------------------------------------------------*
*&
Form BUILD_EVENTS
*&---------------------------------------------------------------------*
*
Build events table
*----------------------------------------------------------------------*
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0

importing
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform.
" BUILD_EVENTS
*&---------------------------------------------------------------------*
*&
Form BUILD_PRINT_PARAMS
*&---------------------------------------------------------------------*
*
Setup print parameters
*----------------------------------------------------------------------*
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform.
" BUILD_PRINT_PARAMS
*&---------------------------------------------------------------------*
*&
Form END_OF_PAGE
*&---------------------------------------------------------------------*
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10)
type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform.
*&---------------------------------------------------------------------*
*&
Form END_OF_LIST
*&---------------------------------------------------------------------*
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10)
type c.
skip.
write:/40 'Page:', sy-pagno .
endform.

You might also like