webdynpro进阶篇案例十二使用Tree静态结构_第1页
webdynpro进阶篇案例十二使用Tree静态结构_第2页
webdynpro进阶篇案例十二使用Tree静态结构_第3页
webdynpro进阶篇案例十二使用Tree静态结构_第4页
webdynpro进阶篇案例十二使用Tree静态结构_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

中间以tree形式展开,不同的结点对应不同的edit这次使用lead_selectioncontext(案例)edticontext中传来传去修改后(Apply),treenode总体架构Main产生tree:XML,赋给 作用:从XML中tree的结构数据,并赋给第层:第层:第三层第四层即使注意,每一层的DISPLAY_TEXT是用来显示在tree的每一节点DISPLAY_ICON是在method NITmethod NIT****GETdatamrapitypereftoif_mr_api.datatempcontenttypexstring.datatempxml_stringtypedatatemp_binarytype tbin mrapi=cl_mime_repository_api=>if_mr_api~get_api(). e_content=tempcontent).callfunctionexportingbuffer=tempcontentimportingoutput_length=temp_binarytablesbinary_tab callfunction'SCMS_BINARY_TO_STRING'exportinginput_length=temp_binaryimportingtext_buffer=tempxml_stringtablesbinary_tab datal_xmltype*CALLFUNCTION*** =datal_ixmltypereftodatal_streamfactorytypereftoif_ixml_stream_factory.datal_istreamtypereftoif_ixml_istream.data typerefto datal_parsertyperefto方法 该方法主要是从MIME中 一个XML文件。再调用initial_contextdatanodetypereftodataiteratortypereftoif_ixml_node_iterator.datanodemaptypereftoif_ixml_named_node_map.CreatingthemainiXMLfactoryl_ixml=cl_ixml=>create().Creatingastreaml_istream=l_streamfactory->create_istream_cstring(string=tempxml_stringCreating =l_ixml- (Createal_parser=l_ixml->create_parser(stream_factory= == ifl_parser->parse()neifl_parser->num_errors()nedata:parseerrortypereftoif_ixml_parse_error, typestring, type type typecount=l_parser->num_errors(write:count,'parseerrorshaveoccured:'.index=0.whileindex<parseerror=l_parser->get_error(index=index).i=parseerror->get_line().write:'line:',i=parseerror->get_column().write:'column:',i.str=parseerror->get_reason().write:str.index=index+1. typereftotypetypeifl_parser->is_dom_generating()eqnode?= checknotnodeisinitial.ifnodeisinitial.iterator=node->create_iterator(*getcurrentnode=iterator->get_next(whilenotnodeisnode->get_type(elementnode =node->get_name().nodemap=node->get_attributes().ifnotnodemapisinitial. attr=nodemap->GET_NAMED_ITEM('ObjectType').VALUE1=ATTR->GET_VALUE().ifVALUE1=initial_context(pa_impnode=node).node=iterator->get_next().PA_IMPNODE methodINITIAL_CONTEXT作用:从XML中tree的结构数据,并PA_IMPNODE methodINITIAL_CONTEXTlt_ccdtypeponentcontroller=>elements_ccd,lt_plttypeponentcontroller=>elements_plt,lt_portypeponentcontroller=>elements_por,lt_sortypeponentcontroller=>elements_sor.data:name1typestring,nodemaptypeREFTOif_ixml_named_node_map,nodetypeREFTOIF_IXML_NODE,lv_opctype =PA_IMPNODE->get_name().nodemap=PA_IMPNODE->get_attributes().lv_opc-filename=GET_NODE_VALUE(pa_id='FILENAME'pa_nodemap=nodemap).lv_opc-variant_id=GET_NODE_VALUE(pa_id='VARIANT_ID'pa_nodemap=nodemap).lv_opc-I_ERKRS_BZ=GET_NODE_VALUE(pa_id='I_ERKRS_BZ'pa_nodemapnodemapCONCATENATE'OperationConcern'lv_opc-i_erkrsintolv_opc-display_textSEPARATEDBYspace.lv_opc-DISPLAY_ICON=Node:move-correspondinglv_opctowd_this-For1stnood:hasthedata:context_nodetypeREFTOIF_WD_CONTEXT_NODE,context_elementtypeREFTOcontext_node=WD_CONTEXT->PATH_GET_NODE('OPC' SET_INITIAL_ELEMENTS=abap_true).COUNTTYPEI,INDEX_NUMTYPEI.NODELIST=PA_IMPNODE->GET_CHILDREN().COUNT=NODELIST->GET_LENGTH().INDEX_NUM=0.DOCOUNTTIMES.SUB_NODE=NODELIST->GET_ITEM(INDEX_NUM).INDEX_NUM=INDEX_NUM+1.name1=SUB_NODE->get_name(DATALV_COA nodemap=SUB_NODE->get_attributes(LV_COA-filename=GET_NODE_VALUE(pa_id='FILENAME'pa_nodemap=nodemap).LV_COA-variant_id=GET_NODE_VALUE(pa_id='VARIANT_ID'pa_nodemap=nodemap).LV_COA-I_KOKRS=GET_NODE_VALUE(pa_id='I_KOKRS'pa_nodemap=nodemap).LV_COA-I_BEZEI=GET_NODE_VALUE(pa_id='I_BEZEI'pa_nodemap=nodemap).LV_COA-I_CTYP=GET_NODE_VALUE(pa_id='I_CTYP'pa_nodemap=nodemap).LV_COA-I_CVACT=GET_NODE_VALUE(pa_id='I_CVACT'pa_nodemap=nodemap).LV_COA-I_CVPROF=GET_NODE_VALUE(pa_id='I_CVPROF'pa_nodemap=nodemapLV_COA-I_KOKFI=GET_NODE_VALUE(pa_id='I_KOKFI'pa_nodemap=nodemap).LV_COA-I_KTOPL=GET_NODE_VALUE(pa_id='I_KTOPL'pa_nodemap=nodemap).LV_COA-I_LMONA=GET_NODE_VALUE(pa_id='I_LMONA'pa_nodemap=nodemap).LV_COA-I_VNAME=GET_NODE_VALUE(pa_id='I_VNAME'pa_nodemap=nodemap).LV_COA-I_WAERS=GET_NODE_VALUE(pa_id='I_WAERS'pa_nodemap=nodemap).LV_COA-I_XWBUK=GET_NODE_VALUE(pa_id='I_XWBUK'pa_nodemap=nodemap).CONCATENATE'ControllingArea'LV_COA-I_KOKRSintoLV_COA-display_textSEPARATEDBYlv_COA-DISPLAY_ICON=**Node:move-correspondingLV_COAtowd_this-*****Thiscanbedata:context_node1typeREFTOIF_WD_CONTEXT_NODE,context_element1typeREFTOIF_WD_CONTEXT_ELEMENT.context_node1=context_element->GET_CHILD_NODE('COA' SET_INITIAL_ELEMENTS=abap_false).*****ThiscanbeDATA:NODELIST1TYPEREFTOIF_IXML_NODE_LIST,SUB_NODE1TYPEREFTOIF_IXML_NODE,COUNT1TYPEI,INDEX_NUM1TYPEI.NODELIST1=SUB_NODE->GET_CHILDREN(count1=nodelist1->get_length().INDEX_NUM1=0.docount1sub_node1=nodelist1->get_item(INDEX_NUM1).INDEX_NUM1=INDEX_NUM1+1.nodemap=SUB_NODE1->get_attributes(datalv_ccd LV_CCD-filename=GET_NODE_VALUE(pa_id='FILENAME'pa_nodemapnodemapLV_CCD-VARIANT_ID=GET_NODE_VALUE(pa_id='VARIANT_ID'pa_nodemap=========LV_CCD-I_DISTRICT=GET_NODE_VALUE(pa_id='I_DISTRICT'pa_nodemap=nodemap).LV_CCD-I_COUNTRY=GET_NODE_VALUE(pa_id='I_COUNTRY'pa_nodemap=nodemap).LV_CCD-I_HOUSE_NUM1=GET_NODE_VALUE(pa_id='I_HOUSE_NUM1'=nodemap=========LV_CCD-I_POST_CODE2=GET_NODE_VALUE(pa_id='I_POST_CODE2'=nodemapLV_CCD-I_POST_CODE1=GET_NODE_VALUE(pa_id='I_POST_CODE1'=nodemapLV_CCD-I_REGION=GET_NODE_VALUE(pa_id='I_REGION'pa_nodemap=nodemap).LV_CCD-I_STREET=GET_NODE_VALUE(pa_id='I_STREET'pa_nodemap=nodemap).LV_CCD-I_TAXJURCODE=GET_NODE_VALUE(pa_id='I_TAXJURCODE'=nodemapLV_CCD-I_WAERS=GET_NODE_VALUE(pa_id='I_WAERS'pa_nodemap=nodemap).LV_CCD-I_TIME_ZONE=GET_NODE_VALUE(pa_id='I_TIME_ZONE'=nodemapCONCATENATE'CompanyCode'LV_CCD-I_BUKRSintolv_ccd-display_textSEPARATEDBYspace.lv_ccd-DISPLAY_ICON=Node:appendLV_CCDto*****Thiscanbedata:context_node2typeREFTOIF_WD_CONTEXT_NODE,context_element2typeREFTOIF_WD_CONTEXT_ELEMENT.context_node2=context_element1->GET_CHILD_NODE('CCD' SET_INITIAL_ELEMENTS=abap_false).*****Thiscanbedata:context_node3typeREFTOIF_WD_CONTEXT_NODE,context_element3typeREFTOIF_WD_CONTEXT_ELEMENT.DATA:NODELIST2TYPEREFTOIF_IXML_NODE_LIST,SUB_NODE2TYPEREFTOIF_IXML_NODE,COUNT2TYPEI,INDEX_NUM2TYPEI.NODELIST2=sub_node1->GET_CHILDREN().INDEX_NUM=0.COUNT2=NODELIST2->GET_LENGTH(docount2sub_node2=nodelist2->get_item(INDEX_NUM).INDEX_NUM=INDEX_NUM+1.nodemap=SUB_NODE2->get_attributes().dataobjtypeTYPEstring.objtype=GET_NODE_VALUE(pa_id='ObjectType'pa_nodemap=nodemap).IFobjtype='PLT'.datalv_plt LV_PLT-filename=GET_NODE_VALUE(pa_id='FILENAME'pa_nodemapnodemapLV_PLT-VARIANT_ID=GET_NODE_VALUE(pa_id='VARIANT_ID'=nodemapLV_PLT-I_WERKS=GET_NODE_VALUE(pa_id='I_WERKS'pa_nodemapnodemapnodemapnodemapnodemap

LV_PLT-I_NAME1=GET_NODE_VALUE(pa_id='I_NAME1'pa_nodemapLV_PLT-I_NAME2=GET_NODE_VALUE(pa_id='I_NAME2'pa_nodemapLV_PLT-I_CITY=GET_NODE_VALUE(pa_id='I_CITY'pa_nodemapLV_PLT-I_DISTRICT=GET_NODE_VALUE(pa_id='I_DISTRICT'=nodemapLV_PLT-I_COUNTRY=GET_NODE_VALUE(pa_id='I_COUNTRY'pa_nodemapnodemapnodemap

LV_PLT-I_FABKL=GET_NODE_VALUE(pa_id='I_FABKL'pa_nodemapLV_PLT-I_HOUSE_NUM=GET_NODE_VALUE(pa_id=pa_nodemap=nodemapLV_PLT-I_LANGU=GET_NODE_VALUE(pa_id='I_LANGU'pa_nodemapnodemapLV_PLT-I_POST_CODE2=GET_NODE_VALUE(pa_id=pa_nodemap=nodemapLV_PLT-I_POST_CODE=GET_NODE_VALUE(pa_id=pa_nodemap=nodemapLV_PLT-I_PO_BOX=GET_NODE_VALUE(pa_id='I_PO_BOX'pa_nodemapnodemapnodemapnodemap

LV_PLT-I_REGION=GET_NODE_VALUE(pa_id='I_REGION'pa_nodemapLV_PLT-I_STREET=GET_NODE_VALUE(pa_id='I_STREET'pa_nodemapLV_PLT-I_TIME_ZONE=GET_NODE_VALUE(pa_id=pa_nodemap=nodemapLV_PLT-I_TAXJURCODE=GET_NODE_VALUE(pa_id=pa_nodemap=nodemap SEPARATEDBYSPACE.lv_PLT-DISPLAY_ICON=Node:appendLV_pltto*****Thiscanbecontext_node3=context_element2->GET_CHILD_NODE('PLT' SET_INITIAL_ELEMENTS=abap_false).*****Thiscanbenodemap

IFobjtype=datalv_sor LV_sor-filename=GET_NODE_VALUE(pa_id='FILENAME'pa_nodemapLV_sor-VARIANT_ID=GET_NODE_VALUE(pa_id='VARIANT_ID'=nodemaplv_sor-I_BOAVO=GET_NODE_VALUE(pa_id='I_BOAVO'pa_nodemapnodemapnodemapnodemap

lv_sor-I_CITY1=GET_NODE_VALUE(pa_id='I_CITY1'pa_nodemaplv_sor-I_COUNTRY=GET_NODE_VALUE(pa_id='I_COUNTRY'pa_nodemaplv_sor-I_HOUSE_NUM1=GET_NODE_VALUE(pa_id=pa_nodemap=nodemapnodemap

lv_sor-I_KUNNR=GET_NODE_VALUE(pa_id='I_KUNNR'pa_nodemaplv_sor-I_POST_CODE2=GET_NODE_VALUE(pa_id=pa_nodemap=nodemaplv_sor-I_POST_CODE=GET_NODE_VALUE(pa_id='I_POST_CODE'pa_nodemap=nodemap).lv_sor-I_PO_BOX=GET_NODE_VALUE(pa_id='I_PO_BOX'pa_nodemapnodemapnodemapnodemap

lv_sor-I_REGION=GET_NODE_VALUE(pa_id='I_REGION'pa_nodemaplv_sor-I_STREET=GET_NODE_VALUE(pa_id='I_STREET'pa_nodemaplv_sor-I_TAXJURCODE=GET_NODE_VALUE(pa_id=pa_nodemap=nodemaplv_sor-I_TIME_ZONE=GET_NODE_VALUE(pa_id='I_TIME_ZONE'pa_nodemap=nodemap).lv_sor-I_TXNAM_SDB=GET_NODE_VALUE(pa_id=pa_nodemap=nodemaplv_sor-I_VKOKL=GET_NODE_VALUE(pa_id='I_VKOKL'pa_nodemapnodemapnodemapnodemapnodemap

lv_sor-I_WAERS=GET_NODE_VALUE(pa_id='I_WAERS'pa_nodemaplv_sor-I_VKORG=GET_NODE_VALUE(pa_id='I_VKORG'pa_nodemaplv_sor-I_VTEXT=GET_NODE_VALUE(pa_id='I_VTEXT'pa_nodemapCONCATENATE'SalesOrg'lv_sor-I_VKORGINTOlv_sor-SEPARATEDBYlv_sor-DISPLAY_ICON=Node:appendLV_sorto*****Thiscanbecontext_node3=context_element2->GET_CHILD_NODE('SOR' SET_INITIAL_ELEMENTS=abap_false).*****Thiscanbenodemap

IFobjtype=datalv_por lv_por-filename=GET_NODE_VALUE(pa_id='FILENAME'pa_nodemaplv_por-VARIANT_IDlv_por-VARIANT_ID=GET_NODE_VALUE(pa_id='VARIANT_ID'=nodemaplv_por-I_EKORG=GET_NODE_VALUE(pa_id='I_EKORG'pa_nodemapnodemaplv_por-I_EKOTX=GET_NODE_VALUE(pa_id='I_EKOTX'pa_nodemapnodemapCONCATENATE'PurchaseOrg'lv_por-I_EKORGINTOlv_por-DISPLAY_TEXTSEPARATEDBYSPACE.lv_por-DISPLAY_ICON=Node:appendLV_porto*****Thiscanbecontext_node3=context_element2->GET_CHILD_NODE('POR' SET_INITIAL_ELEMENTS=abap_false).*****Thiscanbe**savewd_this->Gt_CCD=wd_this->Gt_plt=wd_this->Gt_por=wd_this->Gt_sor=methodGET_NODE_VALUEdatanodetypeREFTOnodemethodGET_NODE_VALUEdatanodetypeREFTOnode=PA_NODEMAP->GET_NAMED_ITEM(PA_IDifnodeisinitial.pa_value=''.PA_VALUE=node->get_value().界面:显示与隐藏左或右部分methodmethodSHOW_LEFT_PANELDATAlo_nd_visibale_controlTYPEREFTODATAlo_el_visibale_controlTYPEREFTOwd_this->wdctx_LR_SHOWexportingname='VISIBLE_LEFT'importingvalue=lv_VISIBLE_LEFT).iflv_VISIBLE_LEFT=name='VISIBLE_LEFT'value='').name='VISIBLE_LEFT'value='X'对应的contextTree:点击不同的节点显示不同的edit这是以COA为例CONTEXT_ELEMENTCONTEXT_ELEMENTmethodONACTIONPRESS_COA*getPath,thensetDATA:LO_ND_CONTEXTTYPEREFTOIF_WD_CONTEXT_NODE,PATHTYPESTRING.PATH=wdevent->GET_STRING('PATH'LO_ND_CONTEXT=WD_CONTEXT->PATH_GET_NODE(pathcontext_elementio_context_element*setEdit methodPATH_LEAD_SELECTIONlt_stringtypeTABLEOFstring,lo_stringtypestring.*getthestringofSPLITi_pathat'.'intoTABLEis_nodetypewdy_boolean,nodepathtypestring,nodetypeREFTOif_wd_context_node,indetypei.is_node=loopatlt_stringinto*formtheNode-IFnodepathisinitial.nodepath=CONCATENATEnodepathlo_stringintonodepathSEPARATEDBY'.'.*setleadselectionofeverynodeinthePathifis_node=abap_true.node=wd_context->path_get_node(nodepath).is_node=abap_false.CALLFUNCTION =inde.node->set_lead_selection_index(inde).is_node=abap_true.*savethenode-P_CONTROLLER->G_PATH=methodSHOW_EDIT_PANEL**First:showtheedit ponentcontroller=>wdctx_enable_view).getalldeclaredattributesStatic_Attributes=stru_attributessetpropertycasei_TYPE.when'COA'.**modifystru_attributes-ENABLE_COA='X'.when**modifystru_attributes-ENABLE_CCD='X'.when**modifystru_attributes-ENABLE_PLT='X'.when**modifystru_attributes-ENABLE_POR='X'.whenwhen**modifystru_attributes-ENABLE_SOR='X'.when**modifystru_attributes-ENABLE_EMPTY='X'.*bindnewelementtonode_attributes->bind_structure(new_item=stru_attributesSET_INITIAL_ELEMENTS=abap_true).同样对应的使用editpanel修改某一节点后,点击apply显示在treeled_selection实时的修改了某一field后,内部的context已经修改。但是,因为我们的tree显示用的display_text和display_icon却不能实时修改,必须得去触发它。methodMODIFY_TREE.TYPEREFTOmethodMODIFY_TREE.TYPEREFTOTYPEREFTOlt_stringtypeTABLEOFstring,lo_stringtypestring.getthestringofSPLITwd_this->g_pathat'.'intoTABLEis_nodetypewdy_boolean,nodepathtypestring,lw_leveltypestring.is_node=loopatlt_stringinto*formtheNode-IFnodepathisinitial.nodepath=CONCATENATEnodepathlo_stringintonodepathSEPARATEDBY'.'.getifis_node=caculatethedeepthlw_level=lo_string.node_attributes=wd_context->path_get_node(nodepath).is_node=abap_false.is_node=abap_true.getdistinguishwhichlevelitiscaselw_level.whenStatic_Attributes=ls_opc**DowhenStatic_Attributes=ls_coamodifythe"Display_like"textCONCATENATE'ControllingArea'ls_coa-I_KOKRSintoLs_COA-display_textSEPARATEDBYspace.modifythe"Display_icon"textLs_COA-DISPLAY_ICON='ICON_OKAY'.BindwhenStatic_Attributes=ls_ccdmodifythe"Display_like"textCONCATENATE'CompanyCode'Ls_CCD-I_BUKRSintols_ccd-display_textSEPARATEDBYspace.modifythe"Display_icon"textLs_Ccd-DISPLAY_ICON='ICON_OKAY'.BindwhenStatic_Attributes=ls_pltmodifythe"Display_like"textCONCATENATE'Plant'LS_PLT-I_WERKSINTOLS_PLT-DISPLAY_TEXTSEPARATEDBYmodifythe"Display_icon"textLs_PLT-DISPLAY_ICON='ICON_OKAY'.BindwhenStatic_Attributes=ls_pormodifythe"Display_like"textCONCATENATE'PurchaseOrg'ls_por-I_EKORGINTOls_por-DISPLAY_TEXTSEPARATEDBYSPACE.modifythe"Display_icon"textLs_por-DISPLAY_ICON='ICON_OKAY'.BindBindwhenStatic_Attributes=ls_sormodifythe"Display_like"textCONCATENATE'SalesOrg'ls_sor-I_VKORGINTOls_sor-DISPLAY_TEXTSEPARATEDBYSPACE.modifythe"Display_icon"textBind作用:实现所有的节点全打methodEXPLAND_ALL

TYPEREFTOif_wd_context_node,TYPEREFTOif_wd_context_element,liketableofTYPEREFTOif_wd_context_element,liketableofelem_attributes,TYPEREFTOif_wd_context_element,liketableofelem_attributes.*1st:node_attributes=wd_context->get_child_node('OPC'***getta

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论