‎2006 Nov 24 5:55 AM
HI,
How to Develop an interactive report to display sales orders for particular customer, items for particular order.
‎2006 Nov 24 6:00 AM
its simple...check below code and understand it...
&----
*& Report ZFR_TEST_APPROVERS_LIST *
*& *
&----
*& *
*& *
&----
REPORT ZFR_TEST_APPROVERS_LIST
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 50.
----
*--Data Declaration
----
DATA: w_level LIKE ZFAP_ROLE_LEVEL-ZLEVEL,
w_user type zuserid,
w_userid LIKE WFSYST-ACT_AGENT.
----
*-- Internal Tables declaration
----
*--To store user history table details
DATA: it_user_history like zfap_history occurs 0 with header line.
*--To store approver list
DATA: it_apprlist TYPE ZFAP_USERS WITH HEADER LINE.
*--Selection Screen
PARAMETERS: p_docno LIKE zfap_history-zbelnr,
p_compcd LIKE zfap_history-zbukrs,
p_zgjahr LIKE zfap_history-zgjahr.
----
*START-OF-SELECTION
----
START-OF-SELECTION.
*--Get the data from history table for the document and comp code.
SELECT *
FROM ZFAP_HISTORY
INTO TABLE it_user_history
WHERE ZBELNR = p_docno and
zbukrs = p_compcd and
zgjahr = p_zgjahr.
*--Sort the internal table by seqno to get the latest row.
SORT it_user_history by zseqno descending.
----
*END-OF-SELECTION
----
END-OF-SELECTION.
read table it_user_history index 1.
*--Username
Concatenate 'US' it_user_history-zsapuserid into w_userid.
clear it_apprlist.
refresh it_apprlist.
*--if the status is not either Missed Vertical/Horizontal deadline
if it_user_history-zstatus NE 'Missed Horizontal Deadline' AND
it_user_history-zstatus NE 'Missed Vertical Deadline'.
CALL FUNCTION 'ZF_AP_CURRENT_APPROVERS'
EXPORTING
user_id = w_userid
comp_code = p_compcd
IMPORTING
LEVEL = w_level
tables
appr_list = it_apprlist
EXCEPTIONS
NO_APPROVERS_FOUND = 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.
elseif it_user_history-zstatus EQ 'Missed Horizontal Deadline'.
CALL FUNCTION 'ZF_AP_VERTICAL_APPROVERS'
EXPORTING
user_id = w_userid
comp_code = p_compcd
tables
escaltion_list = it_apprlist
EXCEPTIONS
USERS_NOT_FOUND = 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.
elseif it_user_history-zstatus EQ 'Missed Vertical Deadline'.
CALL FUNCTION 'ZF_AP_HORIZONTAL_APPROVERS'
EXPORTING
user_id = w_userid
comp_code = p_compcd
tables
escaltion_list = it_apprlist
EXCEPTIONS
USERS_NOT_FOUND = 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.
endif.
write:/10 'Status of the document:'.
write:35 it_user_history-zstatus.
write:/10 'List of Approvers'.
write:/10 '----
'.
loop at it_apprlist.
write: /10 it_apprlist.
endloop.
‎2006 Nov 24 5:57 AM
Please give me you mail ID , I'll send the document.
Regards
Shashi
‎2006 Nov 24 6:10 AM
‎2006 Nov 24 5:58 AM
Hi,
Look at the below sample Program for the Interactive ALV report.
&----
*& Report Z_INTERACTIVE_ALV3 *
*& *
&----
*& *
*& *
&----
report z_interactive_alv4 no standard page heading line-size 650
message-id zz_9838 .
type-pools: slis.
*type declaration for values from ekko
types: begin of i_ekko,
ebeln like ekko-ebeln,
aedat like ekko-aedat,
bukrs like ekko-bukrs,
bsart like ekko-bsart,
lifnr like ekko-lifnr,
end of i_ekko.
data: it_ekko type standard table of i_ekko initial size 0,
wa_ekko type i_ekko.
*type declaration for values from ekpo
types: begin of i_ekpo,
ebeln like ekpo-ebeln,
ebelp like ekpo-ebelp,
matnr like ekpo-matnr,
menge like ekpo-menge,
meins like ekpo-meins,
netpr like ekpo-netpr,
end of i_ekpo.
data: it_ekpo type standard table of i_ekpo initial size 0,
wa_ekpo type i_ekpo .
*variable for Report ID
data: v_repid like sy-repid .
*declaration for fieldcatalog
data: i_fieldcat type slis_t_fieldcat_alv,
wa_fieldcat type slis_fieldcat_alv.
data: it_listheader type slis_t_listheader.
declaration for events table where user comand or set PF status will
be defined
data: v_events type slis_t_event,
wa_event type slis_alv_event.
declartion for layout
data: alv_layout type slis_layout_alv.
declaration for variant(type of display we want)
data: i_variant type disvariant,
i_variant1 type disvariant,
i_save(1) type c.
*PARAMETERS : p_var TYPE disvariant-variant.
*Title displayed when the alv list is displayed
data: i_title_ekko type lvc_title value 'FIRST LIST DISPLAYED'.
data: i_title_ekpo type lvc_title value 'SECONDRY LIST DISPLAYED'.
initialization.
v_repid = sy-repid.
perform build_fieldcatlog.
perform event_call.
perform populate_event.
start-of-selection.
perform data_retrieval.
perform build_listheader using it_listheader.
perform display_alv_report.
&----
*& Form BUILD_FIELDCATLOG
&----
Fieldcatalog has all the field details from ekko
----
form build_fieldcatlog.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-seltext_m = 'PO NO.'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-seltext_m = 'DATE.'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-fieldname = 'BUKRS'.
wa_fieldcat-seltext_m = 'COMPANY CODE'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-fieldname = 'BUKRS'.
wa_fieldcat-seltext_m = 'DOCMENT TYPE'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'IT_EKKO'.
wa_fieldcat-fieldname = 'LIFNR'.
wa_fieldcat-no_out = 'X'.
wa_fieldcat-seltext_m = 'VENDOR CODE'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
endform. "BUILD_FIELDCATLOG
&----
*& Form EVENT_CALL
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
form event_call.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = v_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.
endform. "EVENT_CALL
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
form populate_event.
read table v_events into wa_event with key name = 'TOP_OF_PAGE'.
if sy-subrc eq 0.
wa_event-form = 'TOP_OF_PAGE'.
modify v_events from wa_event transporting form where name =
wa_event-form.
endif.
read table v_events into wa_event with key name = 'USER_COMMAND'.
if sy-subrc eq 0.
wa_event-form = 'USER_COMMAND'.
modify v_events from wa_event transporting form where name =
wa_event-name.
endif.
endform. "POPULATE_EVENT
&----
*& Form data_retrieval
&----
retreiving values from the database table ekko
----
form data_retrieval.
select ebeln aedat bukrs bsart lifnr from ekko into table it_ekko.
endform. "data_retrieval
&----
*& Form bUild_listheader
&----
text
----
-->I_LISTHEADEtext
----
form build_listheader using i_listheader type slis_t_listheader.
data hline type slis_listheader.
hline-info = 'this is my first alv pgm'.
hline-typ = 'H'.
endform. "build_listheader
&----
*& Form display_alv_report
&----
text
----
form display_alv_report.
v_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
i_callback_user_command = 'USER_COMMAND'
i_callback_top_of_page = 'TOP_OF_PAGE'
i_grid_title = i_title_ekko
I_GRID_SETTINGS =
IS_LAYOUT = ALV_LAYOUT
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
i_default = 'ZLAY1'
i_save = 'A'
is_variant = i_variant
it_events = v_events
tables
t_outtab = it_ekko
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_alv_report
&----
*& Form TOP_OF_PAGE
&----
text
----
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_listheader
i_logo =
I_END_OF_LIST_GRID =
.
endform. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
case r_ucomm.
when '&IC1'.
read table it_ekko into wa_ekko index rs_selfield-tabindex.
perform build_fieldcatlog_ekpo.
perform event_call_ekpo.
perform populate_event_ekpo.
perform data_retrieval_ekpo.
perform build_listheader_ekpo using it_listheader.
perform display_alv_ekpo.
endcase.
endform. "user_command
&----
*& Form BUILD_FIELDCATLOG_EKPO
&----
text
----
form build_fieldcatlog_ekpo.
wa_fieldcat-tabname = 'IT_EKPO'.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-seltext_m = 'PO NO.'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'IT_EKPO'.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-seltext_m = 'LINE NO'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'I_EKPO'.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-seltext_m = 'MATERIAL NO.'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'I_EKPO'.
wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-seltext_m = 'QUANTITY'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'I_EKPO'.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-seltext_m = 'UOM'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
wa_fieldcat-tabname = 'I_EKPO'.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-seltext_m = 'PRICE'.
append wa_fieldcat to i_fieldcat.
clear wa_fieldcat.
endform. "BUILD_FIELDCATLOG_EKPO
&----
*& Form event_call_ekpo
&----
we get all events - TOP OF PAGE or USER COMMAND in table v_events
----
form event_call_ekpo.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events = v_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.
endform. "event_call_ekpo
&----
*& Form POPULATE_EVENT
&----
Events populated for TOP OF PAGE & USER COMAND
----
form populate_event_ekpo.
read table v_events into wa_event with key name = 'TOP_OF_PAGE'.
if sy-subrc eq 0.
wa_event-form = 'TOP_OF_PAGE'.
modify v_events from wa_event transporting form where name =
wa_event-form.
endif.
endform. "POPULATE_EVENT
&----
*& Form TOP_OF_PAGE
&----
text
----
form f_top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
it_list_commentary = it_listheader
i_logo =
I_END_OF_LIST_GRID =
.
endform. "TOP_OF_PAGE
&----
*& Form USER_COMMAND
&----
text
----
-->R_UCOMM text
-->, text
-->RS_SLEFIELDtext
----
*retreiving values from the database table ekko
form data_retrieval_ekpo.
select ebeln ebelp matnr menge meins netpr from ekpo into table it_ekpo.
endform.
form build_listheader_ekpo using i_listheader type slis_t_listheader.
data: hline1 type slis_listheader.
hline1-typ = 'H'.
hline1-info = 'CHECKING PGM'.
endform.
form display_alv_ekpo.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER = ' '
I_BUFFER_ACTIVE = ' '
i_callback_program = v_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = 'F_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 =
I_BACKGROUND_ID = ' '
i_grid_title = i_title_ekpo
I_GRID_SETTINGS =
IS_LAYOUT =
it_fieldcat = i_fieldcat[]
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT =
i_save = 'A'
IS_VARIANT =
it_events = v_events
tables
t_outtab = it_ekpo
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.
Regards,
Ram
Reward points if helpful
‎2006 Nov 24 6:00 AM
its simple...check below code and understand it...
&----
*& Report ZFR_TEST_APPROVERS_LIST *
*& *
&----
*& *
*& *
&----
REPORT ZFR_TEST_APPROVERS_LIST
NO STANDARD PAGE HEADING
LINE-SIZE 130
LINE-COUNT 50.
----
*--Data Declaration
----
DATA: w_level LIKE ZFAP_ROLE_LEVEL-ZLEVEL,
w_user type zuserid,
w_userid LIKE WFSYST-ACT_AGENT.
----
*-- Internal Tables declaration
----
*--To store user history table details
DATA: it_user_history like zfap_history occurs 0 with header line.
*--To store approver list
DATA: it_apprlist TYPE ZFAP_USERS WITH HEADER LINE.
*--Selection Screen
PARAMETERS: p_docno LIKE zfap_history-zbelnr,
p_compcd LIKE zfap_history-zbukrs,
p_zgjahr LIKE zfap_history-zgjahr.
----
*START-OF-SELECTION
----
START-OF-SELECTION.
*--Get the data from history table for the document and comp code.
SELECT *
FROM ZFAP_HISTORY
INTO TABLE it_user_history
WHERE ZBELNR = p_docno and
zbukrs = p_compcd and
zgjahr = p_zgjahr.
*--Sort the internal table by seqno to get the latest row.
SORT it_user_history by zseqno descending.
----
*END-OF-SELECTION
----
END-OF-SELECTION.
read table it_user_history index 1.
*--Username
Concatenate 'US' it_user_history-zsapuserid into w_userid.
clear it_apprlist.
refresh it_apprlist.
*--if the status is not either Missed Vertical/Horizontal deadline
if it_user_history-zstatus NE 'Missed Horizontal Deadline' AND
it_user_history-zstatus NE 'Missed Vertical Deadline'.
CALL FUNCTION 'ZF_AP_CURRENT_APPROVERS'
EXPORTING
user_id = w_userid
comp_code = p_compcd
IMPORTING
LEVEL = w_level
tables
appr_list = it_apprlist
EXCEPTIONS
NO_APPROVERS_FOUND = 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.
elseif it_user_history-zstatus EQ 'Missed Horizontal Deadline'.
CALL FUNCTION 'ZF_AP_VERTICAL_APPROVERS'
EXPORTING
user_id = w_userid
comp_code = p_compcd
tables
escaltion_list = it_apprlist
EXCEPTIONS
USERS_NOT_FOUND = 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.
elseif it_user_history-zstatus EQ 'Missed Vertical Deadline'.
CALL FUNCTION 'ZF_AP_HORIZONTAL_APPROVERS'
EXPORTING
user_id = w_userid
comp_code = p_compcd
tables
escaltion_list = it_apprlist
EXCEPTIONS
USERS_NOT_FOUND = 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.
endif.
write:/10 'Status of the document:'.
write:35 it_user_history-zstatus.
write:/10 'List of Approvers'.
write:/10 '----
'.
loop at it_apprlist.
write: /10 it_apprlist.
endloop.