Modify the code as per your requirement....
PROCEDURE Export_Trx (p_records VARCHAR2 ) IS
v_top_record NUMBER :=Get_Block_Property('TRX', Top_Record);
v_cur_record NUMBER :=Get_Block_Property('TRX', Current_Record);
v_cur_item VARCHAR2(255);
v_last_record NUMBER;
v_db_file NUMBER;
v_mime_type VARCHAR2(255) :='text/html' ;
v_buf VARCHAR2(32767) ;
v_url VARCHAR2(500);
i NUMBER := 1;
v_header VARCHAR2(255);
lc_rev_cat VARCHAR2(50);
BEGIN
IF :system.mode = 'ENTER-QUERY' THEN
Msg('Not allowed in "Enter Query" mode. ');
Return;
END IF;
fnd_message.debug('Export_TRX'); --giri
Go_Block('trx');
Globals.mass_trx_select := 1;
IF p_records = 'SELECTED' THEN
v_last_record := GET_BLOCK_PROPERTY('trx', QUERY_HITS);
ELSE
app_window.progress(0,'Fetching records ...');
WHILE :system.last_record = 'FALSE' LOOP
Go_Record(:system.cursor_record + 100);
app_window.progress(Mod(:system.cursor_record,1000)/1000,'Fetching records ...');
SYNCHRONIZE;
END LOOP;
v_last_record := GET_BLOCK_PROPERTY('trx', QUERY_HITS);
app_window.progress(1,'Fetching records ...');
END IF;
First_Record;
IF v_last_record =0 THEN
Globals.mass_trx_select := 0;
Msg('No records for export');
Return;
END IF;
v_db_file :=fnd_gfm.file_create(content_type =>v_mime_type,program_name=>'export');
v_buf:='<html>
<head>
<meta http-equiv="content-Type" content="text/html";charset="UTF-8">
</head>
<body>
<table cellspacing=0 cellpadding=2 width="300%" border="1" style="font-family: Tahoma, Arial; font-size: 10pt;">';
fnd_gfm.file_write_line(v_db_file,v_buf);
-- Export columns header
v_cur_item := Get_Block_Property('TRX_COL', FIRST_ITEM );
v_buf := '<tr>';
WHILE v_cur_item IS NOT NULL LOOP
v_cur_item := 'TRX_COL.'||v_cur_item;
IF Get_Item_Property(v_cur_item, ITEM_CANVAS) IN('TRX_FIXED', 'TRX_DETAIL')
-- IF Get_Item_Property(v_cur_item, ITEM_CANVAS) IN('TRX_FIXED', 'BU')
THEN
v_header :=Name_In(v_cur_item);
IF InStr(v_header, '>')>0 THEN
v_header := Substr(v_header, InStr(v_header, '>') +1);
END IF;
v_buf := v_buf ||'<th>'||v_header||'</th>';
END IF;
v_cur_item := Get_Item_Property(v_cur_item, NEXTITEM );
END LOOP;
v_buf := v_buf || '</tr>';
fnd_gfm.file_write_line(v_db_file,v_buf);
-- Export rows
app_window.progress(0,'Writing to file ...');
LOOP
IF :trx.cb_select = 1 AND p_records = 'SELECTED' OR p_records = 'ALL' THEN
--v_cur_item := 'TRX_NUMBER';
v_cur_item := 'BU';
v_buf := '<tr>';
WHILE v_cur_item <> 'TRX_ID_SELECTED' LOOP
v_cur_item := 'TRX.'||v_cur_item;
--message (' ITEM ' || v_cur_item);
--message (' ITEM ' || v_cur_item);
IF v_cur_item = 'TRX.AMOUNT_ORIGINAL_MIR' THEN
BEGIN
SELECT reversal_category
INTO lc_rev_cat
FROM apps.ar_cash_receipts_all
WHERE cash_receipt_id = :trx.cash_receipt_id;
EXCEPTION
WHEN OTHERS THEN
lc_rev_cat := NULL;
END;
IF lc_rev_cat IS NOT NULL THEN
IF :trx.amount_original_mir <> 0 THEN
:trx.amount_original := '0.00';
v_buf := v_buf ||'<td>'||NVL(Name_In('TRX.AMOUNT_ORIGINAL'), ' ')||'</td>';
-- message (' Amt Original ' || :TRX.AMOUNT_ORIGINAL); pause;
END IF;
ELSIF name_in('TRX.AMOUNT_ORIGINAL_MIR') < 0 THEN
v_buf := v_buf ||'<td>'||NVL(Name_In('TRX.AMOUNT_ORIGINAL_MIR'), ' ')||'</td>';
ELSE
v_buf := v_buf ||'<td>'||NVL(Name_In('TRX.AMOUNT_ORIGINAL'), ' ')||'</td>';
END IF;
ELSIF v_cur_item = 'TRX.AMOUNT_REMAINING_MIR' THEN
IF name_in('TRX.AMOUNT_REMAINING_MIR') < 0 THEN
v_buf := v_buf ||'<td>'||NVL(Name_In('TRX.AMOUNT_REMAINING_MIR'), ' ')||'</td>';
ELSE
v_buf := v_buf ||'<td>'||NVL(Name_In('TRX.AMOUNT_REMAINING'), ' ')||'</td>';
END IF;
ELSIF v_cur_item <> 'TRX.AMOUNT_ORIGINAL_MIR' AND v_cur_item <> 'TRX.AMOUNT_REMAINING_MIR'
AND v_cur_item <> 'TRX.AMOUNT_ORIGINAL' AND v_cur_item <> 'TRX.AMOUNT_REMAINING'
AND Get_Item_Property(v_cur_item, ITEM_CANVAS) IN('TRX_FIXED', 'TRX_DETAIL') THEN
v_buf := v_buf ||'<td>'||NVL(Name_In(v_cur_item), ' ')||'</td>';
END IF;
v_cur_item := Get_Item_Property(v_cur_item, NEXT_NAVIGATION_ITEM );
END LOOP;
v_buf := v_buf || '</tr>';
fnd_gfm.file_write_line(v_db_file,v_buf);
END IF;
EXIT WHEN i = v_last_record OR :system.last_record = 'TRUE';
i := i+1;
Next_Record;
IF Mod(i,50) = 0 THEN
app_window.progress(i/v_last_record, 'Writing to file ...');
END IF;
END LOOP;
v_buf:=' </table> </body> </html> ';
fnd_gfm.file_write_line(v_db_file,v_buf);
v_db_file :=fnd_gfm.file_close(v_db_file);
v_url:=fnd_gfm.construct_download_url(fnd_web_config.gfm_agent,v_db_file,TRUE);
app_window.progress(1,'Writing to file ...');
Go_Block('trx');
Go_Record(v_top_record + Get_Block_Property('TRX', Records_Displayed));
Go_Record(v_top_record);
Globals.mass_trx_select := 0;
Go_Record(v_cur_record);
Web.Show_Document(v_url,'');
EXCEPTION
WHEN OTHERS THEN
Globals.mass_trx_select := 0;
Raise;
END;
No comments:
Post a Comment