Trasanction Codes used in Sales & Marketing Modules
Hi All,
Please provide important Transaction codes (T Codes) that is been using in Sales & Marketing modules for solving the
Support It Ticket for CRM.
Please let me know which are the area's that are using into.
eg: Sa38 is ABAP reporting
Sm37 : background jobs.
Please do reply so that i would be helpful for me,
Thanks in advance
Prajith P
Hi Prajith
Hope the below transaction codes in CRM will be helpful.
Transaction Code - Description
SE19 Badi implementation
SE93 Transaction code check
smw01 workflow
Crm_Erms_mailforms Forms
SWDD ERMS Rule modler workflow
SE 18 BADi creation
SE19 Badi implementation
se11 tables
SE38 Functional module reports/fields display
se11 crmd_orderadm_h
SE16 TC
TSTC
SE93 Application Component - get there displayed all transaction codes for example crm-md-bp
CRMD_ORDER - creating marketing sales and service transactions
BP - BP
CRM_MKTPL FOR search campaigns deals
sost-transmissionRequest forms
scot -administration system status
CRM_UI_FRAME: Access BSP WD work bench
BP -Business Partner (Creation/View/Modification)
CIC0 -Customer Interaction Centre
CRMD_ORDER - CRM Transaction (Create/View/Modify)
SPRO - Configuration related settings
CRMD_CALL_LIST-Create/ Maintain Call list
IB51 / IB52 / IB53-Ibase Creation / Change / View
COMMPR01-Maintain Products
PPOSA_CRM-Display Organizational Model
SBDM-Bdoc maintenance
SMOEAC- Administration console u2013 CRM Middleware
SMQ1,SMQ2 Queue monitoring transactions for inbound and outbound queues.
SMW01 Transaction for monitoring bdocs.
MIddleware t-code
Transactions Transaction Codes
Work process overview SM66
CPU and memory consumption ST06
SAP memory and buffers ST02
Database performance counters ST04
Memory consumption per user SM04 (on each application server)
Table call statistics ST10
CPU & Memory Consumption on IPC Server OS07
CRM Inbound Queue SMQ2
CRM Outbound Queue SMQ
Monitor Load R3AM1
Define Request R3AR2
Run Request R3AR4
Request Business Partner CRMM_BUPA_MAP
Send Business Partner CRMM_BUPA_SEND
RFC statistics (client and server) ST03
Errors in transactional RFCs SM58
BDOC Statistics SMWMFLOW
Response time statistics ST03 & STAD
Error Tracking SMWP
Q-Out Scheduler SMQS
Q-In Scheduler SMQR
Bdoc Error Tracking SMW01 & SMW02
Short Dumps ST22
Admin Console SMOEAC
Process Overview SM50
User List AL08
Data Integrity Manager SDIMA
Similar Messages
-
Transaction code to create a text module and import graphics
Hello everybody
Can anybody tell me the transaction codes used to create text module and import graphicsHi,
use rstxldmc or se78 for graphics uploading and SO10
Reward points if found helpful....
Cheers,
Chandra Sekhar. -
Writing customer code in SALES ORDER MODULE using UI API.
Hi Experts,
I have a problem in writing a data in Sales Order fields...
here's the scenario
after i select the business partner code in my UI i want it to write the customer code in customer textbox of the Sales Order module.
but after i write the error appears.
error: {"Item - Can't set value on item because the item can't get focus. [66000-153]"}
Please help me in this problem.
thanks,
Edited by: Joey Bryan Dante on Aug 26, 2011 7:38 AMDim oItem As SAPbouiCOM.Item
Dim oItems As SAPbouiCOM.Items = oForm.Items
oItem = oItems.Item("3")
Dim oEdit As SAPbouiCOM.EditText
oEdit = oItem.Specific
oEdit.Value = oCardCode
this is my code.
thanks, -
Which t code use before pre sale order
gud morng to all
pls tell me. which t. code use before pre sale order (va21) and why this function use and how
regards,
gaurav pabrejaT.Code: VA11
to create Inquiry
The document flow is
IN > QT > OR > LF > F2
The Inquiry is done in order to get to know the price that the customer is going to get. It can be done over the phone, e-mail or a walk-in.
Regards
AK
reward points if helpful -
BP Master Window, Sales Emp Code used to display Sales Empl Name now displ
BP Master Window, Sales Emp Code used to display Sales Empl Name now displays Sales Emp Code
Our customer has noticed that when they do a search in the BP Master window that one of the
columns that is displayed called the Sales Emplyoyee code s not bringing up the Sales Employee Name
as it once was...
I have checked my local version and in the sales employee code column the name of the sales
employee is displayed NOT the code.
sales employee code column is displaying the code number where once it displayed the name and
even in the play system and in our local version it is displaying the name
as above
Nothing has changed on the system. We have not done any upgrades.
I have checked in SAP notes and could not find any information
Thanks for your help in advance
DHi
There is no option for Sales Employee Name.
However on my system if i select Sales Employee Code it actually shows me the Sales Employee Name.
Which is what my customer orginally had .
For my customer it is now showing Sales Employee Code as Sales Employee Code
However it was previously showing Sales Employee Code and giving a Sales Employee Name instead.
They need the Sales Employee Name not Code
Thanks
D -
How to find company code using sales doc. No
Hi,
I need to print company code, how to find company code using sales doc no. I don't find it VBAK.
Cheers
SenthilDear Senthil
You can find in table VBAK itself - Field BUKRS_VF
thanks
G. Lakshmipathi -
How to know what are the T Codes used by client in SAP HR module in qualit
hi experts,
i have a access of quality server given by my client in SAP HR.I dont know what are the Tcodes used by client.So how i can know what are the Tcodes client is using frequently.i have to list out all TCodes urgently.
PLZ reply ASAP.
Thanx in advance..Hi
You can do this by going to SUIM-Transactions-Executable for User
Then give the user name/id as in user master record and execute. Now the system will display the list of transaction codes used by that particular user.
Regards
Santhosh.S -
Data Transfer Workbench can copy sales & purchase modules's data?
Hi,
Just wondering that,any way to copy the Sales & Purchase Modules's data from existing company to new company? Copy Express can't do it. But how about Data Transfer Workbench can copy?
Thanks
Regards,
Danny
Edited by: Danny Gan on Mar 18, 2008 5:21 AMDanny,
How many field from the ORDR or RDR1 have to exported depends on the business logic implemented and what was being used. No one can really provide a standard set of 5 or 10 fields as you know the clients business better than anyone in the Forum.
If the Client used User fields then data from the user fields should also be exported.
The base fields from ORDR would be CardCode, DocDate, DocDueDate, Transpcode (shipping code), SlpCode, GroupNum (Payment terms code), etc.
Similarly on RDR1, ItemCode, Quantity, Price and any additional row level information that may pertain to their business
Suda -
HR Master Data Use for other SAP Modules?
Which part of SAP HR Master Data can be used by various SAP modules including PP, SD, MM, PS, FI, etc?
Expecting expert input!Which part of SAP HR Master Data can be used by various SAP modules including PP, SD, MM, PS, FI, etc?
Expecting expert input!
Hi
The following may be useful try this out
PP try this tcode and surf on HRMS-CR02 there u can bring the pernr to workcentre
SD Try T Code VPE1 and u can assign the sales personnel using pernr
MM Try T Code XK01 Create employee as vendor and u can use it for Vendor consignment goods via MSK3
FI In fi u can create vendor like mm using FK01 for bulk amount distribution
Hope it helps
with regards
partha -
Process code used for DELFOR inbound idoc
I have to create one interface in that i have to capture the transfer orders from that i have create the DELFOR idoc which used for posting the scheduling agreements.
These agreements will pos teh requirement to the forecast tab.
Please let me know the process code used for this inbound DELFOR idoc.
Regards,
UdayHi Uday,
Firstly: Yes. Delins function module can be used for Delfor. Either case you will make the sytem update the forecast tab of scheduling agreement.
Secondly: Make sure you have one valid sales scheduling agreement maintained for that sold to, customer-material, ship to partner description.
Let me know if you have further concerns;
Regards,
Syed Nasir -
Hi Experts ,
I m working Marketing module, I need all the tables which are useful in Marketing planning, segemnt builder,campaign,lead.
please provide the tables,it is very urgent requirement.
please send the tables to nelakurtir @techmahindra.com
thanks and regards
nelakurtiHi Koti,
Here is:
CNCCRMPRCUSZZBUR Condition Records for Service Contracts. We get Basic Unit Rate, Standing Charge Rate etc.
(This is a Z table used in a leading ISU SAP-CRM implementation. You can give the table SAP0090 this is a standard table. in general all condition tables have the naming convention CNCC*)
CRMD_ORDERADM_H Contains the Header Information for a Business Transaction.
Note:
1. It doesnt store the Business Partner
responsible for the transaction. To
get the Partner No, link it with
CRM_ORDER_INDEX.
2. This table can be used for search
based on the Object Id(Business
Transaction No).
CRMD_CUSTOMER_H Additional Site Details at the Header Level of a Business Transaction
CRMC_PROC_TYPE Master table Business Transaction Type
CRMC_PARTNER_FCT Definition of Partner Functions
SCPRIOT Priorities for Activities with priority text.
Note:
Pass the langu key with the
language in which you want the
text.
CRMC_PROC_TYPE_T Text for a transaction type
CRMC_ACT_OBJ_T Objective Number and Text for Activities
TJ30T All the status code and text
CRMC_PR_ASSIGN Transaction Type and its Transaction Type Object.
IBIB Installed Base/Ibase
IBIN Installed Base Components
Regrards,
Arjun
<b>Reward points if it helps</b> -
Help with SE37 code needed - create sales order
Hi Guurus,
Can you please help? I finally finished with function creation (I just adopted the function, which I found in the system and it works ok, YEAH!!!)
BUT!!! It is working just for the sales order creation with one item.
Is it a big deal if you adopt my code that the function will have possibility to add more then one item?
Thanks in advance
Sao
Here is the code:
*FUNCTION Z_RFC_SD_SIMO_SALES_ORDER2.
*""Local interface:
**" IMPORTING
**" VALUE(P_AUART) TYPE AUART DEFAULT 'zhp'
**" VALUE(P_VKORG) TYPE VKORG DEFAULT 0001
**" VALUE(P_VTWEG) TYPE VTWEG DEFAULT 07
**" VALUE(P_SPART) TYPE SPART DEFAULT 01
**" VALUE(P_AUGRU) TYPE AUGRU DEFAULT 001
**" VALUE(P_BSTKD) TYPE BSTKD DEFAULT 'test si order avtom'
**" VALUE(P_SOLD) TYPE KUNNR DEFAULT 21000069
**" VALUE(P_SHIP) TYPE KUNNR DEFAULT 21000069
**" VALUE(P_MATNR) TYPE MATNR DEFAULT 'SIOBRACUN'
**" VALUE(P_MENGE) TYPE KWMENG DEFAULT 1
**" VALUE(P_PLANT) TYPE WERKS_D DEFAULT 0001
**" VALUE(P_ITCAT) TYPE PSTYV DEFAULT 'ZG2W'
**" VALUE(P_LGORT) TYPE LGORT_D DEFAULT 0001
**" EXPORTING
**" VALUE(V_VBELN) TYPE VBELN
**" VALUE(RESULT) TYPE CHAR01
DATA DECLARATIONS.
**DATA: v_vbeln LIKE vbak-vbeln.
*DATA: header LIKE bapisdhead1.
*DATA: headerx LIKE bapisdhead1x.
*DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.
*DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.
*DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.
*DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
*DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx
*WITH HEADER LINE.
*DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl
*WITH HEADER LINE.
HEADER DATA
*header-doc_type = p_auart.
*headerx-doc_type = 'X'.
*header-sales_org = p_vkorg.
*headerx-sales_org = 'X'.
*header-distr_chan = p_vtweg.
*headerx-distr_chan = 'X'.
*header-division = p_spart.
*headerx-division = 'X'.
**order reason
*header-ord_reason = p_augru.
*headerx-ord_reason = 'X'.
**PO number from MAX
*header-PURCH_NO_C = p_BSTKD.
*headerx-PURCH_NO_C = 'X'.
*headerx-updateflag = 'I'.
PARTNER DATA
*partner-partn_role = 'AG'.
*partner-partn_numb = p_sold.
*APPEND partner.
*partner-partn_role = 'WE'.
*partner-partn_numb = p_ship.
*APPEND partner.
ITEM DATA
*itemx-updateflag = 'I'.
*item-itm_number = '000010'.
*itemx-itm_number = 'X'.
*item-material = p_matnr.
*itemx-material = 'X'.
*item-plant = p_plant.
*itemx-plant = 'X'.
*item-target_qty = p_menge.
*itemx-target_qty = 'X'.
*item-target_qu = ' '.
*itemx-target_qu = 'X'.
*item-item_categ = p_itcat.
*itemx-item_categ = 'X'.
**item-STORE_LOC = p_LGORT.
**itemx-STORE_LOC = 'X'.
*APPEND item.
*APPEND itemx.
Fill schedule lines
*lt_schedules_in-itm_number = '000010'.
*lt_schedules_in-sched_line = '0001'.
*lt_schedules_in-req_qty = p_menge.
*APPEND lt_schedules_in.
Fill schedule line flags
*lt_schedules_inx-itm_number = '000010'.
*lt_schedules_inx-sched_line = '0001'.
*lt_schedules_inx-updateflag = 'X'.
*lt_schedules_inx-req_qty = 'X'.
*APPEND lt_schedules_inx.
Call the BAPI
*CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
*EXPORTING
*sales_header_in = header
*sales_header_inx = headerx
*IMPORTING
*salesdocument_ex = v_vbeln
*TABLES
*return = return
*sales_items_in = item
*sales_items_inx = itemx
*sales_schedules_in = lt_schedules_in
*sales_schedules_inx = lt_schedules_inx
*sales_partners = partner.
Check the return table.
*LOOP AT return WHERE type = 'E' OR type = 'A'.
*EXIT.
*ENDLOOP.
*IF sy-subrc = 0.
*result = 'E'.
*ELSE.
*COMMIT WORK AND WAIT.
*result = 'S'.
*ENDIF.
*ENDFUNCTION.
Edited by: Saso Poljansek on Jan 22, 2008 10:23 AMHi,,
Include YCL_CREATE_SALES_DOCU *
Form salesdocu
This Subroutine is used to create Sales Order
-->P_HEADER Document Header Data
-->P_HEADERX Checkbox for Header Data
-->P_ITEM Item Data
-->P_ITEMX Item Data Checkboxes
-->P_LT_SCHEDULES_IN Schedule Line Data
-->P_LT_SCHEDULES_INX Checkbox Schedule Line Data
-->P_PARTNER text Document Partner
<--P_w_vbeln text Sales Document Number
DATA:
lfs_return like line of t_return.
FORM create_sales_document changing P_HEADER like fs_header
P_HEADERX like fs_headerx
Pt_ITEM like t_item[]
Pt_ITEMX like t_itemx[]
P_LT_SCHEDULES_IN like t_schedules_in[]
P_LT_SCHEDULES_INX like t_schedules_inx[]
Pt_PARTNER like t_partner[]
P_w_vbeln like w_vbeln.
This Perform is used to fill required data for Sales order creation
perform sales_fill_data changing p_header
p_headerx
pt_item
pt_itemx
p_lt_schedules_in
p_lt_schedules_inx
pt_partner.
Function Module to Create Sales and Distribution Document
perform sales_order_creation using p_header
p_headerx
pt_item
pt_itemx
p_lt_schedules_in
p_lt_schedules_inx
pt_partner.
perform return_check using p_w_vbeln .
ENDFORM. " salesdocu
Form commit_work
To execute external commit *
FORM commit_work .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = c_x
ENDFORM. " Commit_work
Include ycl_sales_order_header " To Fill Header data and Item data
Include ycl_sales_order_header.
Form return_check
To validate the sales order creation
FORM return_check using pr_vbeln type vbeln.
if pr_vbeln is initial.
LOOP AT t_return into lfs_return .
WRITE / lfs_return-message.
clear lfs_return.
ENDLOOP. " Loop at return
else.
perform commit_work. " External Commit
Refresh t_return.
fs_disp-text = text-003.
fs_disp-number = pr_vbeln.
append fs_disp to it_disp.
if p_del eq c_x or p_torder eq c_x or
p_pgi eq c_x or p_bill eq c_x.
perform delivery_creation. " Delivery order creation
endif. " If p_del eq 'X'......
endif. " If p_w_vbeln is initial
ENDFORM. " Return_check
*& Form sales_order_creation
text
-->P_P_HEADER text
-->P_P_HEADERX text
-->P_PT_ITEM text
-->P_PT_ITEMX text
-->P_P_LT_SCHEDULES_IN text
-->P_P_LT_SCHEDULES_INX text
-->P_PT_PARTNER text
FORM sales_order_creation USING P_P_HEADER like fs_header
P_P_HEADERX like fs_headerx
P_PT_ITEM like t_item[]
P_PT_ITEMX like t_itemx[]
P_P_LT_SCHEDULES_IN like t_schedules_in[]
P_P_LT_SCHEDULES_INX like t_schedules_inx[]
P_PT_PARTNER like t_partner[].
CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'
EXPORTING
sales_header_in = p_p_header
sales_header_inx = p_p_headerx
IMPORTING
salesdocument_ex = w_vbeln
TABLES
return = t_return
sales_items_in = p_pt_item
sales_items_inx = p_pt_itemx
sales_schedules_in = p_p_lt_schedules_in
sales_schedules_inx = p_p_lt_schedules_inx
sales_partners = p_pt_partner.
ENDFORM. " sales_order_creation
this is code to create sales document
plzz reward if it is usefull...
plzz dont forget to reward...... -
[b]Tutorial:[/b] Simplify Developing OLE Automation Code Using VBA
INTRODUCTION
Automating Office applications from Oracle Forms can be a tedious, frustrating, and time-consuming process. Because the OLE2 and CLIENT_OLE2 built-ins do not validate the automation commands that they relay, code that compiles without errors often dies at runtime with a not-so-helpful error code. This tutorial will demonstrate how to simplify the development of automation code using a tool that ships with all Microsoft Office editions -- the Visual Basic for Applications (VBA) IDE.
The VBA IDE, a core Office component, is a full-fledged development environment featuring code completion, basic syntax highlighting, context-driven help and a runtime debugger. Its Object Browser provides a convenient means of browsing the Word object model, as well as searching by keyword.
For those who may not interested in following this tutorial in detail, I would like to stress the usefulness of the Object Browser as a tool for inspecting the functions supported by OLE server applications and, perhaps more importantly, valid values for function arguments. Whether/not anyone buys the assertion that starting with VBA prototypes is far more productive than pounding out OLE2 code from the very start, they will find the Object Browser invaluable as a reference -- I rely on it exclusively for this sort of documentation.
A BRIEF INTRODUCTION TO THE VBA IDE & THE OBJECT BROWSER UTILITY
Try this:
1. Open Word
2. Launch the VBA IDE by pressing <Alt><F11>
3. Open the Object Browser by pressing <F2>
The Object Browser allows you to visually navigate Word's class hierarchy. Its user interface is a bit crowded, so controls are unlabeled. Hovering the mouse cursor above a control will display a tooltip explaining that control's purpose. The browser's scope can be narrowed by using the Project/Library combo. Typing a keyword or substring in the Search Text combo and clicking on the Search button will cause all classes/members whose name contains the specified search text to be listed in the Search Results pane. Selecting an item from this list will update the two panes below it, showing the selected class, and its members. Beneath the Classes and Members panes is an untitled pane, gray in color, which displays details for the selected class/member, including hyperlinks to relevant information such as arguments, their types and allowable values. If Visual Basic Help is installed, pressing <F1> will display help on a selected class/member. (This feature can be installed from your Office install CD, if necessary.)
NOTE: While it is possible to cut-and-paste the code examples that follow, I highly recommend that they be typed in by hand. Doing so will provide a better understanding of how the IDE's code completion behaves. Use code completion most efficiently by not using the mouse or <Enter> key when selecting from completion lists. Instead, just type enough letters to select the desired list element, then continue along as if you had typed the entire element, typing the next operator in your statement. It really is slick!
HELLO WORLD - VBA-STYLE
1. Open Word
2. Launch the VBA IDE by pressing <Alt><F11>
3. Select Module from the Insert menu.
4. In the blank area that appears, enter the following code:
Public Sub HelloWorld()
Documents.Add
Selection.TypeText ("Hello, world!")
End Sub5. Press <F5> to run the code.
If you switch back to Word by pressing <Alt><F11>, there should appear a newly-created document containing the text Hello, world!.
A MORE AMBITIOUS EXAMPLE
In this example, we will launch Word, type some text, and alter its formatting. For the purposes of this tutorial, consider it the process we wish to automate from within Forms.
1. If Word is running, close it.
2. Open any Office application except Word, such as Excel, Outlook or PowerPoint
3. Launch the VBA IDE by pressing <Alt><F11>.
4. Select References from the Tools menu -- a dialog should pop up.
5. From within this dialog, locate and select Microsoft Word <version> Object Library, then click OK.
6. Select Module from the Insert menu.
7. In the blank area that appears, enter the following code:
Public Sub LaunchWord()
Dim app As Word.Application
Set app = CreateObject("Word.Application")
app.Visible = True '!!! IMPORTANT !!!
app.Documents.Add
With app.Selection
.TypeText "This is paragraph 1."
.TypeParagraph
.TypeText "This is paragraph 2."
.TypeParagraph
.TypeText "This is paragraph 3."
End With
With ActiveDocument
.Paragraphs(1).Range.Words(3).Bold = True
.Paragraphs(2).Range.Words(3).Italic = True
.Paragraphs(3).Range.Words(3).Underline = True
End With
End Sub8. Press <F5> to run the code.
A new Word session should have been launched. Switch to it, to view the results of our handiwork!
TAILORING VBA CODE INTENDED FOR OLE2 CONVERSION
Now, things get a bit uglier. The code listed above gives a good idea of how concise VBA code can be, but With blocks and chained object references do not translate readily into OLE2 code. Here's the same process, rewritten in a more OLE2-friendly style. Note the numerous intermediate object references that have been declared.
Public Sub LaunchWord()
Dim app As Word.Application
Dim doc As Word.Document
Dim docs As Word.Documents
Dim pars As Word.Paragraphs
Dim par As Word.Paragraph
Dim wrds As Word.Words
Dim sel As Word.Selection
Dim rng As Word.Range
Set app = CreateObject("Word.Application")
app.Visible = True '!!! IMPORTANT !!!
Set doc = app.Documents.Add
Set sel = app.Selection
sel.TypeText "This is paragraph 1."
sel.TypeParagraph
sel.TypeText "This is paragraph 2."
sel.TypeParagraph
sel.TypeText "This is paragraph 3."
Set pars = doc.Paragraphs
'select third word of first paragraph and make it bold
Set par = pars.Item(1)
Set rng = par.Range
Set wrds = rng.Words
Set rng = wrds.Item(3)
rng.Bold = True
'select third word of second paragraph and italicize it
Set par = pars.Item(2)
Set rng = par.Range
Set wrds = rng.Words
Set rng = wrds.Item(3)
rng.Italic = True
'select third word of second paragraph and underline it
Set par = pars.Item(3)
Set rng = par.Range
Set wrds = rng.Words
Set rng = wrds.Item(3)
rng.Underline = True
End Sub
TRANSFORMATION: CONVERTING VBA CODE INTO PL/SQL
Here is the PL/SQL counterpart to our previous VBA routine. Compare printouts of the two and note their similarities. Notice the need for argument lists -- this causes the code to fluff up quite a bit, and really interferes with readability.
PROCEDURE LAUNCH_WORD IS
v_app OLE2.OBJ_TYPE; -- Application
v_doc OLE2.OBJ_TYPE; -- Document
v_docs OLE2.OBJ_TYPE; -- Documents collection
v_pars OLE2.OBJ_TYPE; -- Paragraphs collection
v_par OLE2.OBJ_TYPE; -- Paragraph
v_wrds OLE2.OBJ_TYPE; -- Words collection
v_sel OLE2.OBJ_TYPE; -- Selection
v_rng OLE2.OBJ_TYPE; -- Range
v_args OLE2.LIST_TYPE; -- OLE2 argument list
BEGIN
/* launch Word and MAKE IT VISIBLE!!! */
v_app := OLE2.CREATE_OBJ('Word.Application');
OLE2.SET_PROPERTY(v_app, 'Visible', TRUE);
/* initialize key object references */
v_docs := OLE2.GET_OBJ_PROPERTY(v_app, 'Documents');
v_doc := OLE2.INVOKE_OBJ(v_docs, 'Add');
v_sel := OLE2.GET_OBJ_PROPERTY(v_app, 'Selection');
/* type first paragraph */
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, 'This is paragraph 1.');
OLE2.INVOKE(v_sel, 'TypeText', v_args);
OLE2.DESTROY_ARGLIST(v_args);
OLE2.INVOKE(v_sel, 'TypeParagraph');
/* type second paragraph */
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, 'This is paragraph 2.');
OLE2.INVOKE(v_sel, 'TypeText', v_args);
OLE2.DESTROY_ARGLIST(v_args);
OLE2.INVOKE(v_sel, 'TypeParagraph');
/* type third paragraph */
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, 'This is paragraph 3.');
OLE2.INVOKE(v_sel, 'TypeText', v_args);
OLE2.DESTROY_ARGLIST(v_args);
/* set reference to Paragraphs collection */
v_pars := OLE2.GET_OBJ_PROPERTY(v_doc, 'Paragraphs');
/* select third word of first paragraph and make it bold */
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, 1);
v_par := OLE2.INVOKE_OBJ(v_pars, 'Item', v_args);
OLE2.DESTROY_ARGLIST(v_args);
v_rng := OLE2.GET_OBJ_PROPERTY(v_par, 'Range');
v_wrds := OLE2.GET_OBJ_PROPERTY(v_rng, 'Words');
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, 3);
v_rng := OLE2.INVOKE_OBJ(v_wrds, 'Item', v_args);
OLE2.SET_PROPERTY(v_rng, 'Bold', TRUE);
/* select third word of second paragraph and italicize it */
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, 2);
v_par := OLE2.INVOKE_OBJ(v_pars, 'Item', v_args);
OLE2.DESTROY_ARGLIST(v_args);
v_rng := OLE2.GET_OBJ_PROPERTY(v_par, 'Range');
v_wrds := OLE2.GET_OBJ_PROPERTY(v_rng, 'Words');
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, 3);
v_rng := OLE2.INVOKE_OBJ(v_wrds, 'Item', v_args);
OLE2.SET_PROPERTY(v_rng, 'Italic', TRUE);
/* select third word of second paragraph and underline it */
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, 3);
v_par := OLE2.INVOKE_OBJ(v_pars, 'Item', v_args);
OLE2.DESTROY_ARGLIST(v_args);
v_rng := OLE2.GET_OBJ_PROPERTY(v_par, 'Range');
v_wrds := OLE2.GET_OBJ_PROPERTY(v_rng, 'Words');
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, 3);
v_rng := OLE2.INVOKE_OBJ(v_wrds, 'Item', v_args);
OLE2.SET_PROPERTY(v_rng, 'Underline', TRUE);
END;
REFACTORING FOR REUSABILITY AND READABILITY
While the previous procedure runs without errors, it suffers from poor readability which, in turn, makes it difficult to maintain. Here, we address those issues by moving repetetive low-level operations into separate procedures.
PROCEDURE LAUNCH_WORD IS
v_app OLE2.OBJ_TYPE; -- Application
v_doc OLE2.OBJ_TYPE; -- Document
v_docs OLE2.OBJ_TYPE; -- Documents collection
v_sel OLE2.OBJ_TYPE; -- Selection
v_args OLE2.LIST_TYPE; -- OLE2 argument list
BEGIN
/* launch Word and MAKE IT VISIBLE!!! */
v_app := OLE2.CREATE_OBJ('Word.Application');
OLE2.SET_PROPERTY(v_app, 'Visible', TRUE);
/* create a new Word document */
v_docs := OLE2.GET_OBJ_PROPERTY(v_app, 'Documents');
v_doc := OLE2.INVOKE_OBJ(v_docs, 'Add');
v_sel := OLE2.GET_OBJ_PROPERTY(v_app, 'Selection');
/* add a few paragraphs */
PRINT_PARAGRAPH(v_sel, 'This is paragraph 1.');
PRINT_PARAGRAPH(v_sel, 'This is paragraph 2.');
PRINT_PARAGRAPH(v_sel, 'This is paragraph 3.');
/* apply formatting */
APPLY_FORMATTING(v_doc, 1, 3, 'Bold', TRUE);
APPLY_FORMATTING(v_doc, 2, 3, 'Italic', TRUE);
APPLY_FORMATTING(v_doc, 3, 3, 'Underline', TRUE);
END;
PROCEDURE APPLY_FORMATTING(
v_doc OLE2.OBJ_TYPE,
v_paragraph_num NUMBER,
v_word_num NUMBER,
v_attribute VARCHAR2,
v_value BOOLEAN) IS
v_pars OLE2.OBJ_TYPE; -- Paragraphs collection
v_par OLE2.OBJ_TYPE; -- Paragraph
v_wrds OLE2.OBJ_TYPE; -- Words collection
v_rng OLE2.OBJ_TYPE; -- Range
v_args OLE2.LIST_TYPE; -- OLE2 argument list
BEGIN
/* set reference to Paragraphs collection */
v_pars := OLE2.GET_OBJ_PROPERTY(v_doc, 'Paragraphs');
/* get specified paragraph */
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, v_paragraph_num);
v_par := OLE2.INVOKE_OBJ(v_pars, 'Item', v_args);
OLE2.DESTROY_ARGLIST(v_args);
/* get words for specified paragraph */
v_rng := OLE2.GET_OBJ_PROPERTY(v_par, 'Range');
v_wrds := OLE2.GET_OBJ_PROPERTY(v_rng, 'Words');
/* apply formatting to word found at specified index */
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, v_word_num);
v_rng := OLE2.INVOKE_OBJ(v_wrds, 'Item', v_args);
OLE2.SET_PROPERTY(v_rng, v_attribute, v_value);
END;
PROCEDURE PRINT_PARAGRAPH(v_sel OLE2.OBJ_TYPE, v_text VARCHAR2) IS
v_args OLE2.LIST_TYPE;
BEGIN
v_args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(v_args, v_text);
OLE2.INVOKE(v_sel, 'TypeText', v_args);
OLE2.DESTROY_ARGLIST(v_args);
OLE2.INVOKE(v_sel, 'TypeParagraph');
END;
CONCLUSION
It is my hope that this tutorial, despite it's introductory nature, has demonstrated the value of the VBA IDE, the ease with which automation processes can be prototyped using VBA, the noticeable similarity between VBA automation routines and their Forms PL/SQL counterparts, and the advantages of testing automation processes within the VBA IDE. Please feel free to follow up with any specific questions or concerns you may have.
Thanks,
Eric Adamson
Lansing, Michigan
FINAL NOTE: These examples use the OLE2 built-in, and will operate correctly when called from forms running in the Form Builder OC4J. Deploying them to an Oracle Application Server will launch Word on the server itself (if available), which is usually not the developer's intent! Automating Word client-side via web forms requires adding WebUtil support. Adapting the code for WebUtil is trivial -- just replace all instances of OLE2 with CLIENT_OLE2. Adapting forms for WebUtil and configuring OLE support into your Oracle Application Server, however, are beyond the scope of this tutorial.
REVISION HISTORY
This promises to be something of a 'living document'. I've snuck changes through without comment in the past, but in the future, I'll try to document significant changes here.
2006-08-21
* Prefaced boring subject line with text: 'Tutorial:' to clarify purpose
* Added emphasis on value of Object Browser as a referenceThanks James, for your kind words. I do hope this information will help folks out. I honestly believe that tinkering around in the VBA IDE will prove highly gratifying for automation developers. It can be assured that learning to make Word jump through hoops is much more straight-forward in this environment. I'm not one for mottos, but if I were pressed for a cheesy motto, I would say: First, make it work. Then, make it work in Oracle!
Once the idea has sunk in, that Visual Basic routines for automating Word are exact analogs to their OLE2 counterparts, we can remove keywords like Oracle and PL/SQL from our Google searches on Word automation which, at least in this context, are the proverbial kiss of death. Suddenly we find ourselves liberated by the possibility of steal-, ahem... borrowing ideas from the Visual Basic* community!
As for links, my link of choice is invariably http://groups.google.com -- if you don't already use it at least ten times a day, you must try it. This is the venerable USENET archive, including the holdings of now-extinct DejaNews. Another possible site of interest is http://word.mvps.org/FAQs/MacrosVBA, which may serve as a good starting point for those who wish to learn how to do fancy tricks with Word using VBA.
If these links don't prove immediately helpful, please feel free to give specifics on the sort of operations you are interested in automating, and I'll see if I can post an example that addresses it.
Regards,
Eric Adamson
Lansing, Michigan
PS: I do hope, as people read my posts, with every other acronym being VBA, that they are not mistakenly hearing a call to learn Visual Basic. I say this, not because I believe learning VB would be a Bad Thing, but because I assume that few of us feel we have the time to learn a new programming language. Despite having come to the Oracle camp already knowing VB/VBA, and having acquired a fair bit of experience with automating Office applications as an Access developer, I remain confident that what I am suggesting people attempt does not rise to the level of learning a language. What I am suggesting is that they learn enough of the language to get by.
*VB vs. VBA
Just a quick word on this, as readers may wonder why I seem to use these terms interchangeably. Visual Basic (VB) can refer to either a development platform or a programming language. Visual Basic for Applications (VBA) is a language -- more precisely, it is a subset of the Visual Basic language. One purchases VB, usually quite intentionally. VBA is included with Microsoft Office, as is VBA's development environment, the VBA IDE. The key distinction between VB and VBA is that VBA cannot be used to create self-contained executables. Rather, VBA relies on VBA-enabled applications, such as Microsoft Office applications, to serve as a container for VBA code, and to provide a runtime environment for that code. For the purposes of discussing OLE Automation, VB and VBA are quite interchangeable. -
HOWTO: Using a BC4J Application Module in an Stateless EJB Session Bean
HOWTO: Using a BC4J Application Module in an Stateless EJB Session Bean
by Steve Muench
Overview
BC4J provides automatic facilities for deploying any application module as a stateful EJB session bean. If you want to leverage the features of your BC4J application module from a stateless EJB session bean, it's not automatic but it is straightforward to implement. This howto article explains the details.
For our example, we will create a stateless EJB session bean that uses a container-managed transaction. To keep things simple, let's assume the session bean has a single public method on its remote interface named createDepartment() with the following signature:
public void createDepartment(int id, String name, String loc) throws AppException
AppException is an example of an application-specific exception that our method will throw if any problems arise during its execution.The goal of this article is to illustrate how to use the BC4J application module named com.example.hr.HRApp as part of the implementation of this createDepartment method on our stateless enterprise bean. Let's assume that the HRApp application module has a view object member named Departments, based on the com.example.hr.DeptView view object, based on the familiar DEPT table and related to the com.example.hr.Dept entity object so our view can be updateable.
Creating the Stateless Session Bean
We can start by using the JDeveloper Enterprise Bean wizard to create a new stateless session bean called StatelessSampleEJB implemented by:[list][*]com.example.StatelessSampleEJBBean (Bean class)[*]com.example.StatelessSampleEJBHome (Home interface)[*]com.example.StatelessSampleEJB (Remote interface)[list]
We then use the EJB Class Editor to add the createDepartment method to the remote interface of StatelessSampleEJB with the signature above. We edit the remote interface to make sure that it also reflects that the createDepartment method thows the AppException like this:
package com.example;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface StatelessSampleEJB extends EJBObject {
void createDepartment(int id, String name, String loc)
throws RemoteException,AppException;
}Before we start adding BC4J into the picture for our implementation, our StatelessSampleEJBBean class looks like this:
package com.example;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class StatelessSampleEJBBean implements SessionBean {
public void ejbCreate(){}
public void ejbActivate(){}
public void ejbPassivate(){}
public void ejbRemove(){}
public void setSessionContext(SessionContext ctx){
public void createDepartment(int id, String name, String loc)
throws AppException {
// TODO: Implement method here
}We can double-click on the ejb-jar.xml file in our project to see the XML deployment descriptor for the bean we just created:
<ejb-jar>
<enterprise-beans>
<session>
<description>Session Bean ( Stateless )</description>
<display-name>StatelessSampleEJB</display-name>
<ejb-name>StatelessSampleEJB</ejb-name>
<home>com.example.StatelessSampleEJBHome</home>
<remote>com.example.StatelessSampleEJB</remote>
<ejb-class>com.example.StatelessSampleEJBBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>We need to add the extra <assembly-descriptor> section in this file to indicate that the createDepartment method will require a transaction. After this edit, the ejb-jar.xml file looks like this:
<ejb-jar>
<enterprise-beans>
<session>
<description>Session Bean ( Stateless )</description>
<display-name>StatelessSampleEJB</display-name>
<ejb-name>StatelessSampleEJB</ejb-name>
<home>com.example.StatelessSampleEJBHome</home>
<remote>com.example.StatelessSampleEJB</remote>
<ejb-class>com.example.StatelessSampleEJBBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>StatelessSampleEJB</ejb-name>
<method-name>createDepartment</method-name>
<method-params>
<method-param>int</method-param>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
Aggregating a BC4J Application Module
With the EJB aspects of our bean setup, we can proceed to implementing the BC4J application module aggregation.
The first thing we do is add private variables to hold the EJB SessionContext and the instance of the aggregated BC4J ApplicationModule, like this:
// Place to hold onto the aggregated appmodule instance
transient private ApplicationModule _am = null;
// Remember the SessionContext that the EJB container provides us
private SessionContext _ctx = null;and we modify the default, empty implementation of the setSessionContext() method to remember the session context like this:
public void setSessionContext(SessionContext ctx){ _ctx = ctx; }We add additional constants that hold the names of the J2EE datasource that we want BC4J to use, as well as the fully-qualified name of the BC4J application module that we'll be aggregating:
// JNDI resource name for the J2EE datasource to use
private static final String DATASOURCE = "jdbc/OracleCoreDS";
// Fully-qualified BC4J application module name to aggregate
private static final String APPMODNAME = "com.example.hr.HRApp";We expand the now-empty ejbCreate() and ejbRemove() methods to create and destory the aggregated instance of the BC4J application module that we'll use for the lifetime of the stateless session bean. When we're done, ejbCreate() it looks like this:
public void ejbCreate() throws CreateException {
try {
// Setup a hashtable of environment parameters for JNDI initial context
Hashtable env = new Hashtable();
env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
// NOTE: we want to use the BC4J app module in local mode as a simple Java class!
env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
env.put(PropertyConstants.INTERNAL_CONNECTION_PARAMS,DATASOURCE);
// Create an initial context, using this hashtable of environment params
InitialContext ic = new InitialContext(env);
// Lookup a home interface for the application module
ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(APPMODNAME);
// Using the home, create the instance of the appmodule we'll use
_am = home.create();
// Register the BC4J factory to handle EJB container-managed transactions
registerContainerManagedTransactionHandlerFactory();
catch(Exception ex) {
ex.printStackTrace();
throw new CreateException(ex.getMessage());
}and ejbRemove() looks like this:
public void ejbRemove() {
try {
// Cleanup any appmodule resources before getting shutdown
_am.remove();
catch(JboException ex) { /* Ignore */ }
}The helper method named reigsterContainerManagedTransactionHandlerFactory() looks like this:
private void registerContainerManagedTransactionHandlerFactory() {
SessionImpl session = (SessionImpl)_am.getSession();
session.setTransactionHandlerFactory(
new TransactionHandlerFactory() {
public TransactionHandler createTransactionHandler() {
return new ContainerManagedTxnHandlerImpl();
public JTATransactionHandler createJTATransactionHandler() {
return new ContainerManagedTxnHandlerImpl();
}The last detail is to use the BC4J appmodule to implement the createDepartment() method. It ends up looking like this:
public void createDepartment(int id, String name, String loc)
throws AppException {
try {
// Connect the AM to the datasource we want to use for the duration
// of this single method call.
_am.getTransaction().connectToDataSource(null,DATASOURCE,false);
// Use the "Departments" view object member of this AM
ViewObject departments = _am.findViewObject("Departments");
// Create a new row in this view object.
Row newDept = departments.createRow();
// Populate the attributes from the parameter arguments.
newDept.setAttribute("Deptno", new Number(id));
newDept.setAttribute("Dname", name);
newDept.setAttribute("Loc", loc);
// Add the new row to the view object's default rowset
departments.insertRow(newDept);
// Post all changes in the AM, but we don't commit them. The EJB
// container managed transaction handles the commit.
_am.getTransaction().postChanges();
catch(JboException ex) {
// To be good EJB Container-Managed Transaction "citizens" we have
// to mark the transaction as needing a rollback if there are problems
_ctx.setRollbackOnly();
throw new AppException("Error creating dept "+ id +"\n"+ex.getMessage());
finally {
try {
// Disconnect the AM from the datasource we're using
_am.getTransaction().disconnect();
catch(Exception ex) { /* Ignore */ }
Building a Test Client
With the EJB-Tier work done, we can build a sample client program to test this new stateless EJB Session Bean by selecting the bean in the Oracle9i JDeveloper IDE and choosing "Create Sample Java Client" from the right-mouse menu.
When the "Sample EJB Client Details" dialog appears, we take the defaults of connecting to embedded OC4J container. Clicking the (OK) button generates the following test class:
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import com.example.StatelessSampleEJB;
import com.example.StatelessSampleEJBHome;
public class SampleStatelessSampleEJBClient {
public static void main(String [] args) {
SampleStatelessSampleEJBClient sampleStatelessSampleEJBClient =
new SampleStatelessSampleEJBClient();
try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.evermind.server.rmi.RMIInitialContextFactory");
env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "welcome");
env.put(Context.PROVIDER_URL,
"ormi://localhost:23891/current-workspace-app");
Context ctx = new InitialContext(env);
StatelessSampleEJBHome statelessSampleEJBHome =
(StatelessSampleEJBHome)ctx.lookup("StatelessSampleEJB");
StatelessSampleEJB statelessSampleEJB;
// Use one of the create() methods below to create a new instance
// statelessSampleEJB = statelessSampleEJBHome.create();
// Call any of the Remote methods below to access the EJB
// statelessSampleEJB.createDepartment( int id, java.lang.String name, java.lang.String loc );
catch(Throwable ex) {
ex.printStackTrace();
}We uncomment the call to the create() method and add a few calls to the createDepartment() method so that the body of the test program now looks like this:
// Use one of the create() methods below to create a new instance
statelessSampleEJB = statelessSampleEJBHome.create();
// Call any of the Remote methods below to access the EJB
statelessSampleEJB.createDepartment( 13, "Test1","Loc1");
System.out.println("Created department 13");
statelessSampleEJB.createDepartment( 14, "Test2","Loc2");
System.out.println("Created department 14");
try {
// Try setting a department id that is too large!
statelessSampleEJB.createDepartment( 23456, "Test3","Loc3");
catch (AppException ax) {
System.err.println("AppException: "+ax.getMessage());
}Before we can successfully run our SampleStatelessSampleEJBClient we need to first run the EJB bean that the client will try to connect to. Since Oracle9i JDeveloper supports local running and debugging of the EJB-Tier without doing through a full J2EE deployment step, to accomplish this prerequisite step we just need to right-mouse on the StatelessSampleEJB node in the System Navigator and select "Run". This starts up the embedded OC4J instance and runs the EJB right out of the current out path.Finally, we can run the SampleStatelessSampleEJBClient, and see the output of the test program in the JDeveloper log window:
Created department 13
Created department 14
AppException: Error creating dept 23456
JBO-27010: Attribute set with value 23456 for Deptno in Dept has invalid precision/scale
Troubleshooting
One error that might arise while running the example is that the database connection information in your data-sources.xml for the jdbc/OracleCoreDS datasource does not correspond to the database you are trying to test against. If this happens, then double-check the file .\jdev\system\oc4j-config\data-sources.xml under the JDeveloper installation home directory to make sure that the url value provided is what you expect. For example, to work against a local Oracle database running on your current machine, listening on port 1521, with SID of ORCL, you would edit this file to have an entry like this for jdbc/OracleCoreDS :
<data-source
class="com.evermind.sql.DriverManagerDataSource"
name="OracleDS"
location="jdbc/OracleCoreDS"
xa-location="jdbc/xa/OracleXADS"
ejb-location="jdbc/OracleDS"
connection-driver="oracle.jdbc.driver.OracleDriver"
username="scott"
password="tiger"
url="jdbc:oracle:thin:@localhost:1521:ORCL"
inactivity-timeout="30"
/>This is the data-sources.xml file that gets used by the embedded OC4J instance running in JDeveloper.
Conclusion
Hopefully this article has illustrated that it is straightforward to utilize the full power of BC4J in local mode as part of your EJB Stateless Session Beans using container-managed transaction. This example illustrated a single createDepartment method in the enterprise bean, but by replicating the application module interaction code that we've illustrated in createDepartment, any number of methods in your stateless session bean can use the aggregated application module instance created in the ejbCreate() method.
Code Listing
The full code listing for the SampleStatelessEJB bean implementation class looks like this:
* StatelessSampleEJB
* Illustrates how to use an aggregated BC4J application module
* in local mode as part of the implementation of a stateless
* EJB session bean using container-managed transaction.
* HISTORY
* smuench/dmutreja 14-FEB-2002 Created
package com.example;
import oracle.jbo.*;
import oracle.jbo.server.*;
import javax.ejb.*;
import oracle.jbo.domain.Number;
import oracle.jbo.common.PropertyConstants;
import java.util.Hashtable;
import javax.naming.InitialContext;
import oracle.jbo.server.ejb.ContainerManagedTxnHandlerImpl;
public class StatelessSampleEJBBean implements SessionBean {
// JNDI resource name for the J2EE datasource to use
private static final String DATASOURCE = "jdbc/OracleCoreDS";
// Fully-qualified BC4J application module name to aggregate
private static final String APPMODNAME = "com.example.hr.HRApp";
// Place to hold onto the aggregated appmodule instance
transient private ApplicationModule _am = null;
// Remember the SessionContext that the EJB container provides us
private SessionContext _ctx = null;
public void ejbCreate() throws CreateException {
try {
// Setup a hashtable of environment parameters for JNDI initial context
Hashtable env = new Hashtable();
env.put(JboContext.INITIAL_CONTEXT_FACTORY,JboContext.JBO_CONTEXT_FACTORY);
env.put(JboContext.DEPLOY_PLATFORM, JboContext.PLATFORM_LOCAL);
env.put(PropertyConstants.INTERNAL_CONNECTION_PARAMS,DATASOURCE);
// Create an initial context, using this hashtable of environment params
InitialContext ic = new InitialContext(env);
// Lookup a home interface for the application module
ApplicationModuleHome home = (ApplicationModuleHome)ic.lookup(APPMODNAME);
// Using the home, create the instance of the appmodule we'll use
_am = home.create();
// Register the BC4J factory to handle EJB container-managed transactions
registerContainerManagedTransactionHandlerFactory();
catch(Exception ex) {
ex.printStackTrace();
throw new CreateException(ex.getMessage());
public void ejbActivate(){}
public void ejbPassivate(){}
public void ejbRemove(){}
public void setSessionContext(SessionContext ctx){ _ctx = ctx; }
public void createDepartment(int id, String name, String loc)
throws AppException {
try {
// Connect the AM to the datasource we want to use for the duration
// of this single method call.
_am.getTransaction().connectToDataSource(null,DATASOURCE,false);
// Use the "Departments" view object member of this AM
ViewObject departments = _am.findViewObject("Departments");
// Create a new row in this view object.
Row newDept = departments.createRow();
// Populate the attributes from the parameter arguments.
newDept.setAttribute("Deptno", new Number(id));
newDept.setAttribute("Dname", name);
newDept.setAttribute("Loc", loc);
// Add the new row to the view object's default rowset
departments.insertRow(newDept);
// Post all changes in the AM, but we don't commit them. The EJB
// container managed transaction handles the commit.
_am.getTransaction().postChanges();
catch(JboException ex) {
// To be good EJB Container-Managed Transaction "citizens" we have
// to mark the transaction as needing a rollback if there are problems
_ctx.setRollbackOnly();
throw new AppException("Error creating dept "+ id +\n"+ex.getMessage());
finally {
try {
// Disconnect the AM from the datasource we're using
_am.getTransaction().disconnect();
catch(Exception ex) { /* Ignore */ }
private void registerContainerManagedTransactionHandlerFactory() {
SessionImpl session = (SessionImpl)_am.getSession();
session.setTransactionHandlerFactory(
new TransactionHandlerFactory() {
public TransactionHandler createTransactionHandler() {
return new ContainerManagedTxnHandlerImpl();
public JTATransactionHandler createJTATransactionHandler() {
return new ContainerManagedTxnHandlerImpl();Hi Steve, It4s me again;
About the question I made, I tried with a single assembly-descriptor tag and a single container-transaction tag in the deployment descriptor of the session bean and these were the results.
java.lang.NullPointerException
void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
Then I tried with multiple assembly-descriptor tags each with a single container-transaction tag and the results were:
java.lang.NullPointerException
void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
Finally I tried with a single assembly-descriptor and multiple container tags and the results were:
java.lang.NullPointerException
void com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(java.lang.Throwable)
java.lang.Object com.evermind.server.rmi.RMIConnection.invokeMethod(com.evermind.server.rmi.RMIContext, long, long, java.lang.reflect.Method, java.lang.Object[])
java.lang.Object com.evermind.server.rmi.RemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
java.lang.Object com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
java.lang.Object com.evermind.server.ejb.StatelessSessionRemoteInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
void __Proxy1.modificaEnvoltura(java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.Integer, java.lang.String)
void SamplemdeController.envolturaControlEJBClient.main(java.lang.String[])
How can I make my Stateless Session bean work out? -
How to make use of SE37- Function Module & how to find out the table?
Hi ,
1.Could anyone help me what's this SE37-Function module is all about,How to make use of this?
For Eg,If i want to delete a BOM permanently from the system then I have to use the Function module CM_DB_DEL_FROM_ROOT_BOM.
But after giving the particular name what should i do?
Please help me.
2.How to find out the respective table for a particular field sya for T code-COGI, T code MFBF,where its values are getting populated.,Please help in this issue.
Thanks in adavnce for spending some time
Raj.SHi Raj
Function Modules
Function modules are procedures that are defined in special ABAP programs only, so-called function groups, but can be called from all ABAP programs. Function groups act as containers for function modules that logically belong together. You create function groups and function modules in the ABAP Workbench using the Function Builder.
Function modules allow you to encapsulate and reuse global functions in the SAP System. They are managed in a central function library. The SAP System contains several predefined functions modules that can be called from any ABAP program. Function modules also play an important role during updating and in interaction between different SAP systems, or between SAP systems and remote systems through remote communications.
Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Function Builder. The actual ABAP interface definition remains hidden from the programmer. You can define the input parameters of a function module as optional. You can also assign default values to them. Function modules also support exception handling. This allows you to catch certain errors while the function module is running. You can test function modules without having to include them in a program using the Function Builder.
The Function Builder also has a release process for function modules. This ensures that incompatible changes cannot be made to any function modules that have already been released. This applies particularly to the interface. Programs that use a released function module will not cease to work if the function module is changed.
Check this link
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db988735c111d1829f0000e829fbfe/content.htm
You can execute function module in SE37ie you can perform the activiites defined in the function module by executing it.
By deleting BOM you mention the FM name in se37 and execute. In some function module it will ask input parameters as developed in the program , you have to give the input parameters and execute.
Maybe you are looking for
-
How can i use or embed the ' C' language in java
thanks a lot friends for your suggestion on using 'c' language to implement the control of the keyboard ie. to prevent a key stroke of : ctrl+alt+delete keys from closing a running java application. i was advised that it won't be possible to implemen
-
I have created a Slide Show in iPhoto. I have dragged it to the iDVD application. What DVD-R discs do I need to purchase to Burn the Slide Show on? The "Help" informs me: Mac Superdrive only writes to x2.0 general DVD-R discs. I have been unable to f
-
Strange Problem with iPod disk space
I have something over 2Gigs of music in my iPod, so that should leave more than a Gig of space, BUT in iTunes, it says 734 songs, 1.8 days, 2.93 GB however, in the bar on top of that, it says: Used: 3.68GB, Free: 92.8 MB My iPod shows up as a hard dr
-
I'm new to Mac having just moved from a PC. The TD Ameritrade site provides statements as PDF documents which are opened by clicking on a link. The document is displayed in a pop-up window and there is no problem viewing all pages by scrolling. Bu
-
my iphone 4s screen has just turned black but it is still vibrating. I was reading other messages similar and it says to resart phone but holding the home and lock button. However my lock button doesnt work what should i do?