ABAP to xml.docx

上传人:b****4 文档编号:5496252 上传时间:2022-12-17 格式:DOCX 页数:57 大小:26.49KB
下载 相关 举报
ABAP to xml.docx_第1页
第1页 / 共57页
ABAP to xml.docx_第2页
第2页 / 共57页
ABAP to xml.docx_第3页
第3页 / 共57页
ABAP to xml.docx_第4页
第4页 / 共57页
ABAP to xml.docx_第5页
第5页 / 共57页
点击查看更多>>
下载资源
资源描述

ABAP to xml.docx

《ABAP to xml.docx》由会员分享,可在线阅读,更多相关《ABAP to xml.docx(57页珍藏版)》请在冰豆网上搜索。

ABAP to xml.docx

ABAPtoxml

ReportYRS_CLASS_UPLOAD_XML

********************************************************************

*ReportforgeneratingclassfromXML-file

*Author:

SergeyKorolev(slkorolev@mail.ru)

*Doesnotworkwithinterfacesandexceptionclasses

********************************************************************

REPORTyrs_class_upload_xml.

PARAMETERS:

xmlfileTYPElocalfile.

TYPE-POOLS:

seok,seop.

INCLUDEyrs_class_xml_const.

DATA:

corr_mode,

*Extractedstructures(fromXMLfile)

gt_locals_srcTYPEseop_source_string,

gt_locals_defTYPEseop_source_string,

gt_locals_impTYPEseop_source_string,

gt_locals_macTYPEseop_source_string,

gs_classTYPEvseoclass,

gt_attributesTYPEseoo_attributes_r,

gt_methodsTYPEseoo_methods_r,

gt_eventsTYPEseoo_events_r,

gt_typesTYPEseoo_types_r,

gt_parametersTYPEseos_parameters_r,

gt_excepsTYPEseos_exceptions_r,

gt_implementingsTYPEseor_implementings_r,

gs_inheritanceTYPEvseoextend,

gt_redefinitionsTYPEseor_redefinitions_r,

gt_impl_detailsTYPEseor_redefinitions_r,

gt_friendshipsTYPEseof_friendships_r,

gt_typepusagesTYPEseot_typepusages_r,

gt_clsdeferrdsTYPEseot_clsdeferrds_r,

gt_intdeferrdsTYPEseot_intdeferrds_r,

gt_aliasesTYPEseoo_aliases_r,

gt_interfacesTYPEseok_int_typeinfos,

gs_includesTYPEseop_methods_w_include,

gt_textsTYPETABLEOFtextpool,

gt_sourceTYPEseop_source,

gt_type_sourceTYPEseop_source,

gt_mtd_sourceTYPEseo_method_source_table,

wa_mtd_sourceTYPEseo_method_source.

CLASSlcx_xml_errorDEFINITIONDEFERRED.

DATA:

exTYPEREFTOlcx_xml_error.

*----------------------------------------------------------------------*

*CLASSlCX_xml_errorDEFINITIO

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASSlcx_xml_errorDEFINITION

INHERITINGFROMcx_static_check.

PUBLICSECTION.

DATA:

errorTYPEstring.

METHODS:

constructorIMPORTINGvalue(i_error)TYPEstringOPTIONAL.

ENDCLASS."lCX_xml_errorDEFINITIO

*----------------------------------------------------------------------*

*CLASSlcx_xml_section_errorDEFINITIO

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASSlcx_xml_section_errorDEFINITION

INHERITINGFROMlcx_xml_error.

PUBLICSECTION.

METHODS:

constructorIMPORTINGvalue(i_section)TYPEstringOPTIONAL

.

ENDCLASS."lCX_xml_errorDEFINITIO

*----------------------------------------------------------------------*

*CLASSlcx_xml_errorIMPLEMENTATION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASSlcx_xml_errorIMPLEMENTATION.

METHODconstructor.

CALLMETHODsuper->constructor.

error=i_error.

ENDMETHOD."constructor

ENDCLASS."lcx_xml_errorIMPLEMENTATION

*----------------------------------------------------------------------*

*CLASSlcx_xml__section_errorIMPLEMENTATION

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

CLASSlcx_xml_section_errorIMPLEMENTATION.

METHODconstructor.

DATA:

msgTYPEstring.

CONCATENATE'Filedoesnotcontainobligatorysection'

i_section

INTOmsg

SEPARATEDBYspace.

CALLMETHODsuper->constructor

EXPORTING

i_error=msg.

ENDMETHOD."constructor

ENDCLASS."lcx_xml__section_errorIMPLEMENTATION

ATSELECTION-SCREENONVALUE-REQUESTFORxmlfile.

DATA:

file_tableTYPEfiletable,

actionTYPEi,

rcTYPEsysubrc.

FIELD-SYMBOLS:

TYPEfile_table.

CALLMETHODcl_gui_frontend_services=>file_open_dialog

EXPORTING

default_extension='xml'

file_filter=cl_gui_frontend_services=>filetype_xml

CHANGING

file_table=file_table

rc=rc

user_action=action

EXCEPTIONS

file_open_dialog_failed=1

cntl_error=2

error_no_gui=3

not_supported_by_gui=4

OTHERS=5.

IFsy-subrc<>0.

MESSAGEIDsy-msgidTYPEsy-msgtyNUMBERsy-msgno

WITHsy-msgv1sy-msgv2sy-msgv3sy-msgv4.

ENDIF.

CHECKaction=cl_gui_frontend_services=>action_ok.

READTABLEfile_tableINDEX1ASSIGNING.

xmlfile=.

START-OF-SELECTION.

DATA:

retcodeTYPEsysubrc,

source_nodeTYPEREFTOif_ixml_node,

xmlTYPEREFTOcl_xml_document.

CREATEOBJECTxml.

TRY.

CALLMETHODxml->import_from_file

EXPORTING

filename=xmlfile

RECEIVING

retcode=retcode.

IFretcodeNExml->c_ok.

DATA:

msgTYPEstring.

CASEretcode.

WHENxml->c_no_ixml.

msg='ThisisnotXMLfile'.

WHENxml->c_failed.

msg='FailedtoparsetheXMLfile'.

WHENxml->c_not_found.

msg='XMLfilenotfound'.

ENDCASE.

RAISEEXCEPTIONTYPElcx_xml_error

EXPORTINGi_error=msg.

ENDIF.

DEFINEload_section.

callmethodxml->get_data

exporting

name=&1

importing

retcode=retcode

changing

dataobject=&2.

ifretcodenexml->c_ok.

raiseexceptiontypelcx_xml_section_error

exportingi_section=&1.

endif.

END-OF-DEFINITION.

load_section:

c_xml_rootgs_class,

c_xml_attributesgt_attributes,

c_xml_methodsgt_methods,

c_xml_eventsgt_events,

c_xml_typesgt_types,

c_xml_parametersgt_parameters,

c_xml_excepsgt_exceps,

c_xml_implementingsgt_implementings,

c_xml_impl_detailsgt_impl_details,

c_xml_friendshipsgt_friendships,

c_xml_typepusagesgt_typepusages,

c_xml_clsdeferrdsgt_clsdeferrds,

c_xml_intdeferrdsgt_intdeferrds,

c_xml_aliasesgt_aliases,

c_xml_inheritancegs_inheritance,

c_xml_interfacesgt_interfaces,

c_xml_redefinitionsgt_redefinitions,

c_xml_typesourcegt_type_source,

*c_xml_text_poolgt_texts,

c_xml_locals_srcgt_locals_src,

c_xml_locals_defgt_locals_def,

c_xml_locals_macgt_locals_mac,

c_xml_locals_impgt_locals_imp.

*Nowfindmethodimplementationnodecontainingsources

*foreachmethodasasubnode

CALLMETHODxml->find_node

EXPORTING

name=c_xml_method_src

RECEIVING

node=source_node.

IFsource_nodeISINITIAL.

RAISEEXCEPTIONTYPElcx_xml_section_error

EXPORTINGi_section=c_xml_methods.

ENDIF.

source_node=source_node->get_first_child().

DATA:

name1TYPEstring,

name2TYPEstring,

xml_sep(5)VALUE'_--7E'.

WHILENOTsource_nodeISINITIAL.

CLEARwa_mtd_source.

name1=source_node->get_name().

SPLITname1ATxml_sepINTOname1name2.

IFname2ISINITIAL.

wa_mtd_source-cpdname=name1.

ELSE.

CONCATENATEname1name2INTOwa_mtd_source-cpdname

SEPARATEDBY'~'.

ENDIF.

CALLMETHODxml->get_node_data

EXPORTING

node=source_node

IMPORTING

dataobject=wa_mtd_source-source

retcode=retcode.

IFretcode=xml->c_ok.

APPENDwa_mtd_sourceTOgt_mtd_source.

ENDIF.

source_node=source_node->get_next().

ENDWHILE.

CATCHlcx_xml_errorINTOex.

MESSAGEex->errorTYPE'E'.

ENDTRY.

DATA:

answer,

fieldsTYPETABLEOFsvalWITHHEADERLINE,

parameterTYPETABLEOFsparWITHHEADERLINE,

clskeyTYPEseoclskey.

clskey-clsname=gs_class-clsname.

corr_mode='I'.

DO.

CALLFUNCTION'SEO_CLASS_GET'

EXPORTING

clskey=clskey

EXCEPTIONS

not_existing=1

deleted=2

is_interface=3

model_only=4

OTHERS=5.

IFsy-subrcNE0.

EXIT.

ENDIF.

REFRESHparameter.

parameter-param='CLASS'.

parameter-value=clskey-clsname.

APPENDparameter.

CALLFUNCTION'POPUP_TO_CONFIRM'

EXPORTING

titlebar='Classalreadyexists'

text_question=

'Class&CLASS&alreadyexists.Overwrite?

'

default_button='2'

IMPORTING

answer=answer

TABLES

parameter=parameter

EXCEPTIONS

text_not_found=0

OTHERS=0.

CASEanswer.

WHEN'1'.

corr_mode='U'.

EXIT.

WHEN'A'.

RETURN.

ENDCASE.

REFRESHfields.

fields-tabname='SEOCLSKEY'.

fields-fieldname='CLSNAME'.

fields-value=clskey-clsname.

APPENDfields.

CALLFUNCTION'POPUP_GET_VALUES'

EXPORTING

popup_title='Enternewclassname'

IMPORTING

returncode=answer

TABLES

fields=fields

EXCEPTIONS

error_in_fields=1

OTHERS=2.

IFanswer='A'.

RETURN.

ENDIF.

READTABLEfieldsINDEX1.

clskey-clsname=fields-value.

ENDDO.

IFclskey-clsnameNEgs_class-clsname.

gs_class-clsname=clskey-clsname.

gs_class-author=sy-uname.

gs_class-changedby=sy-uname.

gs_class-changedon=sy-datum.

gs_inheritance-clsname=clskey-clsname.

PERFORMrename_classTABLESgt_implementingsUSINGclskey-clsname.

PERFORMrename_classTABLESgt_attributesUSINGclskey-clsname.

PERFORMrename_classTABLESgt_methodsUSINGclskey-clsname.

PERFORMrename_classTABLESgt_eventsUSINGclskey-clsname.

PERFORMrename_classTABLESgt_typesUSINGclskey-clsname.

PERFORMrename_classTABLESgt_parametersUSINGclskey-clsname.

PERFORMrename_classTABLESgt_excepsUSINGclskey-clsname.

PERFORMrename_classTABLESgt_aliasesUSINGclskey-clsname.

PERFORMrename_classTABLESgt_typepusagesUSINGclskey-clsname.

PERFORMrename_classTABLESgt_clsdeferrdsUSINGclskey-clsname.

PERFORMrename_classTABLESgt_intdeferrdsUSINGclskey-clsname.

PERFORMrename_classTABLESgt_redefinitionsUSINGclskey-clsname.

PERFORMrename_classTABLESgt_impl_detailsUSINGclskey-clsname.

PERFORMrename_classTABLESgt_friendshipsUSINGclskey-clsname.

ENDIF.

DATA:

devclassLIKEtadir-devclass,

korrnumLIKEe070-trkorr.

CALLFUNCTION'RS_CORR_INSERT'

EXPORTING

object=gs_class-clsname

object_class='CLAS'

mode=corr_mode

global_lock='X'

master_language=gs_class-langu

IMPORTING

devclass=devclass

korrnum=korrnum

EXCEPTIONS

cancelled=1

permission_failure=2

unknown_objectclass=3

OTHERS=4.

IFsy-subrc<>0.

MESSAGEIDsy-msgidTYPEsy-msgtyNUMBERsy-msgno

WITHsy-msgv1sy-msg

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1