05-08-2006 9:10 AM
Hello every SDNer,
I wanna convert a smartform to a Xml-file with FM FB_CONVERT_FORM_TO_XML. The smartform is 'SF_EXAMPLE_01', but the XML-file has always error. who can help me, to find the problem. the code as following.
regards
Thanks in advance
REPORT ZYLITEST1.
*----
data : x type xstring.
data : begin of itab occurs 0,
f(100) type c,
end of itab.
data : xml type string.
*----
CALL FUNCTION 'FB_CONVERT_FORM_TO_XML'
EXPORTING
I_FORMNAME = 'SF_EXAMPLE_01'
IMPORTING
E_XML = x
EXCEPTIONS
NO_NAME = 1
NO_FORM = 2
NO_ACTIVE_SOURCE = 3
CONVERSION_ERROR = 4
ILLEGAL_FORMTYPE = 5
GENERATION_ERROR = 6
OTHERS = 7
.
*----
CALL FUNCTION 'NLS_STRING_CONVERT_TO_SYS'
EXPORTING
LANG_USED = 'E'
SOURCE = x
FROM_FE = 'MS '
IMPORTING
RESULT = xml
SUBSTED =
EXCEPTIONS
ILLEGAL_SYST_CODEPAGE = 1
NO_FE_CODEPAGE_FOUND = 2
COULD_NOT_CONVERT = 3
OTHERS = 4.
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
.
*----
CALL FUNCTION 'SOTR_SERV_STRING_TO_TABLE'
EXPORTING
TEXT = xml
FLAG_NO_LINE_BREAKS = ' '
LINE_LENGTH =
LANGU = SY-LANGU
TABLES
TEXT_TAB = itab
.
*----
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'c:\aa.xml'
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = 'X'
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = itab
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
05-08-2006 9:30 AM
Check below function module
<b>SDIXML_DATA_TO_DOM</b> Convert SAP data (elementary/structured/table types) into DOM (XML)
<b>SDIXML_DOM_TO_XML</b> Convert DOM (XML) into string of bytes that can be downloaded to PC or application server
<b>SDIXML_DOM_TO_SCREEN</b> Display DOM (XML)
<b>SDIXML_DOM_TO_DATA </b>
regards
vinod
05-08-2006 10:46 AM
incorporate these changes.
after the call of 'FB_CONVERT_FORM_TO_XML' remove all other function calls except gui download
and use the following code
data: dtab type standard table of solix.
data: filelength type i .
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = X " variable holding xml in xstring
TABLES
binary_tab = dtab .
filelength = xstrlen( X ) .
now use dtab in gui_download and the file type has to be BIN and pass filelength .
Regards
Raja
05-08-2006 5:02 PM
Hi Raja,
Thx
another question.
I wanna create a SystemAction,which can create a PDF corresponding my BSP-page. so i need a according SmartForm. i wanna know ,how i can dynamically create a smartform, or can modify the smartform on the fly?
the weblog /people/sap.user72/blog/2004/11/10/bsphowto-generate-pdf-output-from-a-bsp i have read and tested.
FM OPEN_FORM, WRITE_FORM, CLOSE_FORM...
Can man modify the Smartform with WRITE_FORM? Can you give me some suggestions and code.
Thanks in advance
best regards.
Yaning
05-09-2006 9:23 AM
sorry i am not a SMARTFORM expert thus can tell you whether you can dynamically at runtime create smart forms or modify them. may be close this thread and open another thread wiith your new question.
Regards
Raja