Вы находитесь на странице: 1из 7

Connecting to an external source via Java Connector

(By Bob Billings)


CONNECTING TO AN EXTERNAL SOURCE VIA JAVA CONNECTOR.........................................1

Overview
In the process of SAP Order Entry (VA01) it became necessary to provide a fu y! search he"p from an e#terna" source usin$ the %ava &onnector for a materia" "oo'up( I(e( SAP does not store a"" the possib"e search options to return a materia" number( Additiona" searchab"e fie"ds re"ated to a materia" are maintained in an e#terna" system and )e )ant to search on these fie"ds( Java Appication SAP
SM59 VA01
Create Sales Order DefineRFC Destination

'Fuzzy' F4 on material description

Call Remote function passing search request Java App Listens for RFC Call to 'Ja a' destination Select from ta!les !ased on parameters passed" #opulate function module internal ta!le $ith results

RFC Destination

*he )ay this )as accomp"ished )as throu$h an E"ementary search he"p that used the search he"p e#it to connect via a remote function ca"" to the %ava &onnector( *he E"ementary search he"p )as then added to a &o""ective search he"p via the Inc"uded search he"p "ist and connected usin$ the parameter assi$nment button( *hree code snippets fo""o)+ *he function ca"" )hich accepts the re,uest and processes the resu"ts the remote function )hich is mere"y a conduit to and from the remote destinationand a part of the %ava code that accepts input from SAP and returns an interna" tab"e of resu"ts(

1st. The Collective Search Help

2nd. The Elementary Search Help

3rd. The View that supports the Elementary Search Help

4th. The S !" transaction de#inin$ the %&C destination connection.

!th. '(')
The global data top incl de !o" the act al e#it contain$ the !ollo%ing+
type-pools shlp. type-pools f4typ. "Brcke zu alten F4-Bausteinen tables: ddshdefsh. "Tabelle der Default-Suchhilfen data shlpna!e constants: par par par par par par par par like dd"#$-shlpna!e. do!na!e like ddshfprop-fieldna!e $alue %D&'()'*%+ $alue like ddshfprop-fieldna!e $alue %,)-.*%+ te/t like ddshfprop-fieldna!e $alue %T*0T%+ 1lo2 like ddshfprop-fieldna!e $alue%1-&3%+ 1hi4h like ddshfprop-fieldna!e $alue%15675%+ 1te/t like ddshfprop-fieldna!e $alue%1T*0T%+ rollna!e like ddshfprop-fieldna!e $alue %8&--()'*%+ tabna!e like ddshfprop-fieldna!e $alue %T)B()'*%.

Sea"ch help e#it de!inition+


F.(9T6&( :1F41:')T1*06T. ;"---------------------------------------------------------------------;";"-ocal interface: ;" T)B-*S ;" S5-<1T)B T=<* S5-<1D*S981T)B1T ;" 8*9&8D1T)B ST8.9T.8* S*)5-<8*S ;" 95)(76(7 ;" ,)-.*>S5-<? T=<* S5-<1D*S981T ;" ,)-.*>9)--9&(T8&-? -6@* DDS5F49T8- ST8.9T.8* DDS5F49T8;"---------------------------------------------------------------------data: !atnr like !ara-!atnr+ !akt/ like !akt-!akt/+ desc like !akt-!akt/+ recs1to1return like lfaA-bbsnr+ recs1returned like lfaA-bbsnr+ is1selopt like DDS5S*-&<T+ is1shlp1tab like line of shlp1tab+ is1interface like line of shlp1tab-interface. data: be4in of it1return occurs #. include structure :<'18*T.8(. data: end of it1return. data: be4in of filler !atnr !akt/ end of is1disp+ type char##B+ like !ara-!atnr+ like !akt-!akt/+ is1disp.

data: is1return like line of it1return. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 9ase callcontrol-step. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2hen %S*-&(*% or %<8*S*-A% or %<8*S*-% or %D6S<%. e/it. 2hen %S*-*9T%.

clear: is1disp. refresh: record1tab. ;; Find the search ite! C nu!ber of lines to return read table shlp1tab inde/ A into is1shlp1tab. read table is1shlp1tab-interface inde/ A into is1interface. if not is1interface-$alue is initial. !akt/ D is1interface-$alue. else. read table shlp-selopt inde/ A into is1selopt. !akt/ D is1selopt-lo2. endif. recs1to1return D callcontrol-!a/records. ;; call du!!y F' that is re!otely enabled. The Ea$a listener ;; is lookin4 for destination S)<1E),) 9)-- F.(9T6&( %:18F91T&1<'% D*ST6()T6&( %S)<1E),)% *0<&8T6(7 ')@T7 D !akt/ !a/1lines D recs1to1return 6'<&8T6(7 9&.(T D recs1returned T)B-*S 8*S.-T1T)B D it1return. if recs1returned F #. ;; put the return table into search help display table loop at it1return into is1return. is1disp-!atnr D is1return-!atnr. is1disp-!akt/ D is1return-!akt/. append is1disp to record1tab. endloop. else. is1disp-!atnr D %;;;;;;;;;;;;;%. is1disp-!akt/ D %(othin4 returned%. append is1disp to record1tab. endif. callcontrol-step D %D6S<%. e/it. 2hen others. e/it. endcase. *(DF.(9T6&(. ;; 8e!otely enabled function !odule F.(9T6&( :18F91T&1<'. ;"---------------------------------------------------------------------;";"-ocal interface: ;" 6'<&8T6(7 ;" ,)-.*>')@T7? -6@* ')@T-')@T7 ;" ,)-.*>')01-6(*S? -6@* -F)A-BBS(8 ;" *0<&8T6(7 ;" ,)-.*>9&.(T? -6@* -F)A-BBS(8 ;" T)B-*S ;" 8*S.-T1T)B ST8.9T.8* :<'18*T.8( ;"---------------------------------------------------------------------*(DF.(9T6&(.

*th. +'V'
This is the method in server class that handles incoming !C calls" pu!lic oid handleRequest%JCO"Function pFunction& thro$s 'a a"lang"()ception * String class+ame , resol eClass+ame%pFunction"get+ame%&&if %class+ame ., null& * /0ethod method , %/0ethod& Class"for+ame%class+ame&"ne$/nstance%&method"e)ecute%pFunction"get/mport#arameterList%&1 pFunction"get()port#arameterList%&1 pFunction"get2a!le#arameterList%&&3 else * 442hro$ JCO"5!ap()ception if $e don't handle Function" thro$ ne$ +otSupported()ception%&3 3 And this one does the #or$" pu!lic oid e)ecute%JCO"#arameterList p/mport#arameters1 JCO"#arameterList p()port#arameters1 JCO"#arameterList p2a!le#arameters& thro$s #06S()ception * JCO"2a!le ta!le , p2a!le#arameters"get2a!le%7R(S8L2925:7&String searchString , p/mport#arameters"getString%705;2<7&int ma)Return , ne$ /nteger%p/mport#arameters"getString%705=9L/+(S7&&"int6alue%&try * 6aluesCollection>? results , search%searchString1 ma)Return&if %results ., null& * String count , 77 @ results"lengthp()port#arameters"set6alue%count1 7CO8+27&for %int i , A- iBresults"length- i@@& * Display5ttr6alue>? alsString partnumString desc44<et part num als , results>i?"get%75C0anufacturer#art+um!er7&partnum , als"length D A E als>A?"getDisplayString%& F 7null744<et description als , results>i?"get%75CDescription7&desc , als"length D A E als>A?"getDisplayString%& F 7null7if %partnum"length%& D GH& * partnum , partnum"su!string%A1GH&-

3 if %desc"length%& D 4A& * desc , desc"su!string%A14A&3 ta!le"appendRo$%&ta!le"set6alue%partnum1 7052+R7&ta!le"set6alue%desc1 705;2=7&3 p2a!le#arameters"set6alue%ta!le1 7R(S8L2925:7&3 else * p()port#arameters"set6alue%7A71 7CO8+27&3 3 catch %()ception e)c& * e)c"printStacI2race%&3 3

Вам также может понравиться