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 sub-total

Former Member
0 Likes
448

Hi

can plz tell me how to do subtotals in ALV LIST DISPLAY.

3 REPLIES 3
Read only

Former Member
0 Likes
424

Hi,

I have a good article in ALV which I could send it over. You can search in SDN for any articles by Serdar.

cheers

Aveek

Read only

Former Member
0 Likes
424

Hi Naveen,

Refer to the link,

<a href="http://http://www.sap-basis-abap.com/sapalv.htm">http://http://www.sap-basis-abap.com/sapalv.htm</a>

Regards,

Abdul.

P.S: Reward Points, if useful.

Read only

Former Member
0 Likes
424

hi

good

go through this

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.

  • 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.

thnaks

mrutyun^