Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
998 lines (892 sloc) 45.7 KB
<?xml version="1.0" encoding="iso-8859-1"?>
<CLAS CLSNAME="ZSAPLINK_WTAG" VERSION="0" LANGU="E" DESCRIPT="SAPlink - BSP plugin" UUID="450F6CFD574D01B602000000A7E42BB6" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" CHGDANYON="00000000" CLSCCINCL="X" FIXPT="X" UNICODE="X" R3RELEASE="620" CLSBCCAT="00" REFCLSNAME="ZSAPLINK">
<publicSection>class ZSAPLINK_WTAG definition
public
inheriting from ZSAPLINK
create public .
*&quot;* public components of class ZSAPLINK_WTAG
*&quot;* do not include other source files here!!!
public section.
methods CHECKEXISTS
redefinition .
methods CREATEIXMLDOCFROMOBJECT
redefinition .
methods CREATEOBJECTFROMIXMLDOC
redefinition .</publicSection>
<protectedSection>*&quot;* protected components of class ZSAPLINK_WTAG
*&quot;* do not include other source files here!!!
protected section.
methods WTAG_SETATTRIBUTESFROMSTR
importing
!NODE type ref to IF_IXML_ELEMENT
!STRUCTURE type DATA .
methods WTAG_GETSTRUCTUREFROMATTR
importing
!NODE type ref to IF_IXML_ELEMENT
changing
!STRUCTURE type DATA .
methods DELETEOBJECT
redefinition .
methods GETOBJECTTYPE
redefinition .</protectedSection>
<privateSection>*&quot;* private components of class ZSAPLINK_WTAG
*&quot;* do not include other source files here!!!
private section.
methods CORR_INSERT
importing
!P_AUTHOR type SYUNAME
!P_DEVCLASS type DEVCLASS
raising
ZCX_SAPLINK .
class-methods ACCESS_PERMISSION
importing
!P_OBJECT_KEY type C
!P_MODE type STRING default &apos;INSERT&apos;
!P_NO_DIALOG type CHAR1 default &apos;X&apos;
!P_OBJECTTYPE type TROBJTYPE
exporting
!P_DEVCLASS type DEVCLASS
!P_TRANSPORT_KEY type TRKEY
!P_CORR_NUM type TRKORR
!P_MASTER_LANG type SYLANGU
!P_MODIFY_LANG type SY-LANGU
raising
ZCX_SAPLINK .
class-methods DELETE_FROM_WORKING_AREA
importing
!P_TLIBID type O2TLIBID
!P_GLOBAL type XFELD
!P_OBJECTTYPE type TROBJTYPE .
class-methods UPDATE_OBJECT_LISTS
importing
!P_TLIBID type O2TLIBID
!P_OPERATION type C .</privateSection>
<localImplementation>*&quot;* local class implementation for public class
*&quot;* use this source file for the implementation part of
*&quot;* local helper classes</localImplementation>
<localTypes>*&quot;* use this source file for any type declarations (class
*&quot;* definitions, interfaces or data types) you need for method
*&quot;* implementation or private method&apos;s signature</localTypes>
<localMacros>*&quot;* use this source file for any macro definitions you need
*&quot;* in the implementation part of the class</localMacros>
<method CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" VERSION="0" LANGU="E" DESCRIPT="Call RS_ACCESS_PERMISSION" EXPOSURE="0" STATE="1" EDITORDER="2 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="1" MTDNEWEXC="X" R3RELEASE="620" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" SCONAME="P_OBJECT_KEY" VERSION="0" LANGU="E" DESCRIPT="Object Key" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="C"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" SCONAME="P_MODE" VERSION="0" LANGU="E" DESCRIPT="Operation &apos;FREE&apos; | &apos;INSERT&apos;" CMPTYPE="1" MTDTYPE="0" EDITORDER="4 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="STRING" PARVALUE="&apos;INSERT&apos;" PAROPTIONL="X"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" SCONAME="P_NO_DIALOG" VERSION="0" LANGU="E" DESCRIPT="Single-Character Flag" CMPTYPE="1" MTDTYPE="0" EDITORDER="5 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="CHAR1" PARVALUE="&apos;X&apos;" PAROPTIONL="X"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" SCONAME="P_OBJECTTYPE" VERSION="0" LANGU="E" DESCRIPT="Object Type" CMPTYPE="1" MTDTYPE="0" EDITORDER="6 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="TROBJTYPE"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" SCONAME="P_DEVCLASS" VERSION="0" LANGU="E" DESCRIPT="Package" CMPTYPE="1" MTDTYPE="0" EDITORDER="7 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="1" PARPASSTYP="1" TYPTYPE="1" TYPE="DEVCLASS"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" SCONAME="P_TRANSPORT_KEY" VERSION="0" LANGU="E" DESCRIPT="Complete Key of a Transport Object" CMPTYPE="1" MTDTYPE="0" EDITORDER="8 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="1" PARPASSTYP="1" TYPTYPE="1" TYPE="TRKEY"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" SCONAME="P_CORR_NUM" VERSION="0" LANGU="E" DESCRIPT="Request/Task" CMPTYPE="1" MTDTYPE="0" EDITORDER="9 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="1" PARPASSTYP="1" TYPTYPE="1" TYPE="TRKORR"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" SCONAME="P_MASTER_LANG" VERSION="0" LANGU="E" DESCRIPT="SAP R/3 System, Current Language" CMPTYPE="1" MTDTYPE="0" EDITORDER="10 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="1" PARPASSTYP="1" TYPTYPE="1" TYPE="SYLANGU"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" SCONAME="P_MODIFY_LANG" VERSION="0" LANGU="E" DESCRIPT="SAP R/3 System, Current Language" CMPTYPE="1" MTDTYPE="0" EDITORDER="11 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="1" PARPASSTYP="1" TYPTYPE="1" TYPE="SY-LANGU"/>
<exception CLSNAME="ZSAPLINK_WTAG" CMPNAME="ACCESS_PERMISSION" SCONAME="ZCX_SAPLINK" VERSION="0" LANGU="E" DESCRIPT="SAPlink exception class" MTDTYPE="0" EDITORDER="1 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000"/>
<source>METHOD ACCESS_PERMISSION .
* DATA:
* l_uname TYPE syuname,
* l_uname2 TYPE syuname,
* l_tlibid TYPE o2tlibid.
* check object name
CALL FUNCTION &apos;RS_ACCESS_PERMISSION&apos;
EXPORTING
authority_check = &apos;X&apos;
global_lock = &apos;X&apos;
mode = p_mode
object = p_object_key
object_class = p_objecttype
suppress_language_check = p_no_dialog
suppress_language_dialog = p_no_dialog
IMPORTING
devclass = p_devclass
new_master_language = p_master_lang
korrnum = p_corr_num
transport_key = p_transport_key
modification_language = p_modify_lang
EXCEPTIONS
canceled_in_corr = 1
enqueued_by_user = 2
enqueue_system_failure = 3
illegal_parameter_values = 4
locked_by_author = 5
no_modify_permission = 6
no_show_permission = 7
permission_failure = 8
request_language_denied = 9
OTHERS = 10.
case sy-subrc.
when 0.
when 2 or 5.
raise exception type zcx_saplink
exporting textid = zcx_saplink=&gt;locked.
when 6 or 7 or 8 or 9.
raise exception type zcx_saplink
exporting textid = zcx_saplink=&gt;not_authorized.
when others.
raise exception type zcx_saplink
exporting textid = zcx_saplink=&gt;system_error.
endcase.
ENDMETHOD. &quot;access_permission</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="CHECKEXISTS" VERSION="0" LANGU="E" DESCRIPT="Check if object exists" EXPOSURE="2" STATE="1" EDITORDER="9 " DISPID="0 " AUTHOR="USEWH90" CREATEDON="20060831" CHANGEDBY="USEWH90" CHANGEDON="20060831" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" R3RELEASE="620" BCMTDCAT="00" BCMTDSYN="0">
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
* Plugin created by:
* Phil Young
* ptyoun01@gmail.com
method CHECKEXISTS .
data P_TLIBID TYPE O2TLIBID.
P_TLIBID = objName.
exists = cl_o2_taglib_manager=&gt;exists_on_db( p_tlibid ).
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK_WTAG" CMPNAME="CORR_INSERT" VERSION="0" LANGU="E" DESCRIPT="Insert Correction" EXPOSURE="0" STATE="1" EDITORDER="1 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDNEWEXC="X" R3RELEASE="620" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="CORR_INSERT" SCONAME="P_AUTHOR" VERSION="0" LANGU="E" DESCRIPT="SAP System, User Logon Name" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="SYUNAME"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="CORR_INSERT" SCONAME="P_DEVCLASS" VERSION="0" LANGU="E" DESCRIPT="Package" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="DEVCLASS"/>
<exception CLSNAME="ZSAPLINK_WTAG" CMPNAME="CORR_INSERT" SCONAME="ZCX_SAPLINK" VERSION="0" LANGU="E" DESCRIPT="SAPlink exception class" MTDTYPE="0" EDITORDER="1 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000"/>
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
method CORR_INSERT .
data myTROBJTYPE type TROBJTYPE.
myTROBJTYPE = getobjecttype( ).
CALL FUNCTION &apos;RS_CORR_INSERT&apos;
EXPORTING
AUTHOR = p_author
GLOBAL_LOCK = &apos;X&apos;
OBJECT = objName
OBJECT_CLASS = myTROBJTYPE
DEVCLASS = p_devClass
* KORRNUM = CORRNUMBER_LOCAL
MASTER_LANGUAGE = sy-langu
* PROGRAM = PROGRAM_LOCAL
MODE = &apos;INSERT&apos;
* IMPORTING
* AUTHOR = UNAME
* KORRNUM = CORRNUMBER_LOCAL
* DEVCLASS = DEVCLASS_LOCAL
EXCEPTIONS
CANCELLED = 1
PERMISSION_FAILURE = 2
UNKNOWN_OBJECTCLASS = 3.
if sy-subrc &lt;&gt; 0.
case sy-subrc.
when 2.
raise exception type zcx_saplink
exporting
textid = zcx_saplink=&gt;not_authorized.
when others.
raise exception type zcx_saplink
exporting
textid = zcx_saplink=&gt;system_error.
endcase.
endif.
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="CREATEIXMLDOCFROMOBJECT" VERSION="0" LANGU="E" DESCRIPT="Creates an IF_IXML_DOCUMENT from the OBJNAME Attribute" EXPOSURE="2" STATE="1" EDITORDER="5 " DISPID="0 " AUTHOR="USDWM01" CREATEDON="20060720" CHANGEDBY="USEWH90" CHANGEDON="20060830" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" MTDNEWEXC="X" R3RELEASE="620" BCMTDCAT="00" BCMTDSYN="0">
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<exception CLSNAME="ZSAPLINK" CMPNAME="CREATEIXMLDOCFROMOBJECT" SCONAME="ZCX_SAPLINK" VERSION="0" LANGU="E" DESCRIPT="SAPlink exception class" MTDTYPE="0" EDITORDER="1 " AUTHOR="USEWH90" CREATEDON="20060830" CHANGEDON="00000000"/>
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
* Plugin created by:
* Phil Young
* ptyoun01@gmail.com
method CREATEIXMLDOCFROMOBJECT .
data rc type sysubrc.
data: my_wtag type ref to CL_O2_TAG_LIBRARY,
l_tlibid TYPE o2tlibid.
data P_TLIB_EDIT TYPE O2TLIBEDIT.
*xml nodes
data rootNode type ref to if_ixml_element.
l_tlibid = objName.
CALL METHOD CL_O2_TAG_LIBRARY=&gt;GET_INSTANCE
EXPORTING
P_TLIBID = l_tlibid
P_STATE = &apos;A&apos;
RECEIVING
P_TLIB_REF = my_wtag
.
CALL METHOD MY_WTAG-&gt;GET_TAGLIB
RECEIVING
P_TLIB_EDIT = P_TLIB_EDIT
.
* Create parent node
data _objType type string.
_objType = getObjectType( ).
rootNode = xmlDoc-&gt;create_element( _objType ).
WTAG_SETATTRIBUTESFROMSTR( node = rootNode structure = P_TLIB_EDIT
).
*\--------------------------------------------------------------------/
rc = xmldoc-&gt;append_child( rootNode ).
ixmlDocument = xmlDoc.
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="CREATEOBJECTFROMIXMLDOC" VERSION="0" LANGU="E" DESCRIPT="Creates Object on System from IXMLDocument passed in" EXPOSURE="2" STATE="1" EDITORDER="4 " DISPID="0 " AUTHOR="USDWM01" CREATEDON="20060720" CHANGEDBY="USEWH90" CHANGEDON="20060830" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" MTDNEWEXC="X" R3RELEASE="620" BCMTDCAT="00" BCMTDSYN="0">
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<exception CLSNAME="ZSAPLINK" CMPNAME="CREATEOBJECTFROMIXMLDOC" SCONAME="ZCX_SAPLINK" VERSION="0" LANGU="E" DESCRIPT="SAPlink exception class" MTDTYPE="0" EDITORDER="1 " AUTHOR="USEWH90" CREATEDON="20060830" CHANGEDON="00000000"/>
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
* Plugin created by:
* Phil Young
* ptyoun01@gmail.com
method CREATEOBJECTFROMIXMLDOC .
types:
TT_TLINE type standard table of TLINE .
types:
t_t_tag TYPE HASHED TABLE OF o2tag
WITH UNIQUE KEY tlibid tagid .
types:
t_t_tagt TYPE HASHED TABLE OF tagt
WITH UNIQUE KEY tlibid tagid .
types:
t_t_tagatt TYPE HASHED TABLE OF o2tagatt
WITH UNIQUE KEY tlibid tagid attid .
types:
t_t_tagattt TYPE HASHED TABLE OF tagattt
WITH UNIQUE KEY tlibid tagid attid .
types:
t_t_tline TYPE STANDARD TABLE OF tline
WITH DEFAULT KEY .
data rootNode type ref to if_ixml_element.
data _devclass type devclass.
data _objType type string.
data P_TLIB_EDIT TYPE O2TLIBEDIT.
data checkExists type flag.
data l_cx_ref TYPE REF TO zcx_saplink.
_devclass = devclass.
_objType = getObjectType( ).
xmlDoc = ixmlDocument.
rootNode = xmlDoc-&gt;find_from_name( _objType ).
* call method GETSTRUCTUREFROMATTRIBUTES
call method WTAG_GETSTRUCTUREFROMATTR
exporting
node = rootNode
changing
structure = P_TLIB_EDIT.
objName = P_TLIB_EDIT-TLIBID.
checkExists = checkexists( ).
if checkExists is not initial.
if overwrite is initial.
raise exception type zcx_saplink
exporting textid = zcx_saplink=&gt;existing.
else.
* delete object for new install
TRY.
deleteobject( ).
CATCH ZCX_SAPLINK into l_cx_ref.
raise exception l_cx_ref.
ENDTRY.
endif.
endif.
*TYPES:
*
* t_t_tag TYPE HASHED TABLE OF o2tag
* WITH UNIQUE KEY tlibid tagid,
*
* t_t_tagt TYPE HASHED TABLE OF tagt
* WITH UNIQUE KEY tlibid tagid,
*
* t_t_tagatt TYPE HASHED TABLE OF o2tagatt
* WITH UNIQUE KEY tlibid tagid attid,
*
* t_t_tagattt TYPE HASHED TABLE OF tagattt
* WITH UNIQUE KEY tlibid tagid attid,
*
* t_t_tline TYPE STANDARD TABLE OF tline
* WITH DEFAULT KEY.
*
*TYPES: BEGIN OF t_s_docu,
* tlibid TYPE o2tlibid,
* tagid TYPE o2tagid,
* dokhl TYPE dokhl,
* dokil TYPE dokil,
* docu TYPE t_t_tline,
* END OF t_s_docu,
*
* t_t_docu TYPE HASHED TABLE OF t_s_docu
* WITH UNIQUE KEY tlibid tagid.
data wa_o2taglib type o2taglib.
data wa_taglibt type taglibt.
data it_tag type t_t_tag.
data wa_tag like line of it_tag.
data it_tagt type t_t_tagt.
data wa_tagt like line of it_tagt.
data it_tagatt type t_t_tagatt.
data wa_tagatt like line of it_tagatt.
data it_tagattt type t_t_tagattt.
data wa_tagattt like line of it_tagattt.
data wa_tags type O2TAGEDIT.
data wa_attributes type O2ATTEDIT.
data state type r3state value &apos;I&apos;.
* build tables / structures
*extension
move-corresponding P_TLIB_EDIT to wa_o2taglib.
wa_o2taglib-state = state.
wa_o2taglib-author = sy-uname.
wa_o2taglib-createdon = sy-datum.
wa_o2taglib-changedby = sy-uname.
wa_o2taglib-changedon = sy-datum.
wa_o2taglib-stamp = sy-uzeit.
move-corresponding P_TLIB_EDIT to wa_taglibt.
wa_taglibt-state = state.
wa_taglibt-langu = sy-langu.
* elements
loop at P_TLIB_EDIT-TAGS into wa_tags.
wa_tag-tlibid = P_TLIB_EDIT-TLIBID.
move-corresponding wa_tags to wa_tag.
wa_tag-state = state.
wa_tag-author = sy-uname.
wa_tag-createdon = sy-datum.
wa_tag-changedby = sy-uname.
wa_tag-changedon = sy-datum.
insert wa_tag into table it_tag.
move-corresponding wa_tag to wa_tagt.
wa_tagt-langu = sy-langu.
wa_tagt-descript = wa_tags-descript.
insert wa_tagt into table it_tagt.
* attributes
loop at wa_tags-attributes into wa_attributes.
move-corresponding wa_attributes to wa_tagatt.
wa_tagatt-tlibid = P_TLIB_EDIT-TLIBID.
wa_tagatt-state = state.
wa_tagatt-tagid = wa_tags-tagid.
insert wa_tagatt into table it_tagatt.
move-corresponding wa_tagatt to wa_tagattt.
wa_tagattt-descript = wa_attributes-descript.
wa_tagattt-langu = sy-langu.
insert wa_tagattt into table it_tagattt.
clear wa_tagattt.
clear wa_tagatt.
endloop.
clear wa_tag.
clear wa_tagt.
endloop.
* put bsp extension in worklist
data TROBJTYPE type TROBJTYPE.
data trobjName type trobj_name.
TROBJTYPE = GETOBJECTTYPE( ).
trobjName = objName.
TRY.
CALL METHOD CORR_INSERT
EXPORTING
P_AUTHOR = sy-uname
P_DEVCLASS = devclass
.
CATCH ZCX_SAPLINK into l_cx_ref.
raise exception l_cx_ref.
ENDTRY.
TRY.
CALL METHOD ZSAPLINK_WTAG=&gt;ACCESS_PERMISSION
EXPORTING
P_OBJECT_KEY = trobjName
P_MODE = &apos;INSERT&apos;
P_NO_DIALOG = &apos;X&apos;
P_OBJECTTYPE = TROBJTYPE
* IMPORTING
* P_DEVCLASS =
* P_TRANSPORT_KEY =
* P_CORR_NUM =
* P_MASTER_LANG =
* P_MODIFY_LANG =
.
CATCH ZCX_SAPLINK into l_cx_ref.
raise exception l_cx_ref.
ENDTRY.
call function &apos;RS_INSERT_INTO_WORKING_AREA&apos;
EXPORTING
object = TROBJTYPE
obj_name = trobjName
EXCEPTIONS
wrong_object_name = 1.
if sy-subrc &lt;&gt; 0.
raise exception type zcx_saplink
exporting textid = zcx_saplink=&gt;system_error.
endif.
* update database tables
* extension
INSERT INTO o2taglib VALUES wa_o2taglib.
IF wa_taglibt IS NOT INITIAL.
INSERT INTO taglibt VALUES wa_taglibt.
ENDIF.
IF sy-subrc &lt;&gt; 0.
raise exception type zcx_saplink
exporting textid = zcx_saplink=&gt;system_error.
ENDIF.
* elements
INSERT o2tag FROM TABLE it_tag.
IF it_tagt[] IS NOT INITIAL.
INSERT tagt FROM TABLE it_tagt.
ENDIF.
IF sy-subrc &lt;&gt; 0.
raise exception type zcx_saplink
exporting textid = zcx_saplink=&gt;system_error.
ENDIF.
* element attributes
IF it_tagatt[] IS NOT INITIAL.
INSERT o2tagatt FROM TABLE it_tagatt.
ENDIF.
IF it_tagattt[] IS NOT INITIAL.
INSERT tagattt FROM TABLE it_tagattt.
ENDIF.
IF sy-subrc &lt;&gt; 0.
raise exception type zcx_saplink
exporting textid = zcx_saplink=&gt;system_error.
ENDIF.
CALL METHOD ZSAPLINK_WTAG=&gt;UPDATE_OBJECT_LISTS
EXPORTING
P_TLIBID = P_TLIB_EDIT-TLIBID
P_OPERATION = &apos;INSERT&apos;
.
TRY.
CALL METHOD ZSAPLINK_WTAG=&gt;ACCESS_PERMISSION
EXPORTING
P_OBJECT_KEY = trobjName
P_MODE = &apos;FREE&apos;
P_NO_DIALOG = &apos;X&apos;
P_OBJECTTYPE = TROBJTYPE
* IMPORTING
* P_DEVCLASS =
* P_TRANSPORT_KEY =
* P_CORR_NUM =
* P_MASTER_LANG =
* P_MODIFY_LANG =
.
CATCH ZCX_SAPLINK into l_cx_ref.
raise exception l_cx_ref.
ENDTRY.
name = objName.
*CL_O2_TAGLIB_MANAGER-IMPORT_EXTENSION
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="DELETEOBJECT" VERSION="0" LANGU="E" DESCRIPT="Delete object" EXPOSURE="1" STATE="1" EDITORDER="1 " DISPID="0 " AUTHOR="USEWH90" CREATEDON="20060831" CHANGEDBY="USEWH90" CHANGEDON="20060831" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" MTDNEWEXC="X" R3RELEASE="620" BCMTDCAT="00" BCMTDSYN="0">
<exception CLSNAME="ZSAPLINK" CMPNAME="DELETEOBJECT" SCONAME="ZCX_SAPLINK" VERSION="0" LANGU="E" DESCRIPT="SAPlink exception class" MTDTYPE="0" EDITORDER="1 " AUTHOR="USEWH90" CREATEDON="20060831" CHANGEDON="00000000"/>
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
* Plugin created by:
* Phil Young
* ptyoun01@gmail.com
method DELETEOBJECT .
data myTLIBID type O2TLIBID.
data l_cx_ref TYPE REF TO zcx_saplink.
data TROBJTYPE type TROBJTYPE.
data trobjName type trobj_name.
TROBJTYPE = GETOBJECTTYPE( ).
trobjName = objName.
myTLIBID = objName.
TRY.
CALL METHOD ZSAPLINK_WTAG=&gt;ACCESS_PERMISSION
EXPORTING
P_OBJECT_KEY = trobjName
P_MODE = &apos;MODIFY&apos;
P_NO_DIALOG = &apos;X&apos;
P_OBJECTTYPE = TROBJTYPE
* IMPORTING
* P_DEVCLASS =
* P_TRANSPORT_KEY =
* P_CORR_NUM =
* P_MASTER_LANG =
* P_MODIFY_LANG =
.
CATCH ZCX_SAPLINK into l_cx_ref.
raise exception l_cx_ref.
ENDTRY.
* update database tables
* extension
delete from o2taglib where TLIBID = myTLIBID.
delete from taglibt where TLIBID = myTLIBID.
* elements
delete from o2tag where TLIBID = myTLIBID.
delete from tagt where TLIBID = myTLIBID.
* element attributes
delete from o2tagatt where TLIBID = myTLIBID.
delete from tagattt where TLIBID = myTLIBID.
TRY.
CALL METHOD ZSAPLINK_WTAG=&gt;ACCESS_PERMISSION
EXPORTING
P_OBJECT_KEY = trobjName
P_MODE = &apos;FREE&apos;
P_NO_DIALOG = &apos;X&apos;
P_OBJECTTYPE = TROBJTYPE
* IMPORTING
* P_DEVCLASS =
* P_TRANSPORT_KEY =
* P_CORR_NUM =
* P_MASTER_LANG =
* P_MODIFY_LANG =
.
CATCH ZCX_SAPLINK into l_cx_ref.
raise exception l_cx_ref.
ENDTRY.
* remove entry from working area
delete_from_working_area( p_tlibid = myTLIBID
p_global = &apos;X&apos;
p_objecttype = TROBJTYPE ).
* this call also deletes $TMP TADIR entries
update_object_lists( p_tlibid = myTLIBID
p_operation = &apos;DELETE&apos; ).
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK_WTAG" CMPNAME="DELETE_FROM_WORKING_AREA" VERSION="0" LANGU="E" DESCRIPT="Delete BSP Extension from Worklist" EXPOSURE="0" STATE="1" EDITORDER="3 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="1" R3RELEASE="620" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="DELETE_FROM_WORKING_AREA" SCONAME="P_TLIBID" VERSION="0" LANGU="E" DESCRIPT="Tag Library: ID" CMPTYPE="1" MTDTYPE="0" EDITORDER="12 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="O2TLIBID"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="DELETE_FROM_WORKING_AREA" SCONAME="P_GLOBAL" VERSION="0" LANGU="E" DESCRIPT="&apos;X&apos;: ACTUALIZE_WORKING_AREA=&apos;X&apos;" CMPTYPE="1" MTDTYPE="0" EDITORDER="13 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="XFELD"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="DELETE_FROM_WORKING_AREA" SCONAME="P_OBJECTTYPE" VERSION="0" LANGU="E" DESCRIPT="Object Type" CMPTYPE="1" MTDTYPE="0" EDITORDER="14 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="TROBJTYPE"/>
<source>METHOD DELETE_FROM_WORKING_AREA .
DATA:
l_obj_name TYPE trobj_name.
CALL FUNCTION &apos;RS_WORKING_AREA_INIT&apos;.
l_obj_name = p_tlibid.
CALL FUNCTION &apos;RS_DELETE_FROM_WORKING_AREA&apos;
EXPORTING
object = p_objecttype
obj_name = l_obj_name
immediate = &apos;X&apos;
actualize_working_area = p_global.
ENDMETHOD. &quot;delete_from_working_area</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="GETOBJECTTYPE" VERSION="0" LANGU="E" DESCRIPT="Get object type of plugin" EXPOSURE="1" STATE="1" EDITORDER="8 " DISPID="0 " AUTHOR="USEWH90" CREATEDON="20060829" CHANGEDBY="USEWH90" CHANGEDON="20060831" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" BCMTDCAT="00" BCMTDSYN="0">
<parameter VERSION="0" CMPTYPE="0" MTDTYPE="0" EDITORDER="0 " DISPID="0 " CREATEDON="00000000" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="0" TYPTYPE="0"/>
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
method GETOBJECTTYPE .
objecttype = &apos;WTAG&apos;. &quot;BSP Extension
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK_WTAG" CMPNAME="UPDATE_OBJECT_LISTS" VERSION="0" LANGU="E" DESCRIPT="Updating Object Lists" EXPOSURE="0" STATE="1" EDITORDER="4 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="1" R3RELEASE="620" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="UPDATE_OBJECT_LISTS" SCONAME="P_TLIBID" VERSION="0" LANGU="E" DESCRIPT="BSP Extension: ID" CMPTYPE="1" MTDTYPE="0" EDITORDER="15 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="O2TLIBID"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="UPDATE_OBJECT_LISTS" SCONAME="P_OPERATION" VERSION="0" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="16 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="C"/>
<source>METHOD UPDATE_OBJECT_LISTS .
DATA:
l_tree_log TYPE REF TO cl_wb_tree_log,
l_treelog_entry TYPE treelog,
l_treelog_tab TYPE treelog_tab.
CALL FUNCTION &apos;RS_TREE_OBJECT_PLACEMENT&apos;
EXPORTING
object = p_tlibid
type = swbm_c_type_o2_taglibrary
operation = p_operation.
CREATE OBJECT l_tree_log.
CONCATENATE &apos;TL_&apos; p_tlibid INTO l_treelog_entry-tname.
l_treelog_entry-type = swbm_c_type_o2_taglibrary.
l_treelog_entry-name = p_tlibid.
APPEND l_treelog_entry TO l_treelog_tab.
CALL METHOD l_tree_log-&gt;raise_entry_changed
EXPORTING
p_treelog = l_treelog_tab.
ENDMETHOD. &quot;update_object_lists</source>
</method>
<method CLSNAME="ZSAPLINK_WTAG" CMPNAME="WTAG_GETSTRUCTUREFROMATTR" VERSION="0" LANGU="E" DESCRIPT="Updates a structure with node attributes" EXPOSURE="1" STATE="1" EDITORDER="2 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="620" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="WTAG_GETSTRUCTUREFROMATTR" SCONAME="NODE" VERSION="0" LANGU="E" DESCRIPT="IF_IXML_ELEMENT" CMPTYPE="1" MTDTYPE="0" EDITORDER="3 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="WTAG_GETSTRUCTUREFROMATTR" SCONAME="STRUCTURE" VERSION="0" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="4 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="2" PARPASSTYP="1" TYPTYPE="1" TYPE="DATA"/>
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
method WTAG_GETSTRUCTUREFROMATTR .
data attributeList type ref to IF_IXML_NAMED_NODE_MAP.
data nodeIterator type ref to IF_IXML_NODE_ITERATOR.
data attributeNode type ref to if_ixml_node.
data value type string.
data name type string.
field-symbols &lt;value&gt; type any.
************************************************************************
data tableDescr type ref to cl_abap_tabledescr.
data structDescr type ref to cl_abap_structdescr.
data typeDescr type ref to cl_abap_typedescr.
data childNode type ref to if_ixml_element.
data filter type ref to if_ixml_node_filter.
data iterator type ref to if_ixml_node_iterator.
data childName type string.
data it_foo type ref to data.
data wa_foo type ref to data.
field-symbols: &lt;tab&gt; type any table.
field-symbols: &lt;row&gt; type any.
************************************************************************
clear structure.
attributeList = node-&gt;GET_ATTRIBUTES( ).
nodeIterator = attributeList-&gt;create_iterator( ).
attributeNode = nodeIterator-&gt;get_next( ).
while attributeNode is not initial.
name = attributeNode-&gt;get_name( ).
if name = &apos;VERSION&apos;.
value = &apos;0&apos;.
else.
value = attributeNode-&gt;get_value( ).
endif.
assign component name of structure structure to &lt;value&gt;.
if sy-subrc = 0.
************************************************************************
typeDescr = cl_abap_typedescr=&gt;DESCRIBE_BY_DATA(
p_data = &lt;value&gt; ).
try.
tableDescr ?= typeDescr.
catch CX_SY_MOVE_CAST_ERROR.
endtry.
try.
structDescr ?= typeDescr.
catch CX_SY_MOVE_CAST_ERROR.
endtry.
if tableDescr is initial and structDescr is initial.
&lt;value&gt; = value.
elseif tableDescr is initial.
childNode ?= Node-&gt;get_first_child( ).
while childNode is not initial.
childName = childNode-&gt;GET_NAME( ).
if childName = name.
call method WTAG_GETSTRUCTUREFROMATTR
exporting
node = childNode
changing
structure = &lt;value&gt;.
exit.
endif.
childNode ?= childNode-&gt;get_next( ).
endwhile.
else.
create data it_foo type handle tableDescr.
assign it_foo-&gt;* to &lt;tab&gt;.
create data wa_foo like line of &lt;tab&gt;.
assign wa_foo-&gt;* to &lt;row&gt;.
free childNode.
childNode ?= Node-&gt;get_first_child( ).
while childNode is not initial.
childName = childNode-&gt;GET_NAME( ).
if childName = name.
clear &lt;row&gt;.
call method WTAG_GETSTRUCTUREFROMATTR
exporting
node = childNode
changing
structure = &lt;row&gt;.
insert &lt;row&gt; into table &lt;tab&gt;.
endif.
childNode ?= childNode-&gt;get_next( ).
endwhile.
&lt;value&gt; = &lt;tab&gt;.
endif.
clear tableDescr.
clear structDescr.
clear typedescr.
clear it_foo.
clear wa_foo.
************************************************************************
endif.
attributeNode = nodeIterator-&gt;get_next( ).
endwhile.
endmethod.</source>
</method>
<method CLSNAME="ZSAPLINK_WTAG" CMPNAME="WTAG_SETATTRIBUTESFROMSTR" VERSION="0" LANGU="E" DESCRIPT="Creates an XML Attribute list from any structure" EXPOSURE="1" STATE="1" EDITORDER="1 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" R3RELEASE="620" BCMTDCAT="00" BCMTDSYN="0">
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="WTAG_SETATTRIBUTESFROMSTR" SCONAME="NODE" VERSION="0" LANGU="E" DESCRIPT="xml Element" CMPTYPE="1" MTDTYPE="0" EDITORDER="1 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="3" TYPE="IF_IXML_ELEMENT"/>
<parameter CLSNAME="ZSAPLINK_WTAG" CMPNAME="WTAG_SETATTRIBUTESFROMSTR" SCONAME="STRUCTURE" VERSION="0" LANGU="E" CMPTYPE="1" MTDTYPE="0" EDITORDER="2 " DISPID="0 " AUTHOR="USPTY90" CREATEDON="20060919" CHANGEDON="00000000" PARDECLTYP="0" PARPASSTYP="1" TYPTYPE="1" TYPE="DATA"/>
<source>*/---------------------------------------------------------------------\
*| This file is part of SAPlink. |
*| |
*| SAPlink is free software; you can redistribute it and/or modify |
*| it under the terms of the GNU General Public License as published |
*| by the Free Software Foundation; either version 2 of the License, |
*| or (at your option) any later version. |
*| |
*| SAPlink is distributed in the hope that it will be useful, |
*| but WITHOUT ANY WARRANTY; without even the implied warranty of |
*| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
*| GNU General Public License for more details. |
*| |
*| You should have received a copy of the GNU General Public License |
*| along with SAPlink; if not, write to the |
*| Free Software Foundation, Inc., |
*| 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
*\---------------------------------------------------------------------/
method WTAG_SETATTRIBUTESFROMSTR .
data int type i.
int = int.
data structDescr type ref to cl_abap_structDescr.
data aComponent type abap_compdescr.
field-symbols &lt;fieldValue&gt; type any.
data rc type sysubrc.
data sName type string.
data sValue type string.
****************************************************************
data tableDescr type ref to cl_abap_tabledescr.
data structDescr2 type ref to cl_abap_structdescr.
data typeDescr type ref to cl_abap_typedescr.
data childNode type ref to if_ixml_element.
data childName type string.
data it_foo type ref to data.
field-symbols: &lt;tab&gt; type any table.
field-symbols: &lt;row&gt; type any.
****************************************************************
structDescr ?= cl_abap_structDescr=&gt;describe_by_data( structure ).
loop at structDescr-&gt;components into aComponent.
assign component aComponent-name of structure
structure to &lt;fieldValue&gt;.
if sy-subrc = 0.
sName = aComponent-name.
* sValue = &lt;fieldValue&gt;.
* for certain attributes, set to a standard for exporting
case sName.
when &apos;VERSION&apos;. &quot;version should always export as inactive
sValue = &apos;0&apos;.
when &apos;DEVCLASS&apos;. &quot;development class should always be $TMP
sValue = &apos;$TMP&apos;.
when others.
**********************************************************
typeDescr = cl_abap_typedescr=&gt;DESCRIBE_BY_DATA(
p_data = &lt;fieldValue&gt; ).
try.
tableDescr ?= typeDescr.
catch CX_SY_MOVE_CAST_ERROR.
endtry.
try.
structDescr2 ?= typeDescr.
catch CX_SY_MOVE_CAST_ERROR.
endtry.
if tableDescr is initial and structDescr2 is initial.
sValue = &lt;fieldValue&gt;.
elseif tableDescr is initial.
sValue = &apos;$$STRUCTURE$$&apos;.
childName = aComponent-name.
childNode = xmlDoc-&gt;create_element( childName ).
WTAG_SETATTRIBUTESFROMSTR( node = childNode
structure = &lt;fieldValue&gt; ).
rc = Node-&gt;append_child( childNode ).
else.
sValue = &apos;$$TABLE$$&apos;.
create data it_foo type handle tableDescr.
* get reference of &lt;fieldvalue&gt; into it_foo.
assign it_foo-&gt;* to &lt;tab&gt;.
&lt;tab&gt; = &lt;fieldValue&gt;.
loop at &lt;tab&gt; assigning &lt;row&gt;.
childName = aComponent-name.
childNode = xmlDoc-&gt;create_element( childName ).
WTAG_SETATTRIBUTESFROMSTR( node = childNode
structure = &lt;row&gt; ).
rc = Node-&gt;append_child( childNode ).
endloop.
endif.
clear it_foo.
clear tableDescr.
clear structDescr2.
clear typedescr.
* sValue = &lt;fieldValue&gt;.
**********************************************************
endcase.
if sValue is not initial.
rc = Node-&gt;set_attribute( name = sName value = sValue ).
endif.
else.
* WHAT?&gt;!??
endif.
endloop.
endmethod.</source>
</method>
</CLAS>
You can’t perform that action at this time.