How to use parrallel cursor in this code
hi can anyone expalin me how to use parallel cursor for this code ...
loop at itabkpf.
read table ibsegpar_fu with key
belnr = itabkpf-belnr
gjahr = itabkpf-gjahr
bschl = '25' .
Start insert by Pradeep 20082008
sort: itabkpf by belnr,
itabsegpar by belnr.
End insert by Pradeep 20082008
if sy-subrc = 0. "Deleted by pradeep 20082008
select bukrs belnr gjahr bschl koart lifnr wrbtr
wskto pswbt zfbdt augbl augdt sgtxt rebzg rebzj
into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = itabkpf-bukrs and
belnr = itabkpf-belnr and
gjahr = itabkpf-gjahr and
augbl <> itabkpf-belnr and
rebzg <> space and
bschl = '25'.
loop at ibsegpar_fu_1.
Start insert by Pradeep 20082008
sort ibsegpar_fu_1 by belnr.
End insert by Pradeep 20082008
move-corresponding ibsegpar_fu_1 to itabseg.
move ibsegpar_fu_1-belnr to itabseg-augbl.
move ibsegpar_fu_1-rebzg to itabseg-belnr.
move ibsegpar_fu_1-rebzj to itabseg-gjahr.
*********to include code to pick the description for partical payment
select single * from bseg where
bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-belnr and
gjahr = ibsegpar_fu_1-gjahr and
augbl <> ibsegpar_fu_1-belnr and
rebzg = space and
bschl <> '25'.
move bseg-sgtxt to itabseg-sgtxt.
clear bseg.
*********end of code
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-rebzg and
gjahr = ibsegpar_fu_1-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
endloop.
endif. "Deleted by Pradeep 20082008
endloop.
loop at ibsegpar_fu.
sort ibsegpar_fu by belnr. " insert by pradeep
move-corresponding ibsegpar_fu to itabseg.
select bukrs belnr gjahr bschl koart lifnr wrbtr
rebzg rebzj sgtxt into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = ibsegpar_fu-bukrs and
gjahr = ibsegpar_fu-gjahr and
augbl = ibsegpar_fu-belnr and " Pradeep 20082008 Delete
augbl <> ibsegpar_fu-belnr and " Pradeep 20082008 Insert
rebzg = space and
bschl = '25'.
if sy-subrc = 0.
loop at ibsegpar_fu_1.
move ibsegpar_fu_1-rebzg to itabseg-rebzg.
move ibsegpar_fu_1-rebzj to itabseg-rebzj.
endloop.
move ibsegpar_fu-belnr to itabseg-augbl.
move itabseg-rebzg to itabseg-belnr.
move itabseg-rebzj to itabseg-gjahr.
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu-bukrs and
belnr = itabseg-rebzj and
gjahr = itabseg-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
read table itabseg with key
belnr = itabseg-rebzg
gjahr = itabseg-rebzj
bschl = '31' .
if sy-subrc = 0.
delete itabseg index sy-tabix. "Deleted by Pradeep 20082108
endif.
endif.
endloop.
Start insert by Pradeep 20082008
loop at itabseg.
if itabseg-belnr = itabseg-augbl.
delete itabseg.
elseif itabseg-belnr = ' '.
delete itabseg.
endif.
endloop.
End insert by Pradeep 20082008
hi can anyone expalin me how to use parallel cursor for this code ...
loop at itabkpf.
read table ibsegpar_fu with key
belnr = itabkpf-belnr
gjahr = itabkpf-gjahr
bschl = '25' .
Start insert by Pradeep 20082008
sort: itabkpf by belnr,
itabsegpar by belnr.
End insert by Pradeep 20082008
if sy-subrc = 0. "Deleted by pradeep 20082008
select bukrs belnr gjahr bschl koart lifnr wrbtr
wskto pswbt zfbdt augbl augdt sgtxt rebzg rebzj
into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = itabkpf-bukrs and
belnr = itabkpf-belnr and
gjahr = itabkpf-gjahr and
augbl <> itabkpf-belnr and
rebzg <> space and
bschl = '25'.
loop at ibsegpar_fu_1.
Start insert by Pradeep 20082008
sort ibsegpar_fu_1 by belnr.
End insert by Pradeep 20082008
move-corresponding ibsegpar_fu_1 to itabseg.
move ibsegpar_fu_1-belnr to itabseg-augbl.
move ibsegpar_fu_1-rebzg to itabseg-belnr.
move ibsegpar_fu_1-rebzj to itabseg-gjahr.
*********to include code to pick the description for partical payment
select single * from bseg where
bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-belnr and
gjahr = ibsegpar_fu_1-gjahr and
augbl <> ibsegpar_fu_1-belnr and
rebzg = space and
bschl <> '25'.
move bseg-sgtxt to itabseg-sgtxt.
clear bseg.
*********end of code
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-rebzg and
gjahr = ibsegpar_fu_1-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
endloop.
endif. "Deleted by Pradeep 20082008
endloop.
loop at ibsegpar_fu.
sort ibsegpar_fu by belnr. " insert by pradeep
move-corresponding ibsegpar_fu to itabseg.
select bukrs belnr gjahr bschl koart lifnr wrbtr
rebzg rebzj sgtxt into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = ibsegpar_fu-bukrs and
gjahr = ibsegpar_fu-gjahr and
augbl = ibsegpar_fu-belnr and " Pradeep 20082008 Delete
augbl <> ibsegpar_fu-belnr and " Pradeep 20082008 Insert
rebzg = space and
bschl = '25'.
if sy-subrc = 0.
loop at ibsegpar_fu_1.
move ibsegpar_fu_1-rebzg to itabseg-rebzg.
move ibsegpar_fu_1-rebzj to itabseg-rebzj.
endloop.
move ibsegpar_fu-belnr to itabseg-augbl.
move itabseg-rebzg to itabseg-belnr.
move itabseg-rebzj to itabseg-gjahr.
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu-bukrs and
belnr = itabseg-rebzj and
gjahr = itabseg-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
read table itabseg with key
belnr = itabseg-rebzg
gjahr = itabseg-rebzj
bschl = '31' .
if sy-subrc = 0.
delete itabseg index sy-tabix. "Deleted by Pradeep 20082108
endif.
endif.
endloop.
Start insert by Pradeep 20082008
loop at itabseg.
if itabseg-belnr = itabseg-augbl.
delete itabseg.
elseif itabseg-belnr = ' '.
delete itabseg.
endif.
endloop.
End insert by Pradeep 20082008
Similar Messages
-
How to use bind variables in this procedure
Hi Experts,
How to use bind variables in this procedure for static queries.
PROCEDURE DELETE_MER_PROC (M_id IN NUMBER)
IS
BEGIN
V_date DATE;
SELECT PD_DATE INTO v_date FROM PD_MAINTAIN;
DELETE FROM MER_CLEAR
WHERE MER_DT < v_date
AND ID = M_ID;
COMMIT;
END;
How to use v_date and m_id as bind variables in this procedure to avoid hard parsing.
Please help me.
Thanks.976208 wrote:
How to use v_date and m_id as bind variables in this procedure to avoid hard parsing.
You cannot avoid hard parsing - as the 1st time a SQL statement (like the SELECT or DELETE statements in your code) is encountered, it does not reside in the server's Shared Pool, and needs to be added into the pool via a hard parse.
Bind variables does not prevent hard parsing. Hard parsing happens when the SQL statement (with or without bind variables) is a brand new statement encountered by the server.
Bind variables enables the same SQL cursor to be reused, by simply changing the bind variable value.
Not using bind variables means that each SQL statement is unique and not shareable - as the value is hardcoded into the statement and cannot be changed via a bind value. This typically means LOTS of different SQL statements (where the only difference is the changed value in the statement) are created - with each statement being a new statement not seen before in the Shared Pool and needing to be hard parsed.
One does not design one's code not to be hard parsed. There ALWAYS will be a hard parse in order to get a SQL statement into the Shared Pool. One designs one's code to REUSE cursors in the Shared Pool. -
How to use protected method in jsp code
Could anyone tell me how to use protected method in jsp code ...
I declare a Calendar class , and I want to use the isTimeSet method ,
But if I write the code as follows ..
========================================================
<%
Calendar create_date = Calendar.getInstance();
if (create_date.isTimeSet) System.out.println("true");
%>
============================================================
when I run this jsp , it appears the error wirtten "isTimeSet has protected access in java.util.Calendar"The only way to access a protected variable is to subclass.
MyCalendar extends Calendar
but I doubt you need to do this. If you only want to tell if a Calendar object has a time associated with it, try using
cal.isSet( Calendar.HOUR ); -
How to use open cursor and iner join in one statement
Hello All,
Could any one post the code for the below question?
How to use open cursor and iner join in one statement
Regards,
LisaOPEN CURSOR c FOR SELECT carrid connid fldate bookid smoker
FROM sbook innerjoin shook
ORDER BY carrid connid fldate smoker bookid.
Pls reward if helpful. -
How to use shift register in this structure?
Dear All,
In order to use less variety of graph, I want to use shift register to manage and send data to graph.
But there is not only event structure in my vi, for some reason(because I want to use only one button to control running and stop, and this must do through variety of button, I can't put this loop into the event structure) I must use other while loops, I don't know how to use shift register in this structure.
Please tell me anything helpful.
Thank you!
Attachments:
shift register.vi 26 KBhi there
there are a lot of solutions. my favorite one is the usage of a so called "FGV" (functional global variable). this allows you to strore, manipulate and transport data through your app with a minimum of wires. see attachment.. (other users may have other favorite solutions...)
Best regards
chris
CL(A)Dly bending G-Force with LabVIEW
famous last words: "oh my god, it is full of stars!"
Attachments:
Shift Register 7.1.zip 20 KB -
How to improve the performance of this code
Hi gurus
code is given below with LDB
this code look big but most of lines are commented
plz help its urgent
thanks in advance
*& Report ZSALES_RECON
REPORT ZSALES_RECON.
TYPE-POOLS : SLIS.
nodes: bseg , bkpf.
data : begin of zbseg occurs 0,
kunnr like bseg-kunnr,
*lifnr like bseg-lifnr,
dmbtr like bseg-dmbtr,
*shkzg like bseg-shkzg,
*gsber like bseg-gsber,
bschl like bseg-bschl,
*sgtxt like bseg-sgtxt,
total like bseg-dmbtr,
hkont like bseg-hkont,
BUDAT LIKE Bkpf-BUDAT,
belnr LIKE BSEG-belnr,
cash like bseg-dmbtr,
credit like bseg-dmbtr,
abn_voucher like bseg-dmbtr,
barista_voucher like bseg-dmbtr,
accor like bseg-dmbtr,
sodexho like bseg-dmbtr,
gift like bseg-dmbtr,
corp like bseg-dmbtr,
card like bseg-dmbtr,
miscellaneous like bseg-dmbtr,
werks like bseg-werks,
gjahr like bseg-gjahr,
SR_NO TYPE I,
shkzg like bseg-shkzg,
end of zbseg,
TP_TBL_DATA like ZBSEG.
DATA : idx TYPE sy-tabix.
Report data to be shown.
data: it_data like ZBSEG.
Heading of the report.
data: t_heading type slis_t_listheader.
AT SELECTION-SCREEN.
get bkpf.
START-OF-SELECTION.
data : sum_mis like bseg-dmbtr,
sum_abn like bseg-dmbtr,
sum_cash like bseg-dmbtr,
sum_credit like bseg-dmbtr,
sum_card like bseg-dmbtr,
sum_barista_voucher like bseg-dmbtr,
sum_accor like bseg-dmbtr,
sum_sodexho like bseg-dmbtr,
sum_gift like bseg-dmbtr,
sum_corp like bseg-dmbtr.
data : wa1_total like bseg-dmbtr.
data : wa_belnr like bseg-belnr,
wa_kunnr like bseg-kunnr,
wa_werks like bseg-werks,
belnr1 like bseg-belnr,
wa_sr_no type i.
GET BSEG.
data : wa like line of zbseg.
data : count type i,
count1 type i.
move-corresponding bseg to zbseg.
*idx = sy-tabix.
on change of zbseg-belnr.
wa_kunnr = zbseg-kunnr.
wa_kunnr = wa_kunnr+6(4).
select single werks into wa_werks from bseg where belnr = zbseg-belnr
and kunnr = '' and gjahr = zbseg-gjahr.
if wa_kunnr = wa_werks.
if zbseg-bschl <> '01'.
clear: sum_mis,wa1_total,sum_abn,sum_cash,sum_credit,sum_card,
sum_barista_voucher,sum_accor,sum_sodexho,sum_gift,sum_corp.
wa-BUDAT = BKPF-BUDAT.
wa-bschl = zbseg-bschl.
wa-hkont = zbseg-hkont.
wa-belnr = zbseg-belnr.
wa_belnr = wa-belnr.
wa-shkzg = zbseg-shkzg.
wa-kunnr = zbseg-kunnr.
count = wa-sr_no.
*wa-sr_no = count + 1.
idx = idx + 1.
append wa to zbseg.
**count = wa-sr_no.
*wa-sr_no = wa-sr_no + 1.
clear wa-total.
endif.
endif.
endon.
*clear : wa1_total.
if wa_belnr = zbseg-belnr.
loop at zbseg into wa.
wa-total = wa1_total.
wa-bschl = zbseg-bschl.
wa-hkont = zbseg-hkont.
count = sy-tabix.
wa-sr_no = count.
count1 = count.
*wa_sr_no = count.
modify zbseg from wa transporting sr_no.
IF wa-bschl eq '40' and wa-hkont eq '0024013020'.
if sy-tabix = 1.
wa-cash = zbseg-dmbtr.
sum_cash = sum_cash + wa-cash.
wa-cash = sum_cash.
modify zbseg index idx from wa transporting cash.
endif.
endif.
IF wa-bschl eq '40' and wa-hkont eq '0026060010'.
if sy-tabix = 1.
wa-credit = zbseg-dmbtr.
sum_credit = sum_credit + wa-credit.
wa-credit = sum_credit.
modify zbseg index idx from wa transporting credit.
endif.
endif.
IF wa-bschl eq '40' and wa-hkont eq '0026060015'.
if sy-tabix = 1.
wa-abn_voucher = zbseg-dmbtr.
sum_abn = sum_abn + wa-abn_voucher.
wa-abn_voucher = sum_abn.
modify zbseg index idx from wa transporting abn_voucher.
endif.
endif.
IF wa-bschl eq '40' and wa-hkont eq '0026060017'.
if sy-tabix = 1.
wa-barista_voucher = zbseg-dmbtr.
sum_barista_voucher = sum_barista_voucher + wa-barista_voucher.
wa-barista_voucher = sum_barista_voucher.
modify zbseg index idx from wa transporting barista_voucher.
endif.
endif.
IF wa-bschl eq '40' and wa-hkont eq '0026060020'.
if sy-tabix = 1.
wa-sodexho = zbseg-dmbtr.
sum_sodexho = sum_sodexho + wa-sodexho.
wa-sodexho = sum_sodexho.
modify zbseg index idx from wa transporting sodexho.
endif.
endif.
IF wa-bschl eq '40' AND wa-hkont eq '0026060030'.
if sy-tabix = 1.
wa-accor = zbseg-dmbtr.
sum_accor = sum_accor + wa-accor.
wa-accor = sum_accor.
modify zbseg index idx from wa transporting accor.
endif.
endif.
IF wa-bschl eq '40' AND wa-hkont eq '0026070040'.
if sy-tabix = 1.
wa-gift = zbseg-dmbtr.
sum_gift = sum_gift + wa-gift.
wa-gift = sum_gift.
modify zbseg index idx from wa transporting gift.
endif.
endif.
IF wa-bschl eq '40' AND wa-hkont eq '0026060070'.
if sy-tabix = 1.
wa-card = zbseg-dmbtr.
sum_card = sum_card + wa-card.
wa-card = sum_card.
modify zbseg index idx from wa transporting card.
endif.
endif.
IF wa-bschl eq '40' AND wa-hkont eq '0026060018'.
if sy-tabix = 1.
wa-corp = zbseg-dmbtr.
sum_corp = sum_corp + wa-corp.
wa-corp = sum_corp.
modify zbseg index idx from wa transporting corp.
endif.
endif.
*IF wa-bschl eq '11' .
*wa-total = zbseg-dmbtr.
*modify zbseg index idx from wa transporting total.
*endif.
IF wa-bschl EQ '40' or wa-bschl = '01' .
if sy-tabix = 1.
wa-total = zbseg-dmbtr.
wa1_total = wa1_total + wa-total.
wa-total = wa1_total.
*if idx = 2.
*modify zbseg index 1 from wa transporting total.
*else.
modify zbseg index idx from wa transporting total.
*endif.
endif.
endif.
*IF zbseg-TOTAL NE zbseg-DMBTR.
IF wa-BSCHL NE '11' AND wa-BSCHL NE '40'. "AND wa-BSCHL NE '01'.
if sy-tabix = 1.
if wa-shkzg = 'S'.
wa-miscellaneous = - wa-miscellaneous.
endif.
wa-miscellaneous = ZBSEG-DMBTR.
sum_mis = sum_mis + wa-miscellaneous.
wa-miscellaneous = sum_mis.
modify zbseg index idx from wa transporting miscellaneous.
endif.
ENDIF.
*wa1-miscellaneous = wa-miscellaneous.
*modify zbseg index idx from wa.
*ENDIF.
*append wa to zbseg.
*clear:zbseg-dmbtr.
endloop.
endif.
*****endif.
*****endon.
*ENDFORM.
*append zbseg.
*endloop.
End-of-selection.
perform build_alv using zbseg t_heading.
*& Form build_alv
Builds and display the ALV Grid.
form build_alv using t_data
*tp_tbl_data
t_heading type slis_t_listheader.
ALV required data objects.
data: w_title type lvc_title,
w_repid type syrepid,
w_comm type slis_formname,
w_status type slis_formname,
x_layout type slis_layout_alv,
t_event type slis_t_event,
t_fieldcat type slis_t_fieldcat_alv,
t_sort type slis_t_sortinfo_alv.
refresh t_fieldcat.
refresh t_event.
refresh t_sort.
clear x_layout.
clear w_title.
Field Catalog
perform set_fieldcat2 using:
1 'SR_NO' 'SR_NO' 'BKPF' '5' space space 'SR NO' space space space
space space space space space t_fieldcat ,
2 'BELNR' 'BELNR' 'BKPF' '10' space space 'Document No' space space
space space space space space space t_fieldcat ,
3 'BUDAT' 'BUDAT' 'BKPF' '10' space space 'Document Date' space
space space space space space space space t_fieldcat ,
4 'KUNNR' space space space space space 'Site' space space
space space space space space space t_fieldcat ,
5 'TOTAL' space 'BSEG' space space space 'Total' space space space
space space space space 'X' t_fieldcat ,
6 'CASH' 'CASH' 'BSEG' space space space 'Cash Sales'
space space space space space space space 'X' t_fieldcat ,
7 'CREDIT' 'CREDIT' 'BSEG' space space space 'Credit Card'
space space space space space space space 'X' t_fieldcat ,
8 'ABN_VOUCHER' space 'BSEG' space space space 'ABN Voucher' space
space
space space space space space 'X' t_fieldcat ,
9 'BARISTA_VOUCHER' space 'BSEG' '15' space space 'BARISTA Voucher'
space space
space space space space space 'X' t_fieldcat ,
10 'CORP' 'CORP' 'BSEG' space space space 'ABN Corp' space space
space space space space space 'X' t_fieldcat ,
11 'SODEXHO' 'SODEXHO' 'BSEG' space space space 'Sodexho' space
space space space space space space 'X' t_fieldcat ,
12 'ACCOR' 'ACCOR' 'BSEG' space space space 'Accor'
space space space space space space space 'X' t_fieldcat ,
13 'GIFT' 'GIFT' 'BSEG' space space space 'Gift Coupon'
space space space space space space space 'X' t_fieldcat ,
14 'CARD' 'CARD' 'BSEG' space space space 'Diners Card' space
space space space space space space 'X' t_fieldcat ,
15 'MISCELLANEOUS' space 'BKPF' '18' space space
'Miscellaneous Income' space space space space space space space 'X'
t_fieldcat .
*14 'KBETR' 'KBETR' 'KONP' '10' space space 'Tax %age' space space
*space space space space space space t_fieldcat ,
*15 'MWSKZ1' 'MWSKZ1' 'RBKP' space space space 'Tax Type' space
*space
space space space space space space t_fieldcat ,
*16 'AMT' 'AMT' 'RBKP' space space space 'Amount Payable' space
*space
space space space space space 'X' t_fieldcat ,
*17 'WERKS' 'SITE' 'RSEG' space space space 'State' space space
*space space space space space space t_fieldcat .
*18 'GSBER' 'GSBER' 'RBKP' space space space 'Business Area' space
*space space space space space space space t_fieldcat .
Layout
x_layout-zebra = 'X'.
Top of page heading
perform set_top_page_heading using t_heading t_event.
Events
perform set_events using t_event.
GUI Status
w_status = ''.
w_repid = sy-repid.
Title
w_title = <<If you want to set a title for
the ALV, please, uncomment and edit this line>>.
User commands
w_comm = 'USER_COMMAND'.
Order
Example
PERFORM set_order USING '<field>' 'IT_DATA' 'X' space space t_sort.
Displays the ALV grid
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = w_repid
it_fieldcat = t_fieldcat
is_layout = x_layout
it_sort = t_sort
i_callback_pf_status_set = w_status
i_callback_user_command = w_comm
i_save = 'X'
it_events = t_event
i_grid_title = w_title
tables
t_outtab = zbseg
t_data
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " build_alv.
*& Form set_top_page_heading
Creates the report headings.
form set_top_page_heading using t_heading type slis_t_listheader
t_events type slis_t_event.
data: x_heading type slis_listheader,
x_event type line of slis_t_event.
Report title
clear t_heading[].
clear x_heading.
x_heading-typ = 'H'.
x_heading-info = 'SALES RECONCILIATION REPORT'(001).
append x_heading to t_heading.
Top of page event
x_event-name = slis_ev_top_of_page.
x_event-form = 'TOP_OF_PAGE'.
append x_event to t_events.
endform.
*& Form set_events
Sets the events for ALV.
The TOP_OF_PAGE event is alredy being registered in
the set_top_page_heading subroutine.
form set_events using t_events type slis_t_event.
data: x_event type line of slis_t_event.
Example
clear x_event.
x_event-name = .
x_event-form = .
append x_event to t_event.
endform.
*& Form set_order
Adds an entry to the order table.
FORM set_order USING p_fieldname p_tabname p_up p_down p_subtot
t_sort TYPE slis_t_sortinfo_alv.
DATA: x_sort TYPE slis_sortinfo_alv.
CLEAR x_sort.
x_sort-fieldname = p_fieldname.
x_sort-tabname = p_tabname.
x_sort-up = p_up.
x_sort-down = p_down.
x_sort-subtot = p_subtot.
APPEND x_sort TO t_sort.
ENDFORM. "set_order
*& Form set_fieldcat2
Adds an entry to the field catalog.
p_colpos: Column position.
p_fieldname: Field of internal table which is being described by
* this record of the field catalog.
p_ref_fieldname: (Optional) Table field / data element which
* describes the properties of the field.
* If this field is not given, it is copied from
* the fieldname.
p_ref_tabname: (Optional) Table which holds the field referenced
* by <<p_ref_fieldname>>.
If this is not given, the parameter
<<p_ref_fieldname>> references a data element.
p_outputlen: (Optional) Column width.
p_noout: (Optional) If set to 'X', states that the field is not
* showed initially. If so, the field has to be
included in the report at runtime using the display
options.
p_seltext_m: (Optional) Medium label to be used as column header.
p_seltext_l: (Optional) Long label to be used as column header.
p_seltext_s: (Optional) Small label to be used as column header.
p_reptext_ddic: (Optional) Extra small (heading) label to be
* used as column header.
p_ddictxt: (Optional) Set to 'L', 'M', 'S' or 'R' to select
whether to use SELTEXT_L, SELTEXT_M, SELTEXT_S,
or REPTEXT_DDIC as text for column header.
p_hotspot: (Optional) If set to 'X', this field will be used
* as a hotspot area for cursor, alolowing the user
* to click on the field.
p_showasicon: (Optional) If set to 'X', this field will be shown
as an icon and the contents of the field will set
* which icon to show.
p_checkbox: (Optional) If set to 'X', this field will be shown
as a checkbox.
p_edit: (Optional) If set to 'X', this field will be editable.
p_dosum: (Optional) If set to 'X', this field will be summed
(aggregation function) according to the grouping set
by the order functions.
t_fieldcat: Table which contains the whole fieldcat.
FORM set_fieldcat2 USING
p_colpos p_fieldname p_ref_fieldname p_ref_tabname
p_outputlen p_noout
p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
p_hotspot p_showasicon p_checkbox p_edit
p_dosum
t_fieldcat TYPE slis_t_fieldcat_alv.
DATA: wa_fieldcat TYPE slis_fieldcat_alv.
CLEAR wa_fieldcat.
General settings
wa_fieldcat-fieldname = p_fieldname.
wa_fieldcat-col_pos = p_colpos.
wa_fieldcat-no_out = p_noout.
wa_fieldcat-hotspot = p_hotspot.
wa_fieldcat-checkbox = p_checkbox.
wa_fieldcat-icon = p_showasicon.
wa_fieldcat-do_sum = p_dosum.
Set reference fieldname, tablenam and rollname.
If p_ref_tabname is not given, the ref_fieldname given
is a data element.
If p_ref_tabname is given, the ref_fieldname given is a
field of a table.
In case ref_fieldname is not given,
it is copied from the fieldname.
IF p_ref_tabname IS INITIAL.
wa_fieldcat-rollname = p_ref_fieldname.
ELSE.
wa_fieldcat-ref_tabname = p_ref_tabname.
IF p_ref_fieldname EQ space.
wa_fieldcat-ref_fieldname = wa_fieldcat-fieldname.
ELSE.
wa_fieldcat-ref_fieldname = p_ref_fieldname.
ENDIF.
ENDIF.
Set output length.
IF NOT p_outputlen IS INITIAL.
wa_fieldcat-outputlen = p_outputlen.
ENDIF.
Set text headers.
IF NOT p_seltext_m IS INITIAL.
wa_fieldcat-seltext_m = p_seltext_m.
ENDIF.
IF NOT p_seltext_l IS INITIAL.
wa_fieldcat-seltext_l = p_seltext_l.
ENDIF.
IF NOT p_seltext_s IS INITIAL.
wa_fieldcat-seltext_s = p_seltext_s.
ENDIF.
IF NOT p_reptext_ddic IS INITIAL.
wa_fieldcat-reptext_ddic = p_reptext_ddic.
ENDIF.
IF NOT p_ddictxt IS INITIAL.
wa_fieldcat-ddictxt = p_ddictxt.
ENDIF.
Set as editable or not.
IF NOT p_edit IS INITIAL.
wa_fieldcat-input = 'X'.
wa_fieldcat-edit = 'X'.
ENDIF.
APPEND wa_fieldcat TO t_fieldcat.
ENDFORM. "set_fieldcat2
======================== Subroutines called by ALV ================
*& Form top_of_page
Called on top_of_page ALV event.
Prints the heading.
form top_of_page.
call function 'REUSE_ALV_COMMENTARY_WRITE'
exporting
i_logo = <<If you want to set a logo, please,
uncomment and edit this line>>
it_list_commentary = t_heading.
endform. " alv_top_of_page
*& Form user_command
Called on user_command ALV event.
Executes custom commands.
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
Example Code
Executes a command considering the sy-ucomm.
CASE r_ucomm.
WHEN '&IC1'.
Set your "double click action" response here.
Example code: Create and display a status message.
DATA: w_msg TYPE string,
w_row(4) TYPE n.
w_row = rs_selfield-tabindex.
CONCATENATE 'You have clicked row' w_row
'field' rs_selfield-fieldname
'with value' rs_selfield-value
INTO w_msg SEPARATED BY space.
MESSAGE w_msg TYPE 'S'.
ENDCASE.
End of example code.
endform. "user_command
*********************************ldb code start from here *************************************************************
DATABASE PROGRAM OF LOGICAL DATABASE ZBRM_3
top-include and nxxx-include are generated automatically
Do NOT change their names manually!!!
*include DBZBRM_3TOP . " header
*include DBZBRM_3NXXX . " all system routines
include DBZBRM_3F001 . " user defined include
PROGRAM SAPDBZBRM_3 DEFINING DATABASE ZBRM_3.
TABLES:
BKPF,
BSEG.
Hilfsfelder
DATA:
BR_SBUKRS LIKE BKPF-BUKRS,
BR_SBELNR LIKE BKPF-BELNR,
BR_SGJAHR LIKE BKPF-GJAHR,
BR_SBUDAT LIKE BKPF-BUDAT,
BR_SGSBER LIKE BSEG-GSBER.
BR_SBUZEI LIKE BSEG-BUZEI,
BR_SEBELN LIKE BSEG-EBELN,
BR_SEBELP LIKE BSEG-EBELP,
BR_SZEKKN LIKE BSEG-ZEKKN.
working areas for the authority check "n435991
for the company code "n435991
*TYPES : BEGIN OF STYPE_BUKRS, "n435991
BUKRS LIKE T001-BUKRS, "n435991
WAERS LIKE T001-WAERS, "n435991
RETCODE TYPE N, "n435991
END OF STYPE_BUKRS. "n435991
"n435991
*DATA : G_S_BUKRS TYPE STYPE_BUKRS, "n435991
G_T_BUKRS TYPE STYPE_BUKRS OCCURS 0. "n435991
"n435991
for the document type "n435991
*TYPES : BEGIN OF STYPE_BLART, "n435991
BLART LIKE BKPF-BLART, "n435991
RETCODE TYPE N, "n435991
END OF STYPE_BLART. "n435991
"n435991
*DATA : G_S_BLART TYPE STYPE_BLART, "n435991
G_T_BLART TYPE STYPE_BLART OCCURS 0. "n435991
"n435991
for the business area "n435991
*TYPES : BEGIN OF STYPE_GSBER, "n435991
GSBER LIKE BSEG-GSBER, "n435991
RETCODE TYPE N, "n435991
END OF STYPE_GSBER. "n435991
"n435991
*DATA : G_S_GSBER TYPE STYPE_GSBER, "n435991
G_T_GSBER TYPE STYPE_GSBER OCCURS 0. "n435991
"n435991
for the purchasing organization "n435991
*TYPES : BEGIN OF STYPE_EKORG, "n435991
EKORG LIKE EKKO-EKORG, "n435991
RETCODE TYPE N, "n435991
END OF STYPE_EKORG. "n435991
"n435991
*DATA : G_S_EKORG TYPE STYPE_EKORG, "n435991
G_T_EKORG TYPE STYPE_EKORG OCCURS 0. "n435991
"n435991
for the plant "n435991
*TYPES : BEGIN OF STYPE_WERKS, "n435991
WERKS LIKE EKPO-WERKS, "n435991
RETCODE TYPE N, "n435991
END OF STYPE_WERKS. "n435991
"n435991
*DATA : G_S_WERKS TYPE STYPE_WERKS, "n435991
G_T_WERKS TYPE STYPE_WERKS OCCURS 0. "n435991
"n435991
*DATA : G_F_TABIX LIKE SY-TABIX. "n435991
"n435991
working tables for array database access "n934526
*types : begin of stype_key, "n934526
bukrs type bkpf-bukrs, "n934526
belnr type bkpf-belnr, "n934526
gjahr type bkpf-gjahr, "n934526
end of stype_key, "n934526
"n934526
stab_key type standard table of "n934526
stype_key "n934526
with default key. "n934526
Initialwerte setzen
FORM INIT.
ENDFORM.
Selection Screen: Process before output
FORM PBO.
ENDFORM.
Selection Screen: Process after input
FORM PAI USING FNAME MARK.
CHECK MARK = SPACE.
ENDFORM.
Lesen BKPF und Uebergabe an den Selektionsreport
FORM PUT_BKPF.
define locla working areas "n934526
data : l_t_key type stab_key, "n934526
l_t_key_block type stab_key, "n934526
l_t_bkpf type standard table of bkpf. "n934526
"n934526
----------------------------------------------------------"n934526
"n934526
database seletion improved "n934526
at first read all FI doc keys into a lean table "n934526
data: wa like bkpf-belnr.
SELECT * FROM BKPF
where budat in br_budat
AND GJAHR EQ BR_GJAHR-LOW
AND BLART = 'RV'.
AND BLART IN BR_BLAR "n934526
"n934526
check sy-subrc is initial. "n934526
"n934526
then process the found FI doc keys in small blocks "n934526
do. "n934526
if l_t_key[] is initial. "n934526
exit. " no more keys -> leave this DO loop "n934526
endif. "n934526
"n934526
form small blocks with 100 FI docs each "n934526
refresh l_t_key_block. "n934526
append lines of l_t_key from 1 to 100 "n934526
to l_t_key_block. "n934526
delete l_t_key from 1 to 100. "n934526
"n934526
read the complete FI doc headers for the block "n934526
SELECT * FROM BKPF "n934526
into corresponding fields of table l_t_bkpf "n934526
for all entries in l_t_key_block "n934526
WHERE BUKRS = l_t_key_block-BUKRS "n934526
AND BELNR = l_t_key_block-BELNR "n934526
AND GJAHR = l_t_key_block-GJAHR. "n934526
"n934526
provide the complete structure for the PUT "n934526
loop at l_t_bkpf into bkpf. "n934526
process this company code : authority and read T001 "n934526
PERFORM F1000_COMPANY_CODE. "n934526
"n934526
go on if the first authority check was successful "n934526
CHECK : G_S_BUKRS-RETCODE IS INITIAL. "n934526
"n934526
set the currency key and save the keys "n934526
MOVE : G_S_BUKRS-WAERS TO T001-WAERS, "n934526
BKPF-BUKRS TO BR_SBUKRS, "n934526
MOVE BKPF-BELNR TO BR_SBELNR.
MOVE BKPF-GJAHR TO BR_SGJAHR . "n934526
BKPF-GJAHR TO BR_SGJAHR. "n934526
PUT BKPF. "n934526
endloop. "n934526
enddo. "n934526
ENDSELECT.
ENDFORM.
Lesen BSEG und Uebergabe an den Selektionsreport
FORM PUT_BSEG.
define local working areas "n934526
data : l_t_bseg type standard table of bseg. "n934526
"n934526
----------------------------------------------------------"n934526
BR_SGSBER = BR_GSBER-LOW.
"n934526
SELECT * FROM BSEG "n934526
WHERE BELNR EQ BR_SBELNR
AND GJAHR EQ BR_SGJAHR
AND GSBER EQ BR_SGSBER.
check sy-subrc is initial. "n934526
"n934526
loop at l_t_bseg into bseg. "n934526
MOVE BSEG-BUZEI TO BR_SBUZEI.
MOVE BSEG-EBELN TO BR_SEBELN.
MOVE BSEG-EBELP TO BR_SEBELP.
MOVE BSEG-ZEKKN TO BR_SZEKKN.
PUT BSEG.
endSELECT. "n934526
ENDFORM.
"n435991
FORM AUTHORITYCHECK_BKPF "n435991
"n435991
"n435991
*FORM AUTHORITYCHECK_BKPF. "n435991
"n435991
the authority-check for the company code was successful; "n435991
check authority for the document type here "n435991
"n435991
does the buffer contain this document type ? "n435991
READ TABLE G_T_BLART INTO G_S_BLART "n435991
WITH KEY BLART = BKPF-BLART BINARY SEARCH. "n435991
"n435991
CASE SY-SUBRC. "n435991
WHEN 0. "document type is known "n435991
"n435991
WHEN 4. "docment type is new --> insert "n435991
MOVE SY-TABIX TO G_F_TABIX. "n435991
PERFORM F1200_CREATE_BLART_ENTRY. "n435991
INSERT G_S_BLART INTO G_T_BLART "n435991
INDEX G_F_TABIX. "n435991
"n435991
WHEN 8. "document type is new --> append "n435991
PERFORM F1200_CREATE_BLART_ENTRY. "n435991
APPEND G_S_BLART TO G_T_BLART. "n435991
ENDCASE. "n435991
"n435991
set the return code "n435991
MOVE G_S_BLART-RETCODE TO SY-SUBRC. "n435991
"n435991
*ENDFORM. "authoritycheck_bkpf "n435991
"n435991
"n435991
FORM AUTHORITYCHECK_BSEG "n435991
"n435991
"n435991
*FORM AUTHORITYCHECK_BSEG. "n435991
"n435991
does the buffer contain this document type ? "n435991
READ TABLE G_T_GSBER INTO G_S_GSBER "n435991
WITH KEY GSBER = BSEG-GSBER BINARY SEARCH. "n435991
"n435991
CASE SY-SUBRC. "n435991
WHEN 0. "business area is known "n435991
"n435991
WHEN 4. "business area is new --> insert "n435991
MOVE SY-TABIX TO G_F_TABIX. "n435991
PERFORM F1300_CREATE_GSBER_ENTRY. "n435991
INSERT G_S_GSBER INTO G_T_GSBER "n435991
INDEX G_F_TABIX. "n435991
"n435991
WHEN 8. "business area is new --> append "n435991
PERFORM F1300_CREATE_GSBER_ENTRY. "n435991
APPEND G_S_GSBER TO G_T_GSBER. "n435991
ENDCASE. "n435991
"n435991
set the return code "n435991
MOVE G_S_GSBER-RETCODE TO SY-SUBRC. "n435991
"n435991
*ENDFORM. "authoritycheck_bseg "n435991
"n435991ABAP provides few tools to analyse the perfomance of the objects, which was developed by us.
Run time analysis transaction SE30
This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
SQL Trace transaction ST05
by using this tool we can analyse the perfomance issues related to DATABASE calls.
Perfomance Techniques for improve the perfomance of the object.
1) ABAP/4 programs can take a very long time to execute, and can make other processes have to wait before executing. Here are some tips to speed up your programs and reduce the load your programs put on the system:
2) Use the GET RUN TIME command to help evaluate performance. It's hard to know whether that optimization technique REALLY helps unless you test it out.
3) Using this tool can help you know what is effective, under what kinds of conditions. The GET RUN TIME has problems under multiple CPUs, so you should use it to test small pieces of your program, rather than the whole program.
4) Generally, try to reduce I/O first, then memory, then CPU activity. I/O operations that read/write to hard disk are always the most expensive operations. Memory, if not controlled, may have to be written to swap space on the hard disk, which therefore increases your I/O read/writes to disk. CPU activity can be reduced by careful program design, and by using commands such as SUM (SQL) and COLLECT (ABAP/4).
5) Avoid 'SELECT *', especially in tables that have a lot of fields. Use SELECT A B C INTO instead, so that fields are only read if they are used. This can make a very big difference.
6) Field-groups can be useful for multi-level sorting and displaying. However, they write their data to the system's paging space, rather than to memory (internal tables use memory). For this reason, field-groups are only appropriate for processing large lists (e.g. over 50,000 records). If you have large lists, you should work with the systems administrator to decide the maximum amount of RAM your program should use, and from that, calculate how much space your lists will use. Then you can decide whether to write the data to memory or swap space.
Use as many table keys as possible in the WHERE part of your select statements.
7)Whenever possible, design the program to access a relatively constant number of records (for instance, if you only access the transactions for one month, then there probably will be a reasonable range, like 1200-1800, for the number of transactions inputted within that month). Then use a SELECT A B C INTO TABLE ITAB statement.
8) Get a good idea of how many records you will be accessing. Log into your productive system, and use SE80 -> Dictionary Objects (press Edit), enter the table name you want to see, and press Display. Go To Utilities -> Table Contents to query the table contents and see the number of records. This is extremely useful in optimizing a program's memory allocation.
9) Try to make the user interface such that the program gradually unfolds more information to the user, rather than giving a huge list of information all at once to the user.
10) Declare your internal tables using OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to be accessing. If the number of records exceeds NUM_RECS, the data will be kept in swap space (not memory).
11) Use SELECT A B C INTO TABLE ITAB whenever possible. This will read all of the records into the itab in one operation, rather than repeated operations that result from a SELECT A B C INTO ITAB... ENDSELECT statement. Make sure that ITAB is declared with OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to access.
12) If the number of records you are reading is constantly growing, you may be able to break it into chunks of relatively constant size. For instance, if you have to read all records from 1991 to present, you can break it into quarters, and read all records one quarter at a time. This will reduce I/O operations. Test extensively with GET RUN TIME when using this method.
13) Know how to use the 'collect' command. It can be very efficient.
14) Use the SELECT SINGLE command whenever possible.
15) Many tables contain totals fields (such as monthly expense totals). Use these avoid wasting resources by calculating a total that has already been calculated and stored.
Some tips:
1) Use joins where possible as redundant data is not fetched.
2) Use select single where ever possible.
3) Calling methods of a global class is faster than calling function modules.
4) Use constants instead of literals
5) Use WHILE instead of a DO-EXIT-ENDDO.
6) Unnecessary MOVEs should be avoided by using the explicit work area operations
see the follwing links for a brief insifght into performance tuning,
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_Introduction.asp
1. Debuggerhttp://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
2. Run Time Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
3. SQL trace
http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
4. CATT - Computer Aided Testing Too
http://help.sap.com/saphelp_47x200/helpdata/en/b3/410b37233f7c6fe10000009b38f936/frameset.htm
5. Test Workbench
http://help.sap.com/saphelp_47x200/helpdata/en/a8/157235d0fa8742e10000009b38f889/frameset.htm
6. Coverage Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c7/af9a79061a11d4b3d4080009b43351/content.htm
7. Runtime Monitor
http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
8. Memory Inspector
http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
9. ECATT - Extended Computer Aided testing tool.
http://help.sap.com/saphelp_47x200/helpdata/en/20/e81c3b84e65e7be10000000a11402f/frameset.htm
Performance tuning for Data Selection Statement
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm -
How to use at cursor selection
hi gurus,
can anyone tell wats the purpose of
'At cursor-selection' and how to use it in pai module?????
regards,
balaji.shi balaji,
The Best explanation with example comes from our help.sap.com....
http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbabbd35c111d1829f0000e829fbfe/content.htm
Also this might help...
MODULE mod CURSOR-SELECTION}
CHAIN-REQUEST}
SWITCH switch .
... AT CURSOR-SELECTION
The AT CURSOR-SELECTION addition at the event PAI causes the module mod to be called only if
The function used to trigger event PAI has function code "CS" and function type "S"
The cursor is placed on a single input or output field of the screen at the moment of the user action
The call occurs within the usual PAI processing, meaning that the automatic input checks defined in the system or in the ABAP Dictionary are executed and the MODULE statement is called according to its position in the event block. You can use the addition in connection with the FIELD statement.
If the PAI event is triggered under the above circumstances, the function code is not passed to sy-ucomm and the OK field. They keep their previous values.
Note
The function type and function code of a function are determined in the Screen Painter or in the Menu Painter. We recommend to assign function code "CS" in the Menu Painter to function key F2 in order to simultaneously assign the double-click function of the mouse to it. This allows you to assign dialog modules to the selection of input or output fields.
Link: [Re: MODULE REQUEST;
Thanks,
reward If Helpful. -
How to use Xerces parser in my code
Hello all,
This is my first time in the forumn. I am a beginer to xml. I am trying to use xerces SAX parser to parse the xml document. I have downloaded xerces 2.6.2 in the c drive. Can you please guide me how can I use it in my piece of code and how to execute. I tried using the parser available on my system. This code works fine. But I am confused with how can modify my code to parse using Xerces parser.
Help appreciated!
import javax.xml.parsers.SAXParserFactory;//This class creates instances of SAX parser factory
import javax.xml.parsers.SAXParser;//factory returns the SAXParser
import javax.xml.parsers.ParserConfigurationException;//if the parser configuration does not match throws exception
/*2 statements can be substituted by import org.xml.sax.*;
This has interfaces we use for SAX Parsers.
Has Interfaces that are used for SAX Parser.
import org.xml.sax.XMLReader;
import org.xml.sax.SAXException;
import java.io.*;
import java.util.*;
public class CallSAX_18 {
public static void main (String []args)
throws SAXException,
ParserConfigurationException
IOException {
/* 3 statement below can be substitued by this below 1 statement when using other parser
XMLReader xmlReader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
XMLReader xmlReader = saxParser.getXMLReader();
/*/MyContentHandler has callback methods that the SAX parser will use.This class implements startElement() endElement() etc methods.
DBContentHandler dbcontent = new DBContentHandler();
xmlReader.setContentHandler(dbcontent);
xmlReader.parse(new File(args[0]).toURL().toString());Well, I am not too familiar with SAX, but I know my DOMs 8-)
is there a reason you are using SAX to parse versus DOM?
what is your final objective that you want to accomplish? Perhaps
DOM might be better? Are you trying to parsing XML into nodes? -
How to use SET CURSOR in REUSE_ALV_HIERSEQ_LIST_DISPLAY
Hi,
I have added new fields in Standard VL10C ALV report , I have added one editable field in this standard ALV output.
I want to set the cursor by default on the editable column on the specific row depending on some condition also if possible
i want to highlight only that particular row.
Please reply if anybody knows how to do this.
Thanks,
PawanHİ Pawan
You can see the list of events supported by reusable alv with function REUSE_ALV_EVENTS_GET
when I run this function in se37 I see the some events maybe helpful for your question
PF_STATUS_SET : this has to be called from PBO of your screen, so you can try to use SET CURSOR
command to put cursor on the selected field
BEFORE_LINE_OUTPUT : It's called before the output of every single line so you should use command
"FORMAT COLOR COL_POSITIVE INTENSIFIED ON. "for highlighting the line
AFTER_LINE_OUTPUT : than u can use "FORMAT COLOR COL_POSITIVE INTENSIFIED OFF." command
I hope it'll be helpful. -
How to use the google play RSA code on a Mac?
Hi,
I´ve just finished my first Android App using Flash CC and I´d like to upload it to the Google Play Store.
Now Google says there is a RSA-Key Code I have to use ... somehow.
Can anyone tell me what I´ve got to do with it? And please explain it for Dummies
I´ve been searching for some hours now, but I didn´t find anything helpful / anything I could work with. Most Tutorials and Instructions are for FlashBuilder or PC users. Nothing I could use or even understand
I´m working on a Mac using Flash CC - so I´m stuck right now.
So please - HELP ME!
Best regards
JanHi Pahup,
Thank you for your reply!!
I adapted an Android App using Flash CC on a Mac. I already published this App for the Apple App Store. When I published the App for Android I chose Air 3.7.xxx for Android. I also created the p12 certificate using Flash CC in the publishing settigns for Android. So my App is theoretically finished and ready for Upload.
When I went to the Google Play Store Developer Console I had the options to
1.) Upload APK
or
2.) Prepare Store Entry
...so I prepared the Store entry first. When I go to "APK"-Tab in the console it looks like this:
... it says "Upload APK" and the Button below "Get Licence Key". When I click on the license Key Button it looks like this:
So I think I should enter this RSA-Key somehow into my App BEFORE uploading it to the Google Play Store. This is recommended when an Ap is set to be paid. My Application is set to paid.
I did not use any kind of licensing API (until now - cause I don´t know how and what it is for)
This is all new to me. It is the first App I want to bringt to the Android market. I really hoped it would be as easy as getting an app into the Apple App Store. I found so many step by step instructions for dummies on "How to get an Flash iOS App into the App Store plus creating all the certificates needed", so I thought it would be the same for Android. But there is no help at all at the moment. I am totally confused.
So any help, hint or instrusction would be great!!
By the way - this is the App I want to get into the Google Play Store -
How to optimize the performance of this code ?
I've two Movie clips on a flash project. One of them is fixed and the other can be moved by arrow buttons on the keyboard. The two Movie clips have irregular shapes, so HitTestObject and HitTestPoint doesn't work very well. I've a function that detects collision of two movie clips using bitmap. I wanted to update the position of the movable Movie clip so I put the collision detection function under the code of ENTER_FRAME event listener. It works very well, but when I add many fixed movie clips ( about 10 fixed movie clips in one frame ), the game (.swf file) becomes slower and the performance of the PC becomes slower. I thought that my collision detection function has a negative effect on PC performance so I used the class on this page : https://forums.adobe.com/thread/873737
but the same thing happens.
Would you tell me how to speed up the execution of my codes ?
Here is part of my code :
stage.addEventListener(Event.ENTER_FRAME, myOnEnterFrame);
function myOnEnterFrame(event:Event):void
if (doThisFn) // doThisFn is a variable to allow or prevent the movable movie clip form being moved with keyboard arrows
if ( left && !right ) {
player.x -= speed;
player.rotation = player.rotation - speed ;
if( right && !left ) {
player.x += speed;
player.rotation = player.rotation + speed ;
if( up && !down ) {
player.y -= speed;
if( down && !up ) {
player.y += speed;
// The fixed movie clips are wall1 ,wall2 , wall3 , wall4 , ... and so on
// the following code checks how many walls exists on each frame and pushes them into the wallA array
for(var i:int=0;i<1000;i++) // We can put up to 1000 wall object into the wallA array
if(this['wall'+i]) // If the object wall exists, push it into the wallA array
wallA.push(this['wall'+i]);
for(i=0;i<wallA.length;i++)
if( h.hitF (player , wallA[i] ) || gameOverTest ) // This code checks if the player ( the movable movie clip ) hits the walls or not
trace ( "second try" ) ;
gameOver.visible = true ;
doThisFn = false ;
//I think the following codes are easy to excite and run. I think the performance issue is due to previous codes.
if (player.hitTestObject(door))
win.visible = true ;
doThisFn = false ;
if (key) // if there is a key on frame
if (player.hitTestObject(key))
key.visible = false ;
switch( currentFrame )
case 4:
wallA[0].visible = false ;
wallA[0].x = 50000;
break;
case 5:
wall14.play();
wall8.x = 430 ;
break;it's a simple question that usually has no simple answer.
here's an excerpt from a book (Flash Game Development: In a Social, Mobile and 3D World) i wrote.
Optimization Techniques
Unfortunately, I know of no completely satisfactory way to organize this information. In what follows, I discuss memory management first with sub-topics listed in alphabetical order. Then I discuss CPU/GPU management with sub-topics listed in alphabetical order.
That may seem logical but there are, at least, two problems with that organization.
1. I do not believe it is the most helpful way to organize this information.
2. Memory management affects CPU/GPU usage, so everything in the Memory Management section could also be listed in the CPU/GPU section.
Anyway, I am going to also list the information two other ways, from easiest to hardest to implement and from greatest to least benefit.
Both of those later listings are subjective and are dependent on developer experience and capabilities, as well as, the test situation and test environment. I very much doubt there would be a consensus on ordering of these lists. Nevertheless, I think they still are worthwhile.
Easiest to Hardest to Implement
1. Do not use Filters.
2. Always use reverse for-loops and avoid do-loops and avoid while-loops.
3. Explicitly stop Timers to ready them for gc (garbage collection).
4. Use weak event listeners and remove listeners.
5. Strictly type variables whenever possible.
6. Explicitly disable mouse interactivity when mouse interactivity not needed.
7. Replace dispatchEvents with callback functions whenever possible.
8. Stop Sounds to enable Sounds and SoundChannels to be gc'd.
9. Use the most basic DisplayObject needed.
10. Always use cacheAsBitmap and cacheAsBitmapMatrix with air apps (i.e., mobile devices).
11. Reuse Objects whenever possible.
12. Event.ENTER_FRAME loops: Use different listeners and different listener functions applied to as few DisplayObjects as possible.
13. Pool Objects instead of creating and gc'ing Objects.
14. Use partial blitting.
15. Use stage blitting.
16. Use Stage3D
Greatest to Least Benefit
Use stage blitting (if there is enough system memory).
Use Stage3D.
Use partial blitting.
Use cacheAsBitmap and cacheAsBitmapMatrix with mobile devices.
Explicitly disable mouse interactivity when mouse interactivity not needed.
Do not use Filters.
Use the most basic DisplayObject needed.
Reuse Objects whenever possible.
Event.ENTER_FRAME loops: Use different listeners and different listener functions applied to as few DisplayObjects as possible.
Use reverse for-loops and avoid do-loops and while-loops.
Pool Objects instead of creating and gc'ing Objects.
Strictly type variables whenever possible.
Use weak event listeners and remove listeners.
Replace dispatchEvents with callback functions whenever possible.
Explicitly stop Timers to ready for gc.
16. Stop Sounds to enable Sounds and SoundChannels to be gc'd. -
Hello I ran into a problem while running a SQL command using OracleCommand. I am Declaring a cursor to retrieve values from table A and then loop through that dataset to update table B. When I run this script I see my application hanging right there without any response. Do I have to use REF CURSOR? HOW to use it? I can't use DECLARE CURSOR? Need help. Here is my present SQL command
DECLARE CURSOR c_load IS SELECT VALUATION_YR_MTH_NBR,PMT_PRD_NBR,PMT_DAY,PMT_MTH,PMT_YR,SERIES_NAME,GROUP_NAME,FNC_PROD_NAME,SCENARIO_ABBR,PRIN_SCHED_BAL,NET_INT_AMT,SCHED_PRIN_AMT,SPEED_PREPMT_1_MTH_AMT,LOSS_TOTAL_AMT,SURETY_FEE_AMT,INT_FROM_OTHER_GROUP_AMT,PRIN_FROM_OTHER_GROUP_AMT,SENIOR_FIXED_RATE_BOND_BAL,SENIOR_FLOAT_RATE_BOND_BAL,SUBORDINATE_RATE_BOND_BAL,IO_NOTIONAL_BAL,NON_IO_FIXED_INT_PAID_AMT,NON_IO_FLOAT_INT_PAID_AMT,IO_INT_PAID_AMT,TOTAL_PRIN_AMT,BOND_WRITE_DOWNS_AMT,SURETY_PMTS_AMT,OC_BAL,OC_TARGET_BAL,RESIDUAL_INT_AMT,RESIDUAL_PRIN_AMT,RESIDUAL_TOTAL_AMT, CHG_LST_DATE, CHG_LST_USER_ID, CHG_LST_PROG_NAME FROM RESIDCF.CASH_FLOW_FORECAST_UPLOAD WHERE PREV_UPLOADED_IND='Y'; BEGIN FOR c_inx IN c_load LOOP UPDATE RESIDCF.CASH_FLOW_FORECAST SET PMT_DAY=c_inx.PMT_DAY,PMT_MTH=c_inx.PMT_MTH,PMT_YR=c_inx.PMT_YR,PRIN_SCHED_BAL=c_inx.PRIN_SCHED_BAL,NET_INT_AMT=c_inx.NET_INT_AMT,SCHED_PRIN_AMT=c_inx.SCHED_PRIN_AMT,SPEED_PREPMT_1_MTH_AMT=c_inx.SPEED_PREPMT_1_MTH_AMT,LOSS_TOTAL_AMT=c_inx.LOSS_TOTAL_AMT,SURETY_FEE_AMT=c_inx.SURETY_FEE_AMT,INT_FROM_OTHER_GROUP_AMT=c_inx.INT_FROM_OTHER_GROUP_AMT,PRIN_FROM_OTHER_GROUP_AMT=c_inx.PRIN_FROM_OTHER_GROUP_AMT,SENIOR_FIXED_RATE_BOND_BAL=c_inx.SENIOR_FIXED_RATE_BOND_BAL,SENIOR_FLOAT_RATE_BOND_BAL=c_inx.SENIOR_FLOAT_RATE_BOND_BAL,SUBORDINATE_RATE_BOND_BAL=c_inx.SUBORDINATE_RATE_BOND_BAL,IO_NOTIONAL_BAL=c_inx.IO_NOTIONAL_BAL,NON_IO_FIXED_INT_PAID_AMT=c_inx.NON_IO_FIXED_INT_PAID_AMT,NON_IO_FLOAT_INT_PAID_AMT=c_inx.NON_IO_FLOAT_INT_PAID_AMT,IO_INT_PAID_AMT=c_inx.IO_INT_PAID_AMT,TOTAL_PRIN_AMT=c_inx.TOTAL_PRIN_AMT,BOND_WRITE_DOWNS_AMT=c_inx.BOND_WRITE_DOWNS_AMT,SURETY_PMTS_AMT=c_inx.SURETY_PMTS_AMT,OC_BAL=c_inx.OC_BAL,OC_TARGET_BAL=c_inx.OC_TARGET_BAL,RESIDUAL_INT_AMT=c_inx.RESIDUAL_INT_AMT,RESIDUAL_PRIN_AMT=c_inx.RESIDUAL_PRIN_AMT,RESIDUAL_TOTAL_AMT=c_inx.RESIDUAL_TOTAL_AMT , CHG_LST_DATE=c_inx.CHG_LST_DATE , CHG_LST_USER_ID=c_inx.CHG_LST_USER_ID , CHG_LST_PROG_NAME=c_inx.CHG_LST_PROG_NAME WHERE VALUATION_YR_MTH_NBR=c_inx.VALUATION_YR_MTH_NBR AND PMT_PRD_NBR=c_inx.PMT_PRD_NBR AND SERIES_NAME=c_inx.SERIES_NAME AND GROUP_NAME=c_inx.GROUP_NAME AND FNC_PROD_NAME=c_inx.FNC_PROD_NAME AND SCENARIO_ABBR=c_inx.SCENARIO_ABBR; END LOOP; END;That block should run the same from ODP.NET as from SQLPlus. Which is very slowly. You shouldn't be using a cursor here. Instead try an updatable join, or better MERGE (for 9i).
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems30.htm#37586
David -
How can I generate AVI with this code?
Here is the code which I got
import java.io.*;
import java.util.*;
import java.awt.Dimension;
import javax.media.*;
import javax.media.control.*;
import javax.media.protocol.*;
import javax.media.protocol.DataSource;
import javax.media.datasink.*;
import javax.media.format.VideoFormat;
* This program takes a list of JPEG image files and convert them into
* a QuickTime movie.
public class JpegImagesToMovie implements ControllerListener, DataSinkListener {
public boolean doIt(int width, int height, int frameRate, Vector inFiles, MediaLocator outML) {
ImageDataSource ids = new ImageDataSource(width, height, frameRate, inFiles);
Processor p;
try {
System.err.println("- create processor for the image datasource ...");
p = Manager.createProcessor(ids);
} catch (Exception e) {
System.err.println("Yikes! Cannot create a processor from the data source.");
return false;
p.addControllerListener(this);
// Put the Processor into configured state so we can set
// some processing options on the processor.
p.configure();
if (!waitForState(p, p.Configured)) {
System.err.println("Failed to configure the processor.");
return false;
// Set the output content descriptor to QuickTime.
p.setContentDescriptor(new ContentDescriptor(FileTypeDescriptor.MSVIDEO));
// Query for the processor for supported formats.
// Then set it on the processor.
TrackControl tcs[] = p.getTrackControls();
Format f[] = tcs[0].getSupportedFormats();
if (f == null || f.length <= 0) {
System.err.println("The mux does not support the input format: " + tcs[0].getFormat());
return false;
tcs[0].setFormat(f[0]);
System.err.println("Setting the track format to: " + f[0]);
// We are done with programming the processor. Let's just
// realize it.
p.realize();
if (!waitForState(p, p.Realized)) {
System.err.println("Failed to realize the processor.");
return false;
// Now, we'll need to create a DataSink.
DataSink dsink;
if ((dsink = createDataSink(p, outML)) == null) {
System.err.println("Failed to create a DataSink for the given output MediaLocator: " + outML);
return false;
dsink.addDataSinkListener(this);
fileDone = false;
System.err.println("start processing...");
// OK, we can now start the actual transcoding.
try {
p.start();
dsink.start();
} catch (IOException e) {
System.err.println("IO error during processing");
return false;
// Wait for EndOfStream event.
waitForFileDone();
// Cleanup.
try {
dsink.close();
} catch (Exception e) {}
p.removeControllerListener(this);
System.err.println("...done processing.");
return true;
* Create the DataSink.
DataSink createDataSink(Processor p, MediaLocator outML) {
DataSource ds;
if ((ds = p.getDataOutput()) == null) {
System.err.println("Something is really wrong: the processor does not have an output DataSource");
return null;
DataSink dsink;
try {
System.err.println("- create DataSink for: " + outML);
dsink = Manager.createDataSink(ds, outML);
dsink.open();
} catch (Exception e) {
System.err.println("Cannot create the DataSink: " + e);
return null;
return dsink;
Object waitSync = new Object();
boolean stateTransitionOK = true;
* Block until the processor has transitioned to the given state.
* Return false if the transition failed.
boolean waitForState(Processor p, int state) {
synchronized (waitSync) {
try {
while (p.getState() < state && stateTransitionOK)
waitSync.wait();
} catch (Exception e) {}
return stateTransitionOK;
* Controller Listener.
public void controllerUpdate(ControllerEvent evt) {
if (evt instanceof ConfigureCompleteEvent ||
evt instanceof RealizeCompleteEvent ||
evt instanceof PrefetchCompleteEvent) {
synchronized (waitSync) {
stateTransitionOK = true;
waitSync.notifyAll();
} else if (evt instanceof ResourceUnavailableEvent) {
synchronized (waitSync) {
stateTransitionOK = false;
waitSync.notifyAll();
} else if (evt instanceof EndOfMediaEvent) {
evt.getSourceController().stop();
evt.getSourceController().close();
Object waitFileSync = new Object();
boolean fileDone = false;
boolean fileSuccess = true;
* Block until file writing is done.
boolean waitForFileDone() {
synchronized (waitFileSync) {
try {
while (!fileDone)
waitFileSync.wait();
} catch (Exception e) {}
return fileSuccess;
* Event handler for the file writer.
public void dataSinkUpdate(DataSinkEvent evt) {
if (evt instanceof EndOfStreamEvent) {
synchronized (waitFileSync) {
fileDone = true;
waitFileSync.notifyAll();
} else if (evt instanceof DataSinkErrorEvent) {
synchronized (waitFileSync) {
fileDone = true;
fileSuccess = false;
waitFileSync.notifyAll();
public static void main(String args[]) {
if (args.length == 0)
prUsage();
// Parse the arguments.
int i = 0;
int width = -1, height = -1, frameRate = 1;
Vector inputFiles = new Vector();
String outputURL = null;
while (i < args.length) {
if (args.equals("-w")) {
i++;
if (i >= args.length)
prUsage();
width = new Integer(args[i]).intValue();
} else if (args[i].equals("-h")) {
i++;
if (i >= args.length)
prUsage();
height = new Integer(args[i]).intValue();
} else if (args[i].equals("-f")) {
i++;
if (i >= args.length)
prUsage();
frameRate = new Integer(args[i]).intValue();
} else if (args[i].equals("-o")) {
i++;
if (i >= args.length)
prUsage();
outputURL = args[i];
} else {
inputFiles.addElement(args[i]);
i++;
if (outputURL == null || inputFiles.size() == 0)
prUsage();
// Check for output file extension.
if (!outputURL.endsWith(".avi") && !outputURL.endsWith(".AVI")) {
System.err.println("The output file extension should end with a .avi extension");
prUsage();
if (width < 0 || height < 0) {
System.err.println("Please specify the correct image size.");
prUsage();
// Check the frame rate.
if (frameRate < 1)
frameRate = 1;
// Generate the output media locators.
MediaLocator oml;
if ((oml = createMediaLocator(outputURL)) == null) {
System.err.println("Cannot build media locator from: " + outputURL);
System.exit(0);
JpegImagesToMovie imageToMovie = new JpegImagesToMovie();
imageToMovie.doIt(width, height, frameRate, inputFiles, oml);
System.exit(0);
static void prUsage() {
System.err.println("Usage: java JpegImagesToMovie -w <width> -h <height> -f <frame rate> -o <output URL> <input JPEG file 1> <input JPEG file 2> ...");
System.exit(-1);
* Create a media locator from the given string.
static MediaLocator createMediaLocator(String url) {
MediaLocator ml;
if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null)
return ml;
if (url.startsWith(File.separator)) {
if ((ml = new MediaLocator("file:" + url)) != null)
return ml;
} else {
String file = "file:" + System.getProperty("user.dir") + File.separator + url;
if ((ml = new MediaLocator(file)) != null)
return ml;
return null;
// Inner classes.
* A DataSource to read from a list of JPEG image files and
* turn that into a stream of JMF buffers.
* The DataSource is not seekable or positionable.
class ImageDataSource extends PullBufferDataSource {
ImageSourceStream streams[];
ImageDataSource(int width, int height, int frameRate, Vector images) {
streams = new ImageSourceStream[1];
streams[0] = new ImageSourceStream(width, height, frameRate, images);
public void setLocator(MediaLocator source) {
public MediaLocator getLocator() {
return null;
* Content type is of RAW since we are sending buffers of video
* frames without a container format.
public String getContentType() {
return ContentDescriptor.RAW;
public void connect() {
public void disconnect() {
public void start() {
public void stop() {
* Return the ImageSourceStreams.
public PullBufferStream[] getStreams() {
return streams;
* We could have derived the duration from the number of
* frames and frame rate. But for the purpose of this program,
* it's not necessary.
public Time getDuration() {
return DURATION_UNKNOWN;
public Object[] getControls() {
return new Object[0];
public Object getControl(String type) {
return null;
* The source stream to go along with ImageDataSource.
class ImageSourceStream implements PullBufferStream {
Vector images;
int width, height;
VideoFormat format;
int nextImage = 0; // index of the next image to be read.
boolean ended = false;
public ImageSourceStream(int width, int height, int frameRate, Vector images) {
this.width = width;
this.height = height;
this.images = images;
format = new VideoFormat(VideoFormat.JPEG,
new Dimension(width, height),
Format.NOT_SPECIFIED,
Format.byteArray,
(float)frameRate);
* We should never need to block assuming data are read from files.
public boolean willReadBlock() {
return false;
* This is called from the Processor to read a frame worth
* of video data.
public void read(Buffer buf) throws IOException {
// Check if we've finished all the frames.
if (nextImage >= images.size()) {
// We are done. Set EndOfMedia.
System.err.println("Done reading all images.");
buf.setEOM(true);
buf.setOffset(0);
buf.setLength(0);
ended = true;
return;
String imageFile = (String)images.elementAt(nextImage);
nextImage++;
System.err.println(" - reading image file: " + imageFile);
// Open a random access file for the next image.
RandomAccessFile raFile;
raFile = new RandomAccessFile(imageFile, "r");
byte data[] = null;
// Check the input buffer type & size.
if (buf.getData() instanceof byte[])
data = (byte[])buf.getData();
// Check to see the given buffer is big enough for the frame.
if (data == null || data.length < raFile.length()) {
data = new byte[(int)raFile.length()];
buf.setData(data);
// Read the entire JPEG image from the file.
raFile.readFully(data, 0, (int)raFile.length());
System.err.println(" read " + raFile.length() + " bytes.");
buf.setOffset(0);
buf.setLength((int)raFile.length());
buf.setFormat(format);
buf.setFlags(buf.getFlags() | buf.FLAG_KEY_FRAME);
// Close the random access file.
raFile.close();
* Return the format of each video frame. That will be JPEG.
public Format getFormat() {
return format;
public ContentDescriptor getContentDescriptor() {
return new ContentDescriptor(ContentDescriptor.RAW);
public long getContentLength() {
return 0;
public boolean endOfStream() {
return ended;
public Object[] getControls() {
return new Object[0];
public Object getControl(String type) {
return null;
when I execute this file then no error comes but the output file do not get played on any player?
where is the error?here is the code with QUICKTIME
* @(#)JpegImagesToMovie.java 1.3 01/03/13
* Copyright (c) 1999-2001 Sun Microsystems, Inc. All Rights Reserved.
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
* modify and redistribute this software in source and binary code form,
* provided that i) this copyright notice and license appear on all copies of
* the software; and ii) Licensee does not utilize the software in a manner
* which is disparaging to Sun.
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
* This software is not designed or intended for use in on-line control of
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
* the design, construction, operation or maintenance of any nuclear
* facility. Licensee represents and warrants that it will not use or
* redistribute the Software for such purposes.
import java.io.*;
import java.util.*;
import java.awt.Dimension;
import javax.media.*;
import javax.media.control.*;
import javax.media.protocol.*;
import javax.media.protocol.DataSource;
import javax.media.datasink.*;
import javax.media.format.VideoFormat;
* This program takes a list of JPEG image files and convert them into
* a QuickTime movie.
public class JpegImagesToMovie implements ControllerListener, DataSinkListener {
public boolean doIt(int width, int height, int frameRate, Vector inFiles, MediaLocator outML) {
ImageDataSource ids = new ImageDataSource(width, height, frameRate, inFiles);
Processor p;
try {
System.err.println("- create processor for the image datasource ...");
p = Manager.createProcessor(ids);
} catch (Exception e) {
System.err.println("Yikes! Cannot create a processor from the data source.");
return false;
p.addControllerListener(this);
// Put the Processor into configured state so we can set
// some processing options on the processor.
p.configure();
if (!waitForState(p, p.Configured)) {
System.err.println("Failed to configure the processor.");
return false;
// Set the output content descriptor to QuickTime.
p.setContentDescriptor(new ContentDescriptor(FileTypeDescriptor.QUICKTIME));
// Query for the processor for supported formats.
// Then set it on the processor.
TrackControl tcs[] = p.getTrackControls();
Format f[] = tcs[0].getSupportedFormats();
if (f == null || f.length <= 0) {
System.err.println("The mux does not support the input format: " + tcs[0].getFormat());
return false;
tcs[0].setFormat(f[0]);
System.err.println("Setting the track format to: " + f[0]);
// We are done with programming the processor. Let's just
// realize it.
p.realize();
if (!waitForState(p, p.Realized)) {
System.err.println("Failed to realize the processor.");
return false;
// Now, we'll need to create a DataSink.
DataSink dsink;
if ((dsink = createDataSink(p, outML)) == null) {
System.err.println("Failed to create a DataSink for the given output MediaLocator: " + outML);
return false;
dsink.addDataSinkListener(this);
fileDone = false;
System.err.println("start processing...");
// OK, we can now start the actual transcoding.
try {
p.start();
dsink.start();
} catch (IOException e) {
System.err.println("IO error during processing");
return false;
// Wait for EndOfStream event.
waitForFileDone();
// Cleanup.
try {
dsink.close();
} catch (Exception e) {}
p.removeControllerListener(this);
System.err.println("...done processing.");
return true;
* Create the DataSink.
DataSink createDataSink(Processor p, MediaLocator outML) {
DataSource ds;
if ((ds = p.getDataOutput()) == null) {
System.err.println("Something is really wrong: the processor does not have an output DataSource");
return null;
DataSink dsink;
try {
System.err.println("- create DataSink for: " + outML);
dsink = Manager.createDataSink(ds, outML);
dsink.open();
} catch (Exception e) {
System.err.println("Cannot create the DataSink: " + e);
return null;
return dsink;
Object waitSync = new Object();
boolean stateTransitionOK = true;
* Block until the processor has transitioned to the given state.
* Return false if the transition failed.
boolean waitForState(Processor p, int state) {
synchronized (waitSync) {
try {
while (p.getState() < state && stateTransitionOK)
waitSync.wait();
} catch (Exception e) {}
return stateTransitionOK;
* Controller Listener.
public void controllerUpdate(ControllerEvent evt) {
if (evt instanceof ConfigureCompleteEvent ||
evt instanceof RealizeCompleteEvent ||
evt instanceof PrefetchCompleteEvent) {
synchronized (waitSync) {
stateTransitionOK = true;
waitSync.notifyAll();
} else if (evt instanceof ResourceUnavailableEvent) {
synchronized (waitSync) {
stateTransitionOK = false;
waitSync.notifyAll();
} else if (evt instanceof EndOfMediaEvent) {
evt.getSourceController().stop();
evt.getSourceController().close();
Object waitFileSync = new Object();
boolean fileDone = false;
boolean fileSuccess = true;
* Block until file writing is done.
boolean waitForFileDone() {
synchronized (waitFileSync) {
try {
while (!fileDone)
waitFileSync.wait();
} catch (Exception e) {}
return fileSuccess;
* Event handler for the file writer.
public void dataSinkUpdate(DataSinkEvent evt) {
if (evt instanceof EndOfStreamEvent) {
synchronized (waitFileSync) {
fileDone = true;
waitFileSync.notifyAll();
} else if (evt instanceof DataSinkErrorEvent) {
synchronized (waitFileSync) {
fileDone = true;
fileSuccess = false;
waitFileSync.notifyAll();
public static void main(String args[]) {
if (args.length == 0)
prUsage();
// Parse the arguments.
int i = 0;
int width = -1, height = -1, frameRate = 1;
Vector inputFiles = new Vector();
String outputURL = null;
while (i < args.length) {
if (args.equals("-w")) {
i++;
if (i >= args.length)
prUsage();
width = new Integer(args[i]).intValue();
} else if (args[i].equals("-h")) {
i++;
if (i >= args.length)
prUsage();
height = new Integer(args[i]).intValue();
} else if (args[i].equals("-f")) {
i++;
if (i >= args.length)
prUsage();
frameRate = new Integer(args[i]).intValue();
} else if (args[i].equals("-o")) {
i++;
if (i >= args.length)
prUsage();
outputURL = args[i];
} else {
inputFiles.addElement(args[i]);
i++;
if (outputURL == null || inputFiles.size() == 0)
prUsage();
// Check for output file extension.
if (!outputURL.endsWith(".mov") && !outputURL.endsWith(".MOV")) {
System.err.println("The output file extension should end with a .mov extension");
prUsage();
if (width < 0 || height < 0) {
System.err.println("Please specify the correct image size.");
prUsage();
// Check the frame rate.
if (frameRate < 1)
frameRate = 1;
// Generate the output media locators.
MediaLocator oml;
if ((oml = createMediaLocator(outputURL)) == null) {
System.err.println("Cannot build media locator from: " + outputURL);
System.exit(0);
JpegImagesToMovie imageToMovie = new JpegImagesToMovie();
imageToMovie.doIt(width, height, frameRate, inputFiles, oml);
System.exit(0);
static void prUsage() {
System.err.println("Usage: java JpegImagesToMovie -w <width> -h <height> -f <frame rate> -o <output URL> <input JPEG file 1> <input JPEG file 2> ...");
System.exit(-1);
* Create a media locator from the given string.
static MediaLocator createMediaLocator(String url) {
MediaLocator ml;
if (url.indexOf(":") > 0 && (ml = new MediaLocator(url)) != null)
return ml;
if (url.startsWith(File.separator)) {
if ((ml = new MediaLocator("file:" + url)) != null)
return ml;
} else {
String file = "file:" + System.getProperty("user.dir") + File.separator + url;
if ((ml = new MediaLocator(file)) != null)
return ml;
return null;
// Inner classes.
* A DataSource to read from a list of JPEG image files and
* turn that into a stream of JMF buffers.
* The DataSource is not seekable or positionable.
class ImageDataSource extends PullBufferDataSource {
ImageSourceStream streams[];
ImageDataSource(int width, int height, int frameRate, Vector images) {
streams = new ImageSourceStream[1];
streams[0] = new ImageSourceStream(width, height, frameRate, images);
public void setLocator(MediaLocator source) {
public MediaLocator getLocator() {
return null;
* Content type is of RAW since we are sending buffers of video
* frames without a container format.
public String getContentType() {
return ContentDescriptor.RAW;
public void connect() {
public void disconnect() {
public void start() {
public void stop() {
* Return the ImageSourceStreams.
public PullBufferStream[] getStreams() {
return streams;
* We could have derived the duration from the number of
* frames and frame rate. But for the purpose of this program,
* it's not necessary.
public Time getDuration() {
return DURATION_UNKNOWN;
public Object[] getControls() {
return new Object[0];
public Object getControl(String type) {
return null;
* The source stream to go along with ImageDataSource.
class ImageSourceStream implements PullBufferStream {
Vector images;
int width, height;
VideoFormat format;
int nextImage = 0; // index of the next image to be read.
boolean ended = false;
public ImageSourceStream(int width, int height, int frameRate, Vector images) {
this.width = width;
this.height = height;
this.images = images;
format = new VideoFormat(VideoFormat.JPEG,
new Dimension(width, height),
Format.NOT_SPECIFIED,
Format.byteArray,
(float)frameRate);
* We should never need to block assuming data are read from files.
public boolean willReadBlock() {
return false;
* This is called from the Processor to read a frame worth
* of video data.
public void read(Buffer buf) throws IOException {
// Check if we've finished all the frames.
if (nextImage >= images.size()) {
// We are done. Set EndOfMedia.
System.err.println("Done reading all images.");
buf.setEOM(true);
buf.setOffset(0);
buf.setLength(0);
ended = true;
return;
String imageFile = (String)images.elementAt(nextImage);
nextImage++;
System.err.println(" - reading image file: " + imageFile);
// Open a random access file for the next image.
RandomAccessFile raFile;
raFile = new RandomAccessFile(imageFile, "r");
byte data[] = null;
// Check the input buffer type & size.
if (buf.getData() instanceof byte[])
data = (byte[])buf.getData();
// Check to see the given buffer is big enough for the frame.
if (data == null || data.length < raFile.length()) {
data = new byte[(int)raFile.length()];
buf.setData(data);
// Read the entire JPEG image from the file.
raFile.readFully(data, 0, (int)raFile.length());
System.err.println(" read " + raFile.length() + " bytes.");
buf.setOffset(0);
buf.setLength((int)raFile.length());
buf.setFormat(format);
buf.setFlags(buf.getFlags() | buf.FLAG_KEY_FRAME);
// Close the random access file.
raFile.close();
* Return the format of each video frame. That will be JPEG.
public Format getFormat() {
return format;
public ContentDescriptor getContentDescriptor() {
return new ContentDescriptor(ContentDescriptor.RAW);
public long getContentLength() {
return 0;
public boolean endOfStream() {
return ended;
public Object[] getControls() {
return new Object[0];
public Object getControl(String type) {
return null;
and here is the output
C:\>java JpegImagesToMovie -w 1024 -h 768 -f 1 -o out.mov file:/c:/images/5.jpg file:/c:/images/6.jp
g
- create processor for the image datasource ...
Setting the track format to: JPEG
- create DataSink for: file:C:\\out.mov
start processing...
- reading image file: file:/c:/images/5.jpg
- reading image file: file:/c:/images/6.jpg
Done reading all images.
Exception in thread "JMF thread: SendEventQueue: com.sun.media.processor.unknown.Handler" java.lang.
NullPointerException
at com.sun.media.multiplexer.video.QuicktimeMux.writeVideoSampleDescription(QuicktimeMux.jav
a:936)
at com.sun.media.multiplexer.video.QuicktimeMux.writeSTSD(QuicktimeMux.java:925)
at com.sun.media.multiplexer.video.QuicktimeMux.writeSTBL(QuicktimeMux.java:905)
at com.sun.media.multiplexer.video.QuicktimeMux.writeMINF(QuicktimeMux.java:806)
at com.sun.media.multiplexer.video.QuicktimeMux.writeMDIA(QuicktimeMux.java:727)
at com.sun.media.multiplexer.video.QuicktimeMux.writeTRAK(QuicktimeMux.java:644)
at com.sun.media.multiplexer.video.QuicktimeMux.writeMOOV(QuicktimeMux.java:582)
at com.sun.media.multiplexer.video.QuicktimeMux.writeFooter(QuicktimeMux.java:519)
at com.sun.media.multiplexer.BasicMux.close(BasicMux.java:142)
at com.sun.media.BasicMuxModule.doClose(BasicMuxModule.java:172)
at com.sun.media.PlaybackEngine.doClose(PlaybackEngine.java:872)
at com.sun.media.BasicController.close(BasicController.java:261)
at com.sun.media.BasicPlayer.doClose(BasicPlayer.java:229)
at com.sun.media.BasicController.close(BasicController.java:261)
at JpegImagesToMovie.controllerUpdate(JpegImagesToMovie.java:196)
at com.sun.media.BasicController.dispatchEvent(BasicController.java:1254)
at com.sun.media.SendEventQueue.processEvent(BasicController.java:1286)
at com.sun.media.util.ThreadedEventQueue.dispatchEvents(ThreadedEventQueue.java:65)
at com.sun.media.util.ThreadedEventQueue.run(ThreadedEventQueue.java:92) -
How to use JDK5.0 new feature code in tomcat 5.5.9, jsp files
Hi Everyone:
I am trying to use JDK5.0 new feature code -- for loop in jsp file , but got compile error , i try the same code in the java file which is working fine. i am wondering is it tomcat jsp compiler problem ?
following is my code and error msg
/* jdk 5.0 new feature, but cannot use in this jsp file, tomcat version? or setting problem ?
for (Thumbnail thumbnail : thumbnailList){
System.out.println(thumbnail.getAbsolutePath());
// following is working fine in jsp
Iterator iter = thumbnailList.iterator();
while(iter.hasNext()){
Thumbnail thumbnail = (Thumbnail) iter.next();
out.print(thumbnail.getAbsolutePath()+"<BR>");
%>
the error msg is :
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 16 in the jsp file: /test/testImageGallery.jsp
Generated servlet error:
Syntax error on token(s), misplaced construct(s)
An error occurred at line: 16 in the jsp file: /test/testImageGallery.jsp
Generated servlet error:
Syntax error on token ")", : expected
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
I am using fedora core 4 x64bit , tomcat 5.5.9,
java -version
java version "1.5.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_04-b05, mixed mode)
tomcat settings
tomcat5/bin/catalina.sh run
Using CATALINA_BASE: /home/normal/tomcat5
Using CATALINA_HOME: /home/normal/tomcat5
Using CATALINA_TMPDIR: /home/normal/tomcat5/temp
Using JRE_HOME: /home/normal/jdk1.5.0_04The JDT compiler that Tomcat installs by default is only 1.4 compliant.
You can use ant instead:
remove the common/lib/jasper-compiler-jdt.jar file
place ant.jar file from the latest Ant distribution in the common/lib folder.
If you do this, you also need to use the "javac" argument to catalina.sh.
Documentation reference: http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jasper-howto.html -
How to Use Exec function in Java Code
How to Use Exec method
I want to Execute command
net Start "some service"
using exec method of runtime class
or i use some other way if suggestAssuming you have read http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html#exec(java.lang.String) already, I can only suggest to be more specific in what your problems are. If you are after just some example code, then download ftp://ftp.ebi.ac.uk/pub/software/textmining/monq/monq.tar.gz and have a look at the source code of monq.stuff.Exec. It does all those things which are necessary to keep track of a Process after it was created with exec.
Harald.
BioMed Information Extraction: http://www.ebi.ac.uk/Rebholz-srv/whatizit
Maybe you are looking for
-
How can i find my stoled man book ???
my mac book ware stoled from mycar yestrday and( find my mac) is already installed but i dont know the apple id or i cloud id but i have the serial no. is there is any way to track my mac and rerurn it back ? important
-
DW preview shows default font? [subject edited by moderator]
Hi, I've just downloaded and started using Dreamweaver CC, but the preview doesn't show the Google Font in the mark-up? It shows the default font (Times New Roman) instead
-
How can i calculate the average in java
how can i calculate the avergae mark out of two marks for instance in like exam mark out of two other ones thanks for considering this message
-
VAT Number link to Customer tax clasification
Dear All, Give your some inputs on VAT number and Customer tax classifications for MWST determination in sales order, Please check sales orders in scenrio's 1. VAT number not given in customer master in general data - Sold to party. SON - 1 where MW
-
"Wireless connectivity is off" U310 - Windows 8.1
So, I've just installed Windows 8.1, and all drivers needed, but I can't see any wireless networks (it says Off under Wi-Fi tab, and there's no way turning it on). Tried enabling/disabling device, reinstalling drivers, and F7 key but it only turns ai