‎2007 Jan 04 4:38 AM
Hi,
I am getting somewhat frustrated with this one! I hope someone can point me in the right direction. Here is my problem.
I am calling method <b>'set_table_for_first_display'</b> with the changing parameter '<b>it_outtab being'</b> passed a field symbol as type table.
For the first instance this works fine but when the data in the field symbol changes and then subsequently the method <b>'refresh_table_display'</b> is called the old data appears on the screen even though the data in field symbol is different.
The strange things is though, this issue only arises when using field symbols rather than internal tables.
Can anyone shed any light on this?
‎2007 Jan 04 5:48 AM
Hello Neil
The following sample report (based on BCALV_GRID_DEMO) shows how to use field-symbols in ALV lists. Please adjust the GUI status that the ENTER button has ok-code ENTER assigned.
If you simply push the ENTER button several times every time a single entry of the selected data will be deleted. After refreshing the ALV list the displayed data are correct.
If you enter a different table name (e.g. SCARR) into the command line field a new dynamic select nothing happens because the grid instance (at the frontend) does not "know" that the output data (in the backend, i.e. the ABAP program) have been changed. You have to call SET_TABLE_FOR_FIRST_DISPLAY again to "inform" the grid instance about this change.
PROGRAM zus_sdn_bcalv_grid_demo_4.
DATA: ok_code LIKE sy-ucomm,
* gt_sflight TYPE TABLE OF sflight,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA:
gdo_data TYPE REF TO data,
p_table_old TYPE tabname.
FIELD-SYMBOLS:
<gt_outtab> TYPE table.
PARAMETERS:
p_table TYPE tabname DEFAULT 'SFLIGHT'.
START-OF-SELECTION.
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
p_table_old = p_table.
PERFORM dynamic_select
USING
p_table.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
* Instantiate ALV grid control
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = p_table
CHANGING
it_outtab = <gt_outtab>.
ELSEIF ( p_table = p_table_old ). " table did not change
grid1->refresh_table_display( ).
ELSEIF ( p_table <> p_table_old ). " table did change
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = p_table
CHANGING
it_outtab = <gt_outtab>.
p_table_old = p_table.
ENDIF.
ENDMODULE. "PBO OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'ENTER'.
* delete one entry after the other
DELETE <gt_outtab> INDEX 1.
WHEN OTHERS.
* Set new table
p_table = ok_code.
PERFORM dynamic_select
USING p_table.
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
*&---------------------------------------------------------------------*
*& Form DYNAMIC_SELECT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_TABLE text
*----------------------------------------------------------------------*
FORM dynamic_select
USING
value(ud_table) TYPE tabname.
CLEAR: gdo_data.
TRANSLATE ud_table TO UPPER CASE.
CREATE DATA gdo_data TYPE TABLE OF (ud_table).
ASSIGN gdo_data->* TO <gt_outtab>.
SELECT * FROM (ud_table) INTO TABLE <gt_outtab>.
ENDFORM. " DYNAMIC_SELECTRegards
Uwe
‎2007 Jan 04 4:50 AM
‎2007 Jan 04 5:16 AM
Here it is:
*<= This is where I populate the field symbol
data: lv_where_clause type string.
create data it_results_var type table of (w_config-results_tab).
assign it_results_var->* to <results>.
concatenate w_config-batch_fieldname ' eq w_main-batch_no'
into lv_where_clause.
select * into table <results>
from (w_config-results_tab)
where original_file eq w_main-original_file
and (lv_where_clause).
*<= This is where I call the methods
if cust104 is initial.
create object cust104 exporting container_name = 'CUST104'.
create object grid104 exporting i_parent = cust104.
call method grid104->set_table_for_first_display
exporting
i_structure_name = w_config-results_tab
is_layout = s_layo
changing
it_outtab = <results>
else.
call method grid104->refresh_table_display.
endif.
Cheers,
Neil.
‎2007 Jan 04 5:26 AM
Hi Neil,
When You Fieldsymbols.It is like a reference .when you are using data and then assigning the fieldsymbol will have a different instance different time .
There are two ways .
You can do
1 .Use an Internal table that will work .
2 .UNASSIGN the Field symbol <result> . I hope this should work.
Please reward if useful .
‎2007 Jan 04 11:22 PM
Thanks for your help dinesh. I resolved the probelm by using the method 'set_table_for_first_display' everytime.
Cheers,
Neil.
‎2007 Jan 04 5:48 AM
Hello Neil
The following sample report (based on BCALV_GRID_DEMO) shows how to use field-symbols in ALV lists. Please adjust the GUI status that the ENTER button has ok-code ENTER assigned.
If you simply push the ENTER button several times every time a single entry of the selected data will be deleted. After refreshing the ALV list the displayed data are correct.
If you enter a different table name (e.g. SCARR) into the command line field a new dynamic select nothing happens because the grid instance (at the frontend) does not "know" that the output data (in the backend, i.e. the ABAP program) have been changed. You have to call SET_TABLE_FOR_FIRST_DISPLAY again to "inform" the grid instance about this change.
PROGRAM zus_sdn_bcalv_grid_demo_4.
DATA: ok_code LIKE sy-ucomm,
* gt_sflight TYPE TABLE OF sflight,
g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA:
gdo_data TYPE REF TO data,
p_table_old TYPE tabname.
FIELD-SYMBOLS:
<gt_outtab> TYPE table.
PARAMETERS:
p_table TYPE tabname DEFAULT 'SFLIGHT'.
START-OF-SELECTION.
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
p_table_old = p_table.
PERFORM dynamic_select
USING
p_table.
CALL SCREEN 100.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE pbo OUTPUT.
SET PF-STATUS 'MAIN100'.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container
EXPORTING container_name = g_container.
* Instantiate ALV grid control
CREATE OBJECT grid1
EXPORTING i_parent = g_custom_container.
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = p_table
CHANGING
it_outtab = <gt_outtab>.
ELSEIF ( p_table = p_table_old ). " table did not change
grid1->refresh_table_display( ).
ELSEIF ( p_table <> p_table_old ). " table did change
CALL METHOD grid1->set_table_for_first_display
EXPORTING
i_structure_name = p_table
CHANGING
it_outtab = <gt_outtab>.
p_table_old = p_table.
ENDIF.
ENDMODULE. "PBO OUTPUT
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE pai INPUT.
* to react on oi_custom_events:
CALL METHOD cl_gui_cfw=>dispatch.
CASE ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
WHEN 'ENTER'.
* delete one entry after the other
DELETE <gt_outtab> INDEX 1.
WHEN OTHERS.
* Set new table
p_table = ok_code.
PERFORM dynamic_select
USING p_table.
ENDCASE.
CLEAR ok_code.
ENDMODULE. "PAI INPUT
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
* CALL METHOD G_CUSTOM_CONTAINER->FREE.
* CALL METHOD CL_GUI_CFW=>FLUSH.
LEAVE PROGRAM.
ENDFORM. "EXIT_PROGRAM
*&---------------------------------------------------------------------*
*& Form DYNAMIC_SELECT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_TABLE text
*----------------------------------------------------------------------*
FORM dynamic_select
USING
value(ud_table) TYPE tabname.
CLEAR: gdo_data.
TRANSLATE ud_table TO UPPER CASE.
CREATE DATA gdo_data TYPE TABLE OF (ud_table).
ASSIGN gdo_data->* TO <gt_outtab>.
SELECT * FROM (ud_table) INTO TABLE <gt_outtab>.
ENDFORM. " DYNAMIC_SELECTRegards
Uwe
‎2007 Jan 04 6:21 AM
Gruetzi Uwe,
Thanks for the feedback. I think I have not made clear my issue. I will try again.
Currently I have a main alv grid which has several function each one of these functions calls a different ALV grid.
When a line is selected from the main grid and a function called for the first time everything works according to plan. The new grid gets instantiated and displayed on the screen.
The issue happens when the same function is called again but for a different line on the main ALV grid.
Even though the field symbol contains the new data based on the new line selected, when the ALV grid for the function is called is still contains the data from the previous line selected. Even after calling the method <b>'refresh_table_display</b>'. When debugging this process the IT_OUTTAB contains the new data.
Am I going completely insane?
Cheers,
Neil.
‎2007 Jan 04 8:08 AM
Hello Neil
Could you please paste the entire coding?
Regards & Greetings from Zürich
Uwe
‎2007 Jan 04 9:18 PM
HI Uwe,
I love Zurich, I spent 18 months there working for SLI Consulting back in the day! Although the name doesn't look like it but I am actually from Geneva.
Here is the code as requested.
Cheers,
Neil.
&******************************************************************&
& Author : Neil Gardiner &
& &
& Date : December 2006 &
& &
& Description: &
& &
& &
& &
&******************************************************************&
& Modifications: &
& -
& User: Description: Trace: &
& -
& &
& &
&******************************************************************&
program zfhp_audit_trail message-id zi.
<= Tables => *******************************
tables: zzhp_mvt_hdr,
zzhp_mvt_dtl,
pa0105.
<= Type Pools => *****************************
type-pools: cntl.
<= Includes => ******************************
include: <icon>.
<= Types => ******************************
*<= Auto Reconciliation
types: begin of t_journals,
bukrs type bkpf-bukrs,
belnr type bkpf-belnr,
gjahr type bkpf-gjahr,
budat type bkpf-budat,
xblnr type bkpf-xblnr,
debit type bseg-dmbtr,
items type i,
end of t_journals.
types: begin of t_debits,
wrbtr type zzhpfm_mvt_hdr-control_debits,
end of t_debits.
*<= Screen 100
types: begin of t_main ,
original_file type zzhp_mvt_hdr-original_file ,
description type text50 ,
batch_no type zzhp_mvt_hdr-batch_no ,
sequence_no type zzhp_mvt_hdr-sequence_no ,
create_date type zzhp_mvt_hdr-create_date ,
mst_map_errors type zzhp_mvt_hdr-mst_map_errors ,
trn_map_errors type zzhp_mvt_hdr-trn_map_errors ,
total_records type zzhp_mvt_hdr-total_records ,
status type zzhp_mvt_hdr-status ,
status_text(42) type c ,
processed_date type zzhp_mvt_hdr-processed_date ,
processed_time type zzhp_mvt_hdr-processed_time ,
total_gl_debits type zzhp_mvt_hdr-total_gl_debits ,
total_adjustment type zzhp_mvt_hdr-total_adjustment,
objnr(19) type c ,
line_colour(4) type c ,
end of t_main .
*<= Screen 101
types: begin of t_accounting,
bukrs type bkpf-bukrs,
belnr type bkpf-belnr,
gjahr type bkpf-gjahr,
total type bseg-wrbtr,
items type i,
end of t_accounting.
*<= Function codes to be excluded
types: begin of t_exclude,
fcode type rsmpe-func,
end of t_exclude.
<= Itabs => ******************************
data: it_config type standard table of zziface_config,
it_mailto type standard table of zziface_mailto,
it_mvt_hdr type standard table of zzhp_mvt_hdr,
it_exclude type standard table of t_exclude,
it_content type bcsy_text.
*<= Auto Reconciliation
data: it_journals type standard table of t_journals,
it_debits type standard table of t_debits.
*<= Screen 100
data: it_fieldcat type standard table of lvc_s_fcat,
it_main type standard table of t_main,
it_rows type lvc_t_row.
*<= Screen 101
data: it_accounting type standard table of t_accounting,
it_fieldcat101 type standard table of lvc_s_fcat.
*<= Screen 103
data: it_fieldcat103.
*<= Screen 104
data: it_fieldcat104 type standard table of lvc_s_fcat,
it_results type standard table of zzhp_results.
<= Work Areas => ****************************
data: w_config type zziface_config,
w_mailto type zziface_mailto,
w_mvt_hdr type zzhp_mvt_hdr,
w_rows type lvc_s_row,
w_fieldcat type lvc_s_fcat,
w_exclude type t_exclude,
w_content type string.
*<= Screen 100
data: w_main type t_main.
*<= Screen 101
data: w_accounting type t_accounting.
*<= Screen 104
data: w_results type zzhp_results.
*<= Auto Reconciliation
data: w_journals type t_journals,
w_debits type t_debits.
*<= Work areas for SAP document
data: w_doco type soodk,
w_folder type soodk,
w_new_doco type soodk.
<= Structures => ****************************
data: s_layo type lvc_s_layo,
s_toolbar type stb_button.
<= Constants => ****************************
constants: c_interface(9) type c value 'INTERFACE',
c_hiport(6) type c value 'HIPORT' ,
c_iface(7) type c value 'P_IFACE',
c_fname(15) type c value 'PROCESSING_FLAG',
c_usr type p0005-subty value '0001',
c_colon(1) type c value ':' ,
c_000(3) type c value '000' ,
c_100(3) type c value '100' ,
c_0100(4) type c value '0100' ,
c_eq(2) type c value 'EQ' ,
c_0(1) type c value '0' ,
c_1(1) type c value '1' ,
c_2(1) type c value '2' ,
c_3(1) type c value '3' ,
c_i(1) type c value 'I' ,
c_p(1) type c value 'P' ,
c_r(1) type c value 'R' ,
c_s(1) type c value 'S' ,
c_u(1) type c value 'U' ,
c_x(1) type c value 'X' .
*<= Constants for screen processing
constants: c_back type sy-ucomm value 'BACK' ,
c_canc type sy-ucomm value 'CANC' ,
c_exit type sy-ucomm value 'EXIT' ,
c_fb03 type sy-ucomm value 'FB03' ,
c_arecon type sy-ucomm value 'AU_RECON' ,
c_mrecon type sy-ucomm value 'MAN_RECON',
c_all type sy-ucomm value 'HP_ALL' ,
c_reslts type sy-ucomm value 'RESULTS' ,
c_fnote type sy-ucomm value 'FNOTE' ,
c_mvtdtl type sy-ucomm value 'MOV_DTLS' ,
c_msterr type sy-ucomm value 'MST_ERR' ,
c_trnerr type sy-ucomm value 'TRN_ERR' ,
c_inamst type sy-ucomm value 'INA_MST' ,
c_inatrn type sy-ucomm value 'INA_TRN' ,
c_mstmap type sy-ucomm value 'MST_MAP' ,
c_trnmap type sy-ucomm value 'TRN_MAP' .
*<= Constants for HOTSPOT clicks
constants: c_belnr(5) type c value 'BELNR'.
*<= Constants for BATCH status
constants: c_e type c value 'E',
c_d type c value 'D',
c_f type c value 'F',
c_m type c value 'M',
c_t type c value 'T',
c_v type c value 'V'.
*<= Constants for transaction calling
constants: c_mst_map(15) type c value 'ZZHP_MSTALL_DIS',
c_trn_map(15) type c value 'ZZHP_TRNMAP_DIS'.
*<= Constants for authority check
constants: c_06(2) type c value '06',
c_16(2) type c value '16'.
*<= Constants for line colours
constants: c_c310(4) type c value 'C310',
c_c410(4) type c value 'C410',
c_c510(4) type c value 'C510',
c_c610(4) type c value 'C610',
c_c710(4) type c value 'C710'.
*<= Constants for popup function
constants: c_warning(7) type c value 'Warning' ,
c_continue(8) type c value 'Continue',
c_cancel(6) type c value 'Cancel' .
<= Global Variables => *************************
data: v_okcode type sy-ucomm ,
ok_code type sy-ucomm ,
v_xblnr type bkpf-xblnr,
v_index type sy-tabix ,
v_errors type c ,
v_answer type c .
*< Variables for SAP document
data: v_objnam type sofd-objnam,
v_docnam type sofd-objnam,
v_retcode type c.
<= Object Declaration => ************************
*<= Dynamic table selection
data: w_waref type ref to data.
*<= Screen 100
data: it_main_var type ref to data,
cust100 type ref to cl_gui_custom_container,
grid100 type ref to cl_gui_alv_grid.
*<= Screen 101
data: it_header_var type ref to data,
cust101 type ref to cl_gui_custom_container,
grid101 type ref to cl_gui_alv_grid.
*<= Screen 103
data: it_mvt_dtl_var type ref to data,
cust104 type ref to cl_gui_custom_container,
grid104 type ref to cl_gui_alv_grid.
*<= Screen 104
data: it_results_var type ref to data,
cust103 type ref to cl_gui_custom_container,
grid103 type ref to cl_gui_alv_grid.
*<= Email processing
data: send_request type ref to cl_bcs,
document type ref to cl_document_bcs,
bcs_exception type ref to cx_bcs.
<= Field Symbols => **************************
field-symbols: <main> type standard table,
<header> type standard table,
<results> type standard table,
<mvt_dtl> type standard table,
<wa> type any .
<= Ranges => ******************************
ranges: r_status for zzhp_mvt_hdr-status.
<= Local Class Definition => *********************
----
CLASS lcl_event_receiver DEFINITION
----
*
----
class lcl_event_receiver definition.
public section.
class-methods: handle_hotspot_click
for event hotspot_click of cl_gui_alv_grid
importing
e_row_id
e_column_id
es_row_no,
handle_user_command
for event user_command of cl_gui_alv_grid
importing e_ucomm,
handle_toolbar
for event toolbar of cl_gui_alv_grid
importing e_object e_interactive.
private section.
endclass. "lcl_event_receiver DEFINITION
----
CLASS lcl_program_utilities DEFINITION
----
*
----
class lcl_program_utilities definition.
public section.
class-methods: get_index
importing
e_index type sy-tabix
exporting
i_index type sy-tabix.
private section.
endclass. "lcl_program_utilities DEFINITION
<= Selection Screen => *************************
selection-screen: begin of block b01 with frame title text-001.
parameters: p_iface type zziface_descript-original_file.
selection-screen: end of block b01.
<= Initialisation => **************************
initialization.
p_iface = c_hiport.
loop at screen.
case screen-name.
when c_iface.
screen-input = c_0.
endcase.
modify screen.
endloop.
************************************************************************
----
----
----
************************************************************************
*<= Start of selection
start-of-selection.
perform get_config_info using p_iface.
perform authority_check.
perform get_email_recipients.
if sy-batch = c_x.
perform status_range.
perform auto_reconcile.
else.
set screen 100.
endif.
*<= End of selection
end-of-selection.
*<= If the program is executed and in background mode and errors occur
*<= during the processing an email needs to be sent to inform the people
*<= responsible.
if sy-batch = c_x and
v_errors = c_x.
perform send_email.
endif.
************************************************************************
----
----
----
************************************************************************
&----
*& Form get_config_info
&----
text
----
-->P_P_IFACE text
----
form get_config_info using p_p_iface.
select * into table it_config
from zziface_config
where original_file eq p_p_iface.
endform. " get_config_info
&----
*& Form authority_check
&----
text
----
--> p1 text
<-- p2 text
----
form authority_check .
loop at it_config into w_config.
authority-check object w_config-auth_object
id w_config-auth_interface
field w_config-original_file
id 'ACTVT' field c_06.
if sy-subrc ne 0.
message e000 with text-901.
else.
authority-check object w_config-auth_object
id w_config-auth_interface
field w_config-original_file
id 'ACTVT' field c_16.
if sy-subrc <> 0.
w_exclude-fcode = c_arecon. " Exclude Auto Recon
append w_exclude to it_exclude.
clear w_exclude.
w_exclude-fcode = c_mrecon. " Exclude Manual Recon
append w_exclude to it_exclude.
clear w_exclude.
endif.
endif.
endloop.
endform. " authority_check
&----
*& Form status_range
&----
text
----
--> p1 text
<-- p2 text
----
form status_range .
r_status-sign = c_i.
r_status-option = c_eq.
r_status-low = c_p.
append r_status.
clear r_status.
r_status-sign = c_i.
r_status-option = c_eq.
r_status-low = c_u.
append r_status.
clear r_status.
endform. " status_range
&----
*& Form auto_reconcile
&----
text
----
--> p1 text
<-- p2 text
----
form auto_reconcile.
if sy-batch = c_x.
read table it_config into w_config with key original_file = p_iface.
create data it_header_var type table of (w_config-mvt_hdr_tab).
assign it_header_var->* to <header>.
select * into table <header>
from (w_config-mvt_hdr_tab)
where original_file eq w_config-original_file
and status in r_status.
loop at <header> into <wa>.
move-corresponding <wa> to w_mvt_hdr.
perform reconcile_movement using w_mvt_hdr-original_file
w_mvt_hdr-batch_no
w_mvt_hdr-sequence_no
w_mvt_hdr-total_gl_debits
w_mvt_hdr-total_adjustment.
endloop.
else.
call method lcl_program_utilities=>get_index
exporting
e_index = '1'
importing
i_index = v_index.
read table it_main index v_index into w_main.
if w_main-status na 'PURM'.
message i000 with text-113.
exit.
endif.
perform reconcile_movement using w_main-original_file
w_main-batch_no
w_main-sequence_no
w_main-total_gl_debits
w_main-total_adjustment.
.
endif.
endform. " auto_reconcile
&----
*& Form reconcile_movement
&----
text
----
--> p1 text
<-- p2 text
----
form reconcile_movement using p_original_file
p_batch_no
p_sequence_no
p_totals
p_adjustments.
perform create_ref_doc using p_batch_no
changing v_xblnr.
perform get_journals using v_xblnr.
perform get_amounts.
perform check_amounts using p_original_file
p_batch_no
p_sequence_no
p_totals
p_adjustments.
endform. " reconcile_movement
&----
*& Form create_ref_doc
&----
text
----
<--P_XBLNR text
----
form create_ref_doc using p_batch_no
changing p_xblnr.
data: lv_xblnr type bkpf-xblnr.
v_xblnr = w_config-reference2.
replace '&BATCH&' in v_xblnr with p_batch_no.
endform. " create_ref_doc
&----
*& Form get_journals
&----
text
----
-->P_V_XBLNR text
----
form get_journals using p_xblnr.
refresh: it_journals.
select bukrs belnr gjahr into table it_journals
from bkpf
where xblnr eq p_xblnr
and stblg eq ''.
if sy-subrc <> 0.
if sy-batch = c_x.
message i000 with text-110 p_xblnr.
else.
message e000 with text-110 p_xblnr.
endif.
else.
sort it_journals.
endif.
endform. " get_journals
&----
*& Form get_amounts
&----
text
----
--> p1 text
<-- p2 text
----
form get_amounts .
refresh: it_debits.
clear : w_debits.
select wrbtr into table it_debits
from bseg
for all entries in it_journals
where bukrs eq it_journals-bukrs
and belnr eq it_journals-belnr
and gjahr eq it_journals-gjahr
and shkzg eq c_s.
endform. " get_amounts
&----
*& Form check_amounts
&----
text
----
--> p1 text
<-- p2 text
----
form check_amounts using p_original_file
p_batch_no
p_sequence_no
p_totals
p_adjustments.
data: lv_tot type bseg-wrbtr.
loop at it_debits into w_debits.
at first.
sum.
lv_tot = p_totals + p_adjustments.
if w_debits-wrbtr <> lv_tot.
update (w_config-mvt_hdr_tab) set status = c_u
where original_file = p_original_file
and batch_no = p_batch_no
and sequence_no = p_sequence_no.
message id w_config-message_id type c_i number c_000
with p_batch_no text-116 w_debits-wrbtr lv_tot.
if sy-batch <> c_x.
w_main-status = c_u.
modify it_main from w_main index v_index transporting status.
endif.
else.
update (w_config-mvt_hdr_tab) set status = c_r
where original_file = p_original_file
and batch_no = p_batch_no
and sequence_no = p_sequence_no.
message id w_config-message_id type c_i number c_000
with p_batch_no text-117.
if sy-batch <> c_x.
w_main-status = c_r.
modify it_main from w_main index v_index transporting status.
endif.
endif.
endat.
exit.
endloop.
endform. " check_amounts
&----
*& Module status_0100 OUTPUT
&----
text
----
module status_0100 output.
set pf-status '0100' excluding it_exclude.
set titlebar '0100'.
if cust100 is initial.
perform build_layout.
perform build_fieldcat_100.
perform get_data_100.
create object cust100 exporting container_name = 'CUST100'.
create object grid100 exporting i_parent = cust100.
call method grid100->set_table_for_first_display
exporting
i_structure_name = 'IT_MAIN'
is_layout = s_layo
changing
it_outtab = it_main
it_fieldcatalog = it_fieldcat.
else.
call method grid100->refresh_table_display.
endif.
*<= Set the handlers for the events.
set handler lcl_event_receiver=>handle_hotspot_click
for all instances.
set handler lcl_event_receiver=>handle_toolbar for grid100.
set handler lcl_event_receiver=>handle_user_command for grid100.
*<= Set the toolbar of the ALV grip to interactive
call method grid100->set_toolbar_interactive.
endmodule. " status_0100 OUTPUT
&----
*& Form get_data_100
&----
text
----
--> p1 text
<-- p2 text
----
form get_data_100 .
refresh: it_mvt_hdr,
it_main.
clear : w_mvt_hdr,
w_main.
read table it_config into w_config with key original_file = p_iface.
create data it_header_var type table of (w_config-mvt_hdr_tab).
assign it_header_var->* to <header>.
create data w_waref type (w_config-mvt_hdr_tab).
assign w_waref->* to <wa>.
select * into table <header>
from (w_config-mvt_hdr_tab)
where original_file eq w_config-original_file.
loop at <header> into <wa>.
move-corresponding <wa> to w_mvt_hdr.
append w_mvt_hdr to it_mvt_hdr.
endloop.
loop at it_mvt_hdr into w_mvt_hdr.
perform get_sap_document using w_mvt_hdr-objtp
w_mvt_hdr-objyr
w_mvt_hdr-objno
changing w_main-objnr.
perform get_status_text using w_mvt_hdr-status
changing w_main-status_text
w_main-line_colour.
perform get_description using w_mvt_hdr-original_file
changing w_main-description.
w_main-original_file = w_mvt_hdr-original_file .
w_main-batch_no = w_mvt_hdr-batch_no .
w_main-sequence_no = w_mvt_hdr-sequence_no .
w_main-create_date = w_mvt_hdr-create_date .
w_main-mst_map_errors = w_mvt_hdr-mst_map_errors .
w_main-trn_map_errors = w_mvt_hdr-trn_map_errors .
w_main-total_records = w_mvt_hdr-total_records .
w_main-processed_date = w_mvt_hdr-processed_date .
w_main-processed_time = w_mvt_hdr-processed_time .
w_main-total_gl_debits = w_mvt_hdr-total_gl_debits.
w_main-status = w_mvt_hdr-status.
append w_main to it_main.
clear w_main.
endloop.
sort it_main by processed_date batch_no sequence_no ascending.
endform. " get_data_100
&----
*& Form build_fieldcat_100
&----
text
----
--> p1 text
<-- p2 text
----
form build_fieldcat_100 .
w_fieldcat-fieldname = 'ORIGINAL_FILE'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Original File'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'DESCRIPTION'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Description'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'BATCH_NO'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Batch No.'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'SEQUENCE_NO'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Batch Sequence No.'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'CREATE_DATE'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'SAP Posting Date'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'FILE_TIME'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Creation Time'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'MST_MAP_ERRORS'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Master Mapping Errors'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'TRN_MAP_ERRORS'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Transaction Mapping Errors'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'TOTAL_RECORDS'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Total Records'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'STATUS_TEXT'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Batch Status'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'PROCESSED_DATE'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'SAP Received Date'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'PROCESSED_TIME'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'SAP Received Time'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'TOTAL_GL_DEBITS'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Total GL Debits'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'TOTAL_ADJUSTMENT'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'Total Adjustments'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
w_fieldcat-fieldname = 'OBJNR'.
w_fieldcat-tabname = 'IT_MAIN'.
w_fieldcat-coltext = 'SAP Office Document'.
append w_fieldcat to it_fieldcat.
clear w_fieldcat.
endform. " build_fieldcat_100
&----
*& Module exit INPUT
&----
text
----
module exit input.
v_okcode = ok_code.
clear ok_code.
case v_okcode.
when c_exit or c_canc or c_back.
if sy-dynnr = c_0100.
leave program.
else.
leave to screen c_100.
endif.
endcase.
endmodule. " exit INPUT
&----
*& Form build_layout
&----
text
----
--> p1 text
<-- p2 text
----
form build_layout .
s_layo-zebra = c_x.
s_layo-cwidth_opt = c_x.
s_layo-info_fname = 'LINE_COLOUR'.
endform. " build_layout
&----
*& Module user_command_0100 INPUT
&----
text
----
module user_command_0100 input.
v_okcode = ok_code.
clear ok_code.
case v_okcode.
when c_fb03.
perform get_lines.
call screen 101.
when c_arecon.
perform get_lines.
perform status_range.
perform auto_reconcile.
when c_mrecon.
perform popup_message using text-126
changing v_answer.
if v_answer = c_1.
perform get_lines.
perform manual_reconciliation.
endif.
when c_reslts.
perform get_lines.
call screen 104.
when c_fnote.
perform get_lines.
perform make_file_note.
when c_mvtdtl or
c_msterr or
c_trnerr or
c_inamst or
c_inatrn or
c_all.
perform get_lines.
call screen 103.
when c_mstmap.
call transaction c_mst_map.
when c_trnmap.
call transaction c_trn_map.
when others.
endcase.
endmodule. " user_command_0100 INPUT
&----
*& Form get_lines
&----
text
----
--> p1 text
<-- p2 text
----
form get_lines .
call method grid100->get_selected_rows
importing
et_index_rows = it_rows.
if it_rows[] is initial.
message e000 with text-115.
endif.
endform. " get_lines
&----
*& Form manual_reconciliation
&----
text
----
--> p1 text
<-- p2 text
----
form manual_reconciliation .
call method lcl_program_utilities=>get_index
exporting
e_index = '1'
importing
i_index = v_index.
read table it_main index v_index into w_main.
case w_main-status.
when c_m.
v_objnam = c_interface.
w_doco = w_main-objnr.
when others.
v_objnam = c_interface.
concatenate w_main-batch_no
w_main-sequence_no
into v_docnam separated by c_colon.
endcase.
call function 'Z_OVERRIDE_DOCO'
exporting
folder = w_folder
doco = w_doco
folder_name = v_objnam
doco_name = v_docnam
importing
new_doco = w_new_doco
answer = v_retcode
exceptions
folder_not_found = 1
item_not_found = 2
empty_item = 3
docname_missing = 4
others = 5.
case sy-subrc.
when c_0.
*<= Only change the status of the batch to M if the original status
*<= was U.
if w_main-status = c_u.
w_main-status = c_m.
w_main-status_text = text-104.
w_main-objnr = w_new_doco.
w_main-line_colour = c_c410.
modify it_main from w_main index w_rows-index transporting
status
status_text
objnr
line_colour.
update zzhp_mvt_hdr set status = c_m
objtp = w_new_doco-objtp
objyr = w_new_doco-objyr
objno = w_new_doco-objno
where original_file = w_main-original_file
and batch_no = w_main-batch_no
and sequence_no = w_main-sequence_no.
else.
modify it_main from w_main index w_rows-index transporting
objnr.
update zzhp_mvt_hdr set objtp = w_new_doco-objtp
objyr = w_new_doco-objyr
objno = w_new_doco-objno
where original_file = w_main-original_file
and batch_no = w_main-batch_no
and sequence_no = w_main-sequence_no.
endif.
when c_1.
message id w_config-message_id type c_i number c_000
with text-120.
when c_2.
message id w_config-message_id type c_i number c_000
with text-121.
when c_3.
message id w_config-message_id type c_i number c_000
with text-122.
when others.
message id w_config-message_id type c_i number c_000
with text-123.
endcase.
endform. " manual_reconciliation
&----
*& Form get_sap_document
&----
text
----
-->P_OBJTP text
-->P_OBJYR text
-->P_OBJNO text
<--P_OBJNR text
----
form get_sap_document using p_objtp
p_objyr
p_objno
changing p_objnr.
concatenate p_objtp p_objyr p_objno into p_objnr.
endform. " get_sap_document
&----
*& Form get_status_text
&----
text
----
-->P_STATUS text
<--P_P_STATUS text
----
form get_status_text using p_status
changing p_p_status
p_p_line_colour.
case p_status.
when c_e. " Errors in file
p_p_status = text-101.
p_p_line_colour = c_c610.
when c_d. " Reconciled and movement
p_p_status = text-112.
p_p_line_colour = c_c610.
when c_f. " Finished
p_p_status = text-102.
p_p_line_colour = c_c310.
when c_m. " Manual
p_p_status = text-104.
p_p_line_colour = c_c410.
when c_i. " Initial
p_p_status = text-103.
p_p_line_colour = c_c310.
when c_p. " Processed SAP
p_p_status = text-105.
p_p_line_colour = c_c710.
when c_r. " Reconciled
p_p_status = text-100.
p_p_line_colour = c_c510.
when c_u. " Un-Reconciled
p_p_status = text-106.
p_p_line_colour = c_c610.
when c_v. " Validation Errors
p_p_status = text-107.
w_main-line_colour = c_c610.
when c_x. " Posted Document Reversed
p_p_status = text-108.
p_p_line_colour = c_c610.
when c_1.
p_p_status = text-108.
p_p_line_colour = c_c610.
when c_2.
p_p_status = text-108.
p_p_line_colour = c_c610.
when others.
endcase.
endform. " get_status_text
<= Local Class Implementation => ********************
----
CLASS lcl_event_receiver IMPLEMENTATION
----
*
----
class lcl_event_receiver implementation.
method handle_hotspot_click.
case e_column_id.
when c_belnr.
read table it_accounting into w_accounting index e_row_id.
set parameter id 'BLN' field w_accounting-belnr.
set parameter id 'BUK' field w_accounting-bukrs.
set parameter id 'GJR' field w_accounting-gjahr.
call transaction c_fb03 and skip first screen.
endcase.
endmethod. "handle_hotspot_click
method handle_toolbar.
*<= Add refresh button
clear s_toolbar.
move 3 to s_toolbar-butn_type.
append s_toolbar to e_object->mt_toolbar.
clear s_toolbar.
move 'REFR' to s_toolbar-function.
move text-002 to s_toolbar-quickinfo.
move icon_refresh to s_toolbar-icon.
move 0 to s_toolbar-butn_type.
move space to s_toolbar-disabled.
append s_toolbar to e_object->mt_toolbar.
endmethod. "handle_toolbar
method handle_user_command.
case e_ucomm.
when 'REFR'.
perform get_data_100.
call screen 100.
endcase.
endmethod. "handle_user_command
endclass. "lcl_event_receiver IMPLEMENTATION
----
CLASS lcl_program_utilities IMPLEMENTATION
----
*
----
class lcl_program_utilities implementation.
method get_index.
read table it_rows index e_index into w_rows.
i_index = w_rows-index.
endmethod. "get_index
endclass. "lcl_program_utilities IMPLEMENTATION
&----
*& Form get_description
&----
text
----
-->P_ORIGINAL_FILE text
<--P_DESCRIPTION text
----
form get_description using p_original_file
changing p_description.
select single description into p_description
from zziface_descript
where original_file eq p_original_file.
endform. " get_description
&----
*& Form make_file_note
&----
text
----
--> p1 text
<-- p2 text
----
form make_file_note .
call method lcl_program_utilities=>get_index
exporting
e_index = '1'
importing
i_index = v_index.
read table it_main index v_index into w_main.
v_objnam = c_interface.
if not w_main-objnr is initial.
w_doco = w_main-objnr.
else.
concatenate w_main-batch_no
w_main-sequence_no
into v_docnam separated by c_colon.
endif.
call function 'Z_OVERRIDE_DOCO'
exporting
folder = w_folder
doco = w_doco
folder_name = v_objnam
doco_name = v_docnam
importing
new_doco = w_new_doco
answer = v_retcode
exceptions
folder_not_found = 1
item_not_found = 2
empty_item = 3
docname_missing = 4
others = 5.
if sy-subrc = 0.
update zzhp_mvt_hdr set objtp = w_new_doco-objtp
objyr = w_new_doco-objyr
objno = w_new_doco-objno
where original_file = w_mvt_hdr-original_file
and batch_no = w_mvt_hdr-batch_no
and sequence_no = w_mvt_hdr-sequence_no.
endif.
endform. " make_file_note
&----
*& Module status_0101 OUTPUT
&----
text
----
module status_0101 output.
set pf-status '0101'.
set titlebar '0101'.
perform build_fieldcat_101.
perform get_data_101.
if it_accounting[] is initial.
message i000 with text-114.
call screen 100.
endif.
if cust101 is initial.
create object cust101 exporting container_name = 'CUST101'.
create object grid101 exporting i_parent = cust101.
call method grid101->set_table_for_first_display
exporting
i_structure_name = 'IT_ACCOUNTING'
is_layout = s_layo
changing
it_outtab = it_accounting
it_fieldcatalog = it_fieldcat101.
else.
call method grid101->refresh_table_display.
endif.
endmodule. " status_0101 OUTPUT
&----
*& Form build_fieldcat_101
&----
text
----
--> p1 text
<-- p2 text
----
form build_fieldcat_101 .
w_fieldcat-fieldname = 'BUKRS'.
w_fieldcat-tabname = 'IT_ACCOUNTING'.
w_fieldcat-coltext = 'Company Code'.
append w_fieldcat to it_fieldcat101.
clear w_fieldcat.
w_fieldcat-fieldname = 'BELNR'.
w_fieldcat-tabname = 'IT_ACCOUNTING'.
w_fieldcat-coltext = 'Document Number'.
w_fieldcat-hotspot = c_x.
append w_fieldcat to it_fieldcat101.
clear w_fieldcat.
w_fieldcat-fieldname = 'GJAHR'.
w_fieldcat-tabname = 'IT_ACCOUNTING'.
w_fieldcat-coltext = 'Fiscal Year'.
append w_fieldcat to it_fieldcat101.
clear w_fieldcat.
w_fieldcat-fieldname = 'TOTAL'.
w_fieldcat-tabname = 'IT_ACCOUNTING'.
w_fieldcat-coltext = 'Debit/Credit'.
append w_fieldcat to it_fieldcat101.
clear w_fieldcat.
w_fieldcat-fieldname = 'ITEMS'.
w_fieldcat-tabname = 'IT_ACCOUNTING'.
w_fieldcat-coltext = 'Items'.
append w_fieldcat to it_fieldcat101.
clear w_fieldcat.
endform. " build_fieldcat_101
&----
*& Form get_data_101
&----
text
----
--> p1 text
<-- p2 text
----
form get_data_101 .
data: lv_wrbtr type bseg-wrbtr,
lv_shkzg type bseg-shkzg.
call method lcl_program_utilities=>get_index
exporting
e_index = '1'
importing
i_index = v_index.
read table it_main index v_index into w_main.
perform create_ref_doc using w_main-batch_no
w_main-sequence_no
changing v_xblnr.
select bukrs belnr gjahr into table it_accounting
from bkpf
where budat eq w_main-create_date
where xblnr eq v_xblnr.
loop at it_accounting into w_accounting.
select wrbtr shkzg into (lv_wrbtr, lv_shkzg)
from bseg
where bukrs eq w_accounting-bukrs
and belnr eq w_accounting-belnr
and gjahr eq w_accounting-gjahr.
if lv_shkzg = c_s.
add lv_wrbtr to w_accounting-total.
endif.
add 1 to w_accounting-items.
endselect.
modify it_accounting from w_accounting transporting total items.
endloop.
sort it_accounting.
endform. " get_data_101
&----
*& Module status_0103 OUTPUT
&----
text
----
module status_0103 output.
set pf-status '0103'.
set titlebar '0103'.
perform get_data_103.
if <mvt_dtl> is initial.
message i000 with text-114.
call screen 100.
endif.
if cust103 is initial.
create object cust103 exporting container_name = 'CUST103'.
create object grid103 exporting i_parent = cust103.
call method grid103->set_table_for_first_display
exporting
i_structure_name = w_config-mvt_dtl_tab
is_layout = s_layo
changing
it_outtab = <mvt_dtl>.
else.
call method grid103->refresh_table_display.
endif.
endmodule. " status_0103 OUTPUT
&----
*& Form get_data_103
&----
text
----
--> p1 text
<-- p2 text
----
form get_data_103 .
call method lcl_program_utilities=>get_index
exporting
e_index = '1'
importing
i_index = v_index.
read table it_main index v_index into w_main.
perform get_movement_details.
endform. " get_data_103
&----
*& Form get_movement_details
&----
text
----
--> p1 text
<-- p2 text
----
form get_movement_details .
data: lv_where_clause type string.
*<= Create internal table and assign a field-symbol
create data it_mvt_dtl_var type table of (w_config-mvt_dtl_tab).
assign it_mvt_dtl_var->* to <mvt_dtl>.
case v_okcode.
when c_mvtdtl.
concatenate c_fname ' eq 0' into lv_where_clause.
when c_msterr.
concatenate c_fname ' eq 1' into lv_where_clause.
when c_trnerr.
concatenate c_fname ' eq 3' into lv_where_clause.
when c_inamst.
concatenate c_fname ' eq 2' into lv_where_clause.
when c_inatrn.
concatenate c_fname ' eq 4' into lv_where_clause.
when c_all.
select * into table <mvt_dtl>
from (w_config-mvt_dtl_tab)
where original_file eq w_main-original_file
and batch_no eq w_main-batch_no.
exit.
when others.
endcase.
select * into table <mvt_dtl>
from (w_config-mvt_dtl_tab)
where original_file eq w_main-original_file
and batch_no eq w_main-batch_no
and (lv_where_clause).
endform. " get_movement_details
&----
*& Module status_0104 OUTPUT
&----
text
----
module status_0104 output.
set pf-status '0104'.
set titlebar '0104'.
perform get_data_104.
if <results>[] is initial.
message i000 with text-114.
call screen 100.
else.
it_results[] = <results>[].
endif.
if cust104 is initial.
create object cust104 exporting container_name = 'CUST104'.
create object grid104 exporting i_parent = cust104.
call method grid104->set_table_for_first_display
exporting
i_structure_name = w_config-results_tab
is_layout = s_layo
changing
it_outtab = <results>.
else.
call method grid104->refresh_table_display.
endif.
endmodule. " status_0104 OUTPUT
&----
*& Form get_data_104
&----
text
----
--> p1 text
<-- p2 text
----
form get_data_104.
call method lcl_program_utilities=>get_index
exporting
e_index = '1'
importing
i_index = v_index.
read table it_main index v_index into w_main.
perform get_results.
endform. " get_data_104
&----
*& Form get_results
&----
text
----
--> p1 text
<-- p2 text
----
form get_results .
data: lv_where_clause type string.
*<= Create internal table and assign a field-symbol
create data it_results_var type table of (w_config-results_tab).
assign it_results_var->* to <results>.
*<= Set dynamic where clause
concatenate w_config-batch_fieldname ' eq w_main-batch_no'
into lv_where_clause.
select * into table <results>
from (w_config-results_tab)
where original_file eq w_main-original_file
and (lv_where_clause).
endform. " get_results
&----
*& Form get_email_recipients
&----
text
----
--> p1 text
<-- p2 text
----
form get_email_recipients .
select * into table it_mailto
from zziface_mailto
where business_owner = c_hiport.
endform. " get_email_recipients
&----
*& Form send_email
&----
text
----
--> p1 text
<-- p2 text
----
form send_email .
data: lif_recipient type ref to if_recipient_bcs,
lw_recipient type bcss_re3 ,
lv_email type ad_smtpadr ,
lv_subject type so_obj_des .
lv_subject = text-118.
try.
send_request = cl_bcs=>create_persistent( ).
catch cx_bcs into bcs_exception.
endtry.
try.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = it_content
i_length = '12'
i_subject = lv_subject ).
call method send_request->set_document( document ).
catch cx_bcs into bcs_exception.
endtry.
*<= Build receiver list for sending email
try.
loop at it_mailto into w_mailto.
perform get_email_address using w_mailto-receiver
changing lv_email.
lif_recipient = cl_cam_address_bcs=>create_internet_address(
lv_email ).
call method send_request->add_recipient
exporting
i_recipient = lif_recipient
i_express = ' '.
endloop.
catch cx_bcs into bcs_exception.
endtry.
endform. " send_email
&----
*& Form get_email_address
&----
text
----
<--P_EMAIL text
----
form get_email_address using p_perno
changing p_email.
data: lv_uname type sy-uname.
*<= Step 1 - Get the SAP user name based on the Personel No
select * from pa0105
where pernr = p_perno
and subty = c_usr
and begda le sy-datum
and endda ge sy-datum.
endselect.
lv_uname = pa0105-usrid.
*<= Step 2 - Get the email address for the user
call function 'EFG_GEN_GET_USER_EMAIL'
exporting
i_uname = lv_uname
importing
e_email_address = p_email
exceptions
not_qualified = 1
user_not_found = 2
address_not_found = 3
others = 4.
endform. " get_email_address
&----
*& Form popup_message
&----
text
----
-->P_TEXT text
<--P_ANSWER text
----
form popup_message using p_text
changing p_answer.
call function 'POPUP_TO_CONFIRM'
exporting
titlebar = c_warning
text_question = p_text
text_button_1 = c_continue
text_button_2 = c_cancel
default_button = c_1
display_cancel_button = ' '
start_column = 25
start_row = 6
importing
answer = p_answer
exceptions
others = 1.
endform. " popup_message
‎2007 Jan 04 10:42 PM
Hello Neil
I am actually an expatriate from Germany who has spent the last 15 year here in Zürich. Now, back to business.
Have a look at my sample report which I tried to adjust based on your logic. The reason why refreshing the ALV list does not work is as following:
- Any time your report executes the following coding
a new data reference is created, e.g. in my report I had
- = empty itab at beginning - = filled itab after 1st line select[/code]
The de-referencing of this data reference to the field-symbols results in a different itab irrespective of whether it is the very same field-symbols. In other words:
- When you start my report and dynpro '100' (customers) is displayed the grid instance go_grid2 points to the itab corresponding to - When you select a single customer and push button "DETAIL" the itab corresponding to holds the sales area data
- Refreshing the list display for go_grid2 points still to the itab corresponding to and, therefore, will not display any sales areas Conclusion: to link the "new" itab corresponding to to go_grid2 we must use method SET_TABLE_FOR_FIRST_DISPLAY
Finally, here is the coding. Please note that for an odd reason you have to push the BACK button twice to leave the customer ALV list when the detailed ALV list has been displayed at least once.
*
*& Report ZUS_SDN_TWO_ALV_GRIDS_FS
*&
*&----
*
*&
*&
*&----
*
REPORT ZUS_SDN_TWO_ALV_GRIDS_FS.
DATA:
gd_okcode TYPE ui_func,
gd_okcode_save TYPE ui_func,
*
go_docking1 TYPE REF TO cl_gui_docking_container,
go_docking2 TYPE REF TO cl_gui_docking_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_knvv TYPE STANDARD TABLE OF knvv.
DATA:
gdo_itab TYPE REF TO data.
FIELD-SYMBOLS:
TYPE table.
PARAMETERS:
p_tabnam TYPE tabname DEFAULT 'KNVV' NO-DISPLAY.
*----
*
CLASS lcl_eventhandler DEFINITION
*----
*
*
*----
*
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
*----
*
CLASS lcl_eventhandler IMPLEMENTATION
*----
*
*
*----
*
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
define local data
DATA:
ls_knb1 TYPE knb1.
CHECK ( sender = go_grid1 ).
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
IS_ROW_ID =
IS_COLUMN_ID =
is_row_no = es_row_no.
Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
Create docking containers
CREATE OBJECT go_docking1
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_docking2
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_docking1
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CREATE OBJECT go_grid2
EXPORTING
i_parent = go_docking2
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Set event handler
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.
Display data
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
CHANGING
it_outtab = gt_knb1
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Should retrieve no details (i.e. sales areas) because no rows
have been selected yet.
PERFORM entry_show_details.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = p_tabnam
CHANGING
it_outtab = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Link the docking container to the target dynpro
CALL METHOD go_docking1->link
EXPORTING
repid = syst-repid
dynnr = '0100'
CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_docking2->link
EXPORTING
repid = syst-repid
dynnr = '0101'
CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
Flow logic of dynpro:
*
*PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
**
*PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*&----
*
*& Module STATUS_0100 OUTPUT
*&----
*
text
*----
*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
SET TITLEBAR 'xxx'.
Display field-symbol itab again (refresh will not work !!!)
*$Comment
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = p_tabnam
CHANGING
it_outtab = 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_grid2->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
finished = 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.
*$Comment
ENDMODULE. " STATUS_0100 OUTPUT
*&----
*
*& Module USER_COMMAND_0100 INPUT
*&----
*
text
*----
*
MODULE user_command_0100 INPUT.
gd_okcode_save = gd_okcode.
CLEAR: gd_okcode.
CASE gd_okcode_save.
WHEN 'BACK' OR
'END' OR
'CANC'.
CASE syst-dynnr.
WHEN '0100'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
SET SCREEN '0100'. LEAVE SCREEN.
ENDCASE.
User has pushed button "Display Details"
WHEN 'DETAIL'.
PERFORM entry_show_details.
CALL SCREEN '0101'.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode_save.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&----
*
*& Form ENTRY_SHOW_DETAILS
*&----
*
text
*----
*
--> p1 text
<-- p2 text
*----
*
FORM entry_show_details .
define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1.
*$Comment IF ( gdo_itab IS INITIAL ).
CREATE DATA gdo_itab TYPE TABLE OF (p_tabnam).
*$Comment ENDIF.
ASSIGN gdo_itab->* TO 😞
(1) Replace SET_TABLE_FOR_FIRST_DISPLAY method with REFRESH_TABLE_DISPLAY in PBO module
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
SET TITLEBAR 'xxx'.
Display field-symbol itab again (refresh will not work !!!)
*$Comment
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = p_tabnam
CHANGING
it_outtab = <gt_outtab>
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL METHOD go_grid2->refresh_table_display
EXPORTING
IS_STABLE =
I_SOFT_REFRESH =
EXCEPTIONS
finished = 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.
*$Comment
ENDMODULE. " STATUS_0100 OUTPUT[/code]
(2) Create the data reference only once in the FORM routine
define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1.
Create the data reference only once
IF ( gdo_itab IS INITIAL ).
CREATE DATA gdo_itab TYPE TABLE OF (p_tabnam).
ENDIF.
...
ENDFORM.[/code]
Regards
Uwe
‎2007 Jan 04 11:21 PM
Hi Uwe,
That now makes total sense to me! Thanks for the help on this matter. I have changed nmy code to call the method 'set_table_for_first_display' evertime.
Cheers,
Neil.