Code: Alles auswählen.
FUNCTION zread_smartforms
IMPORTING id_name TYPE csequence
id_variant TYPE csequence optional
id_spras TYPE spras default SY-LANGU
EXPORTING et_text TYPE tlinetab
es_header TYPE ssfhead.
DATA:
ld_variant TYPE tdvariant,
ld_name TYPE tdtxtname,
ld_spras TYPE tdspras,
lr_form TYPE REF TO cl_ssf_fb_smart_form,
lr_text TYPE REF TO cl_ssf_fb_text_item.
FIELD-SYMBOLS:
<ls_variant> TYPE ssfvarhdr.
REFRESH et_text.
CLEAR es_header.
ld_spras = id_spras.
IF ld_spras IS INITIAL.
ld_spras = sy-langu.
ENDIF.
ld_name = id_name.
IF ld_name IS INITIAL.
RETURN.
ENDIF.
* read text module
CREATE OBJECT lr_form.
TRY.
* check if exists and lock text module
lr_form->enqueue( language_upd_exit = space
suppress_language_check = space
mode = 'SHOW'
formname = ld_name
authority_check = space ).
lr_form->load( im_formname = ld_name
im_language = ld_spras
im_active = abap_true ).
CATCH cx_ssf_fb.
RETURN.
ENDTRY.
IF lr_form->header-formtype NE cssf_formtype_text.
RETURN.
ENDIF.
es_header = lr_form->header.
* get lines[]
IF et_text IS SUPPLIED.
ld_variant = id_variant.
READ TABLE lr_form->varheader ASSIGNING <ls_variant> WITH KEY vari = ld_variant.
IF sy-subrc EQ 0.
lr_text ?= <ls_variant>-pagetree->obj.
IF lr_text IS BOUND.
et_text = lr_text->text.
ENDIF.
ENDIF.
ENDIF.
lr_form->dequeue( EXPORTING formname = ld_name ).
ENDFUNCTION.
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
abuma
Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report YBC_READ_SMARTFORM_XML
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT YBC_READ_SMARTFORM_XML.
constants: c_xml_ns_uri_sf(255) type c
value 'urn:sap-com:SmartForms:2000:internal-structure', "#EC NOTEXT
c_xml_ns_uri_ifr(255) type c
value 'urn:sap-com:sdixml-ifr:2000'. "#EC NOTEXT
types: t_gnode type ssfgnode,
t_gnodes type tsfgnode.
* internal tables
data: g_nodes type t_gnodes with header line,
wa_g_nodes like line of g_nodes.
data: l_filename type string,
l_file_filter type string,
l_user_action type i.
data: wa_node like line of g_nodes,
l_element type ref to if_ixml_element.
data: l_language_str type string,
l_language(2) type c.
data: l_lines type i,
l_splitted_name_tab type table of string.
data: l_stylename type tdssname,
l_stylevari type tdvariant,
l_save_style type tdssname.
data: g_ixml type ref to if_ixml,
xml_document type ref to if_ixml_document,
xml_element type ref to if_ixml_element,
xml_ns_prefix_sf type string,
xml_ns_uri_sf type string,
xml_ns_uri_ifr type string,
xml_macro_name type string,
xml_macro_rc type i,
xml_macro_objt type stxfobjt,
xml_macro_text type stxftxt,
xml_macro_tline type tline,
xml_upload_language type tdspras.
types: t_raw(250) type x.
data: xml_xtable type table of t_raw with header line,
xml_document_size type i,
g_download_path type string,
g_xml_fullpath type string.
data: sform type ref to cl_ssf_fb_smart_form.
* Namen der aktuell bearbeiteten Objekte
data: formname type tdsfname, " Name des Formulars
variant type tdvariant, " Name der Formularvariante
language type sy-langu, " Bearbeitungssprache
fmnumb type tdfmnumb, " Nummer des zugeordneten Fb
fmnumb_test type tdfmnumb. " Fb zum Test der inaktiven Fassung
parameters form type TDSFNAME obligatory MATCHCODE OBJECT SH_STXFADM.
formname = form.
language = 'D'.
* create form object
create object sform.
call method sform->load
exporting im_formname = formname
im_language = language
im_active = space
importing ex_fmnumb = fmnumb
ex_fmnumb_test = fmnumb_test.
if g_ixml is initial.
g_ixml = cl_ixml=>create( ).
endif.
xml_document = g_ixml->create_document( ).
xml_ns_prefix_sf = 'sf'.
xml_ns_uri_sf = c_xml_ns_uri_sf.
xml_ns_uri_ifr = c_xml_ns_uri_ifr.
clear: xml_document_size, xml_xtable[].
sform->xml_init( ).
* create XML for the entire smart form
call method sform->xml_download
exporting parent = xml_document
changing document = xml_document.
* namespace
l_element = xml_document->get_root_element( ).
l_element->set_attribute( name = xml_ns_prefix_sf
namespace = 'xmlns'
value = xml_ns_uri_sf ).
l_element->set_attribute( name = 'xmlns'
value = xml_ns_uri_ifr ).
* language
write language to l_language.
l_language_str = l_language.
xml_macro_rc = l_element->set_attribute(
name = 'language'
namespace = xml_ns_prefix_sf
value = l_language_str ).
** convert DOM to xml
*call function 'SDIXML_DOM_TO_XML'
* exporting document = xml_document
* importing size = xml_document_size
* tables xml_as_table = xml_xtable
* exceptions others = 1.
*
*
* DATA d TYPE REF TO if_ixml_document.
* DATA e TYPE REF TO if_ixml_element.
* DATA problems TYPE dcxmlprbl.
*
*
*e = d->get_root_element( ).
*
*CALL FUNCTION 'SDIXML_DOM_TO_DATA'
* EXPORTING
* data_as_dom = e
** CONTROL =
* IMPORTING
* DATAOBJECT =
* PROBLEMS = problems
** EXCEPTIONS
** ILLEGAL_OBJECT = 1
** OTHERS = 2
* .
*IF sy-subrc <> 0.
** MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
** WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
data lv_title type sy-title.
concatenate 'Smartform :' form into lv_title.
CALL FUNCTION 'SDIXML_DOM_TO_SCREEN'
EXPORTING
document = xml_document
TITLE = lv_title
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
Da gabs bei mir anfangs noch den Fehler "Forbidden".wreichelt hat geschrieben:Beitrag von wreichelt » 20.02.2017, 13:13
Hallo abuma,
über Hilfsmittel -> Formularinfo kann nach allen möglichen Texten gesucht werden.
Wenn zumindest etwas bekannt ist kann das evtl. hierrüber gefunden werden.
Gruß
Wolfgang