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

ALV

Former Member
0 Likes
810

Hi all,

can anybody give all the FMs in ALV and their short description?

what is the use of BLOCKED LIST... where we can use it ?

and where we can use this HIRARCIAL LIST?

thanks & regards

kanny

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
784

Hi,

The commonly used ALV functions used for this purpose are;

1. REUSE_ALV_VARIANT_DEFAULT_GET

2. REUSE_ALV_VARIANT_F4

3. REUSE_ALV_VARIANT_EXISTENCE

4. REUSE_ALV_EVENTS_GET

5. REUSE_ALV_COMMENTARY_WRITE

6. REUSE_ALV_FIELDCATALOG_MERGE

7. REUSE_ALV_LIST_DISPLAY

8. REUSE_ALV_GRID_DISPLAY

9. REUSE_ALV_POPUP_TO_SELECT

Look at the Demo Progrmas

BCALV_TREE_DEMO Demo for ALV tree control

BCALV_TREE_SIMPLE_DEMO

BC_ALV_DEMO_HTML_D0100

Regards

Sudheer

Hi,

The commonly used ALV functions used for this purpose are;

1. REUSE_ALV_VARIANT_DEFAULT_GET

2. REUSE_ALV_VARIANT_F4

3. REUSE_ALV_VARIANT_EXISTENCE

4. REUSE_ALV_EVENTS_GET

5. REUSE_ALV_COMMENTARY_WRITE

6. REUSE_ALV_FIELDCATALOG_MERGE

7. REUSE_ALV_LIST_DISPLAY

8. REUSE_ALV_GRID_DISPLAY

9. REUSE_ALV_POPUP_TO_SELECT

Look at the Demo Progrmas

BCALV_TREE_DEMO Demo for ALV tree control

BCALV_TREE_SIMPLE_DEMO

BC_ALV_DEMO_HTML_D0100

Regards

Sudheer

5 REPLIES 5
Read only

Former Member
0 Likes
784

Go to transaction SE37 and type REUSEALV and press F4. You wil get all the FMs used in ALV reporting.

Read only

Former Member
0 Likes
784

<b>ALV - ABAP List Viewer</b>

The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).

This helps us to implement all the features mentioned very effectively.

Using ALV, We can have three types of reports:

1. Simple Report

2. Block Report

3. Hierarchical Sequential Report

There are some function modules which will enable to produce the above reports without much effort.

All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.

<b>1. SIMPLE REPORT.</b>

The important function modules are

a. Reuse_alv_list_display

b. Reuse_alv_fieldcatalog_merge

c. Reuse_alv_events_get

d. Reuse_alv_commentary_write

e. Reuse_alv_grid_display

A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.

The important parameters are :

I. Export :

i. I_callback_program : report id

ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status

iii. I_callback_user_command : routine where the function codes are handled

iv. I_structure name : name of the dictionary table

v. Is_layout : structure to set the layout of the report

vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE

vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.

II. Tables :

i. t_outtab : internal table with the data to be output

B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.

The Important Parameters are :

I. Export :

i. I_program_name : report id

ii. I_internal_tabname : the internal output table

iii. I_inclname : include or the report name where all the dynamic forms are handled.

II Changing

ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is

declared in the type pool SLIS.

C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type

Parameters :

I. Import :

Et_Events : The event table is returned with all possible CALLBACK events

for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.

II. Export :

I_List_type :

0 = simple list REUSE_ALV_LIST_DISPLAY

1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY

2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND

3 = hierarchical-sequential block list

REUSE_ALV_BLOCK_LIST_HS_APPEND

D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.

Parameters :

I. it_list_commentary : internal table with the headings of the type slis_t_listheader.

This internal table has three fields :

Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action

Key : only when typ is ‘S’.

Info : the text to be printed

E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.

Parameters : same as reuse_alv_list_display

This is an example for simple list.

<b>2. BLOCK REPORT</b>

This is used to have multiple lists continuously.

The important functions used in this report are:

A. REUSE_ALV_BLOCK_LIST_INIT

B. REUSE_ALV_BLOCK_LIST_APPEND

C. REUSE_ALV_BLOCK_LIST_HS_APPEND

D. REUSE_ALV_BLOCK_LIST_DISPLAY

A. REUSE_ALV_BLOCK_LIST_INIT

Parameters:

I. I_CALLBACK_PROGRAM

II. I_CALLBACK_PF_STATUS_SET

III. I_CALLBACK_USER_COMMAND

This function module is used to set the default gui status etc.

B. REUSE_ALV_BLOCK_LIST_APPEND

Parameters :

Export :

I. is_layout : layout settings for block

II. it_fieldcat : field catalog

III. i_tabname : internal table name with output data

IV. it_events : internal table with all possible events

Tables :

i. t_outtab : internal table with output data.

This function module adds the data to the block.

Repeat this function for all the different blocks to be displayed one after the other.

C. REUSE_ALV_BLOCK_LIST_HS_APPEND

This function module is used for hierarchical sequential blocks.

D. REUSE_ALV_BLOCK_LIST_DISPLAY

Parameters : All the parameters are optional.

This function module display the list with data appended by the above function.

Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.

<b>3. Hierarchical reports :</b>

Hierarchical sequential list output.

The function module is

A. REUSE_ALV_HIERSEQ_LIST_DISPLAY

Parameters:

I. Export:

i. I_CALLBACK_PROGRAM

ii. I_CALLBACK_PF_STATUS_SET

iii. I_CALLBACK_USER_COMMAND

iv. IS_LAYOUT

v. IT_FIELDCAT

vi. IT_EVENTS

vii. i_tabname_header : Name of the internal table in the program containing the

output data of the highest hierarchy level.

viii. i_tabname_item : Name of the internal table in the program containing the

output data of the lowest hierarchy level.

ix. is_keyinfo : This structure contains the header and item table field

names which link the two tables (shared key).

II. Tables

i. t_outtab_header : Header table with data to be output

ii. t_outtab_item : Name of the internal table in the program containing the

output data of the lowest hierarchy level.

slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.

Important Attributes :

A. col_pos : position of the column

B. fieldname : internal fieldname

C. tabname : internal table name

D. ref_fieldname : fieldname (dictionary)

E. ref_tabname : table (dictionary)

F. key(1) : column with key-color

G. icon(1) : icon

H. symbol(1) : symbol

I. checkbox(1) : checkbox

J. just(1) : (R)ight (L)eft (C)ent.

K. do_sum(1) : sum up

L. no_out(1) : (O)blig.(X)no out

M. outputlen : output length

N. seltext_l : long key word

O. seltext_m : middle key word

P. seltext_s : short key word

Q. reptext_ddic : heading (ddic)

R. ddictxt(1) : (S)hort (M)iddle (L)ong

S. datatype : datatype

T. hotspot(1) : hotspot

See the sample report

report ZRGRIRNA no standard page heading

line-count 65

line-size 255

message-id mm.

----


  • GR IR Detail Report *

----


  • Description : The output has to be displayed

  • in the ALV Grid format with the Selection *

  • screen appearing on the output. In The Output *

  • Subtotals for Vendor, Plant, Period, Material,*

  • Valuation Class, Purchase Order,Cost Center, *

  • Cost Element and Receipt Date are displayed *

  • after sorting the data by same fields. *

----


  • Declaration for Tables

----


tables: t001, " Company Codes

t001w, " Plants/Branches

lfa1, " Vendor Master

ska1, " GL Account Master

mara, " Material Master

mbew, " Material Valuation

ekko, " PO Header Data

cska, " Cost Elements

csks, " Cost Centers

bsis, " GL Accounts: Open Items Data

bkpf. " Accounting Doc: Header Data

----


  • Type-pools

----


  • Type pools for ALV display

type-pools : slis.

----


  • Global variables

----


data: g_repid like sy-repid,

g_exit type c,

g_events type slis_t_event,

g_list_top_of_page type slis_t_listheader,

g_exit_caused_by_caller,

g_exit_caused_by_user type slis_exit_by_user,

g_top_of_page type slis_formname value 'TOP_OF_PAGE',

g_variant like disvariant,

g_save.

----


  • Declaration for Constants

----


constants : c_x type c value 'X', " Flag

c_c type c value 'C', " Flag

c_l type c value 'L', " Flag

c_a type c value 'A', " Line Type

c_h type c value 'H', " Dr/Cr

c_s type c value 'S', " Line Type

c_mkpf(4) type c value 'MKPF'. " Table

----


  • Declaration of Internal Tables

----


  • Internal Table for BSIS Table data

data: begin of i_bsis occurs 0,

bukrs like bsis-bukrs, " Company Code

hkont like bsis-hkont, " GR IR Account

gjahr like bsis-gjahr, " Fiscal Year

belnr like bsis-belnr, " Acc Document

buzei like bsis-buzei, " Item No

budat like bsis-budat, " Receipt Date(Posting)

monat like bsis-monat, " Period

end of i_bsis.

  • Internal Table for BSEG Table data

data: begin of i_bseg occurs 0,

bukrs like bsis-bukrs, " Company Code

belnr like bsis-belnr, " Acc Document

buzei like bsis-buzei, " Item No

gjahr like bsis-gjahr, " Fiscal Year

shkzg like bseg-shkzg, " Dr/Cr Indicator

lifnr like bseg-lifnr, " Vendor Code

matnr like bseg-matnr, " Material No

ebeln like bseg-ebeln, " Purchase Order

ebelp like bseg-ebelp, " PO Item

werks like bseg-werks, " Plant

menge like bseg-menge, " PO Quantity

meins like bseg-meins, " UOM

dmbtr like bseg-dmbtr, " Amount in Local Currency

wrbtr like bseg-wrbtr, " Amount in Trans.Currency

end of i_bseg.

  • Internal Table for BKPF Table data

data: begin of i_bkpf occurs 0,

bukrs like bkpf-bukrs, " Company Code

belnr like bkpf-belnr, " Acc Document

gjahr like bkpf-gjahr, " Fiscal Year

waers like bkpf-waers, " Trans. Currency

awkey like bkpf-awkey, " Object Key

awtyp like bkpf-awtyp, " Reference Procedure

end of i_bkpf.

  • Internal Table for MSEG Table data

data: begin of i_mseg occurs 0,

mblnr like mseg-mblnr, " Material Document

mjahr like mseg-mjahr, " Fiscal Year

bwart like mseg-bwart, " Movement Type

matnr like mseg-matnr, " Material No

menge like mseg-menge, " PO Quantity

meins like mseg-meins, " UOM

end of i_mseg.

  • Internal Table for MBEW Table data

data: begin of i_mbew occurs 0,

matnr like mbew-matnr, " Material No

werks like mbew-bwkey, " Plant

bklas like mbew-bklas, " Valuation Class

end of i_mbew.

  • Internal Table for EKPO Table data

data: begin of i_ekpo occurs 0,

ebeln like ekpo-ebeln, " Purchase Order

ebelp like ekpo-ebelp, " PO Item

matnr like ekpo-matnr, " Material No

txz01 like ekpo-txz01, " Material Text

end of i_ekpo.

  • Internal Table for EKKN Table data

data: begin of i_ekkn occurs 0,

ebeln like ekkn-ebeln, " Purchase Order

ebelp like ekkn-ebelp, " PO Item

kostl like ekkn-kostl, " Cost Center

sakto like ekkn-sakto, " Cost Element

end of i_ekkn.

  • Internal Table for LFA1 Table data

data: begin of i_lfa1 occurs 0,

lifnr like lfa1-lifnr, " Vendor

name1 like lfa1-name1, " Name

end of i_lfa1.

  • Declaration of Output Internal Table

data: begin of i_final occurs 0,

lifnr like lfa1-lifnr, " Vendor

werks like bseg-werks, " Plant

monat like bsis-monat, " Period

matnr like mara-matnr, " Material Number

bklas like mbew-bklas, " Val Class

ebeln like bseg-ebeln, " PO

kostl like ekkn-kostl, " Cost Center

sakto like ekkn-sakto, " Cost Element

budat like bsis-budat, " Rec. Date

name1 like lfa1-name1, " Vendor Name

belnr like bsis-belnr, " FI Document

bwart like mseg-bwart, " Movement Type

txz01 like ekpo-txz01, " Material Text

menge like bseg-menge, " Quantity

meins like bseg-meins, " UOM

dmbtr like bseg-dmbtr, " Local Amount

wrbtr like bseg-wrbtr, " Tran.Amount

waers like bkpf-waers, " Tran.Currency

status type c, " Material Status

end of i_final.

  • Internal table to hold field catgory data

data: i_fldcat type slis_t_fieldcat_alv. " Table - field catgory

  • Internal table to hold Sort/Subtotals criteria data

data: i_sort type slis_t_sortinfo_alv. " Table - sort/Subtotals

----


  • Structure

----


data: x_layout type slis_layout_alv, " Structure-layout

x_fldcat like line of i_fldcat, " Structure-field catagory

x_sort like line of i_sort. " Structure-Sort/Subtotals

----


  • Selection screen

----


selection-screen : begin of block b1 with frame title text-000.

parameters:

p_bukrs like t001-bukrs obligatory, " Company Code

p_grira like ska1-saknr default '0241101000' obligatory. " Account

select-options:

s_budat for bkpf-budat, " Posting Date

s_werks for t001w-werks, " Plant

s_lifnr for lfa1-lifnr, " Vendor

s_matnr for mara-matnr, " Material Number

s_kostl for csks-kostl, " Cost Center

s_kstar for cska-kstar, " Cost Element

s_ebeln for ekko-ebeln, " Purchase Order

s_monat for bsis-monat. " Period

selection-screen skip.

parameters:

p_incmt as checkbox default 'X',

p_incnm as checkbox default 'X'.

selection-screen end of block b1.

----


  • Initialization

----


initialization.

g_repid = sy-repid.

perform layout_init using x_layout.

perform eventtab_build using g_events[].

g_variant-report = g_repid.

g_save = 'A'.

----


  • At selection screen

----


at selection-screen.

  • Validation of Selection Screen Fields

perform validate_screen.

----


  • Start of selection

----


start-of-selection.

  • Read Data from Database Tables

perform read_data.

----


  • End of selection

----


end-of-selection.

  • Build layout report layout.

perform populate_layout_stucture.

  • Perform build_field_catalog and Sort Table

perform build_field_catalog.

perform build_sort_totals.

  • List Header for Top-Of-Page

perform comment_build using g_list_top_of_page[].

  • Call list viewer function module

perform call_list_viewer .

****************Form - Routines**************************************

----


  • Form : layout_init

  • Description : Form to Build layout for list display

----


form layout_init using rs_layout type slis_layout_alv.

rs_layout-detail_popup = c_x.

endform.

----


  • Form : Eventtab_build

  • Description : Registration of events to happen during list display

----


form eventtab_build using rt_events type slis_t_event.

  • Registration of events to happen during list display

data: ls_event type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = rt_events.

read table rt_events with key name = slis_ev_top_of_page

into ls_event.

if sy-subrc = 0.

move g_top_of_page to ls_event-form.

append ls_event to rt_events.

endif.

endform. "eventtab_build

----


  • Form : top_of_page

----


*

form top_of_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

  • I_LOGO = 'ENJOYSAP_LOGO'

it_list_commentary = g_list_top_of_page.

endform.

----


  • Form validate_screen

----


  • Validation of Selection Screen fields

----


form validate_screen.

  • Validation of Company Code

clear t001.

if not p_bukrs is initial.

select single bukrs

into t001-bukrs

from t001

where bukrs eq p_bukrs.

if sy-subrc <> 0.

message e899 with 'Enter Valid Company Code'(012).

endif.

endif.

  • Validation of GL Account (GR/IR)

clear ska1.

if not p_grira is initial.

select saknr

into ska1-saknr

from ska1

up to 1 rows

where saknr eq p_grira.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid GR/IR Account'(013).

endif.

endif.

  • Validation of Vendor Code

clear lfa1.

if not s_lifnr[] is initial.

select single lifnr

into lfa1-lifnr

from lfa1

where lifnr in s_lifnr.

if sy-subrc <> 0.

message e899 with 'Enter Valid Vendor'(001).

endif.

endif.

  • Validation of Plant Code

clear t001w.

if not s_werks[] is initial.

select single werks

into t001w-werks

from t001w

where werks in s_werks.

if sy-subrc <> 0.

message e899 with 'Enter Valid Plant'(014).

endif.

endif.

  • Validation of Material Code

clear mara.

if not s_matnr[] is initial.

select single matnr

into mara-matnr

from mara

where matnr in s_matnr.

if sy-subrc <> 0.

message e899 with 'Enter Valid Material'(015).

endif.

endif.

  • Validation of Purchase Order

clear ekko.

if not s_ebeln[] is initial.

select single ebeln

into ekko-ebeln

from ekko

where ebeln in s_ebeln.

if sy-subrc <> 0.

message e899 with 'Enter Valid Purchase Order'(016).

endif.

endif.

  • Validation of Cost Center

clear csks.

if not s_kostl[] is initial.

select kostl

into csks-kostl

from csks

up to 1 rows

where kostl in s_kostl.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid Cost Center'(017).

endif.

endif.

  • Validation of Cost Element

clear cska.

if not s_kstar[] is initial.

select kstar

into cska-kstar

from cska

up to 1 rows

where kstar in s_kstar.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid Cost Element'(018).

endif.

endif.

endform. "validate_screen

&----


*& Form read_data

&----


  • Read the Data from the database Tables

----


form read_data.

  • Get the Accounting Documents for the GR/IR Account Entered on

  • Selection Screen

clear i_bsis.

refresh i_bsis.

select bukrs " Company Code

hkont " GR IR Account

gjahr " Fiscal Year

belnr " Acc Document

buzei " Item No

budat " Receipt Date(Posting)

monat " Period

into table i_bsis

from bsis

where bukrs = p_bukrs

and hkont = p_grira

and budat in s_budat

and monat in s_monat .

if sy-subrc <> 0.

message i899 with 'No data found'(043).

g_exit = c_x.

stop.

endif.

sort i_bsis by bukrs hkont gjahr belnr buzei.

  • Get the Vendor,PO,Material,Qty details from BSEG Table

if not i_bsis[] is initial.

clear i_bseg.

refresh i_bseg.

select bukrs " Company Code

belnr " Acc Document

buzei " Item No

gjahr " Fiscal Year

shkzg " Dr/Cr Indicator

lifnr " Vendor Code

matnr " Material No

ebeln " Purchase Order

ebelp " PO Item

werks " Plant

menge " PO Quantity

meins " UOM

dmbtr " Amount in Local Currency

wrbtr " Amount in Trans.Currency

into table i_bseg

from bseg

for all entries in i_bsis

where bukrs = p_bukrs

and belnr = i_bsis-belnr

and gjahr = i_bsis-gjahr

and buzei = i_bsis-buzei

and lifnr in s_lifnr

and werks in s_werks

and matnr in s_matnr

and ebeln in s_ebeln.

sort i_bseg by bukrs belnr buzei gjahr.

  • Select the Trans.Currency from BKPF Table

clear i_bkpf.

refresh i_bkpf.

select bukrs " Company Code

belnr " Acc Document

gjahr " Fiscal Year

waers " Trans. Currency

awkey " Object Key

awtyp " Reference Procedure

into table i_bkpf

from bkpf

for all entries in i_bsis

where bukrs = p_bukrs

and belnr = i_bsis-belnr

and gjahr = i_bsis-gjahr.

endif.

sort i_bkpf by bukrs belnr gjahr.

  • Get the Quantity and UOM of Material from MSEG Table

if not i_bkpf[] is initial.

clear i_mseg.

refresh i_mseg.

select mblnr " Material Document

mjahr " Fiscal Year

bwart " Movement Type

matnr " Material No

menge " PO Quantity

meins " UOM

into table i_mseg

from mseg

for all entries in i_bkpf

where mblnr = i_bkpf-awkey(10).

endif.

sort i_mseg by mblnr mjahr.

  • Get the Material And Description from EKPO Table

if not i_bseg[] is initial.

clear i_ekpo.

refresh i_ekpo.

select ebeln " Purchase Order

ebelp " PO Item

matnr " Material No

txz01 " Material Text

into table i_ekpo

from ekpo

for all entries in i_bseg

where ebeln = i_bseg-ebeln

and ebelp = i_bseg-ebelp.

sort i_ekpo by ebeln ebelp.

  • Get the Valuation Class from MBEW Table

clear i_mbew.

refresh i_mbew.

select matnr " Material No

bwkey " Plant

bklas " Valuation Class

into table i_mbew

from mbew

for all entries in i_bseg

where matnr = i_bseg-matnr

and bwkey = i_bseg-werks.

sort i_mbew by matnr werks.

  • Get the Cost Center and Cost Element of the PO from EKKN Table

clear i_ekkn.

refresh i_ekkn.

select ebeln " Purchase Order

ebelp " PO Item

kostl " Cost Center

sakto " Cost Element

into table i_ekkn

from ekkn

for all entries in i_bseg

where ebeln = i_bseg-ebeln

and ebelp = i_bseg-ebelp

and kostl in s_kostl

and sakto in s_kstar.

sort i_ekkn by ebeln ebelp.

  • Get the Vendor Name

clear i_lfa1.

refresh i_lfa1.

select lifnr " Vendor

name1 " Name

into table i_lfa1

from lfa1

for all entries in i_bseg

where lifnr = i_bseg-lifnr.

endif.

sort i_lfa1 by lifnr.

  • Move the data to Final Output Internal Table

loop at i_bsis.

i_final-belnr = i_bsis-belnr. " FI Document

i_final-monat = i_bsis-monat. " Period

i_final-budat = i_bsis-budat. " Rec. Date

  • Read the Transaction Currency from BKPF Internal Table

read table i_bkpf with key bukrs = i_bsis-bukrs

belnr = i_bsis-belnr

gjahr = i_bsis-gjahr

binary search.

if sy-subrc = 0.

i_final-waers = i_bkpf-waers. " Tran.Currency

  • Read the Movement Type for all Material Related

  • Documents from MSEG Internal Table

if i_bkpf-awtyp = c_mkpf.

read table i_mseg with key mblnr = i_bkpf-awkey(10)

mjahr = i_bkpf-awkey+10(4).

if sy-subrc = 0.

i_final-bwart = i_mseg-bwart. " Movement Type

endif.

endif.

endif.

  • Read Vendor, Plant, PO Document, Local And Trans.Amounts

  • from BSEG Internal Table

read table i_bseg with key bukrs = i_bsis-bukrs

belnr = i_bsis-belnr

gjahr = i_bsis-gjahr

buzei = i_bsis-buzei

binary search.

if sy-subrc = 0.

i_final-lifnr = i_bseg-lifnr. " Vendor

i_final-werks = i_bseg-werks. " Plant

i_final-ebeln = i_bseg-ebeln. " PO

i_final-dmbtr = i_bseg-dmbtr. " Local Amount

i_final-wrbtr = i_bseg-wrbtr. " Tran.Amount

i_final-menge = i_bseg-menge. " Quantity

i_final-meins = i_bseg-meins. " UOM

  • For Credit Indicator(SHKZG = H) amounts should be (-)ve

if i_bseg-shkzg = c_h.

i_final-dmbtr = i_final-dmbtr * -1.

i_final-wrbtr = i_final-wrbtr * -1.

i_final-menge = i_final-menge * -1.

endif.

  • Read the Material and its Description from EKPO Internal Table

read table i_ekpo with key ebeln = i_bseg-ebeln

ebelp = i_bseg-ebelp

matnr = i_bseg-matnr

binary search.

if sy-subrc = 0.

i_final-matnr = i_ekpo-matnr. " Material Number

i_final-txz01 = i_ekpo-txz01. " Material Text

  • Populate the Material Status depending on the Input Checkbox

  • On Selection Screen

if not i_ekpo-matnr is initial.

i_final-status = c_x.

endif.

endif.

  • Read the PO related Cost Element and Cost Centers

  • from EKKN Internal Table

read table i_ekkn with key ebeln = i_bseg-ebeln

ebelp = i_bseg-ebelp

binary search.

if sy-subrc = 0.

i_final-kostl = i_ekkn-kostl. " Cost Center

i_final-sakto = i_ekkn-sakto. " Cost Element

endif.

  • Read the Valuation Class from MBEW Internal Table

read table i_mbew with key matnr = i_bseg-matnr

werks = i_bseg-werks

binary search.

if sy-subrc = 0.

i_final-bklas = i_mbew-bklas. " Val Class

endif.

  • Read the Vendor Name from LFA1 Internal Table

read table i_lfa1 with key lifnr = i_bseg-lifnr

binary search.

if sy-subrc = 0.

i_final-name1 = i_lfa1-name1. " Vendor Name

endif.

endif.

append i_final.

clear i_final.

endloop.

sort i_final by lifnr werks monat matnr.

  • Depending on the check Box Selected display the data

if p_incmt = c_x and p_incnm ne c_x.

delete i_final where matnr eq space.

elseif p_incnm = c_x and p_incmt ne c_x.

delete i_final where matnr ne space.

endif.

endform. "Read Data

----


  • Form : populate_layout_stucture

  • Description : Populating the layout structure

----


form populate_layout_stucture.

clear x_layout .

  • Layout properties

x_layout-zebra = c_x.

x_layout-detail_popup = c_x.

x_layout-detail_initial_lines = c_x.

x_layout-colwidth_optimize = c_x.

endform. " populate_layout_stucture

----


  • Form : build_field_catalog

  • Description : Building the field catalog data

----


form build_field_catalog.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = g_repid

i_internal_tabname = 'I_FINAL'

i_inclname = g_repid

changing

ct_fieldcat = i_fldcat

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.

  • Getting the Header text for the coloums

loop at i_fldcat into x_fldcat where fieldname = 'LIFNR' or

fieldname = 'NAME1' or

fieldname = 'WERKS' or

fieldname = 'MONAT' or

fieldname = 'MATNR' or

fieldname = 'BKLAS' or

fieldname = 'EBELN' or

fieldname = 'KOSTL' or

fieldname = 'SAKTO' or

fieldname = 'BUDAT' or

fieldname = 'BELNR' or

fieldname = 'BWART' or

fieldname = 'TXZ01' or

fieldname = 'MENGE' or

fieldname = 'MEINS' or

fieldname = 'DMBTR' or

fieldname = 'WRBTR' or

fieldname = 'WAERS' or

fieldname = 'STATUS'.

if x_fldcat-fieldname = 'LIFNR'.

x_fldcat-seltext_l = 'Vendor'(003).

x_fldcat-seltext_m = 'Vendor'(003).

x_fldcat-seltext_s = 'Vendor'(003).

x_fldcat-reptext_ddic = 'Vendor'(003).

x_fldcat-inttype = c_c.

endif.

if x_fldcat-fieldname = 'NAME1'.

x_fldcat-seltext_l = 'Vendor Name'(002).

x_fldcat-seltext_m = 'Vendor Name'(002).

x_fldcat-seltext_s = 'Vendor Name'(002).

x_fldcat-reptext_ddic = 'Vendor Name'(002).

x_fldcat-inttype = c_c.

endif.

if x_fldcat-fieldname = 'WERKS'.

x_fldcat-seltext_l = 'Plant'(010).

x_fldcat-seltext_m = 'Plant'(010).

x_fldcat-seltext_s = 'Plant'(010).

x_fldcat-reptext_ddic = 'Plant'(010).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MONAT'.

x_fldcat-seltext_l = 'Period'(011).

x_fldcat-seltext_m = 'Period'(011).

x_fldcat-seltext_s = 'Period'(011).

x_fldcat-reptext_ddic = 'Period'(011).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MATNR'.

x_fldcat-seltext_l = 'Material'(004).

x_fldcat-seltext_m = 'Material'(004).

x_fldcat-seltext_s = 'Material'(004).

x_fldcat-reptext_ddic = 'Material'(004).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BKLAS'.

x_fldcat-seltext_l = 'Valuation Class'(009).

x_fldcat-seltext_m = 'Valuation Class'(009).

x_fldcat-seltext_s = 'Valuation Class'(009).

x_fldcat-reptext_ddic = 'Valuation Class'(009).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'EBELN'.

x_fldcat-seltext_l = 'Purchase Order'(005).

x_fldcat-seltext_m = 'Purchase Order'(005).

x_fldcat-seltext_s = 'Purchase Order'(005).

x_fldcat-reptext_ddic = 'Purchase Order'(005).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'KOSTL'.

x_fldcat-seltext_l = 'Cost Center'(006).

x_fldcat-seltext_m = 'Cost Center'(006).

x_fldcat-seltext_s = 'Cost Center'(006).

x_fldcat-reptext_ddic = 'Cost Center'(006).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'SAKTO'.

x_fldcat-seltext_l = 'Cost Element'(007).

x_fldcat-seltext_m = 'Cost Element'(007).

x_fldcat-seltext_s = 'Cost Element'(007).

x_fldcat-reptext_ddic = 'Cost Element'(007).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BUDAT'.

x_fldcat-seltext_l = 'Receipt Date'(008).

x_fldcat-seltext_m = 'Receipt Date'(008).

x_fldcat-seltext_s = 'Receipt Date'(008).

x_fldcat-reptext_ddic = 'Receipt Date'(008).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BELNR'.

x_fldcat-seltext_l = 'Acc.Document'(100).

x_fldcat-seltext_m = 'Acc.Document'(100).

x_fldcat-seltext_s = 'Acc.Document'(100).

x_fldcat-reptext_ddic = 'Acc.Document'(100).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BWART'.

x_fldcat-seltext_l = 'Movement Type'(101).

x_fldcat-seltext_m = 'Movement Type'(101).

x_fldcat-seltext_s = 'Movement Type'(101).

x_fldcat-reptext_ddic = 'Movement Type'(101).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'TXZ01'.

x_fldcat-seltext_l = 'Material Text'(102).

x_fldcat-seltext_m = 'Material Text'(102).

x_fldcat-seltext_s = 'Material Text'(102).

x_fldcat-reptext_ddic = 'Material Text'(102).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MENGE'.

x_fldcat-seltext_l = 'Quantity'(103).

x_fldcat-seltext_m = 'Quantity'(103).

x_fldcat-seltext_s = 'Quantity'(103).

x_fldcat-reptext_ddic = 'Quantity'(103).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'MEINS'.

x_fldcat-seltext_l = 'UOM'(104).

x_fldcat-seltext_m = 'UOM'(104).

x_fldcat-seltext_s = 'UOM'(104).

x_fldcat-reptext_ddic = 'UOM'(104).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'DMBTR'.

x_fldcat-seltext_l = 'Amount in Local Curr'(105).

x_fldcat-seltext_m = 'Amount in Local Curr'(105).

x_fldcat-seltext_s = 'Amount in Local Curr'(105).

x_fldcat-reptext_ddic = 'Amount in Local Curr'(105).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'WRBTR'.

x_fldcat-seltext_l = 'Amount in Trans.Curr'(106).

x_fldcat-seltext_m = 'Amount in Trans.Curr'(106).

x_fldcat-seltext_s = 'Amount in Trans.Curr'(106).

x_fldcat-reptext_ddic = 'Amount in Trans.Curr'(106).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'WAERS'.

x_fldcat-seltext_l = 'Trans.Currency'(107).

x_fldcat-seltext_m = 'Trans.Currency'(107).

x_fldcat-seltext_s = 'Trans.Currency'(107).

x_fldcat-reptext_ddic = 'Trans.Currency'(107).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'STATUS'.

x_fldcat-seltext_l = 'Material Status'(019).

x_fldcat-seltext_m = 'Material Status'(019).

x_fldcat-seltext_s = 'Material Status'(019).

x_fldcat-reptext_ddic = 'Material Status'(019).

x_fldcat-ddictxt = c_l.

endif.

modify i_fldcat from x_fldcat index sy-tabix.

endloop.

endform. " build_field_catalog

----


  • Form : build_sort_totals

  • Description : Building the Criteria for Sort/Subtotals

----


form build_sort_totals.

x_sort-fieldname = 'LIFNR'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 1.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'WERKS'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 2.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'MONAT'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 3.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'MATNR'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 4.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'BKLAS'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 5.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'EBELN'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 6.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'KOSTL'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 7.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'SAKTO'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 8.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'BUDAT'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 9.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

endform. " build_sort_totals

----


  • Form : comment_build

  • Description : This form is used to display the Report Header(ALV)

----


*

form comment_build using lt_top_of_page type

slis_t_listheader.

data: l_line type slis_listheader,

l_heading1 like rs38m-repti,

l_date(10), l_time(8).

clear l_line.

l_heading1 = 'GR/IR DETAIL REPORT'(021).

g_repid = sy-repid.

write sy-uzeit to l_time.

write sy-datum to l_date.

l_line-typ = c_h.

move l_heading1 to l_line-info.

append l_line to lt_top_of_page.

clear l_line.

l_line-typ = c_s.

concatenate 'System:'(023) sy-sysid

'Date:'(024) l_date

' Time:'(025)

l_time into l_line-info.

append l_line to lt_top_of_page.

concatenate 'Report:'(026) g_repid

' User:'(027) sy-uname into

l_line-info.

append l_line to lt_top_of_page.

l_line-typ = c_a.

move 'SELECTION CRITERIA:'(028) to l_line-info.

append l_line to lt_top_of_page.

concatenate ' Company Code : '(029)

p_bukrs into l_line-info.

append l_line to lt_top_of_page.

concatenate ' GR/IR Account: '(030)

p_grira into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Posting Date : '(032) s_budat-low

' To: '(031) s_budat-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Plant : '(033) s_werks-low

' To: '(031) s_werks-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Vendor: '(034) s_lifnr-low

' To: '(031) s_lifnr-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Material: '(035) s_matnr-low

' To: '(031) s_matnr-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Cost Center : '(036) s_kostl-low

' To: '(031) s_kostl-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Cost Element: '(037) s_kstar-low

' To: '(031) s_kstar-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Purchase Order: '(038) s_ebeln-low

' To: '(031) s_ebeln-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Period : '(039) s_monat-low

' To: '(031) s_monat-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Include Material Items: '(040)

p_incmt into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Include Non-Material Items: '(041)

p_incnm into l_line-info.

append l_line to lt_top_of_page.

endform.

----


  • Form : call_list_viewer

  • Description : This form is used to display the grid through ALV

----


form call_list_viewer.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = g_repid

is_layout = x_layout

it_fieldcat = i_fldcat[]

i_default = c_x

it_sort = i_sort[]

i_save = g_save

is_variant = g_variant

it_events = g_events[]

importing

e_exit_caused_by_caller = g_exit_caused_by_caller

es_exit_caused_by_user = g_exit_caused_by_user

tables

t_outtab = i_final

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

write: / 'Problem in calling the ALV report'(042).

endif.

endform. " call_list_viewer

<b>

***Reward Points if Useful</b>

Regards

Gokul

Read only

Former Member
0 Likes
785

Hi,

The commonly used ALV functions used for this purpose are;

1. REUSE_ALV_VARIANT_DEFAULT_GET

2. REUSE_ALV_VARIANT_F4

3. REUSE_ALV_VARIANT_EXISTENCE

4. REUSE_ALV_EVENTS_GET

5. REUSE_ALV_COMMENTARY_WRITE

6. REUSE_ALV_FIELDCATALOG_MERGE

7. REUSE_ALV_LIST_DISPLAY

8. REUSE_ALV_GRID_DISPLAY

9. REUSE_ALV_POPUP_TO_SELECT

Look at the Demo Progrmas

BCALV_TREE_DEMO Demo for ALV tree control

BCALV_TREE_SIMPLE_DEMO

BC_ALV_DEMO_HTML_D0100

Regards

Sudheer

Read only

Former Member
0 Likes
784

Hi

ABAP List Viewer

The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).

This helps us to implement all the features mentioned very effectively.

Using ALV, We can have three types of reports:

1. Simple Report

2. Block Report

3. Hierarchical Sequential Report

There are some function modules which will enable to produce the above reports without much effort.

All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.

1. SIMPLE REPORT.

The important function modules are

a. Reuse_alv_list_display

b. Reuse_alv_fieldcatalog_merge

c. Reuse_alv_events_get

d. Reuse_alv_commentary_write

e. Reuse_alv_grid_display

A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.

The important parameters are :

I. Export :

i. I_callback_program : report id

ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status

iii. I_callback_user_command : routine where the function codes are handled

iv. I_structure name : name of the dictionary table

v. Is_layout : structure to set the layout of the report

vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE

vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.

II. Tables :

i. t_outtab : internal table with the data to be output

B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.

The Important Parameters are :

I. Export :

i. I_program_name : report id

ii. I_internal_tabname : the internal output table

iii. I_inclname : include or the report name where all the dynamic forms are handled.

II Changing

ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is

declared in the type pool SLIS.

C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type

Parameters :

I. Import :

Et_Events : The event table is returned with all possible CALLBACK events

for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.

II. Export :

I_List_type :

0 = simple list REUSE_ALV_LIST_DISPLAY

1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY

2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND

3 = hierarchical-sequential block list

REUSE_ALV_BLOCK_LIST_HS_APPEND

D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.

Parameters :

I. it_list_commentary : internal table with the headings of the type slis_t_listheader.

This internal table has three fields :

Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action

Key : only when typ is ‘S’.

Info : the text to be printed

E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.

Parameters : same as reuse_alv_list_display

This is an example for simple list.

2. BLOCK REPORT

This is used to have multiple lists continuously.

The important functions used in this report are:

A. REUSE_ALV_BLOCK_LIST_INIT

B. REUSE_ALV_BLOCK_LIST_APPEND

C. REUSE_ALV_BLOCK_LIST_HS_APPEND

D. REUSE_ALV_BLOCK_LIST_DISPLAY

A. REUSE_ALV_BLOCK_LIST_INIT

Parameters:

I. I_CALLBACK_PROGRAM

II. I_CALLBACK_PF_STATUS_SET

III. I_CALLBACK_USER_COMMAND

This function module is used to set the default gui status etc.

B. REUSE_ALV_BLOCK_LIST_APPEND

Parameters :

Export :

I. is_layout : layout settings for block

II. it_fieldcat : field catalog

III. i_tabname : internal table name with output data

IV. it_events : internal table with all possible events

Tables :

i. t_outtab : internal table with output data.

This function module adds the data to the block.

Repeat this function for all the different blocks to be displayed one after the other.

C. REUSE_ALV_BLOCK_LIST_HS_APPEND

This function module is used for hierarchical sequential blocks.

D. REUSE_ALV_BLOCK_LIST_DISPLAY

Parameters : All the parameters are optional.

This function module display the list with data appended by the above function.

Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.

3. Hierarchical reports :

Hierarchical sequential list output.

The function module is

A. REUSE_ALV_HIERSEQ_LIST_DISPLAY

Parameters:

I. Export:

i. I_CALLBACK_PROGRAM

ii. I_CALLBACK_PF_STATUS_SET

iii. I_CALLBACK_USER_COMMAND

iv. IS_LAYOUT

v. IT_FIELDCAT

vi. IT_EVENTS

vii. i_tabname_header : Name of the internal table in the program containing the

output data of the highest hierarchy level.

viii. i_tabname_item : Name of the internal table in the program containing the

output data of the lowest hierarchy level.

ix. is_keyinfo : This structure contains the header and item table field

names which link the two tables (shared key).

II. Tables

i. t_outtab_header : Header table with data to be output

ii. t_outtab_item : Name of the internal table in the program containing the

output data of the lowest hierarchy level.

slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.

Important Attributes :

A. col_pos : position of the column

B. fieldname : internal fieldname

C. tabname : internal table name

D. ref_fieldname : fieldname (dictionary)

E. ref_tabname : table (dictionary)

F. key(1) : column with key-color

G. icon(1) : icon

H. symbol(1) : symbol

I. checkbox(1) : checkbox

J. just(1) : (R)ight (L)eft (C)ent.

K. do_sum(1) : sum up

L. no_out(1) : (O)blig.(X)no out

M. outputlen : output length

N. seltext_l : long key word

O. seltext_m : middle key word

P. seltext_s : short key word

Q. reptext_ddic : heading (ddic)

R. ddictxt(1) : (S)hort (M)iddle (L)ong

S. datatype : datatype

T. hotspot(1) : hotspot

See the sample report

report ZRGRIRNA no standard page heading

line-count 65

line-size 255

message-id mm.

----


  • GR IR Detail Report *

----


  • Description : The output has to be displayed

  • in the ALV Grid format with the Selection *

  • screen appearing on the output. In The Output *

  • Subtotals for Vendor, Plant, Period, Material,*

  • Valuation Class, Purchase Order,Cost Center, *

  • Cost Element and Receipt Date are displayed *

  • after sorting the data by same fields. *

----


  • Declaration for Tables

----


tables: t001, " Company Codes

t001w, " Plants/Branches

lfa1, " Vendor Master

ska1, " GL Account Master

mara, " Material Master

mbew, " Material Valuation

ekko, " PO Header Data

cska, " Cost Elements

csks, " Cost Centers

bsis, " GL Accounts: Open Items Data

bkpf. " Accounting Doc: Header Data

----


  • Type-pools

----


  • Type pools for ALV display

type-pools : slis.

----


  • Global variables

----


data: g_repid like sy-repid,

g_exit type c,

g_events type slis_t_event,

g_list_top_of_page type slis_t_listheader,

g_exit_caused_by_caller,

g_exit_caused_by_user type slis_exit_by_user,

g_top_of_page type slis_formname value 'TOP_OF_PAGE',

g_variant like disvariant,

g_save.

----


  • Declaration for Constants

----


constants : c_x type c value 'X', " Flag

c_c type c value 'C', " Flag

c_l type c value 'L', " Flag

c_a type c value 'A', " Line Type

c_h type c value 'H', " Dr/Cr

c_s type c value 'S', " Line Type

c_mkpf(4) type c value 'MKPF'. " Table

----


  • Declaration of Internal Tables

----


  • Internal Table for BSIS Table data

data: begin of i_bsis occurs 0,

bukrs like bsis-bukrs, " Company Code

hkont like bsis-hkont, " GR IR Account

gjahr like bsis-gjahr, " Fiscal Year

belnr like bsis-belnr, " Acc Document

buzei like bsis-buzei, " Item No

budat like bsis-budat, " Receipt Date(Posting)

monat like bsis-monat, " Period

end of i_bsis.

  • Internal Table for BSEG Table data

data: begin of i_bseg occurs 0,

bukrs like bsis-bukrs, " Company Code

belnr like bsis-belnr, " Acc Document

buzei like bsis-buzei, " Item No

gjahr like bsis-gjahr, " Fiscal Year

shkzg like bseg-shkzg, " Dr/Cr Indicator

lifnr like bseg-lifnr, " Vendor Code

matnr like bseg-matnr, " Material No

ebeln like bseg-ebeln, " Purchase Order

ebelp like bseg-ebelp, " PO Item

werks like bseg-werks, " Plant

menge like bseg-menge, " PO Quantity

meins like bseg-meins, " UOM

dmbtr like bseg-dmbtr, " Amount in Local Currency

wrbtr like bseg-wrbtr, " Amount in Trans.Currency

end of i_bseg.

  • Internal Table for BKPF Table data

data: begin of i_bkpf occurs 0,

bukrs like bkpf-bukrs, " Company Code

belnr like bkpf-belnr, " Acc Document

gjahr like bkpf-gjahr, " Fiscal Year

waers like bkpf-waers, " Trans. Currency

awkey like bkpf-awkey, " Object Key

awtyp like bkpf-awtyp, " Reference Procedure

end of i_bkpf.

  • Internal Table for MSEG Table data

data: begin of i_mseg occurs 0,

mblnr like mseg-mblnr, " Material Document

mjahr like mseg-mjahr, " Fiscal Year

bwart like mseg-bwart, " Movement Type

matnr like mseg-matnr, " Material No

menge like mseg-menge, " PO Quantity

meins like mseg-meins, " UOM

end of i_mseg.

  • Internal Table for MBEW Table data

data: begin of i_mbew occurs 0,

matnr like mbew-matnr, " Material No

werks like mbew-bwkey, " Plant

bklas like mbew-bklas, " Valuation Class

end of i_mbew.

  • Internal Table for EKPO Table data

data: begin of i_ekpo occurs 0,

ebeln like ekpo-ebeln, " Purchase Order

ebelp like ekpo-ebelp, " PO Item

matnr like ekpo-matnr, " Material No

txz01 like ekpo-txz01, " Material Text

end of i_ekpo.

  • Internal Table for EKKN Table data

data: begin of i_ekkn occurs 0,

ebeln like ekkn-ebeln, " Purchase Order

ebelp like ekkn-ebelp, " PO Item

kostl like ekkn-kostl, " Cost Center

sakto like ekkn-sakto, " Cost Element

end of i_ekkn.

  • Internal Table for LFA1 Table data

data: begin of i_lfa1 occurs 0,

lifnr like lfa1-lifnr, " Vendor

name1 like lfa1-name1, " Name

end of i_lfa1.

  • Declaration of Output Internal Table

data: begin of i_final occurs 0,

lifnr like lfa1-lifnr, " Vendor

werks like bseg-werks, " Plant

monat like bsis-monat, " Period

matnr like mara-matnr, " Material Number

bklas like mbew-bklas, " Val Class

ebeln like bseg-ebeln, " PO

kostl like ekkn-kostl, " Cost Center

sakto like ekkn-sakto, " Cost Element

budat like bsis-budat, " Rec. Date

name1 like lfa1-name1, " Vendor Name

belnr like bsis-belnr, " FI Document

bwart like mseg-bwart, " Movement Type

txz01 like ekpo-txz01, " Material Text

menge like bseg-menge, " Quantity

meins like bseg-meins, " UOM

dmbtr like bseg-dmbtr, " Local Amount

wrbtr like bseg-wrbtr, " Tran.Amount

waers like bkpf-waers, " Tran.Currency

status type c, " Material Status

end of i_final.

  • Internal table to hold field catgory data

data: i_fldcat type slis_t_fieldcat_alv. " Table - field catgory

  • Internal table to hold Sort/Subtotals criteria data

data: i_sort type slis_t_sortinfo_alv. " Table - sort/Subtotals

----


  • Structure

----


data: x_layout type slis_layout_alv, " Structure-layout

x_fldcat like line of i_fldcat, " Structure-field catagory

x_sort like line of i_sort. " Structure-Sort/Subtotals

----


  • Selection screen

----


selection-screen : begin of block b1 with frame title text-000.

parameters:

p_bukrs like t001-bukrs obligatory, " Company Code

p_grira like ska1-saknr default '0241101000' obligatory. " Account

select-options:

s_budat for bkpf-budat, " Posting Date

s_werks for t001w-werks, " Plant

s_lifnr for lfa1-lifnr, " Vendor

s_matnr for mara-matnr, " Material Number

s_kostl for csks-kostl, " Cost Center

s_kstar for cska-kstar, " Cost Element

s_ebeln for ekko-ebeln, " Purchase Order

s_monat for bsis-monat. " Period

selection-screen skip.

parameters:

p_incmt as checkbox default 'X',

p_incnm as checkbox default 'X'.

selection-screen end of block b1.

----


  • Initialization

----


initialization.

g_repid = sy-repid.

perform layout_init using x_layout.

perform eventtab_build using g_events[].

g_variant-report = g_repid.

g_save = 'A'.

----


  • At selection screen

----


at selection-screen.

  • Validation of Selection Screen Fields

perform validate_screen.

----


  • Start of selection

----


start-of-selection.

  • Read Data from Database Tables

perform read_data.

----


  • End of selection

----


end-of-selection.

  • Build layout report layout.

perform populate_layout_stucture.

  • Perform build_field_catalog and Sort Table

perform build_field_catalog.

perform build_sort_totals.

  • List Header for Top-Of-Page

perform comment_build using g_list_top_of_page[].

  • Call list viewer function module

perform call_list_viewer .

****************Form - Routines**************************************

----


  • Form : layout_init

  • Description : Form to Build layout for list display

----


form layout_init using rs_layout type slis_layout_alv.

rs_layout-detail_popup = c_x.

endform.

----


  • Form : Eventtab_build

  • Description : Registration of events to happen during list display

----


form eventtab_build using rt_events type slis_t_event.

  • Registration of events to happen during list display

data: ls_event type slis_alv_event.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = rt_events.

read table rt_events with key name = slis_ev_top_of_page

into ls_event.

if sy-subrc = 0.

move g_top_of_page to ls_event-form.

append ls_event to rt_events.

endif.

endform. "eventtab_build

----


  • Form : top_of_page

----


*

form top_of_page.

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

  • I_LOGO = 'ENJOYSAP_LOGO'

it_list_commentary = g_list_top_of_page.

endform.

----


  • Form validate_screen

----


  • Validation of Selection Screen fields

----


form validate_screen.

  • Validation of Company Code

clear t001.

if not p_bukrs is initial.

select single bukrs

into t001-bukrs

from t001

where bukrs eq p_bukrs.

if sy-subrc <> 0.

message e899 with 'Enter Valid Company Code'(012).

endif.

endif.

  • Validation of GL Account (GR/IR)

clear ska1.

if not p_grira is initial.

select saknr

into ska1-saknr

from ska1

up to 1 rows

where saknr eq p_grira.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid GR/IR Account'(013).

endif.

endif.

  • Validation of Vendor Code

clear lfa1.

if not s_lifnr[] is initial.

select single lifnr

into lfa1-lifnr

from lfa1

where lifnr in s_lifnr.

if sy-subrc <> 0.

message e899 with 'Enter Valid Vendor'(001).

endif.

endif.

  • Validation of Plant Code

clear t001w.

if not s_werks[] is initial.

select single werks

into t001w-werks

from t001w

where werks in s_werks.

if sy-subrc <> 0.

message e899 with 'Enter Valid Plant'(014).

endif.

endif.

  • Validation of Material Code

clear mara.

if not s_matnr[] is initial.

select single matnr

into mara-matnr

from mara

where matnr in s_matnr.

if sy-subrc <> 0.

message e899 with 'Enter Valid Material'(015).

endif.

endif.

  • Validation of Purchase Order

clear ekko.

if not s_ebeln[] is initial.

select single ebeln

into ekko-ebeln

from ekko

where ebeln in s_ebeln.

if sy-subrc <> 0.

message e899 with 'Enter Valid Purchase Order'(016).

endif.

endif.

  • Validation of Cost Center

clear csks.

if not s_kostl[] is initial.

select kostl

into csks-kostl

from csks

up to 1 rows

where kostl in s_kostl.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid Cost Center'(017).

endif.

endif.

  • Validation of Cost Element

clear cska.

if not s_kstar[] is initial.

select kstar

into cska-kstar

from cska

up to 1 rows

where kstar in s_kstar.

endselect.

if sy-subrc <> 0.

message e899 with 'Enter Valid Cost Element'(018).

endif.

endif.

endform. "validate_screen

&----


*& Form read_data

&----


  • Read the Data from the database Tables

----


form read_data.

  • Get the Accounting Documents for the GR/IR Account Entered on

  • Selection Screen

clear i_bsis.

refresh i_bsis.

select bukrs " Company Code

hkont " GR IR Account

gjahr " Fiscal Year

belnr " Acc Document

buzei " Item No

budat " Receipt Date(Posting)

monat " Period

into table i_bsis

from bsis

where bukrs = p_bukrs

and hkont = p_grira

and budat in s_budat

and monat in s_monat .

if sy-subrc <> 0.

message i899 with 'No data found'(043).

g_exit = c_x.

stop.

endif.

sort i_bsis by bukrs hkont gjahr belnr buzei.

  • Get the Vendor,PO,Material,Qty details from BSEG Table

if not i_bsis[] is initial.

clear i_bseg.

refresh i_bseg.

select bukrs " Company Code

belnr " Acc Document

buzei " Item No

gjahr " Fiscal Year

shkzg " Dr/Cr Indicator

lifnr " Vendor Code

matnr " Material No

ebeln " Purchase Order

ebelp " PO Item

werks " Plant

menge " PO Quantity

meins " UOM

dmbtr " Amount in Local Currency

wrbtr " Amount in Trans.Currency

into table i_bseg

from bseg

for all entries in i_bsis

where bukrs = p_bukrs

and belnr = i_bsis-belnr

and gjahr = i_bsis-gjahr

and buzei = i_bsis-buzei

and lifnr in s_lifnr

and werks in s_werks

and matnr in s_matnr

and ebeln in s_ebeln.

sort i_bseg by bukrs belnr buzei gjahr.

  • Select the Trans.Currency from BKPF Table

clear i_bkpf.

refresh i_bkpf.

select bukrs " Company Code

belnr " Acc Document

gjahr " Fiscal Year

waers " Trans. Currency

awkey " Object Key

awtyp " Reference Procedure

into table i_bkpf

from bkpf

for all entries in i_bsis

where bukrs = p_bukrs

and belnr = i_bsis-belnr

and gjahr = i_bsis-gjahr.

endif.

sort i_bkpf by bukrs belnr gjahr.

  • Get the Quantity and UOM of Material from MSEG Table

if not i_bkpf[] is initial.

clear i_mseg.

refresh i_mseg.

select mblnr " Material Document

mjahr " Fiscal Year

bwart " Movement Type

matnr " Material No

menge " PO Quantity

meins " UOM

into table i_mseg

from mseg

for all entries in i_bkpf

where mblnr = i_bkpf-awkey(10).

endif.

sort i_mseg by mblnr mjahr.

  • Get the Material And Description from EKPO Table

if not i_bseg[] is initial.

clear i_ekpo.

refresh i_ekpo.

select ebeln " Purchase Order

ebelp " PO Item

matnr " Material No

txz01 " Material Text

into table i_ekpo

from ekpo

for all entries in i_bseg

where ebeln = i_bseg-ebeln

and ebelp = i_bseg-ebelp.

sort i_ekpo by ebeln ebelp.

  • Get the Valuation Class from MBEW Table

clear i_mbew.

refresh i_mbew.

select matnr " Material No

bwkey " Plant

bklas " Valuation Class

into table i_mbew

from mbew

for all entries in i_bseg

where matnr = i_bseg-matnr

and bwkey = i_bseg-werks.

sort i_mbew by matnr werks.

  • Get the Cost Center and Cost Element of the PO from EKKN Table

clear i_ekkn.

refresh i_ekkn.

select ebeln " Purchase Order

ebelp " PO Item

kostl " Cost Center

sakto " Cost Element

into table i_ekkn

from ekkn

for all entries in i_bseg

where ebeln = i_bseg-ebeln

and ebelp = i_bseg-ebelp

and kostl in s_kostl

and sakto in s_kstar.

sort i_ekkn by ebeln ebelp.

  • Get the Vendor Name

clear i_lfa1.

refresh i_lfa1.

select lifnr " Vendor

name1 " Name

into table i_lfa1

from lfa1

for all entries in i_bseg

where lifnr = i_bseg-lifnr.

endif.

sort i_lfa1 by lifnr.

  • Move the data to Final Output Internal Table

loop at i_bsis.

i_final-belnr = i_bsis-belnr. " FI Document

i_final-monat = i_bsis-monat. " Period

i_final-budat = i_bsis-budat. " Rec. Date

  • Read the Transaction Currency from BKPF Internal Table

read table i_bkpf with key bukrs = i_bsis-bukrs

belnr = i_bsis-belnr

gjahr = i_bsis-gjahr

binary search.

if sy-subrc = 0.

i_final-waers = i_bkpf-waers. " Tran.Currency

  • Read the Movement Type for all Material Related

  • Documents from MSEG Internal Table

if i_bkpf-awtyp = c_mkpf.

read table i_mseg with key mblnr = i_bkpf-awkey(10)

mjahr = i_bkpf-awkey+10(4).

if sy-subrc = 0.

i_final-bwart = i_mseg-bwart. " Movement Type

endif.

endif.

endif.

  • Read Vendor, Plant, PO Document, Local And Trans.Amounts

  • from BSEG Internal Table

read table i_bseg with key bukrs = i_bsis-bukrs

belnr = i_bsis-belnr

gjahr = i_bsis-gjahr

buzei = i_bsis-buzei

binary search.

if sy-subrc = 0.

i_final-lifnr = i_bseg-lifnr. " Vendor

i_final-werks = i_bseg-werks. " Plant

i_final-ebeln = i_bseg-ebeln. " PO

i_final-dmbtr = i_bseg-dmbtr. " Local Amount

i_final-wrbtr = i_bseg-wrbtr. " Tran.Amount

i_final-menge = i_bseg-menge. " Quantity

i_final-meins = i_bseg-meins. " UOM

  • For Credit Indicator(SHKZG = H) amounts should be (-)ve

if i_bseg-shkzg = c_h.

i_final-dmbtr = i_final-dmbtr * -1.

i_final-wrbtr = i_final-wrbtr * -1.

i_final-menge = i_final-menge * -1.

endif.

  • Read the Material and its Description from EKPO Internal Table

read table i_ekpo with key ebeln = i_bseg-ebeln

ebelp = i_bseg-ebelp

matnr = i_bseg-matnr

binary search.

if sy-subrc = 0.

i_final-matnr = i_ekpo-matnr. " Material Number

i_final-txz01 = i_ekpo-txz01. " Material Text

  • Populate the Material Status depending on the Input Checkbox

  • On Selection Screen

if not i_ekpo-matnr is initial.

i_final-status = c_x.

endif.

endif.

  • Read the PO related Cost Element and Cost Centers

  • from EKKN Internal Table

read table i_ekkn with key ebeln = i_bseg-ebeln

ebelp = i_bseg-ebelp

binary search.

if sy-subrc = 0.

i_final-kostl = i_ekkn-kostl. " Cost Center

i_final-sakto = i_ekkn-sakto. " Cost Element

endif.

  • Read the Valuation Class from MBEW Internal Table

read table i_mbew with key matnr = i_bseg-matnr

werks = i_bseg-werks

binary search.

if sy-subrc = 0.

i_final-bklas = i_mbew-bklas. " Val Class

endif.

  • Read the Vendor Name from LFA1 Internal Table

read table i_lfa1 with key lifnr = i_bseg-lifnr

binary search.

if sy-subrc = 0.

i_final-name1 = i_lfa1-name1. " Vendor Name

endif.

endif.

append i_final.

clear i_final.

endloop.

sort i_final by lifnr werks monat matnr.

  • Depending on the check Box Selected display the data

if p_incmt = c_x and p_incnm ne c_x.

delete i_final where matnr eq space.

elseif p_incnm = c_x and p_incmt ne c_x.

delete i_final where matnr ne space.

endif.

endform. "Read Data

----


  • Form : populate_layout_stucture

  • Description : Populating the layout structure

----


form populate_layout_stucture.

clear x_layout .

  • Layout properties

x_layout-zebra = c_x.

x_layout-detail_popup = c_x.

x_layout-detail_initial_lines = c_x.

x_layout-colwidth_optimize = c_x.

endform. " populate_layout_stucture

----


  • Form : build_field_catalog

  • Description : Building the field catalog data

----


form build_field_catalog.

call function 'REUSE_ALV_FIELDCATALOG_MERGE'

exporting

i_program_name = g_repid

i_internal_tabname = 'I_FINAL'

i_inclname = g_repid

changing

ct_fieldcat = i_fldcat

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.

  • Getting the Header text for the coloums

loop at i_fldcat into x_fldcat where fieldname = 'LIFNR' or

fieldname = 'NAME1' or

fieldname = 'WERKS' or

fieldname = 'MONAT' or

fieldname = 'MATNR' or

fieldname = 'BKLAS' or

fieldname = 'EBELN' or

fieldname = 'KOSTL' or

fieldname = 'SAKTO' or

fieldname = 'BUDAT' or

fieldname = 'BELNR' or

fieldname = 'BWART' or

fieldname = 'TXZ01' or

fieldname = 'MENGE' or

fieldname = 'MEINS' or

fieldname = 'DMBTR' or

fieldname = 'WRBTR' or

fieldname = 'WAERS' or

fieldname = 'STATUS'.

if x_fldcat-fieldname = 'LIFNR'.

x_fldcat-seltext_l = 'Vendor'(003).

x_fldcat-seltext_m = 'Vendor'(003).

x_fldcat-seltext_s = 'Vendor'(003).

x_fldcat-reptext_ddic = 'Vendor'(003).

x_fldcat-inttype = c_c.

endif.

if x_fldcat-fieldname = 'NAME1'.

x_fldcat-seltext_l = 'Vendor Name'(002).

x_fldcat-seltext_m = 'Vendor Name'(002).

x_fldcat-seltext_s = 'Vendor Name'(002).

x_fldcat-reptext_ddic = 'Vendor Name'(002).

x_fldcat-inttype = c_c.

endif.

if x_fldcat-fieldname = 'WERKS'.

x_fldcat-seltext_l = 'Plant'(010).

x_fldcat-seltext_m = 'Plant'(010).

x_fldcat-seltext_s = 'Plant'(010).

x_fldcat-reptext_ddic = 'Plant'(010).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MONAT'.

x_fldcat-seltext_l = 'Period'(011).

x_fldcat-seltext_m = 'Period'(011).

x_fldcat-seltext_s = 'Period'(011).

x_fldcat-reptext_ddic = 'Period'(011).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MATNR'.

x_fldcat-seltext_l = 'Material'(004).

x_fldcat-seltext_m = 'Material'(004).

x_fldcat-seltext_s = 'Material'(004).

x_fldcat-reptext_ddic = 'Material'(004).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BKLAS'.

x_fldcat-seltext_l = 'Valuation Class'(009).

x_fldcat-seltext_m = 'Valuation Class'(009).

x_fldcat-seltext_s = 'Valuation Class'(009).

x_fldcat-reptext_ddic = 'Valuation Class'(009).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'EBELN'.

x_fldcat-seltext_l = 'Purchase Order'(005).

x_fldcat-seltext_m = 'Purchase Order'(005).

x_fldcat-seltext_s = 'Purchase Order'(005).

x_fldcat-reptext_ddic = 'Purchase Order'(005).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'KOSTL'.

x_fldcat-seltext_l = 'Cost Center'(006).

x_fldcat-seltext_m = 'Cost Center'(006).

x_fldcat-seltext_s = 'Cost Center'(006).

x_fldcat-reptext_ddic = 'Cost Center'(006).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'SAKTO'.

x_fldcat-seltext_l = 'Cost Element'(007).

x_fldcat-seltext_m = 'Cost Element'(007).

x_fldcat-seltext_s = 'Cost Element'(007).

x_fldcat-reptext_ddic = 'Cost Element'(007).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BUDAT'.

x_fldcat-seltext_l = 'Receipt Date'(008).

x_fldcat-seltext_m = 'Receipt Date'(008).

x_fldcat-seltext_s = 'Receipt Date'(008).

x_fldcat-reptext_ddic = 'Receipt Date'(008).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BELNR'.

x_fldcat-seltext_l = 'Acc.Document'(100).

x_fldcat-seltext_m = 'Acc.Document'(100).

x_fldcat-seltext_s = 'Acc.Document'(100).

x_fldcat-reptext_ddic = 'Acc.Document'(100).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'BWART'.

x_fldcat-seltext_l = 'Movement Type'(101).

x_fldcat-seltext_m = 'Movement Type'(101).

x_fldcat-seltext_s = 'Movement Type'(101).

x_fldcat-reptext_ddic = 'Movement Type'(101).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'TXZ01'.

x_fldcat-seltext_l = 'Material Text'(102).

x_fldcat-seltext_m = 'Material Text'(102).

x_fldcat-seltext_s = 'Material Text'(102).

x_fldcat-reptext_ddic = 'Material Text'(102).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'MENGE'.

x_fldcat-seltext_l = 'Quantity'(103).

x_fldcat-seltext_m = 'Quantity'(103).

x_fldcat-seltext_s = 'Quantity'(103).

x_fldcat-reptext_ddic = 'Quantity'(103).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'MEINS'.

x_fldcat-seltext_l = 'UOM'(104).

x_fldcat-seltext_m = 'UOM'(104).

x_fldcat-seltext_s = 'UOM'(104).

x_fldcat-reptext_ddic = 'UOM'(104).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'DMBTR'.

x_fldcat-seltext_l = 'Amount in Local Curr'(105).

x_fldcat-seltext_m = 'Amount in Local Curr'(105).

x_fldcat-seltext_s = 'Amount in Local Curr'(105).

x_fldcat-reptext_ddic = 'Amount in Local Curr'(105).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'WRBTR'.

x_fldcat-seltext_l = 'Amount in Trans.Curr'(106).

x_fldcat-seltext_m = 'Amount in Trans.Curr'(106).

x_fldcat-seltext_s = 'Amount in Trans.Curr'(106).

x_fldcat-reptext_ddic = 'Amount in Trans.Curr'(106).

x_fldcat-ddictxt = c_l.

x_fldcat-do_sum = c_x.

endif.

if x_fldcat-fieldname = 'WAERS'.

x_fldcat-seltext_l = 'Trans.Currency'(107).

x_fldcat-seltext_m = 'Trans.Currency'(107).

x_fldcat-seltext_s = 'Trans.Currency'(107).

x_fldcat-reptext_ddic = 'Trans.Currency'(107).

x_fldcat-ddictxt = c_l.

endif.

if x_fldcat-fieldname = 'STATUS'.

x_fldcat-seltext_l = 'Material Status'(019).

x_fldcat-seltext_m = 'Material Status'(019).

x_fldcat-seltext_s = 'Material Status'(019).

x_fldcat-reptext_ddic = 'Material Status'(019).

x_fldcat-ddictxt = c_l.

endif.

modify i_fldcat from x_fldcat index sy-tabix.

endloop.

endform. " build_field_catalog

----


  • Form : build_sort_totals

  • Description : Building the Criteria for Sort/Subtotals

----


form build_sort_totals.

x_sort-fieldname = 'LIFNR'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 1.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'WERKS'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 2.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'MONAT'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 3.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'MATNR'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 4.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'BKLAS'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 5.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'EBELN'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 6.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'KOSTL'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 7.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'SAKTO'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 8.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

x_sort-fieldname = 'BUDAT'.

x_sort-tabname = 'I_FINAL'.

x_sort-spos = 9.

x_sort-up = c_x.

x_sort-subtot = c_x.

append x_sort to i_sort.

clear x_sort.

endform. " build_sort_totals

----


  • Form : comment_build

  • Description : This form is used to display the Report Header(ALV)

----


*

form comment_build using lt_top_of_page type

slis_t_listheader.

data: l_line type slis_listheader,

l_heading1 like rs38m-repti,

l_date(10), l_time(8).

clear l_line.

l_heading1 = 'GR/IR DETAIL REPORT'(021).

g_repid = sy-repid.

write sy-uzeit to l_time.

write sy-datum to l_date.

l_line-typ = c_h.

move l_heading1 to l_line-info.

append l_line to lt_top_of_page.

clear l_line.

l_line-typ = c_s.

concatenate 'System:'(023) sy-sysid

'Date:'(024) l_date

' Time:'(025)

l_time into l_line-info.

append l_line to lt_top_of_page.

concatenate 'Report:'(026) g_repid

' User:'(027) sy-uname into

l_line-info.

append l_line to lt_top_of_page.

l_line-typ = c_a.

move 'SELECTION CRITERIA:'(028) to l_line-info.

append l_line to lt_top_of_page.

concatenate ' Company Code : '(029)

p_bukrs into l_line-info.

append l_line to lt_top_of_page.

concatenate ' GR/IR Account: '(030)

p_grira into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Posting Date : '(032) s_budat-low

' To: '(031) s_budat-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Plant : '(033) s_werks-low

' To: '(031) s_werks-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Vendor: '(034) s_lifnr-low

' To: '(031) s_lifnr-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Material: '(035) s_matnr-low

' To: '(031) s_matnr-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Cost Center : '(036) s_kostl-low

' To: '(031) s_kostl-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Cost Element: '(037) s_kstar-low

' To: '(031) s_kstar-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Purchase Order: '(038) s_ebeln-low

' To: '(031) s_ebeln-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Period : '(039) s_monat-low

' To: '(031) s_monat-high into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Include Material Items: '(040)

p_incmt into l_line-info.

append l_line to lt_top_of_page.

concatenate ' Include Non-Material Items: '(041)

p_incnm into l_line-info.

append l_line to lt_top_of_page.

endform.

----


  • Form : call_list_viewer

  • Description : This form is used to display the grid through ALV

----


form call_list_viewer.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_callback_program = g_repid

is_layout = x_layout

it_fieldcat = i_fldcat[]

i_default = c_x

it_sort = i_sort[]

i_save = g_save

is_variant = g_variant

it_events = g_events[]

importing

e_exit_caused_by_caller = g_exit_caused_by_caller

es_exit_caused_by_user = g_exit_caused_by_user

tables

t_outtab = i_final

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

write: / 'Problem in calling the ALV report'(042).

endif.

endform. " call_list_view

<b>Reward points</b>

Regards

Read only

Former Member
0 Likes
784

hi,

The important function modules are

a. Reuse_alv_list_display:This is the function module which prints the data.

b. Reuse_alv_fieldcatalog_merge:his function module is used to

populate a fieldcatalog which is essential to display the data in ALV.

c. Reuse_alv_events_get:Returns table of possible events for a list type

d. Reuse_alv_commentary_write:This is used in the Top-of-page event to print the headings and other comments for the list.

e. Reuse_alv_grid_display:A new function in 4.6 version, to display the results in grid rather than as a preview.

<b>blocked list:</b> :

This is used to have multiple lists continuously.

The important functions used in this report are:

A. REUSE_ALV_BLOCK_LIST_INIT

B. REUSE_ALV_BLOCK_LIST_APPEND

C. REUSE_ALV_BLOCK_LIST_HS_APPEND

D. REUSE_ALV_BLOCK_LIST_DISPLAY

Hirarcial list :

if u want to display daat hirarchialy we use this.

for example if u want tp print header data and corresponding items we use this