Documente Academic
Documente Profesional
Documente Cultură
SAPNetWeaverGatewayDeveloperCenter...|SCN
GettingStarted Newsletters
Hi,Guest
LogOn
JoinUs
Products
Services&Support
AboutSCN
Downloads
Industries
Training&Education
Partnership
DeveloperCenter
Activity
LinesofBusiness
UniversityAlliances
Events&Webinars
Innovation
Browse
SAPNetWeaverGatewayDeveloperCenter 23Posts
Store
SearchtheCommunity
Communications
Actions
1 2
ODATAGATEWAYSINGLESIGNON
PostedbyJagdishGhatageDec12,2014
Previous
Next
Belowarethescreenshotsformakingthegatewayserviceassinglesignon:
OnceapplicationisdevelopedinSEGW,useTcode/IWFND/MAINT_SERVICEforregisteringthe
service
ClickonAddServicebuttontoadd/registertheservice.Belowscreenwillappearonceyou
clickonbutton
FillalltherequiredfieldswithserviceclassnameandpressEnter.
http://scn.sap.com/community/developercenter/netweavergateway/blog
1/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
ServicenamewillappearinSelectBackendServicessection.
Clickonservicename,onepopupwillappearasperthebelowscreenshot.
Aspertheabovescreenshot,youwillfindlastrowasOAuthenablement.Whichwillbe
uncheckedbydefault.ClickoncheckboxtomaketheserviceavailableonSingleSignOn.
AboveallthestepsaretomakeODATAservicesinglesignon.
415Views
1Comments
Tags:sap_netweaver_gateway
GatewayService:OptimizingPerformancewithSQL
Paging
PostedbyJrgKnausDec3,2014
IdidsomePerformanceAnalysisofGatewayServices.MyFocusinthisBLOGisonGET_ENTITYSETMethodswitha
HighNumberofDatabaseEntriesselected,forinstancealotofsalesordersetc.whereitisforperformancereasons
notpossibletoloadalldataintheinitialrequesttotheclient/BrowserandavoidfurthercallsofGETMethod,sofurther
dataisloadedwhentheusersscrollsdownorchangefilters.becausetheserviceisstateless,i'vefoundalotof
expensivesqlstatementsinthetrace.
asofGateway2.0therewillbea'limitedstateful'modecalledsoftstate,seelink:
58760
http://scn.sap.com/docs/DOC
butstatefulgivesotherissues(ressources/memory),andRESTwasdesignedstateless(seenote1986626)
whenlookingatsomestandardfiorigatewayserviceslikesalesorder,thiswasdonelikethis:
CL_LORD_MY_QUOTATION_DPC_EXT
QUOTATIONSET_GET_ENTITYSET
METHODquotationset_get_entityset.
...
"initializepaging,iftopisnotprovided0ispassed.
"noneedtocheckskip,top.Theyareexpectedtobenumbers.ODATAGateway
checksandprovidesus
"numericdata
IFis_pagingtopISNOTINITIAL.
lv_max=is_pagingskip+is_pagingtop.
ENDIF.
...
SELECThead~vbelnhead~auarthead~kunnrASkunagsoldto~name1ASkunag_t
head~angdthead~bnddthead~erdatASerdat_rhead~netwrASnetwr_rhead~waerk
status~gbstk
sdbusiness~bstkdhead~vkorghead~vtweghead~sparthead~vdatustatus~abstk
status~rfstkstatus~uvalsstatus~uvall
UPTOlv_maxROWS
INTOCORRESPONDINGFIELDSOFTABLElt_docs
FROM(lv_from_clause)
http://scn.sap.com/community/developercenter/netweavergateway/blog
2/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
WHEREhead~vbelnINlt_rg_vbeln
...
METHODtruncate_table.
IFiv_skipISNOTINITIAL.
DELETEct_tableTOiv_skip.
ENDIF.
IFiv_topISNOTINITIAL.
DELETEct_tableFROMiv_top+1.
ENDIF.
ENDMETHOD
.
sothegoodthingis,onlythefirstn(50)entriesareselected,butafterseveralscrollrequests,thiswilbe1000and
more.okatleastthedbquerybufferisfilledonthesecondselectstatement,butstillnotverydboptimized.
regardingdboptimized:ilookedatsomehanafioris(XSServer)andtheyareusingSELECTLIMIT50OFFSETn
Statement,sotheycanselecttheDBFrameofRecordsrequired,verynice!
ThiswouldbeniceforABAPaswell.IhopedthattheLIMIT/OFFSETfeaturewouldbeavailablewiththeNEWOPEN
SQLExpressions,butitdidnot(yet)work
ofcourseicanuseNATIVESQLtousethefeature,withtheuseoftheCL_SQL_STATEMENTClass:(alsowithNon
HanaDatabases)
****CreatetheSQLConnectionandpassintheDBCONIDtostatewhichDatabaseConnectionwillbeused
DATAlr_sqlTYPEREFTOcl_sql_statement.
CREATEOBJECTlr_sql
EXPORTING
con_ref=cl_sql_connection=>get_connection('AB1').
****Executeaquery,passinginthequerystringandreceivingaresultsetobject
DATAlr_resultTYPEREFTOcl_sql_result_set.
lr_result=lr_sql>execute_query(
|SELECT*FROMSFLIGHTWHEREMANDT={symandt}ANDCARRID='LH'limit200offset0|).
****Alldata(parametersin,resultssetsback)isdoneviadatareferences
DATAlr_sflightTYPEREFTOdata.
GETREFERENCEOFlt_sflightINTOlr_sflight.
****GettheresultdatasetbackintoourABAPinternaltable
lr_result>set_param_table(lr_sflight).
lr_result>next_package().
lr_result>close().
ThenirememberthenewALVIDAwithIntegratedDataAccessandhereiseeanicefeature:(AlsowithnonHana
Databases)
data:
IS_RESTRICTIONSTypeIF_SADL_QUERY_ENGINE_TYPES=>TY_RESTRICTIONS,
IS_AGGREGATIONTypeIF_SADL_QUERY_ENGINE_TYPES=>TY_AGGREGATION,
IT_SORT_ELEMENTSTypeIF_SADL_QUERY_ENGINE_TYPES=>TT_SORT_ELEMENTS,
IS_REQUESTEDTypeIF_SADL_QUERY_ENGINE_TYPES=>TY_REQUESTED,
IS_PAGINGTypeIF_SADL_QUERY_ENGINE_TYPES=>TY_PAGING,
IS_PARAMETERSTypeIF_SADL_QUERY_ENGINE_TYPES=>TY_PARAMETERS,
EV_NUMBER_HITSTypeI,
EV_NUMBER_ALL_HITSTypeI.
data:row_counttypei.
data:it_rangestypeIF_SALV_SERVICE_TYPES=>YT_NAMED_RANGES.
data:wa_rangelikelineofit_ranges.
data:lt_sbooktypetableofsbook.
DATAms_view_metadataTYPEif_sadl_view_db=>ty_view_metadata.
cl_salv_ida_services=>create_entity_and_abqi(
exportingiv_entity_id=conv#('SBOOK')
iv_entity_type=cl_sadl_entity_factory=>co_typeddic_table_view
importingeo_entity=data(lo_entity)
eo_abqi=data(lo_abqi)).
data(lo_ida_structdescr)=cl_salv_ida_structdescr=>create_for_sadl_entity(
io_entity=lo_entity).
*io_calc_field_handler=io_calc_field_handler).
http://scn.sap.com/community/developercenter/netweavergateway/blog
3/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
data(lo_query_engine)=newcl_salv_ida_query_engine(io_structdescr_prov=lo_ida_structdescr
io_sadl_engine=lo_abqi).
data(lo_idas)=cl_salv_ida_services=>create(io_structdescr_prov=lo_ida_structdescr
io_query_engine=lo_query_engine).
is_pagingstart_row=10.
is_pagingmaximum_rows=20.
refreshit_ranges.
wa_rangename='CARRID'.
wa_rangeoption='EQ'.
wa_rangesign='I'.
wa_rangelow='LH'.
appendwa_rangetoit_ranges.
lo_idas>get_query_engine()>set_selection_range_tab(it_ranges=it_ranges).
LO_ABQI>select(
EXPORTING"is_text_search=ls_text_search
"is_aggregation=VALUE#(count_alias=l_count_alias)
is_requested=VALUE#("fill_number_all_hits=abap_FALSE
"elements=t_group_by_fields
elements=VALUE#((`CARRID`)(`FLDATE`))fill_data=abap_true)
"is_parameters=ms_parameters
is_paging=is_paging
IMPORTING"ev_number_all_hits=row_count).
et_DATA_ROWS=LT_SBOOK).
finally,theIDAdoesnothingelsebutcallingCL_SQL_STATEMENTwithSELECTLIMITnOFFSETx
ihopeyoualsocanusethis:)
401Views
0Comments
Tags:hana,abap,sap_netweaver_gateway,gateway,odata
FileUpload/DownloadinCRMWebUIUsingNet
weaverGateway/ODataServices
PostedbyRamprasadBoyapatiNov12,2014
1).StepbySteptouploadthefileattachmentinCRMWebUIusingNet
WeaverGateway.
CreatetheprojectinSEGWTransactionCodeandtheEntityType:
IntheEntityTypePropertiesselectthecheckbox:Media
AndthepropertiesofEntityTypeare:
AndthenmaptheRFCfunctionmodulefortheCreateOperationintheEntitySet.
http://scn.sap.com/community/developercenter/netweavergateway/blog
4/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
AnddothemappingforGetEntity(Read)OperationintheEntitySet.
ThenRedefinetheDEFINEmethodinthe*MPC_EXTclassandaddthebelowlogic:
METHODdefine.
super>define().
DATA:lo_entityTYPEREFTO/iwbep/if_mgw_odata_entity_typ,
lo_propertyTYPEREFTO/iwbep/if_mgw_odata_property.
lo_entity=model>get_entity_type(iv_entity_name='TerritoryFileAttachment').
IFlo_entityISBOUND.
lo_property=lo_entity>get_property(iv_property_name='MIME_TYPE').
IFlo_propertyISBOUND.
lo_property>set_as_content_type().
ENDIF.
ENDIF.
ENDMETHOD.
ThenRedefinetheCREATE_STREAMMethod(/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_STREAM)inthe
*DPC_EXTclassandimplementthebelowlogictouploadthefileattachmentintotheCRMWebUIforagivenTerritory
Plan.
Allinputparameters/valueswehavetogetintotheSLUGparameterfromtheUISide(Ifwehavemultipleinput
parametervaluesthenwithconcatenationofmultipleparametervalueswithdelimiterwehavetogetthevaluesin
SLUGparameter).
METHOD/iwbep/if_mgw_appl_srv_runtime~create_stream.
DATA:ls_file_attachTYPEztp_s_file_attachment,
lv_tp_guidTYPEcrm_mktpl_ib_mpl_guid,
ls_keyTYPE/iwbep/s_mgw_tech_pair,
lt_keysTYPE/iwbep/t_mgw_tech_pairs,
lv_entityset_nameTYPEstring,
lv_entity_nameTYPEstring,
lo_tech_read_request_contextTYPEREFTO/iwbep/cl_sb_gen_read_aftr_crt,
ls_entityTYPEREFTOdata,
ls_stringTYPEstring.
DATA:ls_boTYPEsibflporb,
lt_propertiesTYPEsdokproptys,
ls_propertiesTYPEsdokpropty,
lt_file_accessTYPEsdokfilacis,
ls_file_accessTYPEsdokfilaci,
lt_file_content_binaryTYPEsdokcntbins,
ls_loioTYPEskwf_io,
ls_phioTYPEskwf_io,
ls_errorTYPEskwf_error,
http://scn.sap.com/community/developercenter/netweavergateway/blog
5/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
lv_file_sizeTYPEi,
lt_messagesTYPEzif_zdmtp_service=>bapiret2_t,
ls_messagesTYPEbapiret2,
lo_dp_facadeTYPEREFTO/iwbep/if_mgw_dp_facade,
lv_destinationTYPErfcdest,
lr_dmtp_serviceTYPEREFTOzcl_dmtp_service,
lv_tp_idTYPEcrm_mktpl_campaignid.
FIELDSYMBOLS:<ls_data>TYPEany.
CLEAR:ls_file_attach,lv_tp_guid,ls_bo,lt_properties,ls_properties,
lt_file_access,ls_file_access,lt_file_content_binary,ls_loio,
ls_phio,ls_error,lv_file_size.
***IV_SLUGparameterwillbepassedfromthefrontendside
SPLITiv_slugAT'/'INTOls_file_attachtp_id
ls_file_attachfilename
ls_file_attachname
ls_file_attachdescription.
****FileType(MIMETYPE)****
ls_file_attachmime_type=is_media_resourcemime_type.
****FileContentinXSTRING.*****
ls_file_attachfile_value=is_media_resourcevalue.
****ConverttheTerritoryPlanIDintoGUID****
CALLFUNCTION'CONVERSION_EXIT_CGPLP_INPUT'
EXPORTING
input=ls_file_attachtp_id
IMPORTING
output=lv_tp_guid.
****BuildAttachmentBusinessObject****
ls_bocatid='BO'.
ls_botypeid='BUS2010010'.
ls_boinstid=lv_tp_guid.
****BuildAttachmentProperties****
ls_propertiesname='KW_RELATIVE_URL'."NAME
ls_propertiesvalue=ls_file_attachname.
APPENDls_propertiesTOlt_properties.
CLEARls_properties.
ls_propertiesname='DESCRIPTION'."DESCRIPTION
ls_propertiesvalue=ls_file_attachdescription.
APPENDls_propertiesTOlt_properties.
CLEARls_properties.
ls_propertiesname='MIMETYPE'."MIMETYPE
ls_propertiesvalue=ls_file_attachmime_type.
APPENDls_propertiesTOlt_properties.
CLEARls_properties.
****ConverttheAttachmentFileDatafromXSTRINGtoBINARY****
CALLFUNCTION'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer=ls_file_attachfile_value
IMPORTING
output_length=lv_file_size
TABLES
binary_tab=lt_file_content_binary.
****BuildFileAccessInformation****
ls_file_accessfile_size=lv_file_size.
http://scn.sap.com/community/developercenter/netweavergateway/blog
6/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
ls_file_accessbinary_flg=abap_true.
ls_file_accessfile_name=ls_file_attachfilename.
ls_file_accessmimetype=ls_file_attachmime_type.
APPENDls_file_accessTOlt_file_access.
CLEARls_file_access.
****UploadtheAttachmentforTerritoryPlaninCRMWEBUI****
CALLMETHODcl_crm_documents=>create_with_table
EXPORTING
business_object=ls_bo
properties=lt_properties
file_access_info=lt_file_access
file_content_binary=lt_file_content_binary
IMPORTING
loio=ls_loio
phio=ls_phio
error=ls_error.
IFls_errorISINITIAL.
ls_file_attachfile_loio_guid=ls_loioobjid.
ELSE.
ls_messagesid=ls_errorid.
ls_messagesnumber=ls_errorno.
ls_messagestype=ls_errortype.
ls_messagesmessage_v1=ls_errorv1.
ls_messagesmessage_v2=ls_errorv2.
ls_messagesmessage_v3=ls_errorv3.
ls_messagesmessage_v4=ls_errorv4.
APPENDls_messagesTOlt_messages.
me>/iwbep/if_sb_dpc_comm_services~rfc_save_log(
EXPORTING
iv_entity_type=iv_entity_name
it_return=lt_messages
it_key_tab=it_key_tab).
****CallRFCcommitwork****
me>/iwbep/if_sb_dpc_comm_services~commit_work(
EXPORTING
iv_rfc_dest=lv_destination).
RETURN.
ENDIF.
**
*****ReadAfterCreate******
**
CREATEOBJECTlo_tech_read_request_context.
*Createkeytableforthereadoperation
ls_keyname='TP_ID'.
ls_keyvalue=ls_file_attachtp_id.
APPENDls_keyTOlt_keys.
ls_keyname='FILENAME'.
ls_keyvalue=ls_file_attachfilename.
APPENDls_keyTOlt_keys.
ls_keyname='IV_OBJECT'.
ls_keyvalue='FILEATTACH'.
APPENDls_keyTOlt_keys.
ls_keyname='FILE_LOIO_GUID'.
ls_keyvalue=ls_file_attachfile_loio_guid.
APPENDls_keyTOlt_keys.
****Setintorequestcontextobjectthekeytableandtheentitysetname****
http://scn.sap.com/community/developercenter/netweavergateway/blog
7/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
lo_tech_read_request_context>set_keys(IMPORTINGet_keys=lt_keys).
lv_entityset_name=io_tech_request_context>get_entity_set_name().
lo_tech_read_request_context>set_entityset_name(IMPORTINGev_entityset_name=
lv_entityset_name).
****Callreadaftercreate****
/iwbep/if_mgw_appl_srv_runtime~get_entity(
EXPORTING
iv_entity_name=iv_entity_name
iv_entity_set_name=iv_entity_set_name
iv_source_name=iv_source_name
it_key_tab=it_key_tab
io_tech_request_context=lo_tech_read_request_context
it_navigation_path=it_navigation_path
IMPORTING
er_entity=ls_entity).
****Sendthereadresponsetothecallerinterface****
ASSIGNls_entity>*TO<ls_data>.
IF<ls_data>ISASSIGNED.
copy_data_to_ref(
EXPORTING
is_data=<ls_data>
CHANGING
cr_data=er_entity).
ENDIF.
ENDIF.
ENDMETHOD.
OncetheCREATE_STREAMmethodredefinesisdonethenwecantesttheserviceusingtheRESTClienttoupload
thefileattachmentintoCRMWebUIforTerritoryPlan.
PleaseNote:Maximumfilesize30MBwillallowtouploadthefilefromCRMWebUIstandardfunctionality.
TesttheserviceusingtheRestclient.
FirstgettheCSRFTokenvaluewhilecallingbelowservice.
ThenintheresponsewewillgettheCSRFTokenValue.
ThengivetheCSRFTokenvalueandSLUGparameterintheHeadersandchoosethefiletouploaditviaOData
Service.OnceweclickonsendthenfilewillbeuploadedinCRMWebUIforagivenTerritoryPlan.
http://scn.sap.com/community/developercenter/netweavergateway/blog
8/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
2).StepbySteptoRead/DownloadthefileattachmentfromCRMWebUI
usingNetWeaverGateway.
ContinuationwithStep1,RedefinetheGET_STREAMMethod
(/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM)inthe*DPC_EXTclassandimplementthebelowlogicto
read/downloadthefileattachmentfromtheCRMWebUIforagivenTerritoryPlan.
METHOD/iwbep/if_mgw_appl_srv_runtime~get_stream.
DATA:ls_key_tabTYPELINEOF/iwbep/t_mgw_name_value_pair,
ls_streamTYPEty_s_media_resource,
is_file_attachmentTYPEztp_s_file_attachment,
es_file_attachTYPEztp_s_file_attachment,
lv_media_valueTYPExstringval,
lv_mime_typeTYPEstring,
lo_dataTYPEREFTOzcl_dmtp_service,
ls_headerTYPEihttpnvp.
****ReadtheKeyFieldValues****
CLEAR:is_file_attachment,ls_key_tab.
READTABLEit_key_tabINTOls_key_tabWITHKEYname='TP_ID'.
IFsysubrc=0.
is_file_attachmenttp_id=ls_key_tabvalue.
ENDIF.
CLEARls_key_tab.
READTABLEit_key_tabINTOls_key_tabWITHKEYname='FILENAME'.
IFsysubrc=0.
is_file_attachmentfilename=ls_key_tabvalue.
ENDIF.
CLEARls_key_tab.
READTABLEit_key_tabINTOls_key_tabWITHKEYname='IV_OBJECT'.
IFsysubrc=0.
is_file_attachmentiv_object=ls_key_tabvalue.
ENDIF.
CLEARls_key_tab.
READTABLEit_key_tabINTOls_key_tabWITHKEYname='FILE_LOIO_GUID'.
IFsysubrc=0.
is_file_attachmentfile_loio_guid=ls_key_tabvalue.
ENDIF.
****ReadFileAttachmentforTerritoryPlan****
DATA:ls_loioTYPEskwf_io,
lt_loioTYPEskwf_ios,
lt_properties_resultTYPEcrm_kw_propst,
ls_properties_resultTYPEcrm_kw_props,
ls_errorTYPEskwf_error,
lt_file_content_asciiTYPEsdokcntascs,
lt_file_content_binaryTYPEsdokcntbins,
lt_file_accessTYPEsdokfilacis,
ls_file_accessTYPEsdokfilaci,
iv_lengthTYPEi,
ls_boTYPEsibflporb,
lv_tp_guidTYPEcrm_mktpl_ib_mpl_guid,
ls_doc_propertyTYPEsdokproptl.
CLEAR:ls_loio,lt_file_access,lt_file_content_ascii,lt_file_content_binary,
ls_error,iv_length,ls_bo,lv_tp_guid,lt_properties_result,lt_loio,
ls_properties_result,ls_doc_property.
****ConverttheTerritoryPlanIDintoGUID****
CALLFUNCTION'CONVERSION_EXIT_CGPLP_INPUT'
EXPORTING
input=is_file_attachmenttp_id
http://scn.sap.com/community/developercenter/netweavergateway/blog
9/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
IMPORTING
output=lv_tp_guid.
****BuildAttachmentBusinessObject****
ls_bocatid='BO'.
ls_botypeid='BUS2010010'.
ls_boinstid=lv_tp_guid.
****GettheAttachmentPropertiesinformation****
CALLMETHODcl_crm_documents=>get_info
EXPORTING
business_object=ls_bo
IMPORTING
ios_properties_result=lt_properties_result
loios=lt_loio.
****ReadtheFileAttachmentLOIOGUIDandClasssandObjecttype****
READTABLElt_loioINTOls_loioWITHKEYobjid=is_file_attachment
file_loio_guid.
IFsysubrcEQ0.
******GettheFileAttachmentDatainBinary******
CALLMETHODcl_crm_documents=>get_with_table
EXPORTING
loio=ls_loio
IMPORTING
file_access_info=lt_file_access
file_content_ascii=lt_file_content_ascii
file_content_binary=lt_file_content_binary
error=ls_error.
IFls_errorISINITIAL.
es_file_attachmentiv_object=is_file_attachmentiv_object.
es_file_attachmenttp_id=is_file_attachmenttp_id.
es_file_attachmentfilename=is_file_attachmentfilename.
es_file_attachmentfile_loio_guid=is_file_attachmentfile_loio_guid.
********ReadFileMIMETYPEandFileSize********
READTABLElt_file_accessINTOls_file_accessINDEX1.
IFsysubrcEQ0.
es_file_attachmentmime_type=ls_file_accessmimetype.
iv_length=ls_file_accessfile_size.
ENDIF.
********ReadAttachmentNAMEandDESCRIPTIONvalues********
READTABLElt_properties_resultINTOls_properties_resultWITHKEYobjtype=
ls_loioobjtype
class=
ls_loioclass
objid=
ls_loioobjid.
IFsysubrcEQ0.
**********ReadNAME**********
CLEARls_doc_property.
READTABLEls_properties_resultpropertiesINTOls_doc_propertyWITHKEYname=
'KW_RELATIVE_URL'.
IFsysubrcEQ0.
es_file_attachmentname=ls_doc_propertyvalue.
ENDIF.
**********ReadDESCRIPTION***********
CLEARls_doc_property.
READTABLEls_properties_resultpropertiesINTOls_doc_propertyWITHKEYname=
'DESCRIPTION'.
IFsysubrcEQ0.
es_file_attachmentdescription=ls_doc_propertyvalue.
http://scn.sap.com/community/developercenter/netweavergateway/blog
10/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
ENDIF.
ENDIF.
IFlt_file_content_binaryISINITIAL.
******Iffileattachmentformatis.TXTthenConvertASCIItoBINARY*****
CALLFUNCTION'SCMS_TEXT_TO_BINARY'
IMPORTING
output_length=iv_length
TABLES
text_tab=lt_file_content_ascii
binary_tab=lt_file_content_binary
EXCEPTIONS
failed=1
OTHERS=2.
IFsysubrc<>0.
**Implementsuitableerrorhandlinghere
ENDIF.
ENDIF.
******ConvertBinaryDatatoXSTRING********
CALLFUNCTION'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length=iv_length
IMPORTING
buffer=es_file_attachmentfile_value
TABLES
binary_tab=lt_file_content_binary
EXCEPTIONS
failed=1
OTHERS=2.
IFsysubrc<>0.
***Implementsuitableerrorhandlinghere
ENDIF.
ENDIF.
ENDIF.
************
IFes_file_attachmentISNOTINITIAL.
******MovetheFileType(MIMETYPE)valuetothefinalworkarea********
ls_streammime_type=es_file_attachmentmime_type.
******MovetheFileContentinXSTRINGtothefinalworkarea**********
ls_streamvalue=es_file_attachmentfile_value.
*******FilltheFileHeaderInformationtodisplaytheactualfilenamewhiledownloadingthefile
attachment********
ls_headername='ContentDisposition'.
ls_headervalue='inlinefilename="'.
CONCATENATEls_headervaluels_file_attachfilename'"'INTOls_headervalue.
set_header(is_header=ls_header).
ENDIF.
CALLMETHODme>copy_data_to_ref
EXPORTING
is_data=ls_stream
CHANGING
cr_data=er_stream.
ENDMETHOD.
OncetheGET_STREAMmethodredefinesisdonethenwecantesttheserviceusingtheRESTClientto
http://scn.sap.com/community/developercenter/netweavergateway/blog
11/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Read/DownloadthefileattachmentfromCRMWebUIforTerritoryPlanusingODataService.
TotesttheserviceforReading/DownloadingthecorrespondingfilefromCRMWebUIcalltheserviceinchrome
Browserwithallkeyfieldparametervalueswith$value.
https://<Host:Port>/sap/opu/odata/sap/ZSN_DM_TP_SRV/TerritoryFileAttachmentSet(TP_ID='CRM
XN14CRM
1292',FILENAME='roadmap.docx',IV_OBJECT='',FILE_LOIO_GUID='005056A501651ED48FB13A5BB66964C9')/$value
511Views
3Comments
Tags:sap_netweaver_gateway,odata,odata_services,customer_relationship_management,sapui5,service_builder
CustomheaderparametersinGateway
PostedbyArshadAnsaryNov10,2014
IstartedoffwithGWlearningaspartofmynewUI5project.AsyouallknowGatewayisaframeworktoexposetherich
backendSAPdataintheformofODATAprotocol.Iamnotgoingtogivesomanymotherhoodstatementsasitiswell
documentedelsewhere
Now..TheProblemStatement
Duringsomanyscenarios,IcameacrossacommonrequirementtopasssomeHTTPrequestheaderparameters.
Totellonesamplescenario,thereisanentitytypeExemption.ThisentitytypeExemptioncanbe'Requested'or
'Approved'fromabusinessperspectivefromaUIapplication.The'Request'or'Approve'actioncanbedoneinbatch
fortheExemptionrecord.Ifwemodelthisasaproperty(IwillcallittheBusinessAction)inentitytypeExemption,the
problemisthatthepayloadwillhavetorepeatthispropertyforalltherecordsthatitissending.
.Allthemorefroma
modellingperspectiveitdoeslooksillytohaveBusinessActioninthatentitytype
ThenIcameacrossablog http://scn.sap.com/community/developercenter/netweaver
gateway/blog/2013/06/21/odatacustomparametersgatewaycanhavethemtoofrom RonSargeant.This
involvedchangestoboththeGWHubsystemlayerandthebackendBEPlayer.Inourcasewedidnothavedeveloper
authorisationinGWhubsystem.TheGWhubsystemisjustusedforregistrationofbackendservice..
Sowhatstheoptionwehave??
WelcomeMrTrial&Error...
IjusttriedasamplescenariowhereinIsendasampleHTTPrequestheaderparameterandseehowdoesitreachour
BrokerGWandthenultimatelytoUnclebackendshome..
ItiredtosendaCustomparameterviarequestheaderparameterforasampleEntitytype.NowIputthebreakpointin
theourDPCclasscorrespondingentityGET_ENTITYSET.Thevalues
http://scn.sap.com/community/developercenter/netweavergateway/blog
12/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Thispartofdebuggingiscalled'HappyDebugging'
.Iwashappytoseethevaluesappearintheimportingparameterio_tech_request_context
WhenIcheckedindebuggertheio_tech_request_contextisoftype/IWBEP/CL_MGW_REQUESTwith
protectedattributeMR_REQUEST
TheattributeMR_REQUESThasdeepstructureTECHNICAL_REQUESTwhichhasattributeslikebelowand
hasaattributeREQUEST_HEADER
Whenwewentinsidewehavetherequestheaderparameterthatwesetonthejourney...
http://scn.sap.com/community/developercenter/netweavergateway/blog
13/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
NowIthoughtitsjustamatterofreadingthevalues.Itsmatterofreadingvaluesfromio_tech_request_context
>mr_request>request_header...(Sosimple)
Thispartofdebuggingiscalled'NotsohappyDebugging'
IrealisedtheattributeMR_REQUESTisaprotectedattributeandcannotbeaccessedbysimpleassignmenttolocal
variable.
SoWhatstheworkaround?
Imadeasubclassofthestandardclass/IWBEP/CL_MGW_REQUEST..
IwroteamethodGET_REQUEST_HEADER_VALUEwhereintakestherequestcontextobject,headerparameter
andreturnsbackthevalue
Thecodeinsidethemethodforreadingtheheaderparameterisasbelow
data:lo_requesttyperefto/IWBEP/IF_MGW_CORE_SRV_RUNTIME=>TY_S_MGW_REQUEST_CONTEXT,
lt_request_headersTYPEtihttpnvp,
ls_request_headerlikeLINEOFlt_request_headers.
lo_request=io_tech_request_context>mr_request.
lt_request_headers=lo_request>technical_requestrequest_header.
READTABLElt_request_headersintols_request_headerwithkeyname=iv_request_parameter.
ifsysubrceq0.
rv_request_value=ls_request_headervalue.
endif.
Readingthevalue
NowIjustneedtousetheutilitymethodGET_REQUEST_HEADER_VALUEofsubclasstogetthecustomparameter
value.
UsethefollowingcodeinyourCRUDQmethodtoreadtherequestheader
DATA:lo_tech_requestTYPEREFTO/iwbep/cl_mgw_request,
lo_tech_request_subTYPEREFTOzcl_gw_mgw_request,
lt_headersTYPEtihttpnvp,
lv_request_headertypestring,
lv_request_header_valuetypestring.
**CastingandAssigningimportingparametertolocalvariable
http://scn.sap.com/community/developercenter/netweavergateway/blog
14/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
lo_tech_request?=io_tech_request_context.
***Instantialtesubclasswithsomedumyheaderparameters
CREATEOBJECTlo_tech_request_sub
EXPORTING
it_headers=lt_headers..
lv_request_header_value=lo_tech_request_sub>get_request_header_value(EXPORTING
io_tech_request_context=lo_tech_request
iv_request_parameter='customparameter').
TestingthecodeFinalshowdown..
NowinGWclientintheGWhubsystemIrunthebelowURLwithHTTPheaderrequestcustomparameters
NowinthedebuggerofGET_ENTITYSET...
533Views
4Comments
MultideepinsertinSAPGateway(SEGWApproach)
PostedbyAnjorWagleOct30,2014
Hieveryone,
Belowexampleshowshowtopassmultiplenestedtablesasinputtoodata/gateway
serviceusingSEGWapproach.
Wehave6tables.
1.Header(Fields:ID,Name,Message_text)
Item1(Fields:ID,Name1,Address)
Item1.1(Fields:ID,Name,State,Country)
Item1.2(Fields:Fname,Mname,LName)
Item2(Fields:ID,Name,City)
Item2.1(Fields:ID,Name,Pincode,Street)
Item1anditem2areinlinetoHeadertable.
Item1.1anditem1.2areinlinetoitem1table.
Item2.1isinlinetoitem2table
Inmultideepinsert,weshouldbeabletopassmultiplelineitemsinitem1,item1.1,item1.2,item2and
http://scn.sap.com/community/developercenter/netweavergateway/blog
15/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
item2.1alongwiththedatainheaderstructure.
a. e.g.
Inputtotheservice:
Outputfromtheservice:
ValueofMessage_textinheaderstructureischangedtoTest1.
Stepstoachievetheabovescenario:
Step1.Create6entitytypesHeader,Item1anditem2,Item1_1,Item1_2,Item2_1.
Propertiesare:
Header:
Item1:
Item1_1:
Item1_2:
http://scn.sap.com/community/developercenter/netweavergateway/blog
16/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Item2:
Item2_1:
*************************************************************************************************************************************************************
Step2.CreateentitysetsHeaderSet,item1Set,item2Set,item1_1Set,item1_2Set,item2_1Set.
*************************************************************************************************************************************************************
Step3:CreateAssociationsbetweenentitytypes:
1.Headeritem1
2.Headeritem2
3.Item1Item1.1
4.Item1item1.2
5.Item2Item2.1
Navigationpropertiesgetcreatedautomaticallyunderentitytype:header,Item1andItem2
*************************************************************************************************************************************************************
Step4:SaveandCheckforanyerror.
Step5:GenerateRuntimeclassesandServices
Step6:RegisterServiceingatewayhub.
Step7:GotoDPC_ExtclassinABAPWorkbench.
Step8:Redefinemethod/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET
ThismethodisredefinedtogetRequestpayloadofMultideepinsert.
Step9:InsideGET_EXPANDED_ENTITYSET,
http://scn.sap.com/community/developercenter/netweavergateway/blog
17/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
ITEM1TOITEM1_1andITEM1TOITEM1_2arenamesofnavigationpropertiesfortableitem1
ITEM2TOITEM2_1ISnavigationpropertyfortableitem2
HEADERITEM1andHEADERITEM2arenavigationpropertiesfortableheader
InsertdataintheStructures.
Add3entriesintableet_expanded_tech_clausetospecifytoframeworkthatthereareinlineentitiesto
thebaseentity(valuestobeinsertedareNavigationproperties).(Absenceofthiscodewillhitthe
get_expanded_entitysetmethod6timesforalltheentitiescreated.
Insertdataintherespectivestructuresandtables(header,item1and
item2,item1.1,item1.2,item2.1)andAppendthatdatainthefinal
SaveandActivate.
Step10:FormtheURL.
http://scn.sap.com/community/developercenter/netweavergateway/blog
18/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
HTTPmethod:GET
Execute(F8).
******************************************************************************************************************************************************
Step11:UsetheresponsefromtheaboverequesttocreaterequestpayloadofMultiDeepInsert.
(Removefeedtagbelowfirstlineandendfeedtag)
Step12:OnceRequestpayloadisgenerated,redefinemethod
/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY
Inside/IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY,
Declaretheoutputstructure.
Readthedatasentbytheuserthroughrequestpayloadintostructurels_headeritem.
Changethemessage_textofHeaderstructure.
ls_headeritemmessage_text='Test1'.
CallCopy_data_to_refandpassls_header_itemasstructure.
Step13:FormtheURL.
URL:
/sap/opu/odata/sap/ZGW_CREATEDEEP_66883_SRV/headerSet
Method:POST.
Execute(F8).
Thiswaywecanimplementsuchscenarios.
Thanks,
AnjorWagle.
http://scn.sap.com/community/developercenter/netweavergateway/blog
19/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
1647Views
3Comments
SAP(Netweaver)Gateway7.3.1ObsoleteRuntime
Artifactscannotbedeleted
PostedbyDirkRoeckmannJun27,2014
Ifoundout(andI'mnottheonlyone),thatifthegatewaycreatesaninterface,whichshowsupinSEGWunderRuntime
Artifactsandyoudeleteitintheclassbuilder(rightmouseclickvia'GotoABAPWorkbench'fromSEGW),itSTILL
showsupunderRuntimeArtifactsandyoucan'tgetridofit.
That'snotgoodbecauseitcanpileupjunkduringprojectdevelopment.
Herenow,untilthisbugisfixed,abruteforceworkaroundforallsufferers:
Theobjectsarelocatedindatabasetable/IWBEP/I_SBD_GA
http://scn.sap.com/community/developercenter/netweavergateway/blog
20/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Ideletedtheentry(Iknow,it'snotelegant,butitworksfornow)andSEGWiscleanagain:
Andthebestthing,ifyoudothisinthedevelopmentsystem,thechangeswillbeeffectiveintargetsystemsafter
transport.
Nevertheless,SAPplzfixthisbug
692Views
0Comments
Tags:gateway,odata,ui5,fiori
DetailedstepbystepprocedureforCreatingGateway
ServicewithalltheCRUDOperationsandtesting
theminServiceExplorerPart2
PostedbyNageshADec22,2013
Inthefirstpart DetailedstepbystepprocedureforCreatingGatewayServicewithalltheCRUDOperationsand
testingtheminServiceExplorerPart1
Idiscussedthethebelowtopic.
1.CreateserviceinGatewaysystemwithalltheCRUDoperations.(CreateReadUpdateDelete).
Beforestarting,Iamexpectingthatyouareabletocreategatewayserviceoryouhavegonethroughmyprevious
blog.InthisblogiwilldiscussaboutmaintainingourserviceandtestingitinServiceExplorer.
OurServiceName:ZBPS_MATR_DEMO_SRV.
NowweneedtoActivateandMaintainourservice,wewilldothatintransaction/IWFND/MAINT_SERVICE.
a.Firstweneedtolocateandaddourservice.Clickonaddservicebutton.
Entersystemaliasandpressenter.Fromthedisplayedlistlocateourserviceandclickoit.
http://scn.sap.com/community/developercenter/netweavergateway/blog
21/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
SaveitinapackageandclickonOk.
SelecttherequestandclickonOk.Againclickonok.Comebackandclickonourservice.
http://scn.sap.com/community/developercenter/netweavergateway/blog
22/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
b.NowweneedtoaddSystemaliastoourservice,i.e.systemswithwhichwearegoingtointeract.
ClickonCreateSystemaliasbuttonandentertherequiredsystemdetailsandsavethechangesandcome
back.
Savethechangesintherequest.
Nowwecanseeoursystemaliasdetails.
NowwewillexploreourserviceforthatclickonExploreservicebutton.
http://scn.sap.com/community/developercenter/netweavergateway/blog
23/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
ClickonExecutetogetServiceDocument.
ServiceDocument:DescribesthelocationandcapabilitiesofoneormoreCollections.
HerewecancheckourEntitysetnameandwewillgetourServiceURI.
HereourURI:http://<hostname>:
<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/
NowcomebackandnowchooseGetServiceMetadataoptionasshownbelowandclickonexecutetogettheservice
metedata.
http://scn.sap.com/community/developercenter/netweavergateway/blog
24/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
NowwewillgetourserviceMetadata.
ServiceMetadataDocument(MetadataDocument):Describesthedatamodel(i.e.structureandorganizationofallthe
resources)exposedasHTTPendpointsbyanODataservice.
NotetheURIofourserviceandwewilluseitfurther.
URI:http://<hostname>:
<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/$metadata
TestingOurService.
NowwewilltestourserviceinGatewayClienttransactionforthatis/IWFND/GW_CLIENT.
PasteourURIinRequestURIfieldandclickonGetHTTPMethod.
ChecktheServiceMetadata.
http://scn.sap.com/community/developercenter/netweavergateway/blog
25/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
NowwewilltestalltheCRUDoperations.
READ:
HereinURIwecanpassvaluesforkeyfieldsonly.
InourexamplewearetryingtoREADMaterial000000000000000023andwewilldothatinGatewayclient.
URI:http://<hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/matrset('000000000000000023')
PastethisURIagainstRequestURIfieldinGatewayclientandselectHTTPMethodGETandclickonexecute.
Output:
QUERY:
Queryistogetmultipleentriesandherewecanpassrangesforselection.
InourexamplewewilltrytofetchMaterialswithintherange000000000000000023to000000000000000038.
URI:
http://<hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/matrset?$filter=Materialge
'000000000000000023'andMaterialle'000000000000000053'
PastethisURI@RequestURIinGatewayclientandselectHTTPMethodGETandclickonexecute.
Output:Wewillgetthreematerialsinouroutput
http://scn.sap.com/community/developercenter/netweavergateway/blog
26/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
CREATE:
NowwewilltrytocreateMaterial000000000000000016.ForthisfirstwewillREADanexistingmaterialandusing
thatXMLwewillCREATEdesiredmaterial.
FirsttrytoREADMaterial000000000000000023byusingtheURIsameasinourREADoperationinGatewayclient.
NowclickonUseasrequestbuttonasbelow.
WewillgetsameXMLinHTTPRequestBody.MakerequirechangesinthatforMaterialcreation.Hereweneedto
selectHTTPMethodPOSTforCREATEoperationandweneedtochangeURIasbelow.
URI:
http://<hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/matrset
OUTPUT:
http://scn.sap.com/community/developercenter/netweavergateway/blog
27/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
UPDATE:NowwewilltrytoUPDATEtheMaterialjustwehavecreatedthroughCREATEoperation.
Dothesamestepsasincreateoperation,firstreadtheMaterial000000000000000016throughREADoperationand
byusingthatxmlasaRequestwewilltrytoUPDATEMaterialGroupofthatMaterial.
URI:http://<hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/matrset('000000000000000016')
HereMatlGroupis00108,wewillupdatethatto00107andwewillverifyitthroughREADoperation.
ClickonUseasRequestandmakethenecessarychangestotheXMLasbelowandselecttheHTTPMethodPUTfor
Updatingandclickonexecute.
Xml:
<?xmlversion="1.0"encoding="utf8"?>
<entryxml:base="http://<hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/"
xmlns="http://www.w3.org/2005/Atom"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<contenttype="application/xml">
<m:properties>
<d:BaseUom>EA</d:BaseUom>
<d:MatlGroup>00107</d:MatlGroup>
<d:BasicView>X</d:BasicView>
<d:MatlType>ROH</d:MatlType>
<d:IndSector>1</d:IndSector>
<d:Material>000000000000000016</d:Material>
<d:MatlDesc>Testmaterialgateway</d:MatlDesc>
<d:LanguIso>EN</d:LanguIso>
<d:Langu>E</d:Langu>
</m:properties>
</content>
</entry>
http://scn.sap.com/community/developercenter/netweavergateway/blog
28/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
OUTPUT:
NowwewillcheckthatwhetherthatMaterialisupdatedornotbyusingREADoperation.SelecttheHTTPMethodGET
andchecktheoutput.
DELETE:
NowwewilltrytoDELETEtheMaterialwhichwehavecreated,forthisweuseHTTPmethodDELETE.
HeretodeletetheMaterialwewilljustsettheDeleteFlagtoX.Firstwewillreadthatmaterialandusingthatxmlasa
requestwewillprocessDeleteoperation.HerewewillselectHTTPmethodDELETEandexecuteitaftermodifying
xml.
XML:
<?xmlversion="1.0"encoding="utf8"?>
<entryxml:base="http://<hostname>:<port>/sap/opu/odata/sap/ZBPS_MATR_DEMO_SRV/"
xmlns="http://www.w3.org/2005/Atom"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
<contenttype="application/xml">
<m:properties>
http://scn.sap.com/community/developercenter/netweavergateway/blog
29/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
<d:MatlGroup>00107</d:MatlGroup>
<d:Material>000000000000000019</d:Material>
<d:DelFlag>X</d:DelFlag>
</m:properties>
</content>
</entry>
OUTPUT:
WiththiswehavecompletedalltheCRUDoperations.
9358Views
8Comments
DetailedstepbystepprocedureforCreatingGateway
ServicewithalltheCRUDOperationsandtesting
theminServiceExplorerPart1
PostedbyNageshADec22,2013
InthisblogIwillexplainCreatingGatewayservicewithallCRUDoperationsBeforestarting,Iamexpectingthatyou
havebasicideaofgatewayserviceandgatewayservicebuilderi.eSEGW
1.CreateserviceinGatewaysystemwithalltheCRUDoperations.(CreateReadUpdateDelete)
CreateprojectinSEGW(GatewayServiceBuilder).
http://scn.sap.com/community/developercenter/netweavergateway/blog
30/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
OurProjectlooksasbelow.
NowweneedtobuildourDatamodel,forthatfirstCreatetheEntitytypebyimportinganRFCInterface.
GivetheEntitytypename,RFCdestinationandnameoftheRFCtobeimportedandclickonnext
Selecttherequiredpropertiesfortheentitytype.
http://scn.sap.com/community/developercenter/netweavergateway/blog
31/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Setkeypropertyfortheentitytype,herewewillmakeMaterialaskeythenclickonFinish.
OurEntitytypeMATRanditspropertieslookasbelow.
CreateEntitysetwithnecessaryentitytype.
http://scn.sap.com/community/developercenter/netweavergateway/blog
32/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
GiveappropriateEntitysetnameandselectthenecessaryEntitytypethenclickoncontinue.
OurProjectlooksasbelow.
AftercreatingEntitysetServiceimplementationalsocreatedwithemptyCRUDoperationswhichneededtobe
implementedbymappingwithRFC/BORinterface.
Nowweneedsaveourchangeswithinarequest.
Nowclickongeneratebuttontogenerateruntimeartifacts.
DataproviderandModelproviderclasseswillbecreated.Clickonok.
http://scn.sap.com/community/developercenter/netweavergateway/blog
33/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Savethechanges.
Runtimeartifactsaregeneratedandlooksasbelow.
NowweneedtoimplementalltheCRUDoperationsinServiceimplementation.
Create
Read/Query
Update
Delete
CREATE:Thisistocreateanewentry.RightclickoncreateandchooseMaptodatasourceoption.
GivetheRFCdestinationnameandselectrequiredRFCthenclickonok.
Nowclickonproposemapping,thesystemwilldomappingautomaticallyorelsewecandoitmanuallyforrequired
fields.Herenoneedtomapallthepropertiesoftheentitytypewewillmaponlytherequiredproperties.Wewilldothe
mappingbydragdropfromFunctionModuleontodatasourceparameteroftheServiceoperation.
http://scn.sap.com/community/developercenter/netweavergateway/blog
34/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Herealltherequiredfieldswillhaveinputmappingasbelow.
HereinourcaseweneedtopassconstantvaluesforBASE_UOM,MATL_GROUPandBASIC_VIEW,wewilldothat
asfollows.Firstappendtherowsandmaintainvaluesunderconstantvaluetab.
Oncemappingisdonesaveyourchanges.NowwewillimplementDELETEoperation.
DELETE:RightclickonDeleteandchooseMaptodatasourceoption.
GivetheRFCdestinationnameandselectrequiredRFCthenclickonok.Herewearemappingwith
BAPI_MATERIAL_SAVEDATA.
Dotherequiredmappingasfollows.HerewearepassingMaterial,DelFlag,MatlGroupfieldssodothemapping
accordingly.
http://scn.sap.com/community/developercenter/netweavergateway/blog
35/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
READ:RightclickonReadandchooseMaptodatasourceoption.
GivetherequiredRFCanddothemappingasbelow.HerewearemappingMaterial,MatlDesc,IndSector,
MatlType,MatlGroup,BaseUomfields.ExceptMaterialallarehavingoutputmapping.
Note:InREADoperationallkeyfieldsshouldhaveinputmapping,hereinourexampleMaterialiskey.
QUERY:RightclickonQueryandchooseMaptodatasourceoption.
Note:InQueryoperationallkeyfieldsshouldhaveoutputmapping.Herewecanalsomaprangesdirectlytopass
rangevalueforselection.
GivetherequiredRFCanddothemappingasbelow.HerewearemappingwithBAPI_MATERIAL_GETLIST
HerewewillmapMatlDescpropertywithappropriateFunctionfieldandourkeypropertyMaterialwithrangetable,for
thatjustdragdropthatfiledontothedatasourcefield.Clickonokinthebelowscreen.
Ourmappinglookslikebelow.
http://scn.sap.com/community/developercenter/netweavergateway/blog
36/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
HerefordisplaypurposewewillagainaddMaterialpropertysinceallkeyfieldsshouldhaveoutputmappinginQuery
operation.
ForthisclickoncreatebuttonandchoosetheMaterialpropertyanddothenecessarymappingasshownbelow.
UPDATE:RightclickonUpdateandchooseMaptodatasourceoption.
GivetherequiredRFC,HerewearemappingwithBAPI_MATERIAL_SAVEDATA.Dotherequiredmappingas
follows.HerewearegoingtoupdateMatlGroupField.
Aftercompletingalltheimplementationssavethechangesandcheckforsyntaxerrors.
NowagainclickonGeneratebuttontoregeneratetheruntimeartifacts.
http://scn.sap.com/community/developercenter/netweavergateway/blog
37/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Checkthesuccessmessages.
WiththiswehavesuccessfullycreatedagatewayservicewithimplementingallCRUDoperations.
Inthenextpart DetailedstepbystepprocedureforCreatingGatewayServicewithalltheCRUDOperationsand
testingtheminServiceExplorerPart2
wewillmaintainourserviceandtestitinServiceExplorer
11973Views
16Comments
ImprovedInsideOutModelling
PostedbyRonSargeantOct17,2013
Whatisinsideoutmodelling?
Itisadesignparadigmthattakesabusinesscomponentandmodelsitsothatitcanbeexposedasaservice.The
entitiesandpropertiesthereofaregenerallydrivenbythecomponentinterface.Themostcommonformofinsideout
driveristheRFCfunctionmodule,althoughBORobjectsandotherslikeGENILareavailable.
Thisisincontrasttooutsideinmodeldesign,wheretheservicethatisrequiredismodelledandtheappropriate
backendcomponentsarelocatedorbuilttoservetheconsumptionmodel.
Theimportantphraseformeistoservetheconsumptionmodelconversely,insideoutdesigncanbeparaphrased
asaserviceimposedbythebusinessmodel.Gatewayconsumersshouldnotreallybeconcernedwithorknow
aboutthebusinessmodelitisgenerallyalotbiggerandmorecomplexthanaparticularserviceusecasewould
need.
I'vediscussedthatpreferredapproachhere: Outsideinmodelling(or"rehab"forRFCaddicts).
Iamnotahugeadvocateofinsideoutmodellingbutwhereitisdeemednecessary,itcanoftenbeimprovedtoworkin
aGatewayODataservicecontext.
LetstaketheSAPexpensesapplication&dataconceptasastartingpoint.Expensesisquiteacomplexbeastithas
notbeendesignedwithmodularaccessinmind,itisverymonolithicinnature.DespitearevampedUIinWebDynpro,
ithasntreallyalteredinthebackendlogicormodel.
Ratherthantacklethewholeoftheexpensescomponent,Imgoingtofocusononeparttripoptions.Theseare
essentiallythelistsofoptionsthatyoucanchoosefordataentrywhilecompletinganexpensesform.Theyaretypically
usedtoprovidecontextandfilldropdownsorothervaluechoicecontrolsinaUI.WhatIfoundinterestingaboutthis
partisthatitmirrorscertainaspectsoftheexpensescomponentonamacrolevel.
Ifyouwishtoobtainthetripoptions,youcangetthedatafromtheBAPI_TRIP_GET_OPTIONS function.
Thisfunctionreturns20tablesofvariousdata!Hereisaprimeexampleofwhereinsideoutdesignfailsformehow
amIgoingtomap20outputstooneentity?TypicallyoneRFCismappedtoanentitytosatisfytheREADoperation.
AtthispointIwouldabandonanyhopeofprovidingawellconceivedserviceandlookattheoutsideinapproachbut
moreonthatlater.
Backtothemodellingexercise:ifIhavetodoitthisway,howdoIdoitwell?
OneBAPI,twentycollections
DoIneedall20tablesformyservice?ThoseIdontneedtofetchIcanremovefromtheplan.
http://scn.sap.com/community/developercenter/netweavergateway/blog
38/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Forexample,Illusethese:
EMP_INFO
DEFAULTS
EXPENSE_TYPES
COUNTRIES
CURRENCIES
(InrealityIllprobablyneedmorebut25%isagoodcutforanexample.)
Now,theapproachthatthemajorityofbeginnersinGatewaywilltakeistotryandsendallfiveofthesetablesbackin
onereadoperation,basedontheassumptionthatsimplerequest/responsescanreturnmultipletables(likeaBAPI!).
Thatisnotthewaytodoit.Youcantdoit.FundamentalODataisbasedonflatstructures.
Hereswherethepromisedimprovementstarts
Whatyoudoiscreatefiveentitieswithcorrespondingentitysets(buildsetsonlyifrequiredEMP_INFOforexample
hasacardinalityof1:1).
Eachentity/collectionisreadbyaseparateGETrequest.
Thishasthefollowingadvantages.
Theserviceentitiesaredecoupledfromthebackendmodelafteralltheyaresiblings,notpartofadependency
set.
Acollectioncanbereadwhenitisrequired,ratherthanobtainedaspartofanotherpackageofcollections.One,
afeworalloftheentitiescanbeaccessedasrequiredwithoutanyrequestconstraints.
Moreofthecollectionscanbeexposediftheserviceevolves,orconversely,deprecationiseasier.
Itdoescarrysomedisadvantageshowever
TheBAPIlogicobtainsall20outputsregardlessofthosethatarerequireddespitetheoutputsbeingoptional,
prettymuchalldataisreturned.
UsingtheBAPIstillaccesses100%ofthedatawhenIonlywant25%.
Eachreadofanentitysetobtainstheotherfourentitysetsagain!
Inperformanceterms,whereIonlywanttoreadfivecollectionswithoneBAPIcall,Iamreading100(5callsx20
tables).Notgreat!
Inthisinsideoutmodel,therehastobeabalancebetweentheunnecessarilycomplexandunclearmeansof
implementingamethodforobtainingthefivecollectionsandtheenforcedconstraintofexcessiveaccess.
...Andtheansweris..?
Movingtowardsasolution,someofyoumayask,IfwereadtheEMP_INFOentitywiththisBAPI,itwouldhaveread
theotherfourdatatablesfortheotherentities.Whydontwejuststorethesetablesinmemorythenusethemtofillthe
othersetswhenrequired?
IndeedthatwouldbeagoodideaexceptthattherequestforEMP_INFOisstateless.Ifwestoretheotherfourtables,
theyaregonewhenwetryarequestforDEFAULTSasasecondrequest,sotheBAPIwillhavetogoandreadthem
again,plustheEMP_INFOwealreadyhave.Andsoonfortheothercollections.
Statefulnesscanbeintroducedfairlyeasily.ItispossibletogetfiveentitysetsinonerequestwithoneBAPIcall.The
keytothisisusingthe$expandoptionwhenarequestisexpandedtherequiredfeedsfortheexpansionare
evaluatedinthesameconnectionsession,thereforethestateismaintainedforthedurationoftherequest.
Onedrawbackisthattheclientneedstoknowhowtoplacethecallintherightwaytotakeadvantageofthis
feature,howeverthefeatureisatleastavailable!
Thefinalmodeldesign
$expandiscommonlyusedtoobtainrelatedentities,howeveritcanbeusedtochainunrelatedGETsintoone
requestaswell.
Inordertoplaceanexpandrequest,therehastobesomerelationbutthereisnoclearrelationbetweentheentities,
theyarenothierarchical.
Illnowtakeatechniquefromtheworldofoutsideinmodellinginordertohelpmerealisethemodel.Iftheentity
designiscomingfromtheoutside,itdoesnothavetohaveadirect(orany!)correlationtoadatamodelontheinside.
AslongasIcandeviseawaytoplacemeaningfuldatainthefeedorresponse,thatentityisvalid.
WhatIneedisacommonrelationforallofmyfive(oreventhefull20)chosenentities.Thisisquiteobviousthe
entitiesareallBAPIoutputs,soitfollowsthatIshouldlookattheinput.
Inordertoprovidethose20outputs,allIrequireisanemployeenumber.ToproperlyqualifythecontextIshouldalso
addadateandlanguage,whichareoptionalinputsbutcanmakeadifference.
Basedonthisinformation,IdesignanentitycalledTripContextwithpropertiesforemployeenumber,tripdateand
languageIalsomakesuretheyareallkeys.
http://scn.sap.com/community/developercenter/netweavergateway/blog
39/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
IcanthenprovideanassociationfrommyTripContexttoeachentityandcollectioninthetripoptionservice.
BecauseIamgoingtorelatemycollectionstoanotherentity,Idonotpayanyattentiontotheinputparametersduring
theRFCwizardsteps.Choosingandrealisinginputsisanotherfeatureofthisprocessthatcreatesalotofconfusionif
theRFCisnotmappingfriendly.
Icancreateallfiveentitieswithoneimport.
Ignoretheinputsandchoosethefivecollectionsfromoutputs.
Markakeysetwithineachentityblock.
Returnedentitiesneedtoberenamed(theyareuppercaseandrefertomultiplesinsomecases).
http://scn.sap.com/community/developercenter/netweavergateway/blog
40/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Createthesets.
CreateassociationsfromTripContexttoeachoftheoptionscollections.
Finally,assignnavigationpropertiestoTripContext.Referentialconstraintsarenotrequiredandcouldnotbe
maintainedinanycase.
Withtherightimplementation,Icannowobtainallofthefivesetsofoptionswithonerequest.
TripContextSet(PersonID='00000005',Language='EN',TripDate=datetime'20131001T00:00:00.0000000')?
$expand=Defaults,TripEmployeeInfo,TripExpenseTypes,TripCountries,TripCurrencies
Explanations:
TripContextSet(PersonID='00000005',Language='EN',TripDate=datetime'20131001T00:00:00.0000000')
TheprimaryentityistheTripContext.ThevaluesthatIusetoGETtheentityareactuallyusedtoestablishthecontext,
i.e.thesevaluesbecomeknowntothedataproviderastheinitialphaseoftherequest.Theentityitselfdoesnotexist,
itisastatedirectiveitisstatingthisisthepersoninquestionandthisisthedateandlanguagethatmayaffectthe
outcome.Idonotneedtoaccessanyfurtherdatainrelationtothisentitydata,andthereturnedentityisthesameas
therequestkey.
ThetrickhereisthatIhavenowestablishedtheinputforthefollowingentitiesthatIwishtoobtain.
$expand=Defaults,TripEmployeeInfo,TripExpenseTypes,TripCountries,TripCurrencies
TheexpandoptionwilllocateeachoftheendpointsofthenavigationpropertiesthatIdefined.InthecaseofDefaults
andTripEmployeeInfo,thesearesingleentityfeeds(cardinality1:1)andthecorrespondingGET_ENTITYmethodwill
becalled.Fortheremainder,thecorrespondingGET_ENTITYSETmethodswillbecalled.
DataProviderlogic
IllmakesomeassumptionsformyDPCclass.
1. IllonlyeverwanttoaccessasingleentityoftypeTripContextnocollectionlogicisrequired.
2. IllonlyeverwanttoaccessTripContextinordertoprovidethecontextforanexpandedfeed.Thereturnformthis
requestispointlesswithoutanexpandoption.
3. NoneofthetripoptionsfeedswillworkunlesstheTripContexthasbeenestablished.
4. Themoreexpandedelementsperrequest,themoreefficienttheproviderishoweverthereturnedfeedsmustbe
requiredforconsumptionforthistoholdtrue!
Basedontheaboveassumptions,Icanintroducesomeefficiency.
WhenTripContextisrequested,whatisreallybeingrequestedarethetripoptionsthatfitintothatcontext.Atthispoint
(TRIPCONTEXT_GET_ENTITY)itwouldbeagoodideatocalltheBAPI,aswehavetheinputvaluesforit.
http://scn.sap.com/community/developercenter/netweavergateway/blog
41/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
ThereisaslightproblemherethereturneddatafromtheBAPIisntrequiredjustnow,thereturnfeedisa
TripContext.HoweverIdoknowthattheDPCisgoingtocontinuerunningduringthisRFCconnectionthe$expand
optionisgoingtoinvokecallsoftheotherGETmethods.
IvegottheentitydataforthosefeedsalreadysoImgoingtostorethem.
Inordertoseparatetheconcernssomewhat,Icreateanaccesslayerclasstomanagethetripoptions.
ThetripoptionsmanagerobjectisthenattachedtomyDPCasanattribute.ItreadstheBAPIandstorestheresultsin
itsobjectspace.
WhenIreachthesecond(impliedby$expand)GETintheprocess,Icannowaskthetripoptionsmanagertogiveme
thereturndata.
Irepeatthisforeachexpectedfeed.
Improved?
Iconsiderthisamuchbetterimplementationofaninsideoutdesign.Atypicalimplementationofthisservice,solely
basedontheBAPI,wouldnothavebeenveryelegant,efficientorassimpletoconsume.
Whatcouldhavebeenaveryinefficientandcumbersomeimplementationisnowwellscaledandfairlysimple.In
tracedteststhisservicecanreturnthefullfeedinunder100milliseconds.
However,itstillreadsmoredatathanrequiredandcouldbewrittenevenmoreefficientlyusingtheoutsidein
modellingapproach.Iintendtotacklethissamescenarioinanoutsideinmannerinafutureblog.
Regards
Ron.
3413Views
26Comments
Customgenerationstrategyhowtoenhancethe
generateddataproviderbaseclasses
PostedbyRonSargeantOct8,2013
ThisarticleexplainshowIbecameinterestedintheservicegenerationcode
andthemeanstoalterit,tosuitmyownrequirements.
Abitofhistory
IhaveidentifiedcertaingenericABAPleveloperationsthatIwishtobeabletoreuseforanyresourcein
servicesthatIimplement.
Theoriginalswereimplementedascodeperservice,whichledtoalotofcutting&pastingandduplication.
Toreducetheseoverheadsandenforceadesignpattern,IintroducedacustomsuperclassformyDPC
baseclass,i.e.subclassed/IWBEP/CL_MGW_PUSH_ABS_DATAtoZCL_MGW_PUSH_ABS_DATA.
BychangingtheinheritanceofmyDPCbase,injectingthenewintermediateclassintothefamily,Icould
inheritanynewattributes,typesormethodsIimplementedinZCL_MGW_PUSH_ABS_DATA.
ThiswasagoodsolutionwithonedrawbackifthemodelwasregeneratedinSEGW,theDPCclassisalso
regenerated.ThatregenerationwouldremovemyinheritancesoIwouldhavetoreapplyitmanually.Not
toobad,asIknowaboutthisstepbutwhataboutinfuturewhenthiswentintoanotherdeveloper's
hands?IwantedarobustsolutionsoIaskedtheGatewayproductteamiftheycouldaddthisfeatureto
ServiceBuildergenerationotherwiseIwouldneedtoimplementaplannedenhancementintheService
Buildercode.TheysuggestedIlookattheGenerationStrategyoptionanddefinedmyownasawayof
providingasolution.
Great,Ireplied,wherearethedocumentationandtoolsforthis?.
Well,thedocumentationwasanoshow(perhapsitexistssomewhere,inGerman?)butMartinBachmann
didpointmetotheconfigurationarea.FromthereIwasabletofigureouthowtoresolvemyplanned
enhancementintoaconfigurationoptioninstead(withsomecodestillneeded).
SincethereisnothingoutthereaboutthisatthetimeofwritingIthoughtitwouldbeagoodexperience
toshare.
ServiceBuilderisconfigurable!
Yes,thatsright!ItsactuallypossibletochangesomeoftheServiceBuilderfunctionalitybyalteringthe
http://scn.sap.com/community/developercenter/netweavergateway/blog
42/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
pluginelements.
Wordofwarning:thisisnotanactivitythatshouldbeundertakenbysomeone
withoutadvanceddeveloperskills.WhatIamdoinghereisafairlylightweight
change,butitwouldbepossibletoradicallyalter(anddamage)yourservice
builderinstallationandtheservicegenerationwithoutduecareandattention.
Abitofexperimentation
Ifyouarestillreading,youobviouslyliketolivedangerously.
ToaccesstheSEGWconfiguration,usetransaction/IWBEP/SBS.
Thisisacrossclientconfigurationarea,soyouhavenofailsafeinabackupclient.
Makenotesofallandanychangesyoumake.
Logchangesinatransport(whichmayormaynotneedtogotoyourPRDenvironment).
Revertanychangesthatyoumakeonatrialanderrorbasisanddonothaveaneedforyoumaybe
messingupsomethingthatyouarentusingbutsomeelseis.
TherearevariousnodesthatcanbechangedbuttheonethatjumpsoutatmeistheGeneration
Strategiesnodeniceandobvious.
However,itbelongsintheDMpluginsnodesetwhatistheparentIamneedingtoworkwith?Im
prettysureits/IWBEP/GENbasedonitsdescriptionbutIalsocheckthecontentoftheGeneration
Strategiesnode.
Ivenoticedthegenerationstrategyasanoptionwhencreatingaservicebutitsalwaysonechoice
0001,soIveneverreallyworriedaboutit.Now,thatsingleoptionhelpsmetoconfirmthatIhavethe
rightnode,becauseitonlycontains0001.Icouldbewrongbutdecidetocarryonandrevertmyworkif
Imwrong.
Firststepistoaddanewstrategy.Idontpick0002asthatmightconflictwithanewSAPstrategy.SoI
optfor9000,inthewayImightforacustomdynpro(ahgoodtimes).
Note:thisonlymakesachoiceof9000possible,itdoesntactuallyhaveanyfurthersettingsinthisview.
Onlyonesmallchange,butIcannowcheckthatIamontherighttrack.IchoseCreateprojectinSEGW
andfindInowhavetwooptionsforgenerationstrategy.
http://scn.sap.com/community/developercenter/netweavergateway/blog
43/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Icanchoosemystrategy,nowhowcanIapplyit?
LookingbackattheDMpluginsetupfor/IWBEP/GEN,itnominatesclass/IWBEP/CL_SBGN_PLUGINasa
delegate,soIlllookatthat.
Ifindtheclasshasonlytwolocallyimplementedmethods,itsconstructorand
CREATE_GENERATION_STRATEGY.Thelattersoundspromising
andcontains:
Jackpot!
Strategy0001createsanobjecttomanagethegenerationandreturnsit.ItseemslogicalthatIcando
thesamewith9000andadifferentobjectinthereturn.
So,whatwillmyreplacementpluginneedtodowhen'9000'ischosen?
Lookingat0001logic,theobjecttypereturnedisaninstanceof/IWBEP/CL_SB_GEN_GENERATOR.I
notethatasanotherobjectthatneeds
changing.
Lookingat/IWBEP/CL_SB_GEN_GENERATOR,IfindmethodGENERATE_DPC.Sofar,allthemethod
nameshavebeenveryhelpful!However,thatisnowinvokingafurtherclass.
DATAlo_dpc_generatorTYPEREFTO/iwbep/cl_sb_gen_dpc_generator.
CREATEOBJECTlo_dpc_generator.
lo_dpc_generator>/iwbep/if_sb_gen_dpc_generate~generate_dpc
WithinthissecondDPCgeneratorclassIfindwhatIamlookingforinmethod
GENERATE_DPC_BASE_ABST_CLASS.Hereisahardcodedreferencetothesuperclassname
/IWBEP/CL_MGW_PUSH_ABS_DATA.ThatsallIwanttochange.
InowknowthatIhavetoalterthreelevelsofthedefaultgenerationstrategytomakeminework.
BacktotheconfigofDMplugins:Iopttocopy/IWBEP/CL_SBGN_PLUGINandplacethecopyinthe
configuration(/IWBEP/CL_SBGN_PLUGINisfinalsoitcanonlybecopiedIwouldrathersubclassit).
http://scn.sap.com/community/developercenter/netweavergateway/blog
44/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
UpdateSep2014thisisindeedapotentialproblemI'veusedmycustomstrategysincean
upgradeofIWBEPandIneededtoredothecopy&modofthisclasstoaccommodatesome
newparametersaddedtosomeframeworkmethods.MylogicwasstillOKbuttheother
'decoupled'methodsoftheclasswereoutofdate
Ialsomakeacopyoftheoriginal/IWBEP/GEN,commentitassuchanddeactivateit.
ZCL_SBGN_PLUGINneedstoreturnacustomgeneratorobjectbasedon/IWBEP/CL_SB_GEN
_GENERATORwhenthestrategy'9000'ischosen.
NowIhaveaproblemIneedtousethesameclassbasisas/IWBEP/CL_SB_GEN_GENERATORforthe
returnparametertoworkasthecorrectreferencetype,butinheritancedoesntworkastoomanyprivate
methodsarepresent,eventhoughtheclassisnotfinal.
Myonlyoptionistocopy/IWBEP/CL_SB_GEN_GENERATORintoZCL_SB_GEN_GENERATORIllchange
theGENERATE_DPCmethodlater.
IaddanewWHENcasefor9000ZCL_SBGN_PLUGINnowprocessesstrategies0001and9000.
when'9000'.
ifiv_gen_strat_versionissupplied.
lv_gen_strat_version=iv_gen_strat_version.
else.
lv_gen_strat_version=lc_gen_strat_version.
endif.
createobjectro_gen_strategy
type
zcl_sb_gen_generator<===customtypereturned
exporting
is_gen_strategy=is_gen_strategy
iv_gen_strat_version=lv_gen_strat_version.
Next,Ilookatwhatisneededfor/IWBEP/CL_SB_GEN_DPC_GENERATORandhowIcanaltermethod
GENERATE_DPC_BASE_ABST_CLASS.
Thisclassisntfinalbutitisheavilyprivatised.IsubclassittoZCL_SB_GEN_DPC_GENERATORbutthat
givesmeverylittlebenefitandnotalotofsecurityagainstversionchangesintheIWBEPcomponent.All
oftheprivatemethodsareredefinedandreplacedwithcopiesoftheoriginals.
Sincealmosteverythinginthisinheritedclassisacopy,Icanchange
GENERATE_DPC_BASE_ABST_CLASSwithouttoomuchconcern.
Addendum:I'vesincefoundthattheregenerationofa"9000service"dumps.Thecausewas
hardtofindbutthefixwassimple.Theinheritancechangeisalsoreferencedinthe
redefinitionspreparation.
Sothisalsoneedschangingtoavoidsuchadump(anotherZCL_SB_GEN_DPC_GENERATOR
method).
http://scn.sap.com/community/developercenter/netweavergateway/blog
45/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
NowthatIhavethefinalZclassbuilt,IcanreturntoZCL_SB_GEN_GENERATORandchangeits
GENERATE_DPCmethod.
Thatisalloftheclassbuildingandconfigdone,soIjustneedtoverifythatitallworks.
Classinjectionhasworked.
http://scn.sap.com/community/developercenter/netweavergateway/blog
46/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Andmycustommethodshaveallbeeninherited.
Afewnotes
ThiscouldalsobeusedforchangestomodelprovidergenerationcurrentlyIdon'thavepressingneedto
changetheMPC.
Onceagenerationstrategyisset,youcannotchangeitunlessyoudeleteandrebuild.Ithinkthislimitationmight
needtobechangedbySAPifwearetousethisfeature.
Icouldmodifythegenerationcodesothatitcomposedtheaddtionalmethodsinmybaseclassorsomething
similar,butIchosenottothismakesthemaintenancesimplerbecauseitlinkstoanoncomposedclasswhich
canbetestedandextendedwithouttouchingthegenerationstrategycode.
Theothergenerationpluginscanbeadaptedtosuit.
Ihopethisgivesthereadersomeideasaboutunlockingsomeofthepowerofaconfigurablebuildertool.
Regards
Ron.
1315Views
7Comments
Tags:service_builder,gateway_plugin,generation_strategy
Unabletoexpandlineitemsusing$expandwhenused
alongwith$filter
PostedbykawishnoorOct2,2013
DearFolks,
Inmyservice,Iamabletoqueryheadercollectionwithafilter.(Delivery_headercollection)
NowIwanttoexpand(Delivery_lineitems)foreachdeliverynos.Ididtheassociationsoftheprincipalkeysofdelivery
headercollectionwithlineitemcollectionfields.Ialsoprovidedtherequirednavigationproperty.
Itriedthefollowingsyntaxesbuttonoavail.
sap/opu/odata/sap/DELVRY_SRV/DELIVERY_HEADER?$filter=C_Tideq
'S0000001284'&$expand=DELIVERY_ITEM,
sap/opu/odata/sap/DELVRY_SRV/DELIVERY_HEADER?$filter=C_Tideq'S0000001284'?
$expand=DELIVERY_ITEM,
sap/opu/odata/sap/DELVRY_SRV/DELIVERY_HEADER?$filter=(C_Tideq
'S0000001284')&$expand=DELIVERY_ITEM.
Pleaseprovidemesomeinsightinthisregard.
Thanks,
http://scn.sap.com/community/developercenter/netweavergateway/blog
47/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Kawish
619Views
2Comments
Tags:$expand
SAPNetweaver2.0SP06InstallParallelsonOSX
hints
PostedbyJohnAstillJul24,2013
IrunanumberofVMsusingParallelsonmyMacandwantedtousethesamefortheavailableNetweaver
Gateway2.0SP06.TherewereacoupleofissuesafterinstallthatneededtoberesolvedbeforeIcoulduse
thesystem.
Theinstallwasveryquickandstraightforwardwithoutanyproblems.
ThefirstissueIhitwaswhenstartingusingSAPMC.Theuserandhostshadbeenconfiguredduringtheinstall,but
themsg_serverprocesshadnotstarted.Lookingatthelogthehostnwgwwasnotreachable.
Checkingthe/etc/hostsfile,noentryfornwgwexisted.ifconfigayieldedtheIPaddressandtheentrywasaddedto
thehostsfile:
192.168.1.12nwgw
WiththehostsentryaddedGatewaystartedandtheprovidedservicescouldbeaccessed.
http://scn.sap.com/community/developercenter/netweavergateway/blog
48/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Thenexthurdlewastogetmyownservicesworking.Amodel/servicewascreatedandconfigured.
ThisimagecombinesboththeGatewayserverandIWBEPaddonforserviceenablement,sotransactionsforbothare
availableinthesystem.
/ifwnd/maint_serviceisthetransactionforenablingthenewservices.
Selectingtheservicetobeaddedcausedashortdump:
http://scn.sap.com/community/developercenter/netweavergateway/blog
49/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
LookingattheerrorstheywearerelatedtotheNONEdestinationconnectioncallfailingonanRFC.Diggingaround
Note1532825thesuggestionforRFC_PINGtobeusedisalludedto.SimplyusingSE37toRFC_PINGNONEsolved
theproblem.
WiththeNONEissueresolveditwasnowpossibletocreateandrunmyownservices:
897Views
0Comments
NWGateway:Tips&Tricks
PostedbySteffenFroehlichJul18,2013
InthisblogIwanttosharesomeexperience,ImadewithNWGateway.Youcanfindmostofmyinformationvia
popularsearchenginesandviaSCN,Ijustwantedtobringittogetherhere.
Updates:
07/30/2013renamingaserviceandmethodinSEGW
02/26/2014provideResponseContexttoimproveperformance
Content
NetWeaverGatewaydocumentation
Cachingaspectswhiletesting
http://scn.sap.com/community/developercenter/netweavergateway/blog
50/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Serviceanalyzation&debugging
Varioustips
Performance
SAPNetWeaverGatewaydocumentationathelp.sap.com
Whileyourapplicationisstillintestphaseit'srecommendedtodisablecacheinallnecessarysystems(NWGateway,
possiblemiddlewarelikeSMP[SAPMobilePlatform]andyourclient).InGatewayyoucandeactivatecachevia
Customizing(transaction:SPRO).Whileyouconstantlytestandextendyourapplication/servicethishelpsnotto
receivedatawhichcomesfromcache.Evenforperformancetestit'sbettertodeactivatecachestoseehowyour
applicationworksunderrealcircumstances.
You'llfindGatewaycustomizingsettinghere:Tx:SPRO>>SAPNetweaver>>Gateway>>ODataChannel>>
Administration>>CacheSettings
It'salsopossibletocreatecleanupjobsorcleancachemanuallyviatransaction/IWFND/CACHE_CLEANUPand
/IWBEP/CACHE_CLEANUP.
Browserdebugging
YoucandebugyourODATAserviceslikeyoudoitwithanyotherwebsite.InGoogleChromeyouhaveanbuildin
developertoolwhichcanbeactivatedviamenu:View>>Developer>>DeveloperTools
MostimportanttabsinDeveloperToolsforanalyzingyourservicesareResources,NetworkandTimeline.
Timing/ErroranalyzesforABAPmethods
SAPgivesyouthepossibilitytotraceexecutiontimeforallmethodswhicharecalledduringyourODATArequest.Just
insert"sapdsdebug=true"afterthequestionmarkinyourURI.You'llgettheresponseandhaveseveraltabstosee
moredetailedinformationonyourrequest.IntabRuntimeyou'llseeexecutiontimesforyourABAPmethods.Ifyou
needthisinformationpermanentlyfordocumentionproposeyoucandownloaditasanHTMLfileondisk.Justchange
theURIparameterto"sapdsdebug=download".
ExamplescreenshotforURIparametersapdsdebug=true
Ifyougetanerrorforyourservicecall,you'llseeanadditionaltabinyourbrowser"Stacktrace".
http://scn.sap.com/community/developercenter/netweavergateway/blog
51/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
URIparamtersapdsdebug=truewillalsoworkintransaction/IWFND/GW_CLIENT.
PerformanceTraceinNWGateway
SAPprovidesyoualsoinNWGatewayanseparatetoolforanalyzingABAPmethodexecutiontimes.Youcanstartthis
toolviatransaction/IWFND/TRACES.Thenicethingforthistoolis,thatyoucaneasilyconfigurethetraceandclickon
yourclientthroughallpagesofyourUI5/nativeapplication.Afterthat,lookintotracestransactionandseewhich
servicearecalled.Anddivedeeperineachservicemeasurement.
Tostartanewmeasurementjustfollowthesesteps:
rightclickon"Users&RequestURIPrefix",enterausername_or_anURIprefix
configurationtab:setperformancetracetovalue"Active"
saveconfiguration,thiswillactivethetracefor2hours
callyourURIviaclient
refreshtracelist
Forfurtherdetails,pleaselookintotheofficialdocumentationbySAP:
http://help.sap.com/saphelp_gateway20sp06/helpdata/en/9d/da3a2ceca344cf85568ae927e9858d/frameset.htm
ExamplescreenshotonperformancetraceinNWGatewaysystem(tx:/IWFND/TRACES)
Varioustips
1)ODatadatatypesinURIs
RespectdatatypeswhichneedaidentifierbeforeactualcontentlikeEdm.Binary,Edm.DateTime,Edm.Guid,
Edm.Time,Edm.DateTimeOffset.
ForexamplewhenusingaEdm.GuidtypeinaURIasakey,ithastobelooklikethis:ServiceEndpoint(guid'xxxx
yyyy...').Seeallexampleshere:
http://www.odata.org/documentation/odatav2documentation/overview/#6_Primitive_Data_Types
2)EclipseGatewayAddOn:servicesaren'tvisible
markeveryentitysetasaddressablewhichareconsideredasan'entrypoint'foryourclient.Allentitysets
whichareaccessableviaURInavigation,shouldn'tbedirectlyaddressableviaaserviceURItooutsideworld
(seecommentby RonSargeant).
3)POST&PUTpayloadfordateproperties
Inmycurrentsetup,whenIwanttocreateorupdateanentitywhichhasadateproperty(ODatatype:Edm.DateTime),I
alwayshavetoprovideattribute'm:null="true"'inpayload.Evenifmydatepropertyhasflag"nullable"setin
transactionSEGW,Ihavetoprovideitwithnullvalue,anyway.OtherwiseIreceivederror:
CX_SXML_PARSE_ERROR:ErrorwhileparsinganXMLstream
http://scn.sap.com/community/developercenter/netweavergateway/blog
52/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Sothistagdoesn'tworkforme:<d:StartDate></d:StartDate>or<d:StartDate/>
Ihavetosetpayloadasfollowing:<d:StartDatem:null="true">
4)renameaServicenodeandyourmethodnames
RenamingaserviceendpointintransactionSEGWisveryeasy.Justgoinfolder"EntitySets"andrenameit.Afteryou
generateyourruntimeobjectseverythingshouldworkfortheclientwiththenewservicename.Butyourmethodsin
DataProviderClass(class*_DPC_EXT)isn'trenamedautomatically.
Torenameyourmethod,youneedtodeleteentitysetinfolder"EntitySets",saveitandinsertitagain(copyproperties
first)).WiththistwostepsyouAssociationSetisgone,sopleasegotofolder"AssociationSets"andfillemptycells
incolumn"DependentEntitySetName".Afternewgenerationofyourruntimeobjectsyou'llseeinSE80thatyou've
gotnewmethodnames.Youhavetoredefinethesenewmethodsandcopycodingfromyouroldonesintoit.
5)getJSONresponseifformat=jsonURIparameterdidn'twork
ProvideHTTPheader"ACCEPT=application/json"
Performance
AlwayskeepinmindperformancewithODataandespeciallymobileclients.Therearesomanyaspectsregarding
performancethatI'mthinkingtowriteaseparateblogaboutthistopic.
amobiledeviceislimitedto5HTTPrequestinparallel
applicationcacheonmobiledevice(e.g.safari)isonlyinprogrammemoryandnotinflashmemory,.That's
becauseitshouldnottodestroyflashmemorybyhugeamountofread/writerequests>>betteruseweb
applicationcache(5MBavailable)
useexpandqueryviaODatatosaverequestsonslownetworks(3G),butrespectthatresponseisbigger
formoreinfopleasetakealookhere:
http://www.igvita.com/slides/2013/breaking1smobilebarrier.pdf
blogabout bestpracticesonperformanceinGatewaywithmanyDosandDon'tsby
ProvideResponseContexttoimproveperformance
DavidFreidlin
Whenyou'reusingURIparameterslike$COUNT,$INLINECOUNT,...Gatewayframeworkprovidesyouwithbuildin
functions,thatyoudon'thavetocountoutputtablebyyourself.Butyoucanoverridethesevariableswithyourown
data(seeoutputstructureES_RESPONSE_CONTEXT).Ifyouimplementaspecialfunctiontocounttheoutputvars,
thatcouldbefaster,thenthegenericpart.MaybeafasteraccesstothetablewithoneselectlikeSELECTcount(guid)
FROMtableINTOlv_linesWHERE...ORDERBYguid.Though,youdon'treallyhavetoselectrealdatafrom
database,whichisn'tneededincaseof$count.
Samplecoding,whichcouldbeusedinGET_ENTITYSETmethodforyourentity:
IFio_tech_request_context>has_count()=abap_true.
"fastselectwithcount>>actuallydon'tfetchanybusinessdatafromdatabase
SELECTcount(guid)FROMtableINTOes_response_contextcountWHERE...ORDERBY
ELSE.
"fetchallbusinessdatafromdatabase
SELECT*FROMtableWHERE.....
ENDIF.
http://scn.sap.com/community/developercenter/netweavergateway/blog
53/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Pleaseseemethod/IWBEP/IF_MGW_CORE_SRV_RUNTIME~READ_ENTITYSETforfurtherdetailsonGWhandling
for$countparameter:
G+authorpage
4663Views
10Comments
Tags:mobility,mobile,sap_netweaver_gateway,gateway,odata,nwgw
MicrosoftBUILD2013
PostedbyCarstenBoennenJun26,2013
AsyouknowSAPNetWeaverGatewayisallaboutdevelopers.ThissaiditisnotonlyaboutSAPdevelopers.
TheMicrosoftBUILDdeveloperconference2013willstartinSanFranciscotomorrow.
InthisblogIwillpostaboutsomeofthenewsfromBUILD2013.
Theofficialhomepagecanbefoundhere:http://www.buildwindows.com/
Followtheeventontwitter:https://twitter.com/bldwin
InterestingarticlebyZDNet:http://www.zdnet.com/thebuilduptomicrosoftsbuild20137000016901/
Day1Thestartbuttonisback...
Day1startednosurpriseherewithakeynotebySteveBallmer.
OneoftheleadingtopicsofthekeynotetodaywastherapidreleasecadenceanditsimportancetoMicrosoftintoday's
world.
To6000developersatthebuildconferenceandcountlessonlineStevepresentedthetoolsanddevicestomake
thishappen.
http://scn.sap.com/community/developercenter/netweavergateway/blog
54/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Oneofthemostanticipated"tools"isandwasWindows8.1.
WithagreatapplausetheaudiencewelcomedthefactthatthestartbuttonwillbebackinWindows8.1.Inadditionit
willbepossibletodirectlyboottothedesktopagain.
YoucandownloadaWindows8.1Previewhere.
AWindows8.1ProductGuideforAppDeveloperscanbefoundhere.
FinallyToolsandSDKcanbefoundhere.
ThissaidyourwayisopentobuildinterestingGatewayappsonWindows8.1.
IntermsofnewdevicesStevepresenteddifferentdevices(e.g.Nokia'sLumia928,925andforoutsidetheUSthe
521)
SprintwilladdWindowsPhonedevicestotheirportfolio(e.g.HTCWindowsPhone8XT,SamsungATIVSNeo)and
therebybroadenthereachofMicrosoft'sWindowsphones.
InterestingtodevelopersisthefactthatStevestressedtheimportanceoftouchformodernapplications.Atthesame
timehestressedthefactthatishastomixwithexistinguserparadigms.Sameistrueforapplications.Inadditionto
modernappsdownloadthroughMicrosoft'smarketplaceitwasmadeclearthatclassicaldesktopappsarenot
forgottenandthatthemixtureisimportanttotheoverallexperience.
IntermsofreachofMicrosoftappsitmightbeinterestingforyoutoreadthatMicrosoftexpectstopass100,000
applicationsonthemarketinthismonth.
InadditiontoSteveJulieLarsonGreen,AntoineLeblond,andGurdeepSinghPallpresentedthelatestandgreatest.
E.g.VisualStudio2013(Previewavailablehere),newbingfeatures,andgesturecontrolforWindows8.1devices.
RustyMcLellanandDaveMcCarthyfinallyshowedtheSparkgameanddevelopmentenvironmentforgameswitha
veryinterestingapproachtomultichannelusageofapplicationseventhoughagameherestillinterestingtosee.
Completekeynote
Welcometotheshow(bySteven"Gugg"GuggenheimerMicrosoftVPandChiefEvangelist)
Day2Thereitis:SAPinthekeynote
SatyaNadellaPresident,Server&ToolsBusinessleadthroughthekeynotetoday.Incontrasttoyesterday's
keynotethefocustodaywasmoreonbackendsystemsandenterpriseapplications.Interestingtonoticeisthefactthat
thecadenceforbackendsisevenfasterthanforthefrontends.
Morespecificallythekeynotewasmainlyabout'thecloudformodernbusiness'.
Thepresentationstartedwithsomeimpressivenumbers:
>50%Fortune500companiesusingWindowsAzure
3.2millionorganizationsactivedirectoryaccountswith68millionusers
2xcompute+storageevery6months
8.5trillionstorageobjects
900k/secstoragetransactionspersecond(2trillion/month)
ToprovethebattlereadinessofAzuresomeadditionalnumberswereprovided:
XBOXLive48millionsubscribers
Skype299millionconnectedusers
Outlook.com1millionusersgainedin24hours
Outlook365Nearly50millionOfficeWebAppsusers
SkyDrive250millionaccounts
bing1billionmobilenotificationsamonth
XBOXLive(again)1.5billiongamesofHalo
Aftertheintroductionthekeynotetookacloserlookatthedifferentchannelsinthatcontext.
StartingwiththeWebtheintegrationwithVisualStudio2013wasshowninadditiontoASP.NETimprovements.
ItwasstressedthatbuildingWebappsisprettysimpleandsuportsoutoftheboxsupportfordifferentbrowser(notonly
IE).
Acloserlookatthemobilechannelcompletedthemultichannelstory.Thedeepintegrationintothedevelopment
environmentwaswelldemonstrated.
ScottGuthrieCorporateVPWindowsAzurethenpresentedtheautoscalefeatureofAzureandwhatitmeansfor
servicessuchasSkype.
WithautoscalefeatureforAzurecostscanbereduceddramatically(>40%).Basicallythefeatureallowssettingrules
forscalingyourcloudenvironment(i.e.addingandremovingcapacityandthusreducingcoststothenecessary
amount).
Thekeynoteoverallhadsomuchinformationthatitisprettyhardtochoosethemostrelevantone.Howeverletme
finishwiththedemoofbiztalkservicesconnectingtoSAPsystemsusingREST.
ThecompletekeynotewillbeavailabletomorrowIwillpostthelinkthenandprovidethepositionoftheSAPbit.
http://scn.sap.com/community/developercenter/netweavergateway/blog
55/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
AfterthekeynoteorsecondpartofthekeynoteSteven"Gugg"GuggenheimerMicrosoftVPandChiefEvangelist
presentedhowtheWindows8architectureallowsreusageofcodingonthedifferentWindows8devices.Inaddition
supportingcompanieswerementionede.g.WalgreensofferingAPItoWindowsdevelopers.
Headsupfortomorrow:nokeynote.
854Views
0Comments
Tags:windows,sap_netweaver_gateway,gateway,microsoft,build,windows_8,windows_8.1
ODatacustomparametersGatewaycanhavethem
too!
PostedbyRonSargeantJun21,2013
SincestartingwithGatewayI'vealwayswonderedwhyoneofthesimplestODataconventionsisnotimplementedin
Gatewayyet.
Simplystated,attheendofaresourcepathyoucanaddtypicalquerystringparametersthatyouwouldseeinother
URIschemesmakessense.
e.g.<resource_path>/<resource_endpoint>?saplanguage=EN
IfyoucallaservicewiththiskindofURIscheme,itwon'tobject.Norwillitpassthoseparameterstoyourbackend
provider.
FrompreviousRESTdevelopmentsinSAP,Iknewthatthequerystringwasprobablybeingacceptedandeven
present,sowhywasitlost?
Afteradebuggingsessionthatwouldhavebenefitedfrom3Dgoogles,Ifoundtheanswer.
a)Gatewayusesthequerystringforother"stuff".
b)Ifthatotherstuff,suchas$expandispresent,thenitgetsprocessed.
c)Ifwhatisinthequerystringisnotwithinanelitegroupofparameters,itisunceremoniouslydiscarded.
Ithoughtthiswasratherharshtheyareonlytryingtobehelpful.Timetobehelpfulinreturn.
Iwantmyparameters.Iplannedthem,raisedthemandsentthemoffonajourneyandIwanttoseethemarrivesafely
atUncleBackend'shome.UncleBackendwillputthemtogooduseandprobablykeepmeinhiswill.
NowIknowthefollowingisprobablygoingtodislodgeaveryfirmstickfromaverytightposteriorsocketsomewhere,
butIdecidedtodosomethingaboutit.
"Getyourcustomparametershere!"
ThefirststepwastoenhancetheODATAprocessor,namelyclass/IWFND/CL_SODATA_PROCESSOR,Method
INIT_REQUEST.IfyouhaveseparateGWandBEP,thisclasswillbeintheGWinstance.
Thiswasdonewiththefollowingimplicitenhancementonthepostexit.
Thebasicstoryhereisthattheexportedtable'et_parameter'isresponsibleforpersistingtheparameternamevalue
pairsthroughtherequestcycle.
Itisatthispointthatallwillbelostifwecannotgrabthemthispieceofcodedoesthat.Anythingthatwasinthequery
stringissaved.
Howdoyouaccesstheminthebackend?Well,theyaren'texposedintheCRUDmethodsignatures,buttheyare
presentintheproviderruntimeobjectyoujustneedtoknowwheretofindthem.
Orwriteamethodinthedataprovidertoreadthemlikethis:
http://scn.sap.com/community/developercenter/netweavergateway/blog
56/57
2/1/2015
SAPNetWeaverGatewayDeveloperCenter...|SCN
Itisthenjustacaseofcallingthismethodwithaparameternametoseeifitispresentandgetitsvalue.
RatherthanwritethismethodintoeveryDPCclass,I'dsuggestputtingintoaninterimcustomclassinsertedintothe
classinheritanceifpossible.ThatwayitwillappearinallyourDPC's.It'seasytodoinSP03butabitharderinSP04
usingSEGWgeneratedcode,Isuspect.
IhaveusedthisenhancementwithnoilleffectsonaliveprojectandbothSP03andSP04versions,butanyone
wishingtousethissolutiondoessoattheirownrisk.
Regards
RS
2182Views
9Comments
Tags:sap_netweaver_gateway,gateway,enhancement,odata_services
1 2
SiteIndex
Privacy
ContactUs
TermsofUse
SAPHelpPortal
LegalDisclosure
Copyright
http://scn.sap.com/community/developercenter/netweavergateway/blog
Previous
Next
FollowSCN
57/57