Tuesday, June 17, 2008

Interactive ALV Pgm

Report zalv_interactive .

type-pools : slis.

tables: zempldb2.

types: begin of ty_makt,
empid(15),
empname(20),
status(20),
end of ty_makt.

data : begin of it_final occurs 0,
empid like zempldb2-empid,
empname like zempldb2-empname,
dob like zempldb2-dob,
status(25),
cnt(3),
end of it_final,
wa_empid like zempldb2-empid,
w_cnt(3).

data it_makt type table of ty_makt with header line.

data : it_fieldcat type slis_t_fieldcat_alv with header line,
jt_fieldcat type slis_t_fieldcat_alv with header line,
it_event type slis_t_event with header line,
it_top type slis_t_listheader with header line,
wa_repid like sy-repid.

**** selection screen *-***********************

selection-screen begin of block b1 with frame title text-001.
select-options: so_empid for zempldb2-empid.
selection-screen end of block b1.

***** start of selection ***********************
start-of-selection.

wa_repid = sy-repid.


select * from zempldb2 into corresponding fields of table it_final.

perform fieldcat.

form fieldcat.

it_fieldcat-fieldname = 'EMPID'.
it_fieldcat-seltext_m = 'Employee ID'.
it_fieldcat-col_pos = 0.
it_fieldcat-outputlen = 15.
it_fieldcat-emphasize = 'X'.
it_fieldcat-hotspot = 'X'.
append it_fieldcat.
clear it_fieldcat.

it_fieldcat-fieldname = 'EMPNAME'.
it_fieldcat-seltext_m = 'Name'.
it_fieldcat-col_pos = 1.
it_fieldcat-outputlen = 15.
append it_fieldcat.
clear it_fieldcat.

it_fieldcat-fieldname = 'DOB'.
it_fieldcat-seltext_m = 'D.O.B'.
it_fieldcat-col_pos = 2.
it_fieldcat-outputlen = 15.
append it_fieldcat.
clear it_fieldcat.

it_fieldcat-fieldname = 'STATUS'.
it_fieldcat-seltext_m = 'STATUS'.
it_fieldcat-col_pos = 3.
it_fieldcat-outputlen = 15.
append it_fieldcat.
clear it_fieldcat.


* it_top-typ = 'H'.
* it_top-info = 'EMPLOYEE DETAILS'.
* APPEND it_top.
* CLEAR it_top.

call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = wa_repid
i_callback_user_command = 'USER_COMMAND'
* i_callback_top_of_page = 'TOP_OF_PAGE'
* i_grid_title = 'EMPLOYEE DETA'
it_fieldcat = it_fieldcat[]
tables
t_outtab = it_final.

endform.


*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->R_UCOMM text
* -->RS_SELFIELD text
*----------------------------------------------------------------------*
form user_command using r_ucomm like sy-ucomm
changing rs_selfield type slis_selfield.

if r_ucomm = '&IC1'.
if rs_selfield-fieldname = 'EMPID'.

wa_empid = rs_selfield-value.

loop at it_final
where
empid = wa_empid.
it_final-status = 'Granted'.

modify it_final transporting status where empid = wa_empid.

endloop.

clear it_makt.
refresh it_makt.
clear jt_fieldcat.
refresh jt_fieldcat.

select * from zempldb2
into corresponding fields of table it_makt
where empid = wa_empid.

it_makt-status = 'Granted'.
modify it_makt transporting status where empid = wa_empid.

* ENDIF.

jt_fieldcat-fieldname = 'EMPID'.
jt_fieldcat-seltext_m = 'Employe ID'.
jt_fieldcat-col_pos = 0.
jt_fieldcat-outputlen = 15.
append jt_fieldcat.
clear jt_fieldcat.

jt_fieldcat-fieldname = 'EMPNAME'.
jt_fieldcat-seltext_m = 'Name'.
jt_fieldcat-col_pos = 1.
jt_fieldcat-outputlen = 15.
append jt_fieldcat.
clear jt_fieldcat.

jt_fieldcat-fieldname = 'STATUS'.
jt_fieldcat-seltext_m = 'STATUS'.
jt_fieldcat-col_pos = 1.
jt_fieldcat-outputlen = 15.
jt_fieldcat-emphasize = 'X'.
append jt_fieldcat.
clear jt_fieldcat.


call function 'REUSE_ALV_GRID_DISPLAY'

exporting
i_callback_program = wa_repid
i_grid_title = ' MATERIAL DETAILS '

it_fieldcat = jt_fieldcat[]

tables
t_outtab = it_makt.

elseif r_ucomm = '&F03'.

perform fieldcat.

endif.

endif.

endform. "USER_COMMAND

*&---------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*

form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_top[].
endform. "TOP_OF_PAGE

No comments: