Application Development 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: 

Steps for Interactive ALV with FM

Former Member
0 Kudos

hi friends,

can any one tell me steps for ALV Interactive report using Function modules

i am having a scenario where i have to display different screens on clicking coreesponding fileds from initial screen

For eg: in my initial screen i have 10 fields

by clicking field1, coressponding detailed data should be displayed in another screen once we back on initial screen

by clicking field2, coressponding detailed data should be displayed in another screen then back to initial screen

and

by clicking fieldn, coressponding detailed data should be displayed in another screen

thanks & regards

Anil kumar

1 ACCEPTED SOLUTION

Former Member
0 Kudos

this is the simple program of interactive ALV ...

you can learn a lot ..which will help you in ur programing .

TABLES: ZAMITCT.",ZAMITFT.

DATA: BEGIN OF T_AMIT_CT OCCURS 0,

NAME TYPE ZAMITCT-NAME,

EMPID TYPE ZAMITCT-EMPID,

AGE TYPE ZAMITCT-AGE,

ROW_NO TYPE I VALUE 0,

END OF T_AMIT_CT.

DATA T_AMIT_FT LIKE TABLE OF ZAMITFT WITH HEADER LINE.

TYPE-POOLS: SLIS.

CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

DATA: WS_TITLE TYPE LVC_TITLE VALUE 'Double click on Name or Empid',

FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

W_FIELDCAT LIKE LINE OF FIELDCAT,

GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV WITH HEADER LINE,

GD_LAYOUT TYPE SLIS_LAYOUT_ALV,

GD_EVENTS TYPE SLIS_T_EVENT,

GD_SORT TYPE SLIS_T_SORTINFO_ALV,

GS_PRINT TYPE SLIS_PRINT_ALV,

GD_REPID LIKE SY-REPID.

START-OF-SELECTION.

PERFORM RETRIEVE_DATA.

PERFORM BUILD_FIELD.

PERFORM EVENTTAB_BUILD USING GD_EVENTS.

PERFORM BUILD_LAYOUT CHANGING GD_LAYOUT.

PERFORM DISPLAY.

&----


*& Form retrieve_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM RETRIEVE_DATA .

DATA: LIN TYPE I.

SELECT * FROM ZAMITCT INTO CORRESPONDING FIELDS OF TABLE T_AMIT_CT.

DESCRIBE TABLE T_AMIT_CT LINES LIN.

IF LIN GT 0.

SORT T_AMIT_CT BY NAME EMPID ASCENDING.

LOOP AT T_AMIT_CT.

T_AMIT_CT-ROW_NO = SY-TABIX.

MODIFY T_AMIT_CT.

ENDLOOP.

ELSE.

SUBMIT ZAMITBIKES2.

ENDIF.

ENDFORM. " retrieve_data

&----


*& Form build_field

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_FIELD .

GD_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = GD_REPID

  • I_INTERNAL_TABNAME = 't_amit_ct'

I_STRUCTURE_NAME = 'ZAMITBIKE'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_INCLNAME =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = FIELDCAT[]

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

LOOP AT FIELDCAT INTO W_FIELDCAT.

W_FIELDCAT-JUST = 'C'.

CASE W_FIELDCAT-FIELDNAME.

WHEN 'ROW_NO'.

W_FIELDCAT-SELTEXT_M = 'ROW_NO'.

W_FIELDCAT-COL_POS = 0.

W_FIELDCAT-KEY = 'X'.

WHEN 'NAME' .

W_FIELDCAT-SELTEXT_M = 'NAME'.

W_FIELDCAT-COL_POS = 1.

W_FIELDCAT-KEY = 'X'.

WHEN 'EMPID'.

W_FIELDCAT-SELTEXT_M = 'EMPID'.

W_FIELDCAT-COL_POS = 2.

W_FIELDCAT-KEY = 'X'.

W_FIELDCAT-HOTSPOT = 'X'.

WHEN 'AGE'.

W_FIELDCAT-SELTEXT_M = 'AGE'.

W_FIELDCAT-COL_POS = 3.

W_FIELDCAT-EMPHASIZE = 'C710'.

W_FIELDCAT-HOTSPOT = 'X'.

ENDCASE.

MODIFY FIELDCAT FROM W_FIELDCAT.

ENDLOOP.

ENDFORM. " build_field

&----


*& Form eventtab_build

&----


  • text

----


  • -->P_GD_EVENTS text

----


FORM EVENTTAB_BUILD USING P_EVENTS TYPE SLIS_T_EVENT.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = P_EVENTS

  • EXCEPTIONS

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

READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_END_OF_LIST INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

MODIFY P_EVENTS FROM LS_EVENT INDEX SY-TABIX.

ENDIF.

ENDFORM. " eventtab_build

&----


*& Form top_of_page

&----


  • text

----


FORM TOP_OF_PAGE.

DATA : P_REPORT_HEADER TYPE SLIS_T_LISTHEADER,

P_REPORT_FOOTER TYPE SLIS_T_LISTHEADER,

GS_LINE TYPE LINE OF SLIS_T_LISTHEADER,

FS_LINE TYPE LINE OF SLIS_T_LISTHEADER.

GS_LINE-TYP = 'H' .

GS_LINE-INFO = 'Employee Details'.

APPEND GS_LINE TO P_REPORT_HEADER.

CLEAR GS_LINE.

GS_LINE-TYP = 'S' .

GS_LINE-INFO = 'Thanks for visiting'.

APPEND GS_LINE TO P_REPORT_HEADER.

CLEAR GS_LINE.

FS_LINE-TYP = 'S' .

FS_LINE-INFO = 'Thanks for visiting'.

APPEND FS_LINE TO P_REPORT_FOOTER.

CLEAR FS_LINE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = P_REPORT_HEADER

I_LOGO = 'WIPROLOGO'

  • I_END_OF_LIST_GRID = 'X'

.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = P_REPORT_FOOTER

I_LOGO = 'WIPRO_LOGO'

I_END_OF_LIST_GRID = 'X'.

ENDFORM. "top_of_page

&----


*& Form build_layout

&----


  • text

----


  • <--P_GD_LAYOUT text

----


FORM BUILD_LAYOUT CHANGING P_GD_LAYOUT.

GD_LAYOUT-NO_INPUT = ''.

GD_LAYOUT-ZEBRA = 'X'.

GD_LAYOUT-HEADER_TEXT = 'My ALV'.

GD_LAYOUT-TOTALS_TEXT = 'Total'(201).

GD_LAYOUT-DETAIL_POPUP = 'X'.

GD_LAYOUT-DETAIL_TITLEBAR = 'Detail List Titlebar'.

ENDFORM. " build_layout

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY .

GD_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = GD_REPID

I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

I_STRUCTURE_NAME = 't_amit_ct'

  • I_BACKGROUND_ID = 't_amit_ct'

I_GRID_TITLE = WS_TITLE

  • I_GRID_SETTINGS =

IS_LAYOUT = GD_LAYOUT

IT_FIELDCAT = FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

IT_EVENTS = GD_EVENTS[]

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

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " DISPLAY

&----


*& Form user_command

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELD text

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE

SLIS_SELFIELD.

CASE SY-UCOMM.

WHEN 'PRV'.

LEAVE TO SCREEN 0.

ENDCASE.

CASE RS_SELFIELD-FIELDNAME.

WHEN 'NAME'.

SELECT * FROM ZAMITFT INTO TABLE T_AMIT_FT WHERE NAME =

RS_SELFIELD-VALUE.

WHEN 'EMPID'.

SELECT * FROM ZAMITFT INTO TABLE T_AMIT_FT WHERE EMPID =

RS_SELFIELD-VALUE.

ENDCASE.

CLEAR: FIELDCAT[],FIELDCAT.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = GD_REPID

I_INTERNAL_TABNAME = 't_amit_ft'

I_STRUCTURE_NAME = 'ZAMITFT'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_INCLNAME =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = FIELDCAT[]

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

LOOP AT FIELDCAT INTO W_FIELDCAT.

W_FIELDCAT-JUST = 'C'.

CASE W_FIELDCAT-FIELDNAME.

WHEN 'NAME'.

W_FIELDCAT-SELTEXT_S = 'NAME'.

W_FIELDCAT-KEY = 'X'.

W_FIELDCAT-COL_POS = 0.

WHEN 'EMPID' .

W_FIELDCAT-SELTEXT_S = 'EMPID'.

W_FIELDCAT-KEY = 'X'.

W_FIELDCAT-COL_POS = 1.

WHEN 'SALARY' .

W_FIELDCAT-SELTEXT_S = 'SALARY'.

W_FIELDCAT-COL_POS = 2.

WHEN 'CITY' .

W_FIELDCAT-SELTEXT_S = 'CITY'.

W_FIELDCAT-COL_POS = 3.

ENDCASE.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = GD_REPID

  • 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 = 't_amit_ft'

I_BACKGROUND_ID = 'BLUE.GIF'

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

IS_LAYOUT = GD_LAYOUT

IT_FIELDCAT = FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

IT_EVENTS = GD_EVENTS

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

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "user_command

&----


*& Form PF_STATUS

&----


  • text

----


  • -->R_STATUS_SET text

----


FORM PF_STATUS USING R_STATUS_SET.

SET PF-STATUS 'STANDARD'.

ENDFORM. "PF_STATUS

7 REPLIES 7

Former Member
0 Kudos

Hi

See the sample code for Interactive ALV list

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

***********************************

report yh645_secndry_alv.

type-pools: slis.

data: fieldcat type slis_t_fieldcat_alv,

fieldcat_ln like line of fieldcat,

fs_layout type slis_layout_alv,

t_layoout like standard table

of fs_layout.

data: begin of fs_spfli,

carrid type spfli-carrid,

connid type spfli-connid,

countryfr type spfli-countryfr,

cityfrom type spfli-cityfrom,

airpfrom type spfli-airpfrom,

countryto type spfli-countryto,

cityto type spfli-cityto,

airpto type spfli-airpto,

fltime type spfli-fltime,

deptime type spfli-deptime,

arrtime type spfli-arrtime,

distance type spfli-distance,

distid type spfli-distid,

fltype type spfli-fltype,

period type spfli-period,

checkbox,

color(3),

end of fs_spfli.

data:

begin of fs_table,

carrid type spfli-carrid,

connid type spfli-connid,

end of fs_table.

data: begin of fs_sflight,

check,

color(3).

include type sflight.

data:end of fs_sflight.

data:

begin of fs_table1,

carrid type sflight-carrid,

connid type sflight-connid,

fldate type sflight-fldate,

end of fs_table1.

data:

t_spfli like standard table

of fs_spfli.

data:

t_table like standard table

of fs_table.

data:

t_table1 like standard table

of fs_table1.

data:

t_sflight like standard table

of fs_sflight.

data:

t_sbook like standard table

of sbook.

data t_layout type slis_layout_alv.

select *

into corresponding fields of table t_spfli

from spfli.

perform start_list_viewer.

perform get_spfli_details.

&----


*& Form SUB1

&----


  • text

----


  • -->RT_EXTAB text

----


form sub1 using rt_extab type slis_t_extab.

data: flight type slis_extab.

flight-fcode = 'SFLIGHT'.

append flight to rt_extab.

set pf-status 'SFLIGHT'. " EXCLUDING RT_EXTAB.

endform. "SUB1

&----


*& Form START_LIST_VIEWER

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form start_list_viewer .

data: pgm like sy-repid.

pgm = sy-repid.

fs_layout-box_fieldname = 'CHECKBOX'.

fs_layout-info_fieldname = 'COLOR'.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = pgm

i_callback_pf_status_set = 'SUB1'

i_callback_user_command = 'USER_COMMAND'

i_structure_name = 'SPFLI'

is_layout = fs_layout

tables

t_outtab = t_spfli

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. " START_LIST_VIEWER

*******Process Call Back Events (Begin)**************************

form user_command using ucomm like sy-ucomm

selfield type slis_selfield.

case ucomm.

when 'SFLIGHT'.

selfield-refresh = 'X'.

perform get_spfli_details.

select *

from sflight

into corresponding fields of table t_sflight

for all entries in t_table

where carrid eq t_table-carrid

and connid eq t_table-connid.

perform display_sflight.

when 'SBOOK'.

selfield-refresh = 'X'.

perform get_sflight_details.

select *

from sbook

into corresponding fields of table t_sbook

for all entries in t_table1

where carrid eq t_table1-carrid

and connid eq t_table1-connid

and fldate eq t_table1-fldate.

perform display_sbook.

endcase.

endform. "USER_COMMAND

&----


*& Form SUB2

&----


  • text

----


  • -->RT_EXTAB text

----


form sub2 using rt_extab type slis_t_extab.

data: flight type slis_extab.

flight-fcode = 'SBOOK'.

append flight to rt_extab.

set pf-status 'SBOOK'. " EXCLUDING RT_EXTAB.

endform. "SUB2

&----


*& Form DISPLAY_SFLIGHT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_sflight .

data: pgm like sy-repid.

pgm = sy-repid.

clear t_layout.

fs_layout-box_fieldname = 'CHECK'.

fs_layout-info_fieldname = 'COLOR'.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = pgm

i_callback_pf_status_set = 'SUB2'

i_callback_user_command = 'USER_COMMAND'

i_structure_name = 'SFLIGHT'

is_layout = fs_layout

tables

t_outtab = t_sflight

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. " DISPLAY_SFLIGHT

&----


*& Form GET_SPFLI_DETAILS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_spfli_details .

loop at t_spfli into fs_spfli.

if fs_spfli-checkbox = 'X'.

fs_spfli-color = 'C51'.

fs_spfli-checkbox = '1'.

fs_table-carrid = fs_spfli-carrid.

fs_table-connid = fs_spfli-connid.

append fs_table to t_table.

modify t_spfli from fs_spfli.

endif.

endloop.

endform. " GET_SFLIGHT_DETAILS

&----


*& Form GET_SFLIGHT_DETAILS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form get_sflight_details .

loop at t_sflight into fs_sflight.

if fs_sflight-check = 'X'.

fs_sflight-color = 'C71'.

fs_sflight-check = '1'.

fs_table1-carrid = fs_sflight-carrid.

fs_table1-connid = fs_sflight-connid.

fs_table1-fldate = fs_sflight-fldate.

append fs_table1 to t_table1.

modify t_sflight from fs_sflight.

endif.

endloop.

endform. " GET_SFLIGHT_DETAILS

&----


*& Form DISPLAY_SBOOK

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form display_sbook .

data: pgm like sy-repid.

pgm = sy-repid.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_callback_program = pgm

i_structure_name = 'SBOOK'

tables

t_outtab = t_sbook

exceptions

program_error = 1

others = 2.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endform. " DISPLAY_SBOOK

Reward points if useful

Regards

Anji

Message was edited by:

Anji Reddy Vangala

Former Member
0 Kudos

&----


*& Report ZSR_ALV_INTERACTIVE

*&

&----


*&

*&

&----


REPORT ZSR_ALV_INTERACTIVE.

TABLES : LFA1,EKKO,EKPO.

SELECT-OPTIONS : VENDOR FOR LFA1-LIFNR.

DATA : BEGIN OF ITAB OCCURS 0,

LIFNR LIKE LFA1-LIFNR,

NAME1 LIKE LFA1-NAME1,

END OF ITAB.

DATA : BEGIN OF JTAB OCCURS 0,

EBELN LIKE EKKO-EBELN,

AEDAT LIKE EKKO-AEDAT,

END OF JTAB.

DATA : BEGIN OF KTAB OCCURS 0,

EBELP LIKE EKPO-EBELP,

MATNR LIKE EKPO-MATNR,

END OF KTAB.

TYPE-POOLS : SLIS.

DATA : REPID LIKE SY-REPID.

DATA :LFA1_B TYPE SLIS_T_FIELDCAT_ALV,

LFA1_W TYPE SLIS_FIELDCAT_ALV,

EKKO_B TYPE SLIS_T_FIELDCAT_ALV,

EKKO_W TYPE SLIS_FIELDCAT_ALV,

EKPO_B TYPE SLIS_T_FIELDCAT_ALV,

EKPO_W TYPE SLIS_FIELDCAT_ALV,

EVENTS_B TYPE SLIS_T_EVENT,

EVENTS_W TYPE SLIS_ALV_EVENT.

PERFORM GET_VAL.

REPID = SY-REPID.

SELECT LIFNR NAME1 FROM LFA1 INTO TABLE ITAB WHERE LIFNR IN VENDOR.

*perform val USING USER_COMMAND sel.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = REPID

IT_FIELDCAT = LFA1_B

IT_EVENTS = EVENTS_B

TABLES

T_OUTTAB = ITAB.

&----


*& Form GET_VAL

&----


  • text this is to put column headings

----


FORM GET_VAL.

LFA1_W-FIELDNAME = 'LIFNR'.

LFA1_W-REF_TABNAME = 'LFA1'.

LFA1_W-REF_FIELDNAME = 'LIFNR'.

APPEND LFA1_W TO LFA1_B.

LFA1_W-FIELDNAME = 'NAME1'.

LFA1_W-REF_TABNAME = 'LFA1'.

LFA1_W-REF_FIELDNAME = 'NAME1'.

APPEND LFA1_W TO LFA1_B.

EKKO_W-FIELDNAME = 'EBELN'.

EKKO_W-REF_TABNAME = 'EKKO'.

EKKO_W-REF_FIELDNAME = 'EBELN'.

APPEND EKKO_W TO EKKO_B.

EKKO_W-FIELDNAME = 'AEDAT'.

EKKO_W-REF_TABNAME = 'EKKO'.

EKKO_W-REF_FIELDNAME = 'AEDAT'.

APPEND EKKO_W TO EKKO_B.

EKPO_W-FIELDNAME = 'EBELP'.

EKPO_W-REF_TABNAME = 'EKPO'.

EKPO_W-REF_FIELDNAME = 'EBELP'.

APPEND EKPO_W TO EKPO_B.

EKPO_W-FIELDNAME = 'MATNR'.

EKPO_W-REF_TABNAME = 'EKPO'.

EKPO_W-REF_FIELDNAME = 'MATNR'.

APPEND EKPO_W TO EKPO_B.

EVENTS_W-NAME = 'USER_COMMAND'.

EVENTS_W-FORM = 'VAL'.

APPEND EVENTS_W TO EVENTS_B.

ENDFORM. "GET_VAL

&----


*& Form VAL

&----


  • text

----


  • -->USER_COMMANtext

  • -->SEL text for retrieving data

----


FORM VAL USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.

DATA : VEN(10) TYPE N,

PO(10) TYPE N.

DATA : MAT(10) TYPE C.

IF SEL-FIELDNAME = 'LIFNR'.

VEN = SEL-VALUE.

SELECT EBELN AEDAT FROM EKKO INTO TABLE JTAB WHERE LIFNR = VEN.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = REPID

  • I_STRUCTURE_NAME = EKKO_B

IT_FIELDCAT = EKKO_B

IT_EVENTS = EVENTS_B

TABLES

T_OUTTAB = JTAB.

ENDIF.

IF SEL-FIELDNAME = 'EBELN'.

PO = SEL-VALUE.

SELECT EBELP MATNR FROM EKPO INTO TABLE KTAB WHERE EBELN = PO.

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'

EXPORTING

I_TITLE = 'ITEM DETAILS'

I_TABNAME = 'EKPO'

IT_FIELDCAT = EKPO_B

I_CALLBACK_PROGRAM = REPID

IMPORTING

ES_SELFIELD = SEL

TABLES

T_OUTTAB = KTAB.

ENDIF.

  • logic to select a record

IF SEL-FIELDNAME = 'MATNR'.

MAT = SEL-VALUE.

SET PARAMETER ID 'MAT' FIELD MAT.

CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.

ENDIF.

ENDFORM. "VAL

santhosh

Former Member
0 Kudos

Check this example program....

BALVSD11

Former Member
0 Kudos

this is the simple program of interactive ALV ...

you can learn a lot ..which will help you in ur programing .

TABLES: ZAMITCT.",ZAMITFT.

DATA: BEGIN OF T_AMIT_CT OCCURS 0,

NAME TYPE ZAMITCT-NAME,

EMPID TYPE ZAMITCT-EMPID,

AGE TYPE ZAMITCT-AGE,

ROW_NO TYPE I VALUE 0,

END OF T_AMIT_CT.

DATA T_AMIT_FT LIKE TABLE OF ZAMITFT WITH HEADER LINE.

TYPE-POOLS: SLIS.

CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.

DATA: WS_TITLE TYPE LVC_TITLE VALUE 'Double click on Name or Empid',

FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

W_FIELDCAT LIKE LINE OF FIELDCAT,

GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV WITH HEADER LINE,

GD_LAYOUT TYPE SLIS_LAYOUT_ALV,

GD_EVENTS TYPE SLIS_T_EVENT,

GD_SORT TYPE SLIS_T_SORTINFO_ALV,

GS_PRINT TYPE SLIS_PRINT_ALV,

GD_REPID LIKE SY-REPID.

START-OF-SELECTION.

PERFORM RETRIEVE_DATA.

PERFORM BUILD_FIELD.

PERFORM EVENTTAB_BUILD USING GD_EVENTS.

PERFORM BUILD_LAYOUT CHANGING GD_LAYOUT.

PERFORM DISPLAY.

&----


*& Form retrieve_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM RETRIEVE_DATA .

DATA: LIN TYPE I.

SELECT * FROM ZAMITCT INTO CORRESPONDING FIELDS OF TABLE T_AMIT_CT.

DESCRIBE TABLE T_AMIT_CT LINES LIN.

IF LIN GT 0.

SORT T_AMIT_CT BY NAME EMPID ASCENDING.

LOOP AT T_AMIT_CT.

T_AMIT_CT-ROW_NO = SY-TABIX.

MODIFY T_AMIT_CT.

ENDLOOP.

ELSE.

SUBMIT ZAMITBIKES2.

ENDIF.

ENDFORM. " retrieve_data

&----


*& Form build_field

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM BUILD_FIELD .

GD_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = GD_REPID

  • I_INTERNAL_TABNAME = 't_amit_ct'

I_STRUCTURE_NAME = 'ZAMITBIKE'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_INCLNAME =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = FIELDCAT[]

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

LOOP AT FIELDCAT INTO W_FIELDCAT.

W_FIELDCAT-JUST = 'C'.

CASE W_FIELDCAT-FIELDNAME.

WHEN 'ROW_NO'.

W_FIELDCAT-SELTEXT_M = 'ROW_NO'.

W_FIELDCAT-COL_POS = 0.

W_FIELDCAT-KEY = 'X'.

WHEN 'NAME' .

W_FIELDCAT-SELTEXT_M = 'NAME'.

W_FIELDCAT-COL_POS = 1.

W_FIELDCAT-KEY = 'X'.

WHEN 'EMPID'.

W_FIELDCAT-SELTEXT_M = 'EMPID'.

W_FIELDCAT-COL_POS = 2.

W_FIELDCAT-KEY = 'X'.

W_FIELDCAT-HOTSPOT = 'X'.

WHEN 'AGE'.

W_FIELDCAT-SELTEXT_M = 'AGE'.

W_FIELDCAT-COL_POS = 3.

W_FIELDCAT-EMPHASIZE = 'C710'.

W_FIELDCAT-HOTSPOT = 'X'.

ENDCASE.

MODIFY FIELDCAT FROM W_FIELDCAT.

ENDLOOP.

ENDFORM. " build_field

&----


*& Form eventtab_build

&----


  • text

----


  • -->P_GD_EVENTS text

----


FORM EVENTTAB_BUILD USING P_EVENTS TYPE SLIS_T_EVENT.

DATA: LS_EVENT TYPE SLIS_ALV_EVENT.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = P_EVENTS

  • EXCEPTIONS

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

READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_END_OF_LIST INTO LS_EVENT.

IF SY-SUBRC = 0.

MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.

MODIFY P_EVENTS FROM LS_EVENT INDEX SY-TABIX.

ENDIF.

ENDFORM. " eventtab_build

&----


*& Form top_of_page

&----


  • text

----


FORM TOP_OF_PAGE.

DATA : P_REPORT_HEADER TYPE SLIS_T_LISTHEADER,

P_REPORT_FOOTER TYPE SLIS_T_LISTHEADER,

GS_LINE TYPE LINE OF SLIS_T_LISTHEADER,

FS_LINE TYPE LINE OF SLIS_T_LISTHEADER.

GS_LINE-TYP = 'H' .

GS_LINE-INFO = 'Employee Details'.

APPEND GS_LINE TO P_REPORT_HEADER.

CLEAR GS_LINE.

GS_LINE-TYP = 'S' .

GS_LINE-INFO = 'Thanks for visiting'.

APPEND GS_LINE TO P_REPORT_HEADER.

CLEAR GS_LINE.

FS_LINE-TYP = 'S' .

FS_LINE-INFO = 'Thanks for visiting'.

APPEND FS_LINE TO P_REPORT_FOOTER.

CLEAR FS_LINE.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = P_REPORT_HEADER

I_LOGO = 'WIPROLOGO'

  • I_END_OF_LIST_GRID = 'X'

.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

IT_LIST_COMMENTARY = P_REPORT_FOOTER

I_LOGO = 'WIPRO_LOGO'

I_END_OF_LIST_GRID = 'X'.

ENDFORM. "top_of_page

&----


*& Form build_layout

&----


  • text

----


  • <--P_GD_LAYOUT text

----


FORM BUILD_LAYOUT CHANGING P_GD_LAYOUT.

GD_LAYOUT-NO_INPUT = ''.

GD_LAYOUT-ZEBRA = 'X'.

GD_LAYOUT-HEADER_TEXT = 'My ALV'.

GD_LAYOUT-TOTALS_TEXT = 'Total'(201).

GD_LAYOUT-DETAIL_POPUP = 'X'.

GD_LAYOUT-DETAIL_TITLEBAR = 'Detail List Titlebar'.

ENDFORM. " build_layout

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY .

GD_REPID = SY-REPID.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = GD_REPID

I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'

I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

I_STRUCTURE_NAME = 't_amit_ct'

  • I_BACKGROUND_ID = 't_amit_ct'

I_GRID_TITLE = WS_TITLE

  • I_GRID_SETTINGS =

IS_LAYOUT = GD_LAYOUT

IT_FIELDCAT = FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

IT_EVENTS = GD_EVENTS[]

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

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " DISPLAY

&----


*& Form user_command

&----


  • text

----


  • -->R_UCOMM text

  • -->RS_SELFIELD text

----


FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE

SLIS_SELFIELD.

CASE SY-UCOMM.

WHEN 'PRV'.

LEAVE TO SCREEN 0.

ENDCASE.

CASE RS_SELFIELD-FIELDNAME.

WHEN 'NAME'.

SELECT * FROM ZAMITFT INTO TABLE T_AMIT_FT WHERE NAME =

RS_SELFIELD-VALUE.

WHEN 'EMPID'.

SELECT * FROM ZAMITFT INTO TABLE T_AMIT_FT WHERE EMPID =

RS_SELFIELD-VALUE.

ENDCASE.

CLEAR: FIELDCAT[],FIELDCAT.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = GD_REPID

I_INTERNAL_TABNAME = 't_amit_ft'

I_STRUCTURE_NAME = 'ZAMITFT'

  • I_CLIENT_NEVER_DISPLAY = 'X'

  • I_INCLNAME =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

CHANGING

CT_FIELDCAT = FIELDCAT[]

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

LOOP AT FIELDCAT INTO W_FIELDCAT.

W_FIELDCAT-JUST = 'C'.

CASE W_FIELDCAT-FIELDNAME.

WHEN 'NAME'.

W_FIELDCAT-SELTEXT_S = 'NAME'.

W_FIELDCAT-KEY = 'X'.

W_FIELDCAT-COL_POS = 0.

WHEN 'EMPID' .

W_FIELDCAT-SELTEXT_S = 'EMPID'.

W_FIELDCAT-KEY = 'X'.

W_FIELDCAT-COL_POS = 1.

WHEN 'SALARY' .

W_FIELDCAT-SELTEXT_S = 'SALARY'.

W_FIELDCAT-COL_POS = 2.

WHEN 'CITY' .

W_FIELDCAT-SELTEXT_S = 'CITY'.

W_FIELDCAT-COL_POS = 3.

ENDCASE.

ENDLOOP.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = GD_REPID

  • 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 = 't_amit_ft'

I_BACKGROUND_ID = 'BLUE.GIF'

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

IS_LAYOUT = GD_LAYOUT

IT_FIELDCAT = FIELDCAT[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

I_DEFAULT = 'X'

I_SAVE = 'A'

  • IS_VARIANT =

IT_EVENTS = GD_EVENTS

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

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "user_command

&----


*& Form PF_STATUS

&----


  • text

----


  • -->R_STATUS_SET text

----


FORM PF_STATUS USING R_STATUS_SET.

SET PF-STATUS 'STANDARD'.

ENDFORM. "PF_STATUS

former_member198270
Active Contributor
0 Kudos

hi Anil ,

Please find the 2 level drill down interactive alv program code

************************************************************************

--


GLOBAL DECLARATIONS--

************************************************************************

  • THIS DEFINES GLOBAL TYPES FOR ALV.

TYPE-POOLS: slis.

  • TRANSPARENT TABLES USED FOR DATA FETCHING

TABLES: ekko,ekpo,eket,lfa1,ekbe.

DATA : i_fieldcat TYPE slis_t_fieldcat_alv," FOR FIELDCATALOG

i2_fieldcat TYPE slis_t_fieldcat_alv,"FOR FIELDCATALOG 2

i3_fieldcat TYPE slis_t_fieldcat_alv, "FOR FIELDCATALOG 3

i_eventcat TYPE slis_t_event, "FOR EVENTCATALOG

i_layout TYPE slis_layout_alv, "FOR LAYOUT

i_sortinfo TYPE slis_t_sortinfo_alv. "FOR SORTING

  • VARIABLE FOR COUNT OF PO

DATA: n TYPE i ,

i TYPE i,

po_item TYPE ebelp,

v_count(1) VALUE 'N'.

*********************************************************************

--


TYPES--

*********************************************************************

--


DATA DECLARATION FOR VENDOR MASTER--

TYPES: BEGIN OF t_lfa1,

lifnr TYPE lifnr, "VENDOR CODE

name1 TYPE name1_gp, "VENDOR NAME

END OF t_lfa1.

--


DATA DECLARATION FOR HEADER(EKKO)--

TYPES: BEGIN OF t_ekko,

ebeln TYPE ebeln, "PURCHASE ORDER NUMBER

lifnr TYPE elifn, "VENDOR CODE

c TYPE i, "PURCHASE ORDER COUNT

END OF t_ekko.

--


DATA DECLARATION FOR DETAIL(EKPO)--

TYPES: BEGIN OF t_ekpo,

ebeln TYPE ebeln, "PURCHASE ORDER NUMBER

ebelp TYPE ebelp, "PURCHASE ORDER ITEM

menge TYPE bstmg, "PURCHASE ORDER QTY

END OF t_ekpo,

--


DATA DECLARATION FOR EKET TABLE--

BEGIN OF t_eket,

ebeln TYPE ebeln, "PURCHASE ORDER NUMBER

ebelp TYPE ebelp, "PURCHASE ORDER ITEM

etenr TYPE eeten, "DELIVERY SCHEDULE LINE COUNTER

wemng TYPE weemg, "QUANTITY OF GOODS RECIEVED

END OF t_eket ,

*----


DATA DECLARATION FOR FINAL TABLE(FIRST

SCREEN)----


BEGIN OF t_tab,

lifnr TYPE elifn,

ebeln TYPE ebeln,

name1 TYPE name1_gp,

ebelp TYPE ebelp,

menge TYPE bstmg,

etenr TYPE eeten,

wemng TYPE weemg,

c TYPE i,

END OF t_tab.

--


DATA DECLARATION FOR FINAL TABLE (SECOND SCREEN)---

TYPES: BEGIN OF t_vendor,

lifnr TYPE elifn,

ebeln TYPE ebeln,

ebelp TYPE ebelp,

menge TYPE bstmg,

wemng TYPE p,

END OF t_vendor,

--


DATA DECLARATION FOR EKBE--

BEGIN OF t_ekbe,

ebeln TYPE ebeln,

ebelp TYPE ebelp,

bwart TYPE bwart,

menge TYPE menge_d,

END OF t_ekbe.

*********************************************************************

--


WORK AREA--

*********************************************************************

DATA : wa_lfa1 TYPE t_lfa1,

wa_ekko TYPE t_ekko,

wa_ekpo TYPE t_ekpo,

wa_eket TYPE t_eket,

wa_tab TYPE t_tab,

wa_vendor TYPE t_vendor,

wa_ekbe TYPE t_ekbe,

wa_grn TYPE t_ekbe,

wa_full TYPE t_vendor.

*********************************************************************

--


INTERNAL TABLES--

*********************************************************************

DATA: it_lfa1 TYPE STANDARD TABLE OF t_lfa1 WITH HEADER LINE ,

it_ekko TYPE STANDARD TABLE OF t_ekko WITH HEADER LINE ,

it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE,

it_eket TYPE STANDARD TABLE OF t_eket WITH HEADER LINE,

it_tab TYPE STANDARD TABLE OF t_tab WITH HEADER LINE,

it_vendor TYPE STANDARD TABLE OF t_vendor WITH HEADER LINE,

it_ekbe TYPE STANDARD TABLE OF t_ekbe WITH HEADER LINE,

it_grn TYPE STANDARD TABLE OF t_ekbe WITH HEADER LINE,

it_full TYPE STANDARD TABLE OF t_vendor WITH HEADER LINE.

DATA: vendor TYPE elifn.

DATA: qty TYPE p,

c TYPE i.

*********************************************************************

--


SELECTION SCREEN--

**********************************************************************

SELECTION-SCREEN BEGIN OF BLOCK main WITH FRAME TITLE text-001.

SELECT-OPTIONS : s_lifnr FOR lfa1-lifnr OBLIGATORY.

SELECTION-SCREEN END OF BLOCK main.

*********************************************************************

--


AT SELECTION-SCREEN--

*********************************************************************

AT SELECTION-SCREEN.

SELECT lifnr INTO (it_lfa1-lifnr) FROM lfa1 WHERE lifnr IN

s_lifnr.

ENDSELECT.

IF sy-subrc <> 0.

MESSAGE e001.

ENDIF.

*********************************************************************

--


START-OF-SELECTION--

*********************************************************************

START-OF-SELECTION.

  • FETCH RECORDS FROM THE DATABASE INTO THE INTERNAL TABLE.

PERFORM zf_select_it_tab.

  • PREPARE FIELDCATALOG FOR THE MAIN (1ST LIST) REPORT.

PERFORM zf_build_fieldcat USING i_fieldcat.

  • DEFINE EVENT TABLE

PERFORM build_eventcat USING i_eventcat.

  • DETERMINE THE SORTING SEQUENCE.

PERFORM build_sort USING i_sortinfo.

  • DISPLAY ALV GRID.

PERFORM zf_display_alv_list.

&----


*& Form ZF_SELECT_IT_TAB

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


*SELECTING DATA FROM IT_LFA1 TABLE

FORM zf_select_it_tab .

SELECT lifnr

name1

INTO TABLE it_lfa1

FROM lfa1

WHERE lifnr IN s_lifnr.

IF sy-subrc = 0.

SORT it_lfa1 BY lifnr.

ENDIF.

*SELECTING DATA FROM EKKO TABLE

IF NOT it_lfa1[] IS INITIAL.

SELECT

ebeln

lifnr

FROM ekko

INTO TABLE it_ekko

FOR ALL ENTRIES IN it_lfa1

WHERE lifnr = it_lfa1-lifnr.

IF sy-subrc = 0.

SORT it_ekko BY ebeln.

ENDIF.

ENDIF.

*SELECTING DATA FROM EKPO TABLE

IF NOT it_ekko[] IS INITIAL.

SELECT

ebeln

ebelp

menge

FROM ekpo

INTO TABLE it_ekpo

FOR ALL ENTRIES IN it_ekko

WHERE ebeln = it_ekko-ebeln.

IF sy-subrc = 0.

SORT it_ekpo BY ebeln ebelp.

ENDIF.

ENDIF.

*SELECTING DATA FROM EKET TABLE

IF NOT it_ekpo[] IS INITIAL.

SELECT

ebeln

ebelp

etenr

wemng

FROM eket

INTO TABLE it_eket

FOR ALL ENTRIES IN it_ekpo

WHERE ebeln = it_ekpo-ebeln

AND ebelp = it_ekpo-ebelp.

SORT it_eket BY ebeln ebelp etenr.

ENDIF.

*SELECTING DATA FROM EKBE TABLE

IF NOT it_eket[] IS INITIAL.

SELECT

ebeln

ebelp

bwart

menge

FROM ekbe

INTO TABLE it_ekbe

FOR ALL ENTRIES IN it_eket

WHERE ebelp = it_eket-ebelp

AND ebeln = it_eket-ebeln

AND bwart = '101'.

ENDIF.

*********************************************************

  • THIS BLOCK MOVES THE FIELDS FROM DIFFERENT *

  • TABLES(EKKO,LFA1,EKPO,EKET) INTO A FINAL TABLE IT_TAB *

  • *

*********************************************************

CLEAR wa_tab.

CLEAR it_tab.

LOOP AT it_lfa1 INTO wa_lfa1.

READ TABLE it_ekko INTO wa_ekko WITH KEY lifnr = wa_lfa1-lifnr

BINARY SEARCH.

READ TABLE it_lfa1 INTO wa_lfa1

WITH KEY lifnr = wa_lfa1-lifnr

BINARY SEARCH.

IF sy-subrc = 0.

MOVE: wa_lfa1-name1 TO wa_tab-name1.

MOVE: wa_lfa1-lifnr TO wa_tab-lifnr.

ENDIF.

APPEND wa_tab TO it_tab.

CLEAR : wa_tab,wa_lfa1.

ENDLOOP.

**READ FOR SECOND SCREEN

REFRESH it_full.

CLEAR : wa_full,

wa_eket,

wa_ekpo.

LOOP AT it_eket INTO wa_eket.

READ TABLE it_ekpo INTO wa_ekpo WITH KEY ebeln = wa_eket-ebeln

ebelp = wa_eket-ebelp

BINARY SEARCH.

IF sy-subrc = 0.

READ TABLE it_ekko INTO wa_ekko WITH KEY ebeln =

wa_ekpo-ebeln

BINARY SEARCH.

IF sy-subrc = 0.

READ TABLE it_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_ekko-lifnr

BINARY SEARCH.

IF sy-subrc = 0.

wa_full-ebelp = wa_ekpo-ebelp.

wa_full-menge = wa_ekpo-menge.

wa_full-lifnr = wa_lfa1-lifnr.

wa_full-ebeln = wa_ekko-ebeln.

wa_full-wemng = wa_eket-wemng.

ENDIF.

ENDIF.

ENDIF.

APPEND wa_full TO it_full.

CLEAR : wa_ekko,wa_ekpo,wa_eket,wa_full.

ENDLOOP.

  • COUNT OF PO

LOOP AT it_tab.

LOOP AT it_ekko WHERE lifnr = it_tab-lifnr.

c = c + 1.

ENDLOOP.

it_tab-c = c.

MODIFY it_tab TRANSPORTING c.

CLEAR c.

ENDLOOP.

ENDFORM. " ZF_SELECT_IT_TAB

&----


*& Form ZF_BUILD_FIELDCAT

&----


  • FIELD CATALOG FOR FIRST SCREEN

----


  • -->P_I_FIELDCAT text

----


FORM zf_build_fieldcat USING p_i_fieldcat TYPE slis_t_fieldcat_alv.

REFRESH p_i_fieldcat.

DATA: l_fieldcat TYPE slis_fieldcat_alv.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '1'.

l_fieldcat-fieldname = 'LIFNR'.

l_fieldcat-tabname = 'IT_TAB'.

l_fieldcat-key = 'X'.

l_fieldcat-emphasize = 'C410'.

l_fieldcat-seltext_l = 'VENDOR CODE'.

l_fieldcat-outputlen = 20.

APPEND l_fieldcat TO p_i_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '2'.

l_fieldcat-fieldname = 'NAME1'.

l_fieldcat-tabname = 'IT_TAB'.

l_fieldcat-emphasize = 'C410'.

l_fieldcat-seltext_l = 'VENDOR NAME'.

l_fieldcat-outputlen = 20.

APPEND l_fieldcat TO p_i_fieldcat.

CLEAR l_fieldcat.

l_fieldcat-col_pos = '3'.

l_fieldcat-fieldname = 'C'.

l_fieldcat-tabname = 'IT_TAB'.

l_fieldcat-emphasize = 'C410'.

l_fieldcat-seltext_l = 'PO COUNT'.

l_fieldcat-outputlen = 10.

APPEND l_fieldcat TO p_i_fieldcat.

ENDFORM. " ZF_BUILD_FIELDCAT

&----


*& Form ZF_DISPLAY_ALV_LIST

&----


  • CALLING FUNCTION FOR ALV GRID DISPLAY

----


  • --> p1 text

  • <-- p2 text

----


FORM zf_display_alv_list .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = 'Z8AS_SHADOW_ALV_INTERACTIVE'

i_callback_user_command = 'USER_COMMAND'

is_layout = i_layout

it_fieldcat = i_fieldcat

it_events = i_eventcat

TABLES

t_outtab = it_tab

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " ZF_DISPLAY_ALV_LIST

&----


*& Form BUILD_SORT

&----


  • SORTING OUTPUT BY PURCHASE ORDER AND LINE ITEM

----


  • -->P_I_SORTINFO text

----


FORM build_sort USING p_i_sortinfo TYPE slis_t_sortinfo_alv.

REFRESH p_i_sortinfo.

DATA: l_sortinfo TYPE slis_sortinfo_alv.

CLEAR l_sortinfo.

l_sortinfo-spos = '1'.

l_sortinfo-fieldname = 'LIFNR'.

l_sortinfo-tabname = 'IT_VENDOR'.

l_sortinfo-up = 'X'.

l_sortinfo-group = 'UL'.

APPEND l_sortinfo TO p_i_sortinfo.

CLEAR l_sortinfo.

l_sortinfo-spos = '2'.

l_sortinfo-fieldname = 'EBELN'.

l_sortinfo-tabname = 'IT_VENDOR'.

l_sortinfo-up = 'X'.

l_sortinfo-group = 'UL'.

APPEND l_sortinfo TO p_i_sortinfo.

ENDFORM. " BUILD_SORT

&----


*& Form BUILD_EVENTCAT

&----


*

----


  • -->P_I_EVENTCAT text

----


FORM build_eventcat USING p_i_eventcat TYPE slis_t_event.

REFRESH p_i_eventcat.

DATA: i_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = p_i_eventcat

EXCEPTIONS

list_type_wrong = 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.

CLEAR i_event.

READ TABLE p_i_eventcat WITH KEY name = slis_ev_user_command INTO

i_event.

IF sy-subrc = 0.

MOVE 'USER_COMMAND' TO i_event-form.

APPEND i_event TO p_i_eventcat.

ENDIF.

ENDFORM. " BUILD_EVENTCAT

&----


*& FORM USER_COMMAND

&----


FORM user_command USING p_ucomm TYPE sy-ucomm

p_selfield TYPE slis_selfield.

CASE p_ucomm.

WHEN '&IC1'.

READ TABLE it_tab INTO wa_tab INDEX p_selfield-tabindex.

IF p_selfield-fieldname = 'LIFNR'.

vendor = p_selfield-value.

PERFORM zf_vendor_details.

PERFORM zf2_build_fieldcat USING i2_fieldcat.

PERFORM zf_display_grid.

ENDIF.

CLEAR p_selfield.

ENDCASE.

ENDFORM. " ZF_USER_COMMAND

&----


*& Form ZF_VENDOR_DETAILS

&----


  • THIS FORM IS USED FOR MOVING DATA FROM IT_TAB TO IT_VENDOR

----


  • --> p1 text

  • <-- p2 text

----


FORM zf_vendor_details .

CLEAR wa_ekko.

CLEAR it_ekko.

REFRESH it_vendor.

LOOP AT it_full INTO wa_full WHERE lifnr = vendor.

MOVE :

wa_full-lifnr TO wa_vendor-lifnr,

wa_full-ebeln TO wa_vendor-ebeln,

wa_full-ebelp TO wa_vendor-ebelp,

wa_full-menge TO wa_vendor-menge,

wa_full-wemng TO wa_vendor-wemng.

APPEND wa_vendor TO it_vendor.

CLEAR : wa_vendor.

ENDLOOP.

ENDFORM. " ZF_VENDOR_DETAILS

&----


*& Form ZF2_BUILD_FIELDCAT

&----


  • THIS FORM IS USED FOR CATALOG SCREEN 2

----


  • -->P_I_FIELDCAT text

----


FORM zf2_build_fieldcat USING p_i_fieldcat TYPE slis_t_fieldcat_alv.

REFRESH p_i_fieldcat.

DATA: l2_fieldcat TYPE slis_fieldcat_alv.

CLEAR l2_fieldcat.

l2_fieldcat-col_pos = '1'.

l2_fieldcat-fieldname = 'LIFNR'.

l2_fieldcat-tabname = 'IT_VENDOR'.

l2_fieldcat-key = 'X'.

l2_fieldcat-emphasize = 'C410'.

l2_fieldcat-seltext_l = 'VENDOR CODE'.

l2_fieldcat-outputlen = 20.

APPEND l2_fieldcat TO p_i_fieldcat.

CLEAR l2_fieldcat.

l2_fieldcat-col_pos = '2'.

l2_fieldcat-fieldname = 'EBELN'.

l2_fieldcat-tabname = 'IT_VENDOR'.

l2_fieldcat-key = 'X'.

l2_fieldcat-emphasize = 'C410'.

l2_fieldcat-seltext_l = 'PURCHASE ORDER NUMBER'.

l2_fieldcat-outputlen = 20.

APPEND l2_fieldcat TO p_i_fieldcat.

CLEAR l2_fieldcat.

l2_fieldcat-col_pos = '3'.

l2_fieldcat-fieldname = 'EBELP'.

l2_fieldcat-tabname = 'IT_VENDOR'.

l2_fieldcat-key = 'X'.

l2_fieldcat-emphasize = 'C710'.

l2_fieldcat-seltext_l = 'PO ITEM'.

l2_fieldcat-outputlen = 20.

APPEND l2_fieldcat TO p_i_fieldcat.

CLEAR l2_fieldcat.

l2_fieldcat-col_pos = '4'.

l2_fieldcat-fieldname = 'MENGE'.

l2_fieldcat-tabname = 'IT_VENDOR'.

l2_fieldcat-key = 'X'.

l2_fieldcat-emphasize = 'C410'.

l2_fieldcat-seltext_l = 'PO QTY'.

l2_fieldcat-outputlen = 20.

APPEND l2_fieldcat TO p_i_fieldcat.

CLEAR l2_fieldcat.

l2_fieldcat-col_pos = '5'.

l2_fieldcat-fieldname = 'WEMNG'.

l2_fieldcat-tabname = 'IT_VENDOR'.

l2_fieldcat-key = 'X'.

l2_fieldcat-emphasize = 'C450'.

l2_fieldcat-seltext_l = 'QTY RECIEVED'.

l2_fieldcat-outputlen = 20.

APPEND l2_fieldcat TO p_i_fieldcat.

CLEAR l2_fieldcat.

ENDFORM. "ZF2_BUILD_FIELDCAT

&----


*& Form ZF_DISPLAY_ALV_LIST

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM zf_display_grid .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = 'Z8AS_SHADOW_ALV_INTERACTIVE'

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USER_COMMAND1'

it_fieldcat = i2_fieldcat

it_sort = i_sortinfo

  • IMPORTING

TABLES

t_outtab = it_vendor

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. "ZF_DISPLAY_GRID

&----


*& FORM USER_COMMAND1

&----


FORM user_command1 USING p_ucomm TYPE sy-ucomm

p_selfield TYPE slis_selfield.

CASE p_ucomm.

WHEN '&IC1'.

READ TABLE it_vendor INTO wa_vendor INDEX p_selfield-tabindex.

IF p_selfield-fieldname = 'WEMNG'.

po_item = wa_vendor-ebelp.

PERFORM zf_grn.

PERFORM zf3_build_fieldcat USING i3_fieldcat.

PERFORM zf1_display_grid.

ENDIF.

ENDCASE.

ENDFORM. " ZF_USER_COMMAND

&----


*& Form ZF3_BUILD_FIELDCAT

&----


  • FIELD CATALOG FOR THIRD SCREEN

----


  • -->P_I3_FIELDCAT text

----


FORM zf3_build_fieldcat USING p_i_fieldcat TYPE slis_t_fieldcat_alv

.

REFRESH p_i_fieldcat.

DATA: l3_fieldcat TYPE slis_fieldcat_alv.

CLEAR l3_fieldcat.

l3_fieldcat-col_pos = '1'.

l3_fieldcat-fieldname = 'EBELN'.

l3_fieldcat-tabname = 'IT_GRN'.

l3_fieldcat-key = 'X'.

l3_fieldcat-emphasize = 'C410'.

l3_fieldcat-seltext_l = 'P.O. NO'.

l3_fieldcat-outputlen = 20.

APPEND l3_fieldcat TO p_i_fieldcat.

CLEAR l3_fieldcat.

l3_fieldcat-col_pos = '2'.

l3_fieldcat-fieldname = 'EBELP'.

l3_fieldcat-tabname = 'IT_GRN'.

l3_fieldcat-key = 'X'.

l3_fieldcat-emphasize = 'C410'.

l3_fieldcat-seltext_l = 'P.O.ITEM'.

l3_fieldcat-outputlen = 20.

APPEND l3_fieldcat TO p_i_fieldcat.

CLEAR l3_fieldcat.

l3_fieldcat-col_pos = '3'.

l3_fieldcat-fieldname = 'BWART'.

l3_fieldcat-tabname = 'IT_GRN'.

l3_fieldcat-key = 'X'.

l3_fieldcat-emphasize = 'C410'.

l3_fieldcat-seltext_l = 'MOVEMENT TYPE'.

l3_fieldcat-outputlen = 20.

APPEND l3_fieldcat TO p_i_fieldcat.

CLEAR l3_fieldcat.

l3_fieldcat-col_pos = '4'.

l3_fieldcat-fieldname = 'MENGE'.

l3_fieldcat-tabname = 'IT_GRN'.

l3_fieldcat-key = 'X'.

l3_fieldcat-emphasize = 'C410'.

l3_fieldcat-seltext_l = 'GR QUANTITY'.

l3_fieldcat-outputlen = 20.

APPEND l3_fieldcat TO p_i_fieldcat.

CLEAR l3_fieldcat.

ENDFORM. " ZF3_BUILD_FIELDCAT

&----


*& Form ZF1_DISPLAY_GRID

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM zf1_display_grid .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = 'Z8AS_SHADOW_ALV_INTERACTIVE'

it_fieldcat = i3_fieldcat

  • IMPORTING

TABLES

t_outtab = it_grn

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " ZF1_DISPLAY_GRID

&----


*& Form ZF_GRN

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM zf_grn .

CLEAR wa_eket .

CLEAR it_eket.

REFRESH it_grn.

LOOP AT it_vendor INTO wa_vendor WHERE ebelp = po_item.

IF sy-subrc = 0.

READ TABLE it_ekbe INTO wa_ekbe WITH KEY

ebeln = wa_vendor-ebeln

ebelp = wa_vendor-ebelp.

IF sy-subrc = 0.

IF wa_ekbe-bwart = '101'.

MOVE: wa_ekbe-ebeln TO wa_grn-ebeln,

wa_ekbe-ebelp TO wa_grn-ebelp,

wa_ekbe-bwart TO wa_grn-bwart,

wa_ekbe-menge TO wa_grn-menge.

APPEND wa_grn TO it_grn.

CLEAR wa_ekbe.

CLEAR wa_grn.

ELSE.

MESSAGE e001.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " ZF_GRN

Reward points if helful.

Regards,

amber S

Former Member
0 Kudos

Hi Anil,

Use USER_COMMAND of ALV.

refer this code :

FORM Z_USER_COMMAND USING P_UCOMM TYPE SY-UCOMM

P_SELFIELD TYPE SLIS_SELFIELD.

CASE P_UCOMM.

WHEN '&IC1'.

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = P_SELFIELD-VALUE

IMPORTING

OUTPUT = ACTUAL_MATNR

EXCEPTIONS

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

ENDCASE.

REWARD POINTS IF HELPFUL.

Regards,

Hemant

Former Member
0 Kudos

Hi,

Refer to the following link:

http://www.sapdevelopment.co.uk/reporting/alv/alvgrid.htm

Hope this helps.

Reward if helpful.

Regards,

Sipra