Permalink
Fetching contributors…
Cannot retrieve contributors at this time
422 lines (353 sloc) 20 KB
<?xml version="1.0" encoding="iso-8859-1"?>
<CLAS CLSNAME="ZSAPLINK_PDF_FORMS" VERSION="0" LANGU="E" DESCRIPT="SAPlink - Programs" UUID="0B9526B3AABD5941B0F001C273BF36C4" CATEGORY="00" EXPOSURE="2" STATE="1" RELEASE="0" AUTHOR="BCUSER" CREATEDON="20061010" CHANGEDON="00000000" CHGDANYON="00000000" CLSFINAL="X" CLSCCINCL="X" FIXPT="X" UNICODE="X" R3RELEASE="700" CLSBCCAT="00" DURATION_TYPE="0 " RISK_LEVEL="0 " REFCLSNAME="ZSAPLINK">
<publicSection>class ZSAPLINK_PDF_FORMS definition
public
inheriting from ZSAPLINK
final
create public .
*&quot;* public components of class ZSAPLINK_PDF_FORMS
*&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_SMARTFORM
*&quot;* do not include other source files here!!!
protected section.
methods DELETEOBJECT
redefinition .
methods GETOBJECTTYPE
redefinition .</protectedSection>
<privateSection>*&quot;* private components of class ZSAPLINK_SMARTFORM
*&quot;* do not include other source files here!!!
private section.</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" CMPNAME="CHECKEXISTS" VERSION="0" LANGU="E" DESCRIPT="Check if object exists" EXPOSURE="2" STATE="1" EDITORDER="9 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20061006" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" R3RELEASE="700" 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 checkexists .
SELECT SINGLE name FROM fplayout INTO objname WHERE name = objname.
IF sy-subrc = 0.
exists = &apos;X&apos;.
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="BCUSER" CREATEDON="20061006" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" MTDNEWEXC="X" R3RELEASE="700" 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="BCUSER" CREATEDON="20061006" 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 createixmldocfromobject .
DATA rootnode TYPE REF TO if_ixml_element.
DATA sourcenode TYPE REF TO if_ixml_element.
DATA rc TYPE sysubrc.
DATA sourcestring TYPE string.
DATA _objtype TYPE string.
TYPES: t_raw(1024) TYPE x.
DATA: l_wb_form TYPE REF TO if_fp_wb_form,
l_form TYPE REF TO if_fp_form,
l_formname TYPE fpname,
l_name TYPE string,
l_file_table TYPE filetable,
l_filename TYPE string,
l_pathname TYPE string,
l_fullpath TYPE string,
l_rc TYPE i,
l_user_action TYPE i,
l_xstring TYPE xstring,
l_string TYPE string,
l_binary_table TYPE TABLE OF t_raw,
l_binary_length TYPE i,
l_node TYPE REF TO if_fp_node,
l_form_wb TYPE REF TO cl_fp_wb_form,
l_form_wb_if TYPE REF TO if_fp_wb_form.
l_formname = objname.
TRY.
CALL METHOD cl_fp_wb_form=&gt;load
EXPORTING
i_name = l_formname
RECEIVING
r_wb_form = l_form_wb_if.
CATCH cx_fp_api_usage .
CLEAR ixmldocument.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=&gt;not_found.
CATCH cx_fp_api_repository .
CLEAR ixmldocument.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=&gt;not_found.
CATCH cx_fp_api_internal .
CLEAR ixmldocument.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=&gt;not_found.
ENDTRY.
l_wb_form ?= l_form_wb_if.
l_form ?= l_wb_form-&gt;get_object( ).
l_name = l_wb_form-&gt;get_name( ).
TRY.
l_xstring = cl_fp_helper=&gt;convert_form_to_xstring( l_form ).
CATCH cx_fp_api_internal.
CLEAR ixmldocument.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING textid = zcx_saplink=&gt;not_found.
ENDTRY.
_objtype = getobjecttype( ).
rootnode = xmldoc-&gt;create_element( _objtype ).
DATA: wa_fplayout TYPE fplayout.
SELECT SINGLE * FROM fplayout INTO wa_fplayout WHERE name = objname.
setattributesfromstructure( node = rootnode structure = wa_fplayout
).
sourcenode = xmldoc-&gt;create_element( &apos;PDFform&apos; ).
l_string = l_xstring.
rc = sourcenode-&gt;if_ixml_node~set_value( l_string ).
rc = rootnode-&gt;append_child( sourcenode ).
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="BCUSER" CREATEDON="20061006" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" MTDNEWEXC="X" R3RELEASE="700" 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="BCUSER" CREATEDON="20061006" 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 createobjectfromixmldoc .
DATA rootnode TYPE REF TO if_ixml_element.
DATA progattribs TYPE trdir.
DATA sourcenode TYPE REF TO if_ixml_element.
DATA l_xml_node TYPE REF TO if_ixml_element.
DATA source TYPE string.
DATA sourcetable TYPE table_of_strings.
DATA _objtype TYPE string.
DATA checkexists TYPE flag.
DATA: wa_fplayout TYPE fplayout,
formname TYPE tdsfname,
modif_language TYPE sylangu.
TYPES: t_raw(1024) TYPE x.
DATA: l_exception_workbench TYPE REF TO cx_fp_ui_workbench,
l_exception_usage TYPE REF TO cx_fp_api_usage,
l_exception_repository TYPE REF TO cx_fp_api_repository,
l_exception_internal TYPE REF TO cx_fp_api_internal,
l_message_text TYPE string,
l_form TYPE REF TO if_fp_form,
l_file_table TYPE filetable,
l_filename TYPE string,
l_rc TYPE i,
l_user_action TYPE i,
l_xstring TYPE xstring,
l_binary_table TYPE TABLE OF t_raw,
l_binary_length TYPE i,
l_node TYPE REF TO if_fp_node,
m_wb_object TYPE REF TO if_fp_wb_form.
_objtype = getobjecttype( ).
xmldoc = ixmldocument.
rootnode = xmldoc-&gt;find_from_name( _objtype ).
CALL METHOD getstructurefromattributes
EXPORTING
node = rootnode
CHANGING
structure = wa_fplayout.
objname = wa_fplayout-name.
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
deleteobject( ).
ENDIF.
ENDIF.
sourcenode = rootnode-&gt;find_from_name( &apos;PDFform&apos; ).
source = sourcenode-&gt;get_value( ).
l_xstring = source.
formname = objname.
TRY.
TRY.
cl_fp_wb_helper=&gt;form_exists( wa_fplayout-name ).
CATCH cx_fp_api_usage INTO l_exception_usage.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = &apos;Error creating PDF form&apos;.
CATCH cx_fp_api_repository INTO l_exception_repository.
CASE l_exception_repository-&gt;textid.
WHEN cx_fp_api_repository=&gt;object_already_exists.
l_message_text = l_exception_repository-&gt;get_text( ).
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = &apos;Object already exists&apos;.
ENDCASE.
ENDTRY.
TRY.
l_form = cl_fp_helper=&gt;convert_xstring_to_form( i_xstring = l_xstring i_language = sy-langu ).
CALL METHOD cl_fp_helper=&gt;set_new_layout_id
CHANGING
c_form = l_form.
CATCH cx_fp_api_internal.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = &apos;Convert XML error&apos;.
EXIT.
ENDTRY.
TRY.
m_wb_object = cl_fp_wb_form=&gt;create( i_name = wa_fplayout-name i_form = l_form ).
CATCH cx_fp_api_usage INTO l_exception_usage.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = &apos;Error creating PDF form&apos;.
CATCH cx_fp_api_repository INTO l_exception_repository.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = &apos;Error creating PDF form&apos;.
ENDTRY.
TRY.
m_wb_object-&gt;save( ).
CATCH cx_fp_api_usage INTO l_exception_usage.
TRY.
m_wb_object-&gt;free( ).
CATCH cx_fp_api.
ENDTRY.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = &apos;Error saving PDF form&apos;.
CATCH cx_fp_api_repository INTO l_exception_repository.
TRY.
m_wb_object-&gt;free( ).
CATCH cx_fp_api.
ENDTRY.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = &apos;Error saving PDF form&apos;.
CATCH cx_fp_api_internal INTO l_exception_internal.
TRY.
m_wb_object-&gt;free( ).
CATCH cx_fp_api.
ENDTRY.
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = &apos;Error saving PDF form&apos;.
ENDTRY.
TRY.
m_wb_object-&gt;free( ).
CATCH cx_fp_api.
ENDTRY.
CATCH cx_fp_ui_workbench INTO l_exception_workbench.
IF l_exception_workbench-&gt;textid &lt;&gt; cx_fp_ui_workbench=&gt;error_occured.
l_message_text = l_exception_workbench-&gt;get_text( ).
RAISE EXCEPTION TYPE zcx_saplink
EXPORTING msg = l_message_text.
ENDIF.
ENDTRY.
ENDMETHOD.</source>
</method>
<method CLSNAME="ZSAPLINK" CMPNAME="DELETEOBJECT" VERSION="0" LANGU="E" DESCRIPT="Delete object" EXPOSURE="1" STATE="1" EDITORDER="1 " DISPID="0 " AUTHOR="BCUSER" CREATEDON="20061006" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" MTDNEWEXC="X" R3RELEASE="700" 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="BCUSER" CREATEDON="20061006" 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 deleteobject .
DATA: l_wb_form TYPE REF TO cl_fp_wb_form,
l_formname TYPE fpname.
l_formname = objname.
TRY.
CALL METHOD cl_fp_wb_form=&gt;delete
EXPORTING
i_name = l_formname.
CATCH cx_fp_api_usage .
CATCH cx_fp_api_repository .
ENDTRY.
ENDMETHOD. &quot;createobjectfromixmldoc</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="BCUSER" CREATEDON="20061006" CHANGEDON="00000000" MTDTYPE="0" MTDDECLTYP="0" MTDABSTRCT="X" R3RELEASE="700" 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;SFPF&apos;. &quot;Form Object: Form
ENDMETHOD.</source>
</method>
</CLAS>