10-08-2007 5:32 PM
Hi Gurus,
I have a report program, when i run it I display an output summary on ALV Grid, and when i click on each of the row in the output summary, I'm suppose to see the item detail of each record.
This item detail is showing for some record and is not showing for some other records (when i use different selections). I debugged it and observed that the table populating the ALV grid actually has records in it. The ALV grid is not just displaying the records.
I debugged the 2 examples (one showing record and the other not showing), I found out that nothing is different in the way they run till they populate the final internal record to passed to the ALV Grid.
Please any suggestions on this:
This is the function code for the ALV grid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_program_id
i_callback_pf_status_set = c_detail_status
i_callback_user_command = c_detail_user_comm
i_grid_title = lv_grid_title
is_layout = w_detail_layout
it_fieldcat = i_detail_fieldcat
it_sort = i_detail_sort
TABLES
t_outtab = i_faglflexa[] "NEM - detail
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e064
WITH sy-subrc.
Function REUSE_ALV_GRID_DISPLAY failed on detail view SY-SUBRC = &
ENDIF.
10-08-2007 5:37 PM
Hi Basil, please send the full code.
Maybe your fieldcat is the problem.
Regards.
RP
10-08-2007 7:15 PM
This is the full code:
----
***INCLUDE ZFIGL_HYPERION_F01.
----
&----
*& Form open_files
&----
Open files used by the program.
----
FORM open_files.
OPEN DATASET p_fileot FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
MESSAGE g_message.
IF sy-subrc <> 0.
MESSAGE e056
WITH g_message.
Unable to open output file &
ENDIF.
ENDFORM. " open_files
&----
*& Form close_files
&----
Close files used by the program.
----
FORM close_files.
CLOSE DATASET p_fileot.
ENDFORM. " close_files
&----
*& Form extract_data
&----
Extract data from database needed to generate output file and report.
----
FORM extract_data.
Get the required general ledger totals records.
PERFORM get_faglflext_data.
Derive any other necessary fields for I_FAGLFLEXT.
PERFORM derive_add_fields_faglflext.
Split records by fiscal period.
PERFORM split_records_by_period.
Summarize the detail records to allow for creation of the file and
reporting.
PERFORM summarize_records_by_period.
Get the required general ledger actual line items records.
PERFORM get_faglflexa_data.
Derive any other necessary fields for I_FAGLFLEXA.
PERFORM derive_add_fields_faglflexa.
Sort the detail and summary output tables into key sequence.
PERFORM sort_output_tables.
ENDFORM. " extract_data
&----
*& Form process_data
&----
Create the requested file and report.
----
FORM process_data.
Create the local file if requested by the user or the month-end file
at month-end.
IF cb_test = c_not_selected.
PERFORM create_pc_file.
ELSEIF sy-uname = c_user_batch_admin.
PERFORM create_output_file.
ENDIF.
Create the necessary tables for summary ALV report.
PERFORM build_summary_layout.
PERFORM build_summary_field_catalog.
PERFORM build_summary_sort_table.
Check to see that there is data in the summary output table. If yes,
generate report, if not, then give a message to the user.
READ TABLE i_output_summary INDEX 1 TRANSPORTING NO FIELDS.
IF sy-subrc <> 0.
MESSAGE s062.
STOP.
No data extracted for selection criteria entered
ENDIF.
Generate the summary ALV report view.
PERFORM generate_summary_alv_report.
ENDFORM. " process_data
&----
*& Form verify_user_selections
&----
Verify data input by the user.
----
FORM verify_user_selections.
IF NOT p_ryear IS INITIAL.
IF p_ryear < 2006 OR
p_ryear > 2100.
MESSAGE e057.
Fiscal year is invalid
ENDIF.
ENDIF.
If program is being run in a non-test mode and the user has left the
fiscal year selection blank, display a error message.
IF cb_test IS INITIAL AND
p_ryear IS INITIAL.
MESSAGE e058.
A fiscal year must be entered when generating the file
ENDIF.
If program is being run in a non-test mode and the user has left the
period selection blank, display a error message.
IF cb_test IS INITIAL AND
s_rpmax IS INITIAL.
MESSAGE e132.
A period must be entered when generating the file
ENDIF.
IF cb_test IS INITIAL AND
p_lfile IS INITIAL.
MESSAGE e071.
Local filename is required when generating the file
ENDIF.
****Basil Balogun's addition to include the hyperion acct in selection. (10/03/2007)***
IF s_rhype IS NOT INITIAL.
LOOP AT s_rhype.
CLEAR r_hyper.
r_hyper-sign = 'I'.
r_hyper-option = 'CP'.
CONCATENATE '' s_rhype-low '' INTO r_hyper-low.
APPEND r_hyper.
ENDLOOP.
SELECT bukrs saknr hyper
FROM zall_gl_hype INTO TABLE i_zall_gl
WHERE hyper IN r_hyper.
LOOP AT i_zall_gl INTO w_zall_gl.
w_zall_gl1-saknr = w_zall_gl-saknr.
w_zall_gl2-bukrs = w_zall_gl-bukrs.
APPEND w_zall_gl1-saknr TO i_zall_gl1.
APPEND w_zall_gl2-bukrs TO i_zall_gl2.
CLEAR: w_zall_gl, w_zall_gl1, w_zall_gl2.
ENDLOOP.
SORT i_zall_gl1 BY saknr.
SORT i_zall_gl2 BY bukrs.
DELETE ADJACENT DUPLICATES FROM i_zall_gl1 COMPARING saknr.
DELETE ADJACENT DUPLICATES FROM i_zall_gl2 COMPARING bukrs.
IF s_racct IS INITIAL.
LOOP AT i_zall_gl1 INTO w_zall_gl1.
r_saknr-sign = 'I'.
r_saknr-option = 'EQ'.
r_saknr-low = w_zall_gl1.
APPEND r_saknr.
CLEAR r_saknr.
CLEAR w_zall_gl1.
ENDLOOP.
ELSE.
r_saknr[] = s_racct[].
ENDIF.
IF s_rbukrs IS INITIAL.
LOOP AT i_zall_gl2 INTO w_zall_gl2.
r_bukrs-sign = 'I'.
r_bukrs-option = 'EQ'.
r_bukrs-low = w_zall_gl2-bukrs.
APPEND r_bukrs.
CLEAR r_bukrs.
CLEAR w_zall_gl2.
ENDLOOP.
ELSE.
r_bukrs[] = s_rbukrs[].
ENDIF.
ELSE.
r_saknr[] = s_racct[].
r_bukrs[] = s_rbukrs[].
SELECT bukrs saknr hyper
FROM zall_gl_hype INTO TABLE i_zall_gl.
ENDIF.
****Basil Balogun's addition to include the hyperion acct in selection. (10/03/2007)***
ENDFORM. " verify_user_selections
&----
*& Form get_faglflext_data
&----
Get FAGLFLEXT (General Ledger: Totals) data from the database.
----
FORM get_faglflext_data .
Use the fiscal year for the selection, if it was populated by the
user.
IF NOT p_ryear IS INITIAL.
SELECT ryear rldnr rvers racct rbukrs prctr rfarea kokrs segment
zzsarea zzsareaim rassc hsl01 hsl02 hsl03 hsl04 hsl05 hsl06
hsl07 hsl08 hsl09 hsl10 hsl11 hsl12 hsl13 hsl14 hsl15 hsl16
hslvt
INTO TABLE i_faglflext
FROM faglflext
WHERE rldnr = c_run_ledger AND
rbukrs IN r_bukrs AND
racct IN r_saknr AND
rfarea IN s_rfarea AND
prctr IN s_prctr AND
ryear = p_ryear AND
rvers = c_run_version.
ELSE.
SELECT ryear rldnr rvers racct rbukrs prctr rfarea kokrs segment
zzsarea zzsareaim rassc hsl01 hsl02 hsl03 hsl04 hsl05 hsl06
hsl07 hsl08 hsl09 hsl10 hsl11 hsl12 hsl13 hsl14 hsl15 hsl16
hslvt
INTO TABLE i_faglflext
FROM faglflext
WHERE rldnr = c_run_ledger AND
rbukrs IN r_bukrs AND
racct IN r_saknr AND
rfarea IN s_rfarea AND
prctr IN s_prctr AND
rvers = c_run_version.
ENDIF.
ENDFORM. " get_faglflext_data
&----
*& Form derive_add_fields_faglflext
&----
Derive additional fields needed for the I_FAGLFLEXT.
----
FORM derive_add_fields_faglflext.
Get needed company code and profit center data from the database.
PERFORM get_t001_data.
PERFORM get_t880_data.
READ TABLE i_faglflext INDEX 1 TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
PERFORM get_cepc_data.
ENDIF.
SORT i_zall_gl BY bukrs saknr.
LOOP AT i_faglflext INTO w_faglflext.
Get necessary company code data.
READ TABLE i_t001 INTO w_t001
WITH KEY bukrs = w_faglflext-rbukrs
BINARY SEARCH.
IF sy-subrc <> 0.
MESSAGE e059
WITH w_faglflext-rbukrs.
Company code & not found on table T001
ENDIF.
Determine the entity.
PERFORM derive_entity USING w_t001-rcomp
CHANGING w_faglflext-entity.
Determine the strategic segment.
PERFORM derive_strategic_segment USING w_faglflext-rassc
w_faglflext-prctr
CHANGING w_faglflext-strat_seg
w_faglflext-zzsareaim
w_faglflext-zzsarea.
Determine the strategic segment channel.
PERFORM derive_strat_seg_chnl USING w_faglflext-rassc
w_faglflext-prctr
CHANGING w_faglflext-strat_seg_chnl.
Determine the all item ID and all products.
PERFORM derive_all_item_id USING w_t001-waers
CHANGING w_faglflext-all_item_id
w_faglflext-all_products.
Determine the all customers and all customers channel.
PERFORM derive_all_customers_fields USING w_faglflext-strat_seg
*w_faglflext-strat_seg_chnl
CHANGING w_faglflext-all_cust
*w_faglflext-all_cust_chnl.
Determine the sub account using the company ID of the trading partner.
PERFORM derive_sub_account USING w_faglflext-rassc
CHANGING w_faglflext-sub_acct.
PERFORM derive_sub_account USING w_t001-rcomp
w_faglflext-rassc
CHANGING w_faglflext-sub_acct.
****Begin Basil changes to include hyperion acct in selection (10/03/2007).
READ TABLE i_zall_gl INTO w_zall_gl
WITH KEY bukrs = w_faglflext-rbukrs
saknr = w_faglflext-racct
BINARY SEARCH.
IF sy-subrc = 0.
****End Basil changes to include hyperion acct in selection (10/03/2007).
Determine the Hyperion account number from G/L account long text.
PERFORM derive_hyperion_account USING w_faglflext-racct
w_faglflext-rfarea
"KMK5/22/06 ITR: 20592
w_faglflext-sub_acct
w_faglflext-rassc
w_faglflext-prctr
CHANGING w_faglflext-hyperion_acct
w_faglflext-reverse_sign "NEM8/21/06 ITR: 24286
w_faglflext-balance_sheet "NEM8/21/06 ITR: 24286
w_faglflext-zzsarea
w_faglflext-zzsareaim
w_faglflext-strat_seg.
ENDIF.
Determine the all customers and all customers channel.
PERFORM derive_all_customers_fields USING w_faglflext-strat_seg
w_faglflext-strat_seg_chnl
CHANGING w_faglflext-all_cust
w_faglflext-all_cust_chnl.
Update i_FAGLFLEXT with the newly derive fields.
MODIFY i_faglflext FROM w_faglflext
TRANSPORTING entity
strat_seg
strat_seg_chnl
all_item_id
all_products
all_cust
all_cust_chnl
hyperion_acct
sub_acct
fiscal_period
zzsarea
zzsareaim
reverse_sign "NEM8/21/06 ITR: 24286
balance_sheet. "NEM8/21/06 ITR: 24286
ENDLOOP.
CHECK s_rhype IS NOT INITIAL.
SORT s_rhype BY low.
LOOP AT i_faglflext INTO w_faglflext.
READ TABLE s_rhype WITH KEY low = w_faglflext-hyperion_acct.
IF sy-subrc NE 0.
CLEAR w_faglflext-hyperion_acct.
MODIFY i_faglflext FROM w_faglflext.
ENDIF.
ENDLOOP.
DELETE i_faglflext WHERE hyperion_acct IS INITIAL.
ENDFORM. " derive_add_fields_faglflext
&----
*& Form derive_entity
&----
Derive the entity using the company code.
----
-->RCOMP - Company code.
<--ENTITY - Entity
----
FORM derive_entity USING rcomp TYPE t_t001-rcomp
CHANGING entity TYPE t_faglflext-entity.
CLEAR:
entity.
Get necessary global company code data.
READ TABLE i_t880 INTO w_t880
WITH KEY rcomp = rcomp
BINARY SEARCH.
IF sy-subrc = 0.
entity = w_t880-name2+0(3).
TRANSLATE entity TO UPPER CASE.
ELSE.
MESSAGE e060
WITH w_t001-rcomp.
Company code & not found on table T880
ENDIF.
ENDFORM. " derive_entity
&----
*& Form get_t001_data
&----
Get T001 (Company Codes) data from the database.
----
FORM get_t001_data.
SELECT bukrs waers rcomp
INTO TABLE i_t001
FROM t001
CLIENT SPECIFIED
WHERE mandt = sy-mandt.
SORT i_t001 BY bukrs.
ENDFORM. " get_t001_data
&----
*& Form get_t880_data
&----
Get T880 (Global Company Data (for KONS Ledger)) data from the
database.
----
FORM get_t880_data.
SELECT rcomp name2
INTO TABLE i_t880
FROM t880
CLIENT SPECIFIED
WHERE mandt = sy-mandt.
SORT i_t880 BY rcomp.
ENDFORM. " get_t880_data
&----
*& Form derive_all_item_id
&----
Derive the all item ID from the company code currency key.
----
-->WAERS - Currency key.
<--ALL_ITEM_ID - All item ID.
<--ALL_ITEM_ID - All item ID.
----
FORM derive_all_item_id USING waers TYPE t_t001-waers
CHANGING all_item_id TYPE t_faglflext-all_item_id
all_products TYPE t_faglflext-all_products
.
CLEAR:
all_item_id.
Populate all item ID.
all_item_id = c_all_item_id.
IF waers = c_us_dollars.
REPLACE '*' WITH c_united_states INTO all_item_id.
ELSE.
REPLACE '*' WITH c_local INTO all_item_id.
ENDIF.
Populate all products.
all_products = c_all_products.
TRANSLATE all_products TO UPPER CASE.
ENDFORM. " derive_all_item_id
&----
*& Form derive_all_customers_fields
&----
Derive the all customers and all customer channel fields from
the strategic segment and strategic segment channel respectively.
----
-->STRAT_SEG - Strategic segment.
-->STRAT_SEG_CHNL - Strategic segment channel.
<--ALL_CUST - All customers.
<--ALL_CUST_CHNL - All customers channel.
----
FORM derive_all_customers_fields USING strat_seg TYPE
t_faglflext-strat_seg
strat_seg_chnl TYPE
t_faglflext-strat_seg_chnl
CHANGING all_cust TYPE
t_faglflext-all_cust
all_cust_chnl TYPE
t_faglflext-all_cust_chnl.
CLEAR:
all_cust,
all_cust_chnl.
all_cust = strat_seg.
all_cust+2(1) = c_all_customers.
TRANSLATE all_cust TO UPPER CASE.
all_cust_chnl = strat_seg_chnl.
TRANSLATE all_cust_chnl TO UPPER CASE.
ENDFORM. " derive_all_customers_fields
&----
*& Form derive_hyperion_account
&----
Read G/L account long text to get the Hyperion account number.
----
-->RACCT - SAP G/L account number.
<--HYPERION_ACCT - Hyperion account number.
----
FORM derive_hyperion_account USING racct TYPE t_faglflext-racct
farea TYPE t_faglflext-rfarea
"KMK5/22/06 ITR 20592
sub_account TYPE
t_faglflext-sub_acct
rassc TYPE t_faglflext-rassc
prctr TYPE t_faglflext-prctr
CHANGING hyperion_acct TYPE t_faglflext-hyperion_acct
reverse_sign TYPE t_faglflext-reverse_sign "NEM8/21/06 ITR: 24286
balance_sheet TYPE t_faglflext-balance_sheet "NEM8/21/06 ITR: 24286
zzsarea TYPE t_faglflext-zzsarea
zzsareaim TYPE t_faglflext-zzsareaim
strat_seg TYPE t_faglflext-strat_seg.
DATA:
lv_text_name TYPE thead-tdname,
l_strl TYPE i VALUE 0,
l_hyperion_acct(10), "KMK5/20/06 ITR 20527
l_farea(10) VALUE '0000000000', "KMK5/22/06 ITR 20592
l_balance_sheet(1), "NEM8/17/06 ITR 25792
l_string TYPE tline-tdline. "NEM8/17/06 ITR 25792
DATA: l_hyp_account_1 TYPE tline-tdline,
l_hyp_account_2 TYPE tline-tdline,
l_hyp_account_3 TYPE tline-tdline.
reverse_sign = '1'.
SELECT SINGLE bilkt xbilk
FROM ska1
INTO (l_hyperion_acct,l_balance_sheet)
WHERE ktopl = c_global_tcoa
AND saknr = racct.
balance_sheet = l_balance_sheet.
l_string = w_zall_gl-hyper.
SEARCH l_string FOR '-'.
IF sy-subrc = '0'.
reverse_sign = -1.
ELSE.
reverse_sign = 1.
ENDIF.
CHECK w_zall_gl-hyper IS NOT INITIAL.
CLEAR: l_hyp_account_1, l_hyp_account_2, l_hyp_account_3.
SPLIT w_zall_gl-hyper
AT ';'
INTO l_hyp_account_1 l_hyp_account_2 l_hyp_account_3.
IF l_hyp_account_2 IS INITIAL. " Only one hyperion account
hyperion_acct = l_hyp_account_1+0(7).
l_strl = STRLEN( hyperion_acct ) - 1.
IF hyperion_acct+l_strl(1) EQ '1'.
CLEAR sub_account.
PERFORM repopulate_strategic_segment
USING rassc prctr
CHANGING strat_seg.
zzsareaim = g_hold_sales_type.
zzsarea = g_hold_sales_area.
ENDIF.
ELSE. " Two or more hyperion accounts
IF sub_account > ''.
hyperion_acct = l_hyp_account_2+0(7).
ELSE.
hyperion_acct = l_hyp_account_1+0(7).
ENDIF.
ENDIF.
CLEAR: w_hyperion.
w_hyperion-racct = racct.
w_hyperion-hyperion_acct = hyperion_acct.
w_hyperion-reverse_sign = reverse_sign.
ENDFORM. " derive_hyperion_account
&----
*& Form derive_sub_account
&----
Determine the sub account based on the company ID of the trading
partner.
----
-->RASSC - Company ID of trading partner.
<--SUB_ACCT - Sub account.
----
*FORM derive_sub_account USING rassc TYPE t_faglflext-rassc
CHANGING sub_acct TYPE t_faglflext-sub_acct.
*
IF rassc IS INITIAL.
CLEAR: sub_acct.
ELSE.
sub_acct = rassc.
TRANSLATE sub_acct TO UPPER CASE.
ENDIF.
*
*ENDFORM. " derive_sub_account
FORM derive_sub_account USING rcomp TYPE t_t001-rcomp
rassc TYPE t_faglflext-rassc
CHANGING sub_acct TYPE t_faglflext-sub_acct.
IF rassc IS INITIAL.
CLEAR: sub_acct.
ELSE.
READ TABLE i_t880 INTO w_t880
WITH KEY rcomp = rassc
BINARY SEARCH.
IF sy-subrc = 0.
sub_acct = w_t880-name2.
TRANSLATE sub_acct TO UPPER CASE.
ELSE.
MESSAGE e060
WITH w_t001-rcomp.
Company code & not found on table T880
ENDIF.
ENDIF.
ENDFORM. " derive_sub_account
&----
*& Form repopulate_strategic_segment
&----
Derive the strategic segment based on the company ID of the trading
partner or the profit center.
----
-->RASSC - Company ID of trading partner.
-->PRCTR - Profit center.
<--STRAT_SEG - Strategic segment.
----
FORM repopulate_strategic_segment USING rassc TYPE t_faglflext-rassc
prctr TYPE t_faglflext-prctr
CHANGING strat_seg TYPE t_faglflext-strat_seg
.
DATA:
lv_segment TYPE cepc-segment.
CLEAR:
strat_seg.
Find the valid profit center record.
LOOP AT i_cepc INTO w_cepc
WHERE prctr = prctr AND
datab <= sy-datum AND
datbi >= sy-datum.
Pad segment with leading zeros if necessary.
lv_segment = w_cepc-segment.
SHIFT lv_segment RIGHT DELETING TRAILING ' '.
TRANSLATE lv_segment USING ' 0'.
Get the segment name from FAGL_SEGMT (Master Data for Segments).
SELECT SINGLE *
FROM fagl_segmt
WHERE langu = sy-langu AND
segment = lv_segment.
IF sy-subrc = 0.
strat_seg = fagl_segmt-name+0(3).
TRANSLATE strat_seg TO UPPER CASE.
ENDIF.
ENDLOOP.
ENDFORM. "repopulate_strategic_segment
" repopulate_strategic_segment&----
"----
*
*& Form derive_strategic_segment
&----
Derive the strategic segment based on the company ID of the trading
partner or the profit center.
----
-->RASSC - Company ID of trading partner.
-->PRCTR - Profit center.
<--STRAT_SEG - Strategic segment.
----
FORM derive_strategic_segment USING rassc TYPE t_faglflext-rassc
prctr TYPE t_faglflext-prctr
CHANGING strat_seg TYPE t_faglflext-strat_seg
sales_type TYPE t_faglflext-zzsareaim
sales_area TYPE t_faglflext-zzsarea.
DATA:
lv_segment TYPE cepc-segment.
CLEAR:
strat_seg.
*Hold values in Sales Type and Sales area before setting to default
*values
In case need to use them later
g_hold_sales_type = sales_type.
g_hold_sales_area = sales_area.
If the company ID of the trading partner is populated, then set the
strategic segment to a default value.
And set Sales Type and Sales area to default values **NEM 07/13/06
IF NOT rassc IS INITIAL.
strat_seg = c_def_strat_seg.
sales_type = c_sales_type.
sales_area = c_sales_area.
TRANSLATE strat_seg TO UPPER CASE.
TRANSLATE sales_type TO UPPER CASE.
TRANSLATE sales_area TO UPPER CASE.
EXIT.
ENDIF.
Find the valid profit center record.
LOOP AT i_cepc INTO w_cepc
WHERE prctr = prctr AND
datab <= sy-datum AND
datbi >= sy-datum.
Pad segment with leading zeros if necessary.
lv_segment = w_cepc-segment.
SHIFT lv_segment RIGHT DELETING TRAILING ' '.
TRANSLATE lv_segment USING ' 0'.
Get the segment name from FAGL_SEGMT (Master Data for Segments).
SELECT SINGLE *
FROM fagl_segmt
WHERE langu = sy-langu AND
segment = lv_segment.
IF sy-subrc = 0.
strat_seg = fagl_segmt-name+0(3).
TRANSLATE strat_seg TO UPPER CASE.
ENDIF.
ENDLOOP.
ENDFORM. " derive_strategic_segment
&----
*& Form get_cepc_data
&----
Get CEPC (Profit Center Master Data Table) data from the database.
----
FORM get_cepc_data.
SELECT prctr datbi kokrs datab khinr segment
INTO TABLE i_cepc
FROM cepc
FOR ALL ENTRIES IN i_faglflext
WHERE prctr = i_faglflext-prctr.
SORT i_cepc BY prctr datab.
ENDFORM. " get_cepc_data
&----
*& Form derive_strat_seg_chnl
&----
Derive the strategic segment channel based on the company ID of the
trading partner or the profit center area.
----
-->RASSC - Company ID of trading partner.
-->PRCTR - Profit center.
<--STRAT_SEG_CHNL - Strategic segment channel.
----
FORM derive_strat_seg_chnl USING rassc TYPE t_faglflext-rassc
prctr TYPE t_faglflext-prctr
CHANGING strat_seg_chnl TYPE
t_faglflext-strat_seg_chnl.
CLEAR:
g_setclass,
g_subclass,
g_setname,
strat_seg_chnl.
If the company ID of the trading partner is populated, then set the
strategic segment to a default value.
IF NOT rassc IS INITIAL.
strat_seg_chnl = c_def_strat_seg_chnl.
TRANSLATE strat_seg_chnl TO UPPER CASE.
EXIT.
ENDIF.
Check for SETNAME = 2*** in setleaf table.
PERFORM get_setleaf_data USING c_prctr_group
prctr
CHANGING g_subrc.
IF g_subrc NE c_no_record.
PERFORM find_setleaf_record CHANGING g_subrc.
SELECT SINGLE *
FROM setheadert
WHERE setclass = g_setclass AND
subclass = g_subclass AND
setname = g_setname AND
langu = sy-langu.
IF sy-subrc = 0.
strat_seg_chnl = setheadert-descript+0(2).
TRANSLATE strat_seg_chnl TO UPPER CASE.
ENDIF.
ELSE.
Find the valid profit center record.
LOOP AT i_cepc INTO w_cepc
WHERE prctr = prctr AND
datab <= sy-datum AND
datbi >= sy-datum.
Get the correct SETNODE (Lower-level sets in sets) record.
PERFORM get_setnode_data USING c_prctr_group
w_cepc-khinr
CHANGING g_subrc.
PERFORM find_setnode_record CHANGING g_subrc.
IF g_subrc = c_no_record.
EXIT.
ENDIF.
If an appropriate SETNODE record still has not been found, then
keep looking.
IF g_subrc = c_wrong_record.
DO.
PERFORM get_setnode_data USING c_prctr_group
w_setnode-setname
CHANGING g_subrc.
PERFORM find_setnode_record CHANGING g_subrc.
IF g_subrc = c_no_record OR
g_subrc = c_correct_record.
EXIT.
ENDIF.
ENDDO.
ENDIF.
In the end, there was no SETNODE record to find.
IF g_subrc = c_no_record.
EXIT.
ENDIF.
SELECT SINGLE *
FROM setheadert
WHERE setclass = g_setclass AND
subclass = g_subclass AND
setname = g_setname AND
langu = sy-langu.
IF sy-subrc = 0.
strat_seg_chnl = setheadert-descript+0(2).
TRANSLATE strat_seg_chnl TO UPPER CASE.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " derive_strat_seg_chnl
&----
*& Form get_setnode_data
&----
Get SETNODE (Lower-level sets in sets) data from the database.
----
-->SETCLASS - Set class.
-->SUBSETNAME - Subordinate set ID.
<--SUBRC - Return code.
----
FORM get_setnode_data USING setclass TYPE c
subsetname TYPE c
CHANGING subrc TYPE sy-subrc.
SELECT setclass subclass setname
INTO TABLE i_setnode
FROM setnode
WHERE setclass = c_prctr_group AND
subsetname = subsetname.
subrc = sy-subrc.
ENDFORM. " get_setnode_data
&----
*& Form get_setleaf_data
&----
Get SETLEAF (Values in Sets) data from the database.
----
-->SETCLASS - Set class.
-->VALFROM - Subordinate set ID.
<--SUBRC - Return code.
----
FORM get_setleaf_data USING setclass TYPE c
valfrom TYPE c
CHANGING subrc TYPE sy-subrc.
subrc = c_correct_record.
SELECT setclass setname valfrom subclass
INTO TABLE i_setleaf
FROM setleaf
WHERE setclass = c_prctr_group AND
valfrom = valfrom AND
setname GE '2000' AND
setname LE '2999'.
IF sy-subrc <> 0.
subrc = c_no_record.
EXIT.
ENDIF.
ENDFORM. " get_setleaf_data
&----
*& Form find_setleaf_record
&----
Find the appropriate SETLEAF record.
----
<--SUBRC - Return code.
----
FORM find_setleaf_record CHANGING subrc TYPE sy-subrc.
subrc = c_wrong_record.
If no records were found during selection, then exit the routine.
READ TABLE i_setleaf INDEX 1 TRANSPORTING NO FIELDS.
IF sy-subrc <> 0.
subrc = c_no_record.
EXIT.
ENDIF.
Check to see if one of the records has a setname in the 2000 series of
numbers.
LOOP AT i_setleaf INTO w_setleaf.
g_setclass = w_setleaf-setclass.
g_subclass = w_setleaf-subclass.
g_setname = w_setleaf-setname.
subrc = c_correct_record.
ENDLOOP.
ENDFORM. " find_setleaf_record
&----
*& Form find_setnode_record
&----
Find the appropriate SETNODE record.
----
<--SUBRC - Return code.
----
FORM find_setnode_record CHANGING subrc TYPE sy-subrc.
subrc = c_wrong_record.
If no records were found during selection, then exit the routine.
READ TABLE i_setnode INDEX 1 TRANSPORTING NO FIELDS.
IF sy-subrc <> 0.
subrc = c_no_record.
EXIT.
ENDIF.
Check to see if one of the records has a setname in the 2000 series of
numbers.
LOOP AT i_setnode INTO w_setnode.
IF w_setnode-setname+0(1) = c_valid_number.
g_setclass = w_setnode-setclass.
g_subclass = w_setnode-subclass.
g_setname = w_setnode-setname.
subrc = c_correct_record.
EXIT.
ENDIF.
ENDLOOP.
ENDFORM. " find_setnode_record
&----
*& Form split_records_by_period
&----
Split the i_FAGLFLEXT records by fiscal period. This is necessary
because all (16) fiscal periods are on one record.
----
FORM split_records_by_period .
REFRESH:
i_output_detail.
LOOP AT i_faglflext INTO w_faglflext.
START OF CHANGES BY BAYAPV on 07/07/2007**********************
*SELECT SINGLE BUKRS
SAKNR
XOPVW
into w_skb1
from skb1
FOR ALL ENTRIES IN I_FAGLFLEXT
where bukrs = w_faglflext-rbukrs
and SAKNR = w_faglflext-racct.
*
*IF w_skb1-XOPVW = 'X'.
*SELECT BUKRS
HKONT
BELNR
into table i_bsas
from bsas
where bukrs = w_SKB1-bukrs
and hkont = w_skb1-saknr.
*IF sy-subrc = 0.
*CONTINUE.
*ELSE.
*endif.
**END OF CHANGES BY BAYAPV.*********************************
BEGIN changes by NEM8/23/06
If a balance sheet account add record to detail records
IF w_faglflext-balance_sheet = 'X'.
PERFORM build_i_output_detail_record.
ELSE.
CLEAR:
g_loop_count.
DO 16 TIMES.
g_loop_count = g_loop_count + 1.
Check to see if this period is to be included in the data.
CHECK g_loop_count EQ s_rpmax.
Create the field symbol pointer to the correct hslxx field.
g_hslxx = c_hslxx.
REPLACE 'xx' WITH g_loop_count+1(2) INTO g_hslxx.
ASSIGN (g_hslxx) TO <fs_hslxx>.
IF <fs_hslxx> <> 0.
PERFORM build_i_output_detail_record.
ENDIF.
EXIT.
ENDDO.
ENDIF.
*ENDIF.
ENDLOOP.
ENDFORM. " split_records_by_period
&----
*& Form build_year_to_date_total
&----
Build year-to-date total based on period selected.
----
FORM build_year_to_date_total CHANGING year_to_date.
CLEAR:
g_loop_count.
year_to_date = w_faglflext-hslvt.
DO 16 TIMES.
g_loop_count = g_loop_count + 1.
Check to see if this period is to be included in the data.
CHECK g_loop_count IN s_rpmax.
Create the field symbol pointer to the correct hslxx field.
g_hslxx = c_hslxx.
REPLACE 'xx' WITH g_loop_count+1(2) INTO g_hslxx.
ASSIGN (g_hslxx) TO <fs_hslxx>.
year_to_date = year_to_date + <fs_hslxx>.
IF g_loop_count EQ s_rpmax.
EXIT.
ENDIF.
ENDDO.
ENDFORM. " build_year_to_date_total
&----
*& Form build_i_output_detail_record
&----
Build i_OUTPUT_DETAIL record.
----
FORM build_i_output_detail_record.
CLEAR: w_output_detail.
w_output_detail-entity = w_faglflext-entity.
w_output_detail-strat_seg = w_faglflext-strat_seg.
w_output_detail-strat_seg_chnl = w_faglflext-strat_seg_chnl.
w_output_detail-all_item_id = w_faglflext-all_item_id.
w_output_detail-all_products = w_faglflext-all_products.
w_output_detail-zzsareaim = w_faglflext-zzsareaim.
w_output_detail-zzsarea = w_faglflext-zzsarea.
w_output_detail-all_cust = w_faglflext-all_cust.
w_output_detail-all_cust_chnl = w_faglflext-all_cust_chnl.
w_output_detail-hyperion_acct = w_faglflext-hyperion_acct.
w_output_detail-sub_acct = w_faglflext-sub_acct.
w_output_detail-ryear = w_faglflext-ryear.
w_output_detail-fiscal_period = g_loop_count.
SHIFT w_output_detail-fiscal_period RIGHT DELETING TRAILING ' '.
TRANSLATE w_output_detail-fiscal_period USING ' 0'.
BEGIN changes by NEM8/23/06
use year-to-date total for balance sheet accounts
IF w_faglflext-balance_sheet = 'X'.
PERFORM build_year_to_date_total CHANGING w_output_detail-amount.
*w_output_detail-amount = w_faglflext-hslvt + w_faglflext-hsl01 +
*w_faglflext-hsl02 + w_faglflext-hsl03 + w_faglflext-hsl04 +
*w_faglflext-hsl05 + w_faglflext-hsl06 + w_faglflext-hsl07 +
*w_faglflext-hsl08 + w_faglflext-hsl09 +
*w_faglflext-hsl10 + w_faglflext-hsl11 + w_faglflext-hsl12 +
*w_faglflext-hsl13 + w_faglflext-hsl14 +
w_faglflext-hsl15 + w_faglflext-hsl16.
w_output_detail-fiscal_period = s_rpmax.
SHIFT w_output_detail-fiscal_period RIGHT DELETING TRAILING ' '.
TRANSLATE w_output_detail-fiscal_period USING ' 0'.
ELSE.
w_output_detail-amount = ( <fs_hslxx> ).
ENDIF.
END changes by NEM8/23/06
BEGIN changes by NEM8/21/06
reverse sign if indicated by "reverse" flag
w_output_detail-amount = w_output_detail-amount *
w_faglflext-reverse_sign.
END changes by NEM8/21/06
APPEND w_output_detail TO i_output_detail.
ENDFORM. " build_i_output_detail_record
&----
*& Form summarize_records_by_period
&----
Sumamrize the detail records for file creation and reporting purposes.
----
FORM summarize_records_by_period .
REFRESH:
i_output_summary.
LOOP AT i_output_detail INTO w_output_detail.
COLLECT w_output_detail INTO i_output_summary.
ENDLOOP.
Depending on user input (CB_ZEROS), determine if summary records that
net to zero should be displayed.
IF cb_zeros = space.
LOOP AT i_output_summary INTO w_output_summary.
IF w_output_summary-amount = 0.
DELETE i_output_summary.
ENDIF.
ENDLOOP.
ENDIF.
ENDFORM. " summarize_records_by_period
&----
*& Form sort_output_tables
&----
*Sort the output tables (detail and summary) into the required sequence.
----
FORM sort_output_tables .
Sort output detail table by required fields.
SORT i_faglflexa BY entity
strat_seg
strat_seg_chnl
all_item_id
all_products
zzsareaim
zzsarea
all_cust
all_cust_chnl
hyperion_acct
sub_acct
ryear
fiscal_period.
Sort output summary table by required fields.
SORT i_output_summary BY entity
strat_seg
strat_seg_chnl
all_item_id
all_products
zzsareaim
zzsarea
all_cust
all_cust_chnl
hyperion_acct
sub_acct
ryear
fiscal_period.
FREE:
i_output_detail.
ENDFORM. " sort_output_tables
&----
*& Form create_output_file
&----
Create the file requested by the user.
----
FORM create_output_file.
Do not generate a file if there is no data to output.
READ TABLE i_output_summary INDEX 1 TRANSPORTING NO FIELDS.
IF sy-subrc <> 0.
EXIT.
ENDIF.
Build the ouput filename.
PERFORM build_output_filename.
Open the output file.
PERFORM open_files.
g_need_headers = c_selected.
LOOP AT i_output_summary INTO w_output_summary.
*Do not send summarized records where the netted amount is equal to
*zero.
IF w_output_summary-amount = 0.
CONTINUE.
ENDIF.
*If this is the first summary record to output, then create the
*appropriate
file header records.
IF g_need_headers = c_selected.
PERFORM create_file_header_records USING c_monthend_file.
ENDIF.
PERFORM build_file_detail_records USING c_monthend_file.
ENDLOOP.
Close the output file.
PERFORM close_files.
ENDFORM. " create_output_file
&----
*& Form create_file_header_records
&----
Create the file header records.
----
-->FILE_TYPE - Type of file to create (local or not).
----
FORM create_file_header_records USING file_type TYPE c.
Build the first header record.
CLEAR: w_header_record.
w_header_record+0(6) = c_header_actual_data.
Output the header record to the appropriate destination.
IF file_type = c_local_file.
w_local_file = w_header_record.
APPEND w_local_file TO i_local_file.
ELSEIF file_type = c_monthend_file.
TRANSFER w_header_record TO p_fileot.
ENDIF.
Determine the first and last period used to generate the file.
DO 16 TIMES.
g_loop_count = sy-index.
PERFORM find_first_and_last_period USING g_loop_count.
ENDDO.
Build the second header record.
CLEAR: w_header_record.
w_header_record0(2) = g_first_period1(2).
Output the header record to the appropriate destination.
IF file_type = c_local_file.
w_local_file = w_header_record.
APPEND w_local_file TO i_local_file.
ELSEIF file_type = c_monthend_file.
TRANSFER w_header_record TO p_fileot.
ENDIF.
Build the third header record.
CLEAR: w_header_record.
w_header_record0(2) = g_last_period1(2).
Output the header record to the appropriate destination.
IF file_type = c_local_file.
w_local_file = w_header_record.
APPEND w_local_file TO i_local_file.
ELSEIF file_type = c_monthend_file.
TRANSFER w_header_record TO p_fileot.
ENDIF.
CLEAR: g_need_headers.
ENDFORM. " create_file_header_records
&----
*& Form build_summary_layout
&----
Build the ALV layout structure for the summary view.
----
FORM build_summary_layout .
CLEAR: w_summary_layout.
w_summary_layout-zebra = c_selected.
w_summary_layout-colwidth_optimize = c_selected.
ENDFORM. " build_summary_layout
&----
*& Form build_summary_field_catalog
&----
Build the ALV field catalog table for the summary view.
----
FORM build_summary_field_catalog .
REFRESH:
i_summary_fieldcat.
Entity.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field01
text-300
c_char
c_not_selected
3.
Strategic segment.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field02
text-301
c_char
c_not_selected
3.
Strategic segment channel.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field03
text-302
c_char
c_not_selected
2.
All item ID.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field04
text-303
c_char
c_not_selected
3.
All products.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field05
text-304
c_char
c_not_selected
1.
Sales area Imp.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field06
text-305
c_char
c_not_selected
1.
Geographic sales area.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field07
text-306
c_char
c_not_selected
2.
All customers.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field08
text-307
c_char
c_not_selected
3.
All customers channel.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field09
text-308
c_char
c_not_selected
2.
Hyperion account.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field10
text-309
c_char
c_not_selected
7.
Sub account.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field11
text-310
c_char
c_not_selected
3.
Fiscal year.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field12
text-311
c_char
c_not_selected
4.
Fiscal period.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field13
text-312
c_char
c_not_selected
3.
Amount.
PERFORM add_field_to_field_catalog TABLES i_summary_fieldcat
USING c_summary_table
c_summary_field14
text-313
c_curr
c_not_selected
31.
ENDFORM. " build_summary_field_catalog
&----
*& Form add_field_to_field_catalog
&----
Add field to the summary field catalog table.
----
-->FIELDCATTAB - Table of ALV field catalog fields.
-->TABLE_NAME - Name of the internal table contain data.
-->FIELD_NAME - Field name within internal table.
-->SEL_TEXT - Column heading text.
-->DATATYPE - Type of field being processed.
-->HOTSPOT - Set field as hotspot.
-->LENGTH - Output length of field.
----
FORM add_field_to_field_catalog TABLES fieldcattab TYPE
slis_t_fieldcat_alv
USING table_name TYPE c
field_name TYPE c
sel_text TYPE c
datatype TYPE c
hotspot TYPE c
length TYPE int1.
CLEAR: w_fieldcat.
w_fieldcat-tabname = table_name.
w_fieldcat-fieldname = field_name.
w_fieldcat-seltext_l = sel_text.
w_fieldcat-outputlen = length.
w_fieldcat-hotspot = hotspot.
APPEND w_fieldcat TO fieldcattab.
ENDFORM. " add_field_to_field_catalog
&----
*& Form build_summary_sort_table
&----
Build the ALV sort table for the summary view.
----
FORM build_summary_sort_table.
REFRESH:
i_summary_sort.
Entity.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field01
c_sort_ascending
'01'.
Strategic segment.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field02
c_sort_ascending
'02'.
Strategic segment channel.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field03
c_sort_ascending
'03'.
All item ID.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field04
c_sort_ascending
'04'.
All products.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field05
c_sort_ascending
'05'.
Sales area Imp.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field06
c_sort_ascending
'06'.
Geographic sales area.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field07
c_sort_ascending
'07'.
All customers.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field08
c_sort_ascending
'08'.
All customers channel.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field09
c_sort_ascending
'09'.
Hyperion account.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field10
c_sort_ascending
'10'.
Sub account.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field11
c_sort_ascending
'11'.
Fiscal year.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field12
c_sort_ascending
'12'.
Fiscal period.
PERFORM add_field_to_sort_table TABLES i_summary_sort
USING c_summary_field13
c_sort_ascending
'13'.
ENDFORM. " build_summary_sort_table
&----
*& Form add_field_to_sort_table
&----
Add field to the summary sort table.
----
-->SORTAB - Table of ALV sort fields.
-->FIELDNAME - Name of field for sorting.
-->DIRECTION - Direction of sort (ascending or descending).
-->POSITION - Position of field within sort sequence.
----
FORM add_field_to_sort_table TABLES sorttab TYPE slis_t_sortinfo_alv
USING fieldname TYPE c
direction TYPE c
position TYPE c.
CLEAR: w_sorttab.
w_sorttab-spos = position.
w_sorttab-fieldname = fieldname.
IF direction = c_sort_ascending.
w_sorttab-up = c_selected.
ELSEIF direction = c_sort_descending.
w_sorttab-down = c_selected.
ENDIF.
APPEND w_sorttab TO sorttab.
ENDFORM. " add_field_to_sort_table
&----
*& Form SUMMARY_SET_STATUS
&----
Set the PF status for the summary view.
----
-->EXCLTAB - Table of function codes to exclude from status.
----
FORM summary_set_status USING excltab TYPE slis_t_extab.
DATA:
lw_excltab TYPE slis_extab.
Turn off the function code for the summary view.
REFRESH:
excltab.
lw_excltab-fcode = c_summary_view.
APPEND lw_excltab TO excltab.
SET PF-STATUS c_report_status EXCLUDING excltab.
ENDFORM. " SUMMARY_SET_STATUS
&----
*& Form generate_summary_alv_report
&----
Generate the summary ALV report view.
----
FORM generate_summary_alv_report.
DATA:
lv_grid_title TYPE lvc_title.
g_program_id = sy-repid.
lv_grid_title = text-100.
Summary View
Generate the ALV grid display, for the summary data, to present
to the user.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_program_id
i_callback_pf_status_set = c_summary_status
i_callback_user_command = c_summary_user_comm
i_grid_title = lv_grid_title
is_layout = w_summary_layout
it_fieldcat = i_summary_fieldcat
it_sort = i_summary_sort
TABLES
t_outtab = i_output_summary
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e063
WITH sy-subrc.
Function REUSE_ALV_GRID_DISPLAY failed on summary view SY-SUBRC = &
ENDIF.
ENDFORM. " generate_summary_alv_report
&----
*& Form summary_user_comm
&----
Process user commands on the summary view.
----
--> UCOMM - User command.
--> SELFIELD - Structure with information on the selecton field.
----
FORM summary_user_comm USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Determine what function code was passed and take appropriate action.
CASE ucomm.
WHEN c_choose_row.
PERFORM generate_item_dtl_alv_report USING selfield-tabindex.
WHEN c_detail_view.
PERFORM generate_detail_alv_report.
ENDCASE.
ENDFORM. " summary_user_comm
&----
*& Form generate_detail_alv_report
&----
Generate the detail ALV report view.
----
FORM generate_detail_alv_report .
DATA:
lv_grid_title TYPE lvc_title.
g_program_id = sy-repid.
lv_grid_title = text-101.
Detail View
Create the necessary tables for detail ALV report.
PERFORM build_detail_layout.
PERFORM build_detail_field_catalog.
PERFORM build_detail_sort_table.
Generate the ALV grid display, for the detail data, to present
to the user.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_program_id
i_callback_pf_status_set = c_detail_status
i_callback_user_command = c_detail_user_comm
i_grid_title = lv_grid_title
is_layout = w_detail_layout
it_fieldcat = i_detail_fieldcat
it_sort = i_detail_sort
TABLES
t_outtab = i_faglflexa[] "NEM - detail
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e064
WITH sy-subrc.
Function REUSE_ALV_GRID_DISPLAY failed on detail view SY-SUBRC = &
ENDIF.
ENDFORM. " generate_detail_alv_report
&----
*& Form DETAIL_SET_STATUS
&----
Set the PF status for the detail view.
----
-->EXCLTAB - Table of function codes to exclude from status.
----
FORM detail_set_status USING excltab TYPE slis_t_extab.
DATA:
lw_excltab TYPE slis_extab.
Turn off the function code for the detail view.
REFRESH:
excltab.
lw_excltab-fcode = c_detail_view.
APPEND lw_excltab TO excltab.
SET PF-STATUS c_report_status EXCLUDING excltab.
ENDFORM. " DETAIL_SET_STATUS
&----
*& Form build_detail_layout
&----
Build the ALV layout structure for the detail view.
----
FORM build_detail_layout.
CLEAR: w_detail_layout.
w_detail_layout-zebra = c_selected.
w_detail_layout-colwidth_optimize = c_selected.
ENDFORM. " build_detail_layout
&----
*& Form build_detail_field_catalog
&----
Build the ALV field catalog table for the detail view.
----
FORM build_detail_field_catalog .
REFRESH:
i_detail_fieldcat.
SAP document number.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field15
text-354
c_char
c_selected
10.
SAP company code.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field16
text-355
c_char
c_not_selected
4.
SAP profit center.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field17
text-356
c_char
c_not_selected
10.
SAP partner profit center.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field18
text-357
c_char
c_not_selected
10.
SAP G/L account.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field19
text-358
c_char
c_not_selected
10.
SAP functional area.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field20
text-359
c_char
c_not_selected
16.
SAP trading partner.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field21
text-362
c_char
c_not_selected
2.
SAP Geo sales area.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field22
text-360
c_char
c_not_selected
2.
SAP G sales area part.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field23
text-361
c_char
c_not_selected
2.
SAP import/export.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field24
text-363
c_char
c_not_selected
1.
SAP product type.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field25
text-364
c_char
c_not_selected
4.
SAP product source.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field26
text-365
c_char
c_not_selected
4.
Entity.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field01
text-328
c_char
c_not_selected
3.
Strategic segment.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field02
text-329
c_char
c_not_selected
3.
Strategic segment channel.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field03
text-330
c_char
c_not_selected
2.
All item ID.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field04
text-331
c_char
c_not_selected
3.
All products.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field05
text-332
c_char
c_not_selected
1.
Sales area Imp.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field06
text-333
c_char
c_not_selected
1.
Geographic sales area.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field07
text-334
c_char
c_not_selected
2.
All customers.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field08
text-335
c_char
c_not_selected
3.
All customers channel.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field09
text-336
c_char
c_not_selected
2.
Hyperion account.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field10
text-337
c_char
c_not_selected
7.
Sub account.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field11
text-338
c_char
c_not_selected
3.
Fiscal year.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field12
text-339
c_char
c_not_selected
4.
Fiscal period.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field13
text-340
c_char
c_not_selected
3.
Amount.
PERFORM add_field_to_field_catalog TABLES i_detail_fieldcat
USING c_detail_table
c_detail_field14
text-341
c_curr
c_not_selected
31.
ENDFORM. " build_detail_field_catalog
&----
*& Form build_detail_sort_table
&----
Build the ALV sort table for the detail view.
----
FORM build_detail_sort_table.
REFRESH:
i_detail_sort.
Entity.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field01
c_sort_ascending
'01'.
Strategic segment.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field02
c_sort_ascending
'02'.
Strategic segment channel.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field03
c_sort_ascending
'03'.
All item ID.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field04
c_sort_ascending
'04'.
All products.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field05
c_sort_ascending
'05'.
Sales area Imp.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field06
c_sort_ascending
'06'.
Geographic sales area.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field07
c_sort_ascending
'07'.
All customers.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field08
c_sort_ascending
'08'.
All customers channel.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field09
c_sort_ascending
'09'.
Hyperion account.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field10
c_sort_ascending
'10'.
Sub account.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field11
c_sort_ascending
'11'.
Fiscal year.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field12
c_sort_ascending
'12'.
Fiscal period.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field13
c_sort_ascending
'13'.
ENDFORM. " build_detail_sort_table
&----
*& Form detail_user_comm
&----
Process user commands on the detail view.
----
--> UCOMM - User command.
--> SELFIELD - Structure with information on the selecton field.
----
FORM detail_user_comm USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Determine what function code was passed and take appropriate action.
CASE ucomm.
WHEN c_hotspot_selected.
PERFORM process_hotspot USING selfield.
WHEN c_summary_view.
PERFORM generate_summary_alv_report.
ENDCASE.
ENDFORM. " detail_user_comm
&----
*& Form generate_item_dtl_alv_report
&----
Generate the item detail ALV report. This will allow the user to only
see the detail that makes up a particular row within the summary view.
----
--> TABINDEX - Index of summary record being processed.
----
FORM generate_item_dtl_alv_report USING tabindex TYPE
slis_selfield-tabindex.
DATA:
lv_grid_title TYPE lvc_title.
g_program_id = sy-repid.
lv_grid_title = text-102.
Item Detail View
Build output item detail records for associated summary view line.
PERFORM build_output_item_dt_entries USING tabindex.
Create the necessary tables for item detail ALV report.
PERFORM build_item_detail_layout.
PERFORM build_item_detail_field_cat.
PERFORM build_item_detail_sort_table.
Generate the ALV grid display, for the item detail data, to present
to the user.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_program_id
i_callback_pf_status_set = c_item_detail_status
i_callback_user_command = c_dtl_item_user_comm
i_grid_title = lv_grid_title
is_layout = w_item_detail_layout
it_fieldcat = i_item_dtl_fieldcat
it_sort = i_item_detail_sort
TABLES
t_outtab = i_faglflexa_item
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e065
WITH sy-subrc.
*Function REUSE_ALV_GRID_DISPLAY failed on item detail view SY-SUBRC = &
ENDIF.
ENDFORM. " generate_item_dtl_alv_report
&----
*& Form build_ITEM_detail_layout
&----
Build the ALV layout structure for the item detail view.
----
FORM build_item_detail_layout.
CLEAR: w_item_detail_layout.
w_item_detail_layout-zebra = c_selected.
w_item_detail_layout-colwidth_optimize = c_selected.
ENDFORM. " build_item_detail_layout
&----
*& Form build_item_detail_field_cat
&----
Build the ALV field catalog table for the item detail view.
----
FORM build_item_detail_field_cat.
REFRESH:
i_item_dtl_fieldcat.
SAP document number.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field15
text-342
c_char
c_selected
10.
SAP company code.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field16
text-343
c_char
c_not_selected
4.
SAP profit center.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field17
text-344
c_char
c_not_selected
10.
SAP partner profit center.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field18
text-345
c_char
c_not_selected
10.
SAP G/L account.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field19
text-346
c_char
c_not_selected
10.
SAP functional area.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field20
text-347
c_char
c_not_selected
16.
SAP trading partner.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field21
text-350
c_char
c_not_selected
2.
SAP Geo sales area.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field22
text-348
c_char
c_not_selected
2.
SAP G sales area part.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field23
text-349
c_char
c_not_selected
2.
SAP import/export.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field24
text-351
c_char
c_not_selected
1.
SAP product type.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field25
text-352
c_char
c_not_selected
4.
SAP product source.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field26
text-353
c_char
c_not_selected
4.
Entity.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field01
text-314
c_char
c_not_selected
3.
Strategic segment.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field02
text-315
c_char
c_not_selected
3.
Strategic segment channel.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field03
text-316
c_char
c_not_selected
2.
All item ID.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field04
text-317
c_char
c_not_selected
3.
All products.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field05
text-318
c_char
c_not_selected
1.
Sales area Imp.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field06
text-319
c_char
c_not_selected
1.
Geographic sales area.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field07
text-320
c_char
c_not_selected
2.
All customers.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field08
text-321
c_char
c_not_selected
3.
All customers channel.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field09
text-322
c_char
c_not_selected
2.
Hyperion account.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field10
text-323
c_char
c_not_selected
7.
Sub account.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field11
text-324
c_char
c_not_selected
3.
Fiscal year.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field12
text-325
c_char
c_not_selected
4.
Fiscal period.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field13
text-326
c_char
c_not_selected
3.
Amount.
PERFORM add_field_to_field_catalog TABLES i_item_dtl_fieldcat
USING c_item_detail_table
c_item_detail_field14
text-327
c_curr
c_not_selected
31.
ENDFORM. " build_item_detail_field_cat
&----
*& Form build_item_detail_sort_table
&----
Build the ALV sort table for the item detail view.
----
FORM build_item_detail_sort_table.
REFRESH:
i_detail_sort.
Entity.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field01
c_sort_ascending
'01'.
Strategic segment.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field02
c_sort_ascending
'02'.
Strategic segment channel.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field03
c_sort_ascending
'03'.
All item ID.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field04
c_sort_ascending
'04'.
All products.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field05
c_sort_ascending
'05'.
Sales area Imp.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field06
c_sort_ascending
'06'.
Geographic sales area.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field07
c_sort_ascending
'07'.
All customers.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field08
c_sort_ascending
'08'.
All customers channel.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field09
c_sort_ascending
'09'.
Hyperion account.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field10
c_sort_ascending
'10'.
Sub account.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field11
c_sort_ascending
'11'.
Fiscal year.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field12
c_sort_ascending
'12'.
Fiscal period.
PERFORM add_field_to_sort_table TABLES i_detail_sort
USING c_detail_field13
c_sort_ascending
'13'.
ENDFORM. " build_item_detail_sort_table
&----
*& Form ITEM_DETAIL_SET_STATUS
&----
Set the PF status for the item detail view.
----
-->EXCLTAB - Table of function codes to exclude from status.
----
FORM item_detail_set_status USING excltab TYPE slis_t_extab.
DATA:
lw_excltab TYPE slis_extab.
Turn off the function codes for the summary and detail views.
REFRESH:
excltab.
lw_excltab-fcode = c_summary_view.
APPEND lw_excltab TO excltab.
lw_excltab-fcode = c_detail_view.
APPEND lw_excltab TO excltab.
SET PF-STATUS c_report_status EXCLUDING excltab.
ENDFORM. " ITEM_DETAIL_SET_STATUS
&----
*& Form build_output_item_dt_entries
&----
Build i_OUTPUT_ITEM_DETAIL table entries.
----
-->TABINDEX - Index of summary record being processed.
----
FORM build_output_item_dt_entries USING tabindex TYPE
slis_selfield-tabindex.
REFRESH:
i_faglflexa_item.
READ TABLE i_output_summary INTO w_output_summary INDEX tabindex.
ITR 26888
Retrieve all of the associated detail records.
LOOP AT i_faglflexa INTO w_faglflexa
WHERE entity = w_output_summary-entity AND
strat_seg = w_output_summary-strat_seg AND
strat_seg_chnl = w_output_summary-strat_seg_chnl AND
all_item_id = w_output_summary-all_item_id AND
all_products = w_output_summary-all_products AND
zzsareaim = w_output_summary-zzsareaim AND
zzsarea = w_output_summary-zzsarea AND
all_cust = w_output_summary-all_cust AND
all_cust_chnl = w_output_summary-all_cust_chnl AND
hyperion_acct = w_output_summary-hyperion_acct AND
sub_acct = w_output_summary-sub_acct AND
ryear = w_output_summary-ryear AND
fiscal_period = w_output_summary-fiscal_period.
CLEAR:
w_faglflexa_item.
w_faglflexa_item = w_faglflexa.
APPEND w_faglflexa_item TO i_faglflexa_item.
ENDLOOP.
ENDFORM. " build_output_item_dt_entries
&----
*& Form build_output_filename
&----
Build the output filename for the month-end run.
----
FORM build_output_filename.
Get the entity for the filename.
READ TABLE i_output_summary INTO w_output_summary INDEX 1.
IF sy-subrc = 0.
REPLACE 'uuu' WITH w_output_summary-entity INTO p_fileot.
ENDIF.
Begin changes by NEM 07/1/06
Put the period into filename.
REPLACE 'mm' WITH s_rpmax INTO p_fileot.
Put the year into filename.
REPLACE 'yy' WITH p_ryear INTO p_fileot.
Get the period for the filename.
READ TABLE i_tvarvc INTO w_tvarvc
WITH KEY c_tvarvc_period.
*
IF sy-subrc = 0.
REPLACE 'mm' WITH w_tvarvc-low+0(2) INTO p_fileot.
ENDIF.
*
Get the year for the filename.
READ TABLE i_tvarvc INTO w_tvarvc
WITH KEY c_tvarvc_year.
*
IF sy-subrc = 0.
REPLACE 'yy' WITH w_tvarvc-low+2(2) INTO p_fileot.
ENDIF.
End changes by NEM 07/1/06
ENDFORM. " build_output_filename
&----
*& Form find_first_and_last_period
&----
Determine the first and last periods used to generate the output file.
----
-->PERIOD - Number of period to test.
----
FORM find_first_and_last_period USING period TYPE n.
IF period EQ s_rpmax.
Set the first period used to generate the file.
IF period < g_first_period OR
g_first_period IS INITIAL.
g_first_period = period.
ENDIF.
Set the last period used to generate the file.
IF period > g_last_period OR
g_last_period IS INITIAL.
g_last_period = period.
ENDIF.
ENDIF.
ENDFORM. " find_first_and_last_period
&----
*& Form build_file_detail_records
&----
Create the file detail records.
----
-->FILE_TYPE - Type of file to create (local or not).
----
FORM build_file_detail_records USING file_type TYPE c.
CLEAR: w_file_detail.
w_file_detail-entity = w_output_summary-entity.
w_file_detail-strat_seg = w_output_summary-strat_seg.
w_file_detail-strat_seg_chnl = w_output_summary-strat_seg_chnl.
w_file_detail-all_item_id = w_output_summary-all_item_id.
w_file_detail-all_products = w_output_summary-all_products.
w_file_detail-zzsareaim = w_output_summary-zzsareaim.
w_file_detail-zzsarea = w_output_summary-zzsarea.
w_file_detail-all_cust = w_output_summary-all_cust.
w_file_detail-all_cust_chnl = w_output_summary-all_cust_chnl.
w_file_detail-period_char1 = c_period.
w_file_detail-inp = c_inp.
w_file_detail-comma_char = c_comma.
w_file_detail-hyperion_acct = w_output_summary-hyperion_acct.
PERFORM format_amount USING w_output_summary-amount
CHANGING g_amount.
IF NOT w_output_summary-sub_acct IS INITIAL.
CONCATENATE c_period
w_output_summary-sub_acct
c_comma
g_amount
INTO w_file_detail-rassc_area.
ELSE.
CONCATENATE c_comma
g_amount
INTO w_file_detail-rassc_area.
ENDIF.
Output the detail record to the appropriate destination.
IF file_type = c_local_file.
w_local_file = w_file_detail.
APPEND w_local_file TO i_local_file.
ELSEIF file_type = c_monthend_file.
TRANSFER w_file_detail TO p_fileot.
ENDIF.
ENDFORM. " build_file_detail_records
&----
*& Form format_amount
&----
Format the amount field for the output file (-ZZZZZZZZ9.990000000).
----
-->AMOUNT_IN - Unformatted amount.
<--AMOUNT_OUT - Formatted amount.
----
FORM format_amount USING amount_in TYPE faglflext-hsl01
CHANGING amount_out TYPE c.
DATA:
lv_sign(1).
CLEAR:
amount_out,
lv_sign.
g_packed_amount = amount_in.
If the amount is negative, remove the trailing sign.
IF g_packed_amount < 0.
g_packed_amount = g_packed_amount * -1.
lv_sign = c_minus_sign.
ENDIF.
amount_out = g_packed_amount.
SHIFT amount_out LEFT DELETING LEADING ' '.
If the amount is negative, add a leading sign.
IF lv_sign = c_minus_sign.
CONCATENATE c_minus_sign
amount_out
INTO amount_out.
CONDENSE amount_out NO-GAPS.
ENDIF.
ENDFORM. " format_amount
&----
*& Form create_pc_file
&----
Create a local file on the user's PC.
----
FORM create_pc_file.
DATA:
lv_lfile TYPE string.
g_need_headers = c_selected.
LOOP AT i_output_summary INTO w_output_summary.
*Do not send summarized records where the netted amount is equal to
*zero.
IF w_output_summary-amount = 0.
CONTINUE.
ENDIF.
*If this is the first summary record to output, then create the
*appropriate
file header records.
IF g_need_headers = c_selected.
PERFORM create_file_header_records USING c_local_file.
ENDIF.
PERFORM build_file_detail_records USING c_local_file.
ENDLOOP.
Download the file to the user's PC.
lv_lfile = p_lfile.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_lfile
TABLES
data_tab = i_local_file
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE e070
WITH sy-subrc.
Function module GUI_DOWNLOAD failed. SY-SUBRC = &
ENDIF.
ENDFORM. " create_pc_file
&----
*& Form get_help_with_local_file
&----
Get help with the local filename.
----
FORM get_help_with_local_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-repid
dynpro_number = sy-dynnr
field_name = ' '
IMPORTING
file_name = g_filename.
p_lfile = g_filename.
ENDFORM. " get_help_with_local_file
&----
*& Form get_faglflexa_data
&----
Get FAGLFLEXA (General Ledger: Actual Line Items) data from the
database.
----
FORM get_faglflexa_data.
Use the fiscal year for the selection, if it was populated by the
user.
IF NOT p_ryear IS INITIAL.
SELECT ryear docnr rldnr rvers racct rbukrs prctr rfarea kokrs
segment pprctr zzsarea zzsareapa zzsareaim rassc hsl zzprodsrc
zzprodtyp poper
INTO TABLE i_faglflexa
FROM faglflexa
WHERE ryear = p_ryear AND
rldnr = c_run_ledger AND
rvers = c_run_version AND
rbukrs IN r_bukrs AND
racct IN r_saknr AND
prctr IN s_prctr AND
rfarea IN s_rfarea." AND
poper EQ s_rpmax. "ADDED ON 12/05/2006
*ITR 26158
ELSE.
SELECT ryear docnr rldnr rvers racct rbukrs prctr rfarea kokrs
segment pprctr zzsarea zzsareapa zzsareaim rassc hsl
zzprodsrc
zzprodtyp poper
INTO TABLE i_faglflexa
FROM faglflexa
WHERE rldnr = c_run_ledger AND
rvers = c_run_version AND
rbukrs IN r_bukrs AND
racct IN r_saknr AND
prctr IN s_prctr AND
rfarea IN s_rfarea.
poper EQ s_rpmax.
ENDIF.
*
*End of change ITR # 33616 by DAKSHINM
*Created a Index Z1 and rearranged the select statment accordingly
START OF CHANGES BY BAYAPV ITR 49257 ON 07/04/2007*************************
IF NOT i_faglflexa[] IS INITIAL.
SELECT bukrs
saknr
xopvw
INTO TABLE i_skb1
FROM skb1
FOR ALL ENTRIES IN i_faglflexa
WHERE
bukrs EQ i_faglflexa-rbukrs
AND saknr = i_faglflexa-racct.
IF NOT i_skb1[] IS INITIAL.
SELECT bukrs
hkont
belnr
INTO TABLE i_bsas
FROM bsas
FOR ALL ENTRIES IN i_skb1
WHERE
bukrs = i_skb1-bukrs AND
hkont = i_skb1-saknr.
ENDIF.
ENDIF.
LOOP AT i_bsas INTO w_bsas.
*
READ TABLE i_skb1 INTO w_skb1 WITH KEY
saknr = w_bsas-hkont
xopvw = 'X'.
*
IF sy-subrc EQ 0.
DELETE i_faglflexa WHERE docnr = w_bsas-belnr.
ENDIF.
ENDLOOP.
END OF CHANGES BY BAYAPV ITR 49257 on 07/04/2007****************************
ENDFORM. " get_faglflexa_data
&----
*& Form derive_add_fields_faglflexa
&----
Derive additional fields needed for the I_FAGLFLEXA.
----
FORM derive_add_fields_faglflexa.
LOOP AT i_faglflexa INTO w_faglflexa.
START OF CHANGES BY loganatk ITR 49257 ON 07/13/2007*************************
CLEAR w_bsas.
CLEAR w_skb1.
READ TABLE i_bsas INTO w_bsas WITH KEY
belnr = w_faglflexa-docnr.
IF sy-subrc EQ 0.
READ TABLE i_skb1 INTO w_skb1 WITH KEY
saknr = w_faglflexa-racct
xopvw = 'X'.
IF sy-subrc EQ 0.
DELETE i_faglflexa WHERE docnr = w_bsas-belnr
AND racct = w_bsas-hkont.
from w_faglflexa.
CONTINUE.
ENDIF.
ENDIF.
Set the fiscal period.
w_faglflexa-fiscal_period = w_faglflexa-poper.
Get necessary company code data.
READ TABLE i_t001 INTO w_t001
WITH KEY bukrs = w_faglflexa-rbukrs
BINARY SEARCH.
IF sy-subrc <> 0.
MESSAGE e059
WITH w_faglflexa-rbukrs.
Company code & not found on table T001
ENDIF.
Determine the entity.
PERFORM derive_entity USING w_t001-rcomp
CHANGING w_faglflexa-entity.
Determine the strategic segment.
PERFORM derive_strategic_segment USING w_faglflexa-rassc
w_faglflexa-prctr
CHANGING w_faglflexa-strat_seg
w_faglflexa-zzsareaim
w_faglflexa-zzsarea.
Determine the strategic segment channel.
PERFORM derive_strat_seg_chnl USING w_faglflexa-rassc
w_faglflexa-prctr
CHANGING w_faglflexa-strat_seg_chnl.
Determine the all item ID and all products.
PERFORM derive_all_item_id USING w_t001-waers
CHANGING w_faglflexa-all_item_id
w_faglflexa-all_products.
Determine the all customers and all customers channel.
PERFORM derive_all_customers_fields USING w_faglflexa-strat_seg
*w_faglflexa-strat_seg_chnl
CHANGING w_faglflexa-all_cust
*w_faglflexa-all_cust_chnl.
Determine the sub account using the company ID of the trading partner.
PERFORM derive_sub_account USING w_t001-rcomp
w_faglflexa-rassc
"NEM6/27/06 -ITR:21977
CHANGING w_faglflexa-sub_acct.
Determine the Hyperion account number from G/L account long text.
PERFORM derive_hyperion_account USING w_faglflexa-racct
w_faglflexa-rfarea
"KMK5/22/06 -ITR:20592
w_faglflexa-sub_acct
w_faglflexa-rassc
w_faglflexa-prctr
CHANGING w_faglflexa-hyperion_acct
w_faglflexa-reverse_sign "NEM8/21/06 ITR: 24286
w_faglflexa-balance_sheet "NEM8/21/06 ITR: 24286
w_faglflexa-zzsarea
w_faglflexa-zzsareaim
w_faglflexa-strat_seg.
Determine the all customers and all customers channel.
PERFORM derive_all_customers_fields USING w_faglflexa-strat_seg
w_faglflexa-strat_seg_chnl
CHANGING w_faglflexa-all_cust
w_faglflexa-all_cust_chnl.
Remove leading zeros from SAP profit center.
PERFORM remove_leading_zeros USING w_faglflexa-prctr
CHANGING w_faglflexa-prctr.
Remove leading zeros from SAP partner profit center.
PERFORM remove_leading_zeros USING w_faglflexa-pprctr
CHANGING w_faglflexa-pprctr.
Remove leading zeros from SAP G/L account.
PERFORM remove_leading_zeros USING w_faglflexa-racct
CHANGING w_faglflexa-racct.
Update i_FAGLFLEXA with the newly derive fields.
MODIFY i_faglflexa FROM w_faglflexa
TRANSPORTING prctr
pprctr
racct
entity
strat_seg
strat_seg_chnl
all_item_id
all_products
all_cust
all_cust_chnl
hyperion_acct
sub_acct
fiscal_period
zzsarea
zzsareaim
reverse_sign "NEM8/21/06 ITR: 24286
balance_sheet. "NEM8/21/06 ITR: 24286
ENDLOOP.
CHECK s_rhype IS NOT INITIAL.
SORT s_rhype BY low.
LOOP AT i_faglflexa INTO w_faglflexa.
READ TABLE s_rhype WITH KEY low = w_faglflexa-hyperion_acct.
IF sy-subrc NE 0.
CLEAR w_faglflexa-hyperion_acct.
MODIFY i_faglflexa FROM w_faglflexa.
ENDIF.
ENDLOOP.
DELETE i_faglflexa WHERE hyperion_acct IS INITIAL.
ENDFORM. " derive_add_fields_faglflexa
&----
*& Form process_hotspot
&----
Process hotspot selected by the user.
----
--> SELFIELD - Structure with information on the selecton field.
----
FORM process_hotspot USING selfield TYPE slis_selfield.
Exit this routine if the user has selected an invalid hotspot.
IF selfield-value IS INITIAL.
EXIT.
ENDIF.
The document number is currently the only hotspot field on the report.
IF selfield-sel_tab_field = c_detail_docnr.
PERFORM call_transaction_fb03 USING c_detail_table
selfield-value
selfield-tabindex.
ELSEIF selfield-sel_tab_field = c_detail_item_docnr.
PERFORM call_transaction_fb03 USING c_item_detail_table
selfield-value
selfield-tabindex.
ENDIF.
ENDFORM. " process_hotspot
&----
*& Form call_transaction_fb03
&----
Call transaction
----
-->TABLE - Name of table to read to get the required data.
-->VALUE - Document number.
-->TABINDEX - Index of record within table to retrieve.
----
FORM call_transaction_fb03 USING table TYPE slis_tabname
value TYPE slis_selfield-value
tabindex TYPE slis_selfield-tabindex.
IF table = c_detail_table.
READ TABLE i_faglflexa INTO w_faglflexa INDEX tabindex.
ELSEIF table = c_item_detail_table.
READ TABLE i_faglflexa_item INTO w_faglflexa_item INDEX tabindex.
ENDIF.
IF sy-subrc <> 0.
MESSAGE e075
WITH tabindex.
Invalid pointer to requested detail table.
ENDIF.
Set the required parameter IDs for transaction FB03.
IF table = c_detail_table.
SET PARAMETER ID 'BLN' FIELD value.
SET PARAMETER ID 'BUK' FIELD w_faglflexa-rbukrs.
SET PARAMETER ID 'GJR' FIELD w_faglflexa-ryear.
ELSEIF table = c_item_detail_table.
SET PARAMETER ID 'BLN' FIELD value.
SET PARAMETER ID 'BUK' FIELD w_faglflexa_item-rbukrs.
SET PARAMETER ID 'GJR' FIELD w_faglflexa_item-ryear.
ENDIF.
CALL TRANSACTION c_document_display AND SKIP FIRST SCREEN.
ENDFORM. " call_transaction_fb03
&----
*& Form DETAIL_ITEM_USER_COMM
&----
Process user commands on the item detail view.
----
--> UCOMM - User command.
--> SELFIELD - Structure with information on the selecton field.
----
FORM detail_item_user_comm USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Determine what function code was passed and take appropriate action.
CASE ucomm.
WHEN c_hotspot_selected.
PERFORM process_hotspot USING selfield.
ENDCASE.
ENDFORM. " DETAIL_ITEM_USER_COMM
&----
*& Form remove_leading_zeros
&----
Remove leading zeros from field.
----
-->FIELD_IN - Field with leading zeros.
<--FIELD_OUT - Field without leading zeros.
----
FORM remove_leading_zeros USING field_in
CHANGING field_out.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = field_in
IMPORTING
output = field_out.
ENDFORM. " remove_leading_zeros
10-08-2007 5:42 PM
HI,
U have to refresh the ALV Grid before it displays the data.Then only the datas for the next selection will be displayed.
Regards,
Padmam.
10-08-2007 6:04 PM
HI
u have this in your code
<b>it_fieldcat = i_detail_fieldcat
it_sort = i_detail_sort</b>
Now check this:
<b>it_fieldcat = i_detail_fieldcat[]
it_sort = i_detail_sort[]</b>
Regards
Gregory
10-09-2007 5:59 PM