0% found this document useful (0 votes)
89 views

Create Odata Service Using RFC FM

Odata service

Uploaded by

raju.knvs1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
89 views

Create Odata Service Using RFC FM

Odata service

Uploaded by

raju.knvs1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 26
Made By Rahul sharma SAP ADAP Associate Consultant ‘create Odata Service Using Remote Enabled Function Module First Let's create a2 Custom RFC function Module that will be to save enquiry details and another will be to get enquiry detals for that first lets create a custom ztable for enquiry details, Name of rtable ~zenquiry_detal ©) Database table ZenauiRy DETAILS [3 view i ee ee Now let's create an RFC FM fo the above table to save data and fetch data tobe use inthe Odata Fist, e's create a function group and goto tcode se80. Give the name of Function Group and press enter. Made By Rahul sharma “SAP ABAP Associate Consultant == ‘mre | [Wea othe ARAPWorthech sams) 5 [ee Reyourentfothe nt ent ot ABA elm? r ra Create Function ou x oon 25TH DEANS Jeminod ‘Give the short text and ck on save and save it inthe package. =I (Racin —~] ff] Welcome tot a nam [B) Sv) [Are you ready for tt copcnone | catoknn Ara 2 Viszs0 gee? Stn ose > tated came Desay > we > cate "es Sees Made By Rahul sharma ‘SAP ABAP Associate Consultant Now Activate it. Now, Go to t-code se37 and give the name of Fm -zenquiry_detals. Be Ot TG A remy aaa Hose lick on create, ‘Create Function Module x netin Mot [2ENOUTRY_DETAILS Function group: [280 ENQUIRY DETATLS Shor text Enguity Detail vswe Xx ‘Give the details ke function group, shorttext and click on save. vases met oes ans same ce en =p ener roe "Now go to attributes and click on re radiobutton, Made By Rahul sharma “SAP ABAP Associate Consultant aun: = ‘Bot Ghangng Tees scepter Source cade o Te wseae © ewte nce rng ings] vane rm ncn 2 mecomontaaingis fe] aie re Son ica ca ‘Declare the Above importing parameter with pass-by value. unter most pot Chowhe Tbe Gente Snacecte Boo) coeur = one 9 ‘And Declare exporting parameter with passby value also. Now, gt the source code tab and write code ther, Ce ee ‘utes ingot Expt Cragg Tables acetone Source cde Made By Rahul sharma ‘SAP ABAP Associate Consultant ‘ite the below code in FM suwbaes Iman eierchrgg Tables scp: souce cose "Now, Let's test our Fm whether itis saving the data in ztable or not. Fillin the above details. Made By Rahul sharma “SAP ABAP Associate Consultant ‘We can see the message that enquiry details have been successfully created. Let's check the data inthe 2table. ‘We can see the data has been successfully created. [Now let's create another FM which will get details of RFC FM, runcion Modul: ENQUIRY_DETATLS_get a 7 change {Go to 5037 give the FM name and click onthe Create button. Made By Rahul sharma ‘SAP ABAP Associate Consultant = Create Function Module x Function Moaut:* | ZENQUIRY_DETAILS_GET Function group:* [250 _ENOUIRY_DETATLS ‘Shor text * Enq Det vswe x ‘Give the details ke Function Group, and short text, and click onthe save button. ‘vos mor yor argh Tes cepts sue cae Pecsere corestoms epi ase ren te BE {0 renew betas es chp BET ‘Goto the Attribute tab and select re radiobutton to make it aremote-enabled function module. ves most pot Cimpre hes Gls Soueecse aoe = io joel sl "Now go to the Import parameter tab, and give 1D no. there. sa oo ee rere = a = a cy | Made By Rahul sharma “SAP ABAP Associate Consultant Inthe export parameter tab give the above information. Auwbutes impor Expat Charging Tebles Exceptions Source code Now go to the source code tab and writ the code there. ee ee uybtesompot ge Charge Tables eelons seucecooe Bib ‘ite the Above code. Now let's tes it. Made By Rahul sharma “SAP ABAP Associate Consultant ‘Wecan seit is fetching the above detail ‘Now we have tested both fet and they are working fine, Let's create an Oda service. es seed YJ = bk me vA \ 9 SAP Menu Goto t-code segw Made By Rahul sharma “SAP ABAP Associate Consultant | more v (Al fal fe) [1 '6) fe|[>) > (f MO_C_PRODUCT_MAINTAIN ‘lick on Create Project. Create Project. x Project [ZENQUIRY_DETATLS Description» [Enquiry Det Attributes Project Type [Senvce with SAP Annotations vy] Generation Strategy: Standard v] Object Directory Entry Package:*[STHP Person Responsible» [BEST Y Local object ‘Give the above details ike the Project name and description and save it. Now right- wea oat D> zc testaec oF 0 ve zenourer_neranis ely Boy a BOE oy o q 0 > gue > 0 >e2 a > z_Meat__ >) Reta Mocet trom Fie ogra (0 >2i Revie >) poe Smee 'ssocu > B21 pede > |__FCIBOR mnertace jyRDo Oo >e2 Seep 1 Ea fetrence >| Sern le ES Oe ps custon a senicet Gm orn ‘A3step witard ville Opened. Fillin the details: Like entity type toca radiobutton Tye Name " Made By Rahul sharma “SAP ABAP Associate Consultant ‘lek on next button. O89 2 Bf Gower e cn owe a = acon 6 cman owe a = 8 Gnet ewe ‘Selec al the fells and dle on next. 2 Made By Rahul sharma SAP ABAP associate Consultant ‘Give Key Fields to and click on finish. \ ZENQUIRY_DETAILS \ eS\Data Model’ Entity Types > == ZENQURY Co Associations v WEntiy Sets == ZENOURYSet I Here we can see now entity types and entity sets have been created. Now, expand service implementation, then zenguiryset then select getEntity and then right click and select map to datasource. 13 Made By Rahul sharma veaemysm = ZENQURYSet © Senco inplenentaon Vea ZENOURYSet 9 cca dee wise 3G Gete, 28 Ups Display [Runtime & > Da Service M > (&ZKK_PO_DE] (> GzonaTa_se| Target System @ Locat © Remote RFC Destination: Data Source Attributes Type: Name: ‘Map to Data Source Go to ABAP Workbench Details “SAP ABAP Associate Consultant ‘Map to Data Source x Remote Function Gall ‘zenquiry_details_get v ® Here give the RFC type and in the name give the name of FM zenquiry details got. And click on the Continue select button propose mapping. 1“ Made By Rahul sharma “SAP ABAP Associate Consultant cgjastafacae |e) Here we can see lelds automatically populate now. |WE CAN SEE WE HAVE SOME ERRORS TO RESOLVE OUR ERROR FOLLOW THE BELOW STEPS ‘As we knowin the FM -zenguiry_ detail get we have an 1D importing parameter we will add to our enquirset. FTN) (e115) sey cron cry a 22a =) I) Gi) Rrra) = cI ‘lic on INSERT ROW at the top. 15 Made By Rahul sharma SAP ADAP Associate Consultant 11 pint Operon ty un) te ZENGURYSAt @ COO BH SL OE rms) fecal 38) Soy Setar Comte vie ML. bata seen Puree a] No evan © awn Insert id input sing the 4 key. ‘You wil se IN_id with the input fed as been added in zenquiryset. you want to change the direction you can double click on direction and you can change the retin, Now we can check f there is any error oF not. ‘We can see there sno error in our zenquityset Now we are done with the get data part, now it's to implement create entity to create the data, 6 Made By Rahul sharma “SAP ABAP Associate Consultant He O88 FS & > (no_€ pROOUET MAINTAIN 3 Seo cero # em re cori [ae Gam <__] one SRE — feast 2 Baan otis cf eo “tm tot — Coa Y SaEAty pes | moste © osu Co Associations: s - a ee ~ Serie lemeton (™ [rZ010URY_DETALS hs ben coe nec naings Right-click on Create then map tothe data source. = Map to Data Source x ‘Target System © toeat © Remote Dota Source Atibutes ‘yp: [Remote Funcfon Call vx ‘Give the details tke the type and name of RFC FM which s creating our entry and click on continue. 7 Made By Rahul sharma “SAP ABAP Associate Consultant Fae ee a senso B08 OOO GO sy Osman) Gon oso eos aio) ‘We are goting the error message now click onthe Fé button of datasource parameter ON ex_message and select ex. message. ~ a ZENOURY_DETALS, fewno ae lessace iwosue ETL MeSsAce Made By Rahul sharma ‘SAP ABAP Associate Consultant ae sae a Secmmann LOCO OSO OO CO ‘We can see datasource parameter and direction has been changed for exmessage. [Now check and generate it. ea o2ase Gia oaoeo ss am ‘lick on generate button. ¥) More Aral) [11 [e1/>) macping ot operation creste 8H oo > (WO_C_PRODUCT_WAINTAIN o [> S0_PRICING_coNorTrONRECOMg 8 |Pr- Entty Set property 1 > zap 1] enane 5 > z01_resr are ole 5g zenavtny-DeTAILS ] Nero wea mae rife oie ) SEM Tyee 5 eaesace 7S ee zehQUR 1° Made By Rahul sharma “SAP ABAP Associate Consultant = Model and Senice Defnton x Mode Provider Class ‘Bese Class Nam” [2CL_ZENOUIRY DETAILS WC Data Provider Class ss Nam: [2CL_ZENOUTRY_DETATLS_DPC_EXT ‘Bose Class Name: [2CL_ZENOUIRY_DETATLS_DPC Service Regisvation Tectiea Met Name [ZENOUIRY_DETATLS OL Teeticl Service Nane:* [ZENQUTRY_DETATLS SRV Y contin ‘lic on continue and save tin the local abject. "Now lets check the method of dpc_ext class of create_entity and get_entity. Made By Rahul sharma “SAP ABAP Associate Consultant ‘We can see sap automatically creates the code inthe create and get_entity methods [Now lets register our service. a Made By Rahul sharma ‘SAP ABAP Associate Consultant ‘lick on the local object and click on the continue button. ‘We can ee our service status turned green. ‘lick on maintain. (@ essere) [@ Dae evi] [seri Dan] (Dw “Type Teeeal serie Nave ve seve omerpzon ene ‘BEPZENGURYDETALS.GRY SV ErmuryOWe ICF Nodes system Ala (erate a A ST seme SS os a ‘Double click on service and execute the sap gateway client. Fist lets check whether our service working or not Made By Rahul sharma “SAP ABAP Associate Consultant © Comm 4 ese merken Qseernpanmm Some a MHL ‘We can see our service working fine Sede === ea [Now let's read 1 existing record and later we can use the same record to create anew record using the post option. “Toread select entity set. EntitySets (1) 1 Entry found Restrictions Use below URI to read the data, 2 Made By Rahul sharma ‘SAP ABAP Associate Consultant ‘ce inn GU ATA Neo TAarpad —————— > a Here we are getting below data. a ae eRe ESS [OSes ae) ‘We can see In our able we have already entries with id 1000000000, 1000000001. [Now create a record with anew key. ‘lick on use as request ss en a ren ss ITP Respro Poss Te 1095 ms ©] Qe) Cesare] (Fenrir) (Frm) (5 Bate =p ww eaten Made By Rahul sharma ‘SAP ABAP Associate Consultant Scegoens nenaes env. anane™| 105 ‘esting of RFC EM using odata service", f12s01 58 Facet 5) “= ietaaacar + 4 Sheepi/ 1542024. denoz_com:8021/290/ pa odata/ sap/2MG0TRY_DETAL : ‘Sheep: //at2i2i.sencs-coms021/aup/pa/oasea/e4p/ Sea BETA, 4 ‘Change the 1D key and message. Made By Rahul sharma SAP ABAP associate Consultant ‘We can see the message code 201 with created Lets check our stable, = ee We can see the data also saved in our able Inthis we use RFCEM %

You might also like