‎2006 Aug 25 7:16 AM
HI All,
Pls send me a simple ALV Report.As my requirment is In select-option I'm passing two field & In O/P I've to get 8 fields as ALV grid display.One of the field In O/P should display in dicending order.
Pls send me sample report as I'm very new to ALV.
Thanks in advance
Singha
‎2006 Aug 25 7:22 AM
Try to go through programs starting with BCALV* or
transaction DWDM to explore and find one suitable for
your requirements.
Kind Regards
Eswar
‎2006 Aug 25 7:26 AM
See Demo program BCALV_GRID_DEMO in se38
Its helpful to you
Reward if Helpful
Regard
‎2006 Aug 25 7:54 AM
hi,
i am giving u code for a sample ALV with explanation.
REPORT z_alv_simple_example_with_itab .
************************************************************************
*Simple example to use ALV and to define the ALV data in an internal
*table
************************************************************************
Martin Schlegel, BearingPoint, December 2004
*
Thanks to Madhusudhan Sonee and Rama Krishna Kommineni for testing
and feedback
*
************************************************************************
************************************************************************
*For a very long time, people gave me the feeling that ALV is a
*complicated tool that is difficult to understand and to use.
*Lately I had to use it and I discovered that ALV is easy to use and
*saves a lot of work:
*ALV will generate the column headings on its own, so one does not need
*to work on headlines and transalation.
*ALV allows the user to select the columns he wants to see, so the user
*does not need to contact a developer for every change he likes to have.
*ALV allows the user to create his own sums, so
*ALV has a simple way to work with internal tables.
*If you really want to save time, use ALV instead of write!
************************************************************************
*
*Please take 30 minutes to explore the following example and see how
*easy it is to use ALV!
*
************************************************************************
*data definition
INCLUDE <icon>.
TABLES:
marav. "Table MARA and table MAKT
----
Data to be displayed in ALV
Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
matically determine the fieldstructure from this source program
DATA:
BEGIN OF imat OCCURS 100,
ios(4) TYPE c,
matnr LIKE marav-matnr, "Material number
maktx LIKE marav-maktx, "Material short text
matkl LIKE marav-matkl, "Material group (so you can test to make
" intermediate sums)
ntgew LIKE marav-ntgew, "Net weight, numeric field (so you can test to
"make sums)
gewei LIKE marav-gewei, "weight unit (just to be complete)
END OF imat.
----
Other data needed
field to store report name
DATA i_repid LIKE sy-repid.
field to check table length
DATA i_lines LIKE sy-tabix.
----
Data for ALV display
TYPE-POOLS: slis.
DATA int_fcat TYPE slis_t_fieldcat_alv.
----
SELECT-OPTIONS:
s_matnr FOR marav-matnr MATCHCODE OBJECT mat1.
----
START-OF-SELECTION.
read data into table imat
SELECT * FROM marav
INTO CORRESPONDING FIELDS OF TABLE imat
WHERE matnr IN s_matnr.
LOOP AT imat.
IF imat-matnr+0(1) = 'M'.
MOVE icon_green_light TO imat-ios.
MODIFY imat.
ENDIF.
IF imat-matnr+0(1) = 'Z'.
MOVE icon_red_light TO imat-ios.
MODIFY imat.
ENDIF.
ENDLOOP.
Check if material was found
CLEAR i_lines.
DESCRIBE TABLE imat LINES i_lines.
IF i_lines LT 1.
Using hardcoded write here for easy upload
WRITE: / 'No materials found.'.
EXIT.
ENDIF.
END-OF-SELECTION.
----
Now, we start with ALV
----
To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
The fieldcatalouge can be generated by FUNCTION
'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
report source, including this report.
The only problem one might have is that the report and table names
need to be in capital letters. (I had it )
----
Store report name
i_repid = sy-repid.
Create Fieldcatalogue from internal table
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'IMAT' "capital letters!
i_inclname = i_repid
CHANGING
ct_fieldcat = int_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*explanations:
I_PROGRAM_NAME is the program which calls this function
*
I_INTERNAL_TABNAME is the name of the internal table which you want
to display in ALV
*
I_INCLNAME is the ABAP-source where the internal table is defined
(DATA....)
CT_FIELDCAT contains the Fieldcatalouge that we need later for
ALV display
IF sy-subrc <> 0.
WRITE: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
ENDIF.
*This was the fieldcatlogue
----
And now, we are ready to display our list
*----
Call for ALV list display
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'
i_callback_program = i_repid
it_fieldcat = int_fcat
i_save = 'A'
TABLES
t_outtab = imat
EXCEPTIONS
program_error = 1
OTHERS = 2.
*
*explanations:
I_CALLBACK_PROGRAM is the program which calls this function
*
IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains
now the data definition needed for display
*
I_SAVE allows the user to save his own layouts
*
T_OUTTAB contains the data to be displayed in ALV
IF sy-subrc <> 0.
WRITE: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
ENDIF.
Hope this will help you.
‎2007 Feb 15 12:08 PM
hi,
report z_alv_data_display .
*Table declaration
tables :
bsis,
bsas.
----
Declaration of the Internal Table
data : begin of itab occurs 100,
belnr like bsas-belnr, " Accounting document number
bldat like bsas-bldat, " Document date
budat like bsas-budat, " Posting date
hkont like bsas-hkont, " GL account
dmbtr like bsas-dmbtr, " Amount in local currency
xblnr like bsas-xblnr, " Reference document number
end of itab.
----
Other data needed
field to store report name
data i_repid like sy-repid.
field to check table length
data i_lines like sy-tabix.
----
Data for ALV display
type-pools: slis.
data: int_fcat type slis_t_fieldcat_alv,
is_layout type slis_fieldcat_alv.
data: wa_fieldcat like line of int_fcat.
----
*Selection Screen Declaration
selection-screen: begin of block b1.
parameters : ddate like bsas-bldat,
glact like bsas-hkont.
selection-screen:end of block b1.
----
*Select the document date, amount, document no from the table bsas
start-of-selection.
select bldat
dmbtr
belnr
budat
hkont
xblnr
from bsas
into (itab-bldat,
itab-dmbtr,
itab-belnr,
itab-budat,
itab-hkont,
itab-xblnr)
where bldat eq ddate and hkont eq glact.
append itab.
endselect.
select bldat
dmbtr
belnr
budat
hkont
xblnr
from bsis
into (itab-bldat,
itab-dmbtr,
itab-belnr,
itab-budat,
itab-hkont,
itab-xblnr)
where bldat eq ddate and hkont eq glact.
append itab.
endselect.
Check if material was found
clear i_lines.
describe table itab lines i_lines.
if i_lines lt 1.
Using hardcoded write here for easy upload
write: /
'No DATA found.'.
exit.
endif.
end-of-selection.
Store report name
i_repid = sy-repid.
*This was the fieldcatlogue
----
to display the list of data
is_layout-col_pos = 1.
is_layout-fieldname = 'BELNR'.
is_layout-tabname = 'ITAB'.
is_layout-seltext_l = 'Document No'.
append is_layout to int_fcat.
clear is_layout.
is_layout-col_pos = 2.
is_layout-fieldname = 'BLDAT'.
is_layout-tabname = 'ITAB'.
is_layout-seltext_l = 'Document Dt'.
append is_layout to int_fcat.
clear is_layout.
is_layout-col_pos = 3.
is_layout-fieldname = 'BUDAT'.
is_layout-tabname = 'ITAB'.
is_layout-seltext_l = 'Posting Dt'.
append is_layout to int_fcat.
clear is_layout.
is_layout-col_pos = 4.
is_layout-fieldname = 'HKONT'.
is_layout-tabname = 'ITAB'.
is_layout-seltext_l = 'GL Act No'.
append is_layout to int_fcat.
clear is_layout.
is_layout-col_pos = 5.
is_layout-fieldname = 'DMBTR'.
is_layout-tabname = 'ITAB'.
is_layout-seltext_l = 'Amt(Lcl Curncy)'.
append is_layout to int_fcat.
clear is_layout.
is_layout-col_pos = 6.
is_layout-fieldname = 'XBLNR'.
is_layout-tabname = 'ITAB'.
is_layout-seltext_l = 'Reference'.
append is_layout to int_fcat.
clear is_layout.
*----
Call for ALV list display
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'
i_callback_program = i_repid
it_fieldcat = int_fcat[]
i_save = 'A'
tables
t_outtab = itab[]
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
write: /
'Returncode',
sy-subrc,
'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
endif.
‎2007 Feb 15 12:49 PM
hi
good
go to SE38 give BCALV* and put F4,you ll find lots of example related to AVL,test them and ust them accordingly.
thanks
mrutyun^