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 report

Former Member
0 Likes
1,544

hi all..i have done my alv report are got my result perfectly but i have some doubts...

here is my code...

*&----


*

**& Report Z_ABHI_ALV1 **

**& **

*&----


*

**& **

**& **

*&----


*

REPORT z_abhi_alv1 .

TYPE-POOLS :slis.

******TABLE DECLARATIONS*********

TYPES: BEGIN OF str_kna1,

kunnr TYPE kunnr,

name1 TYPE name1_gp,

land1 TYPE land1_gp,

ort01 TYPE ort01_gp,

END OF str_kna1.

*******WORK AREA AND INTERNAL TABLE******

DATA: w_kna1 TYPE str_kna1,

t_kna1 TYPE STANDARD TABLE OF str_kna1.

*******FIELDCATS DECLARATIONS***************

DATA: w_fcat TYPE slis_fieldcat_alv,

t_fcat TYPE slis_t_fieldcat_alv.

******EVENTS DECLARATIONS*****************

DATA: w_event TYPE slis_alv_event,

t_event TYPE slis_t_event.

APPEND W_EVENT TO T_EVENT.

******LIST HEADER DECLARATIONS*************

DATA: w_listheader TYPE slis_listheader,

t_listheader TYPE slis_t_listheader.

APPEND W_LISTHEADER TO T_LISTHEADER.

*****FILLING FCAT*************

w_fcat-col_pos = '1'.

w_fcat-fieldname = 'KUNNR'.

w_fcat-seltext_m = 'CUST NO'.

APPEND w_fcat TO t_fcat.

w_fcat-col_pos = '2'.

w_fcat-fieldname = 'NAME1'.

w_fcat-seltext_m = 'CUST NAME'.

APPEND w_fcat TO t_fcat.

w_fcat-col_pos = '3'.

w_fcat-fieldname = 'LAND1'.

w_fcat-seltext_m = 'COUNTRY'.

APPEND w_fcat TO t_fcat.

w_fcat-col_pos = '4'.

w_fcat-fieldname = 'ORT01'.

w_fcat-seltext_m = 'CITY'.

APPEND w_fcat TO t_fcat.

*********FILLING EVENTS***********

w_event-name = 'TOP_OF_PAGE'.

w_event-form = 'SUB1'.

APPEND W_EVENT TO T_EVENT.

********FILLING COMMENTS*********

w_listheader-typ = 'H'.

w_listheader-info = 'CUSTOMER INFORMATION'.

APPEND W_LISTHEADER TO T_LISTHEADER.

*********DATA EXTRACTION**********

SELECT kunnr

name1

land1

ort01 FROM kna1 INTO TABLE t_kna1.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

    • I_INTERFACE_CHECK = ' '*

    • I_BYPASSING_BUFFER = ' '*

    • I_BUFFER_ACTIVE = ' '*

I_CALLBACK_PROGRAM = SY-CPROG

    • I_CALLBACK_PF_STATUS_SET = ' '*

    • I_CALLBACK_USER_COMMAND = ' '*

    • I_CALLBACK_TOP_OF_PAGE = ' '*

    • I_CALLBACK_HTML_TOP_OF_PAGE = ' '*

    • I_CALLBACK_HTML_END_OF_LIST = ' '*

    • I_STRUCTURE_NAME =*

    • I_BACKGROUND_ID = ' '*

    • I_GRID_TITLE =*

    • I_GRID_SETTINGS =*

    • IS_LAYOUT =*

it_fieldcat = t_fcat

    • IT_EXCLUDING =*

    • IT_SPECIAL_GROUPS =*

    • IT_SORT =*

    • IT_FILTER =*

    • IS_SEL_HIDE =*

    • I_DEFAULT = 'X'*

    • I_SAVE = ' '*

    • IS_VARIANT =*

IT_EVENTS = T_EVENT

    • IT_EVENT_EXIT =*

    • IS_PRINT =*

    • IS_REPREP_ID =*

    • I_SCREEN_START_COLUMN = 0*

    • I_SCREEN_START_LINE = 0*

    • I_SCREEN_END_COLUMN = 0*

    • I_SCREEN_END_LINE = 0*

    • IT_ALV_GRAPHICS =*

    • IT_HYPERLINK =*

    • IT_ADD_FIELDCAT =*

    • IT_EXCEPT_QINFO =*

    • I_HTML_HEIGHT_TOP =*

    • I_HTML_HEIGHT_END =*

    • IMPORTING*

    • E_EXIT_CAUSED_BY_CALLER =*

    • ES_EXIT_CAUSED_BY_USER =*

TABLES

t_outtab = t_kna1

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.

*&----


*

*& Form SUB1

FORM sub1.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = T_LISTHEADER.

    • I_LOGO =*

    • I_END_OF_LIST_GRID =*

.

*&----


*

    • text*

*----


*

ENDFORM.

these are my doubts::::

*1)in FM reuse_alv_grid_display wht does " I_CALLBACK_PROGRAM = SY-CPROG*

signifies?????

2)wht is the use of appending w_fcat,w_event etc to t_fcat,t_ecent resp...cant we directly w_fcat n t_fcat????

thanx in advance

1 ACCEPTED SOLUTION
Read only

awin_prabhu
Active Contributor
0 Likes
1,511

Hi friend,

1.Program that is using the function module 'REUSE_ALV_GRID_DISPLAY'

should be mentioned in I_CALLBACK_PROGRAM parameter.

Its a mapping between the program and function module.

2. w_fcat,w_event are work areas, that is they can hold only a single record at a time.

So, for displaying many records, we have to use internal tables t_fcat,t_event.

Append all work areas to the internal table and pass that table to the Function

'REUSE_ALV_GRID_DISPLAY'.

Thanks..........

12 REPLIES 12
Read only

Former Member
0 Likes
1,511

Hi,

In this FM,

I_CALLBACK_PROGRAM signifies you current program name,

you can pass here SY-REPID also which will also point to your current report name.

Regrds

Mansi

Read only

0 Likes
1,511

where i can find my correct prog name..as in my prog it is sy-cprog???where can i find that sy-cprog???

Read only

0 Likes
1,511

hi,

cprog is current prog name.. u can get it by passing sy-repid to a variable (string) and pass it 2 the FM.

2: W-fcat all these are work area n not tables. this FM accepts tables for Fcat and events etc. so we need 2 build up tables by passing values 2 work areas.

Also look that Layout is to be passed as a work area and not as a table.

regards,

ags.

Read only

0 Likes
1,511

Hi,

SY_CPROG is a system field which will dynamically point to your

program name in which you have written you alv coding.

Regrds

Mansi

Read only

Former Member
0 Likes
1,511

*1)in FM reuse_alv_grid_display wht does " I_CALLBACK_PROGRAM = SY-CPROG*

signifies?????

I_CALLBACK_PROGRAM signifies you current program name, Function module wil understand the program name in which the Functionmodule wil cal.

you can pass here SY-REPID or u can write ur program name also

2)wht is the use of appending w_fcat,w_event etc to t_fcat,t_ecent resp...cant we directly w_fcat n t_fcat????

.

Fcat is also like internal table

fcat ur declared as table w_fcat is like worh area so u need to upload all to table finally

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,511

Hi,

Have a look at this document for ALV, it really helpful.

https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a41...

Hope this solves your problem.

Thanks & Regards,

Tarun Gambhir

Read only

Former Member
Read only

awin_prabhu
Active Contributor
0 Likes
1,512

Hi friend,

1.Program that is using the function module 'REUSE_ALV_GRID_DISPLAY'

should be mentioned in I_CALLBACK_PROGRAM parameter.

Its a mapping between the program and function module.

2. w_fcat,w_event are work areas, that is they can hold only a single record at a time.

So, for displaying many records, we have to use internal tables t_fcat,t_event.

Append all work areas to the internal table and pass that table to the Function

'REUSE_ALV_GRID_DISPLAY'.

Thanks..........

Read only

Former Member
0 Likes
1,511

Hi ,

I_CALLBACK_PROGRAM refers to the program that calss this Function Modue ( REUSE_ALV_GRID_DISPLAY).This is the current program name itself.

You need to append wa_filedcat to it_filedcat because this is teh palce where you define the atatributes of the different fileds taht are to be output.Each row corresponds to a single field that is diaplayed.

IT_EVENTS contaisn the list of events that needs to be performed . So by using on WA_EVENT you cannot achieve the functionality of Multiple events in output .that is the reason for appending the WA_EVENTS to IT_EVENTS .

Regards,

Radhika.

Read only

Former Member
0 Likes
1,511

Hi,

1) I_CALLBACK_PROGRAM signifies your program name, you can pass here SY-REPID or u can write ur program name also

2) w_fcat,w_event etc are work areas you have to append values to internal table because work area can contains only one record at a time . where as internal table can hold more records.

thats why u cant use w_fcat in place of t_fcat.

Read only

Former Member
0 Likes
1,511

**&---------------------------------------------------------------------**
**& Report Z_ABHI_ALV1 **
**& **
**&---------------------------------------------------------------------**
**& **
**& **
**&---------------------------------------------------------------------**

REPORT z_abhi_alv1 .

TYPE-POOLS :slis.

*******TABLE DECLARATIONS**********

TYPES: BEGIN OF str_kna1,
kunnr TYPE kunnr,
name1 TYPE name1_gp,
land1 TYPE land1_gp,
ort01 TYPE ort01_gp,
END OF str_kna1.

********WORK AREA AND INTERNAL TABLE*******

DATA: w_kna1 TYPE str_kna1,
t_kna1 TYPE STANDARD TABLE OF str_kna1.

********FIELDCATS DECLARATIONS****************

DATA: w_fcat TYPE slis_fieldcat_alv,
t_fcat TYPE slis_t_fieldcat_alv.

*******EVENTS DECLARATIONS******************

DATA: w_event TYPE slis_alv_event,
t_event TYPE slis_t_event.

APPEND W_EVENT TO T_EVENT.
*******LIST HEADER DECLARATIONS**************

DATA: w_listheader TYPE slis_listheader,
t_listheader TYPE slis_t_listheader.

APPEND W_LISTHEADER TO T_LISTHEADER.
******FILLING FCAT**************

w_fcat-col_pos = '1'.
w_fcat-fieldname = 'KUNNR'.
w_fcat-seltext_m = 'CUST NO'.

APPEND w_fcat TO t_fcat.

w_fcat-col_pos = '2'.
w_fcat-fieldname = 'NAME1'.
w_fcat-seltext_m = 'CUST NAME'.

APPEND w_fcat TO t_fcat.

w_fcat-col_pos = '3'.
w_fcat-fieldname = 'LAND1'.
w_fcat-seltext_m = 'COUNTRY'.

APPEND w_fcat TO t_fcat.

w_fcat-col_pos = '4'.
w_fcat-fieldname = 'ORT01'.
w_fcat-seltext_m = 'CITY'.

APPEND w_fcat TO t_fcat.

**********FILLING EVENTS************

w_event-name = 'TOP_OF_PAGE'.
w_event-form = 'SUB1'.

APPEND W_EVENT TO T_EVENT.

*********FILLING COMMENTS**********

w_listheader-typ = 'H'.
w_listheader-info = 'CUSTOMER INFORMATION'.

APPEND W_LISTHEADER TO T_LISTHEADER.

**********DATA EXTRACTION***********

SELECT kunnr
name1
land1
ort01 FROM kna1 INTO TABLE t_kna1.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-CPROG
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = t_fcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
IT_EVENTS = T_EVENT
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = t_kna1
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.

**&--------------------------------------------------------------------**
*& Form SUB1
FORM sub1.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = T_LISTHEADER.
* I_LOGO =
* I_END_OF_LIST_GRID =
.
**&--------------------------------------------------------------------**
* text
**---------------------------------------------------------------------**


ENDFORM.

PLEASE USE CODE TAGS

Read only

Former Member
0 Likes
1,511

For your reference =>How to post code in SCN.

Also, Please feel free for R&D and testing the Code tags in Test & Playground Forum forum .

FOR YOUR INFORMATION.