09-28-2015 7:15 AM
Hi,
I have a SAPscript text, which contains an email text, I have to send via bcs-classes. Email sending is working fine, but now I am supposed to translate some program variables within the SAPscript text.
I think "program symbols" and the FM text_symbol_replace are the right way, but which attributes such a program variable has to have to be determined?
I have to say, that my mail is sent by a method, not by a report (so, no "global" fields are available).
10-06-2015 8:57 AM
Hi,
Thinking aloud....
If you call a function from your method...
In the function group at the top you put your variable data.
And my test: (very crud)
Function group top include
FUNCTION y_r_eitan_tests_06.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"----------------------------------------------------------------------
DATA: st_thead TYPE thead .
DATA: it_lines TYPE tline_tab .
st_thead-tdobject = 'TEXT' .
st_thead-tdname = 'Y_R_EITAN_01' .
st_thead-tdid = 'ST' .
st_thead-tdspras = 'E' .
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = st_thead-tdid
language = st_thead-tdspras
name = st_thead-tdname
object = st_thead-tdobject
IMPORTING
header = st_thead
TABLES
lines = it_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc NE 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
st_makt-matnr = '1234567890' .
st_makt-maktx = 'I am a description !!!' .
* Not used !!!!!!!!!!
* CALL FUNCTION 'TEXT_SYMBOL_REPLACE'
* EXPORTING
* header = st_thead
* INIT = ' '
* option_dialog = abap_true
* program = sy-repid
* REPLACE_PROGRAM = 'X'
* REPLACE_STANDARD = 'X'
* REPLACE_SYSTEM = 'X'
* REPLACE_TEXT = 'X'
* STARTLINE = 1
* ENDLINE = 99999
* IMPORTING
* CHANGED =
* NEWHEADER =
* TABLES
* lines = it_lines .
DATA: st_options TYPE itcpo.
st_options-tdprogram = sy-repid .
CALL FUNCTION 'PRINT_TEXT'
EXPORTING
OPTIONS = st_options
dialog = abap_true
header = st_thead
TABLES
lines = it_lines
EXCEPTIONS
canceled = 1
device = 2
form = 3
OPTIONS = 4
unclosed = 5
unknown = 6
format = 7
textformat = 8
communication = 9
bad_pageformat_for_print = 10
OTHERS = 11.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFUNCTION.
Note that the use of PRINT_TEXT .
You can suspend the dialog and get your OTFDATA from there.
Regards.
09-28-2015 7:13 PM
The same concept is used in POPUP_TO_CONFIRM, where the function replaces variables from a text object, using the values passed by the calling program.
Thanks,
Juwin
09-29-2015 10:28 AM
09-29-2015 3:23 AM
I used READ_TEXT followed by TEXT_CONTROL_REPLACE in one of the programs, but it was a report, so no such issues. Have a look at the FM documentation. There is parameter PROGRAM that might be helpful (although I didn't quite get the documentation text, seems like a bad translation).
Also take a look at 'where used' -> Classes for this FM.
09-29-2015 9:22 AM
Unfortunately not. I call TEXT_SYMBOL_REPLACE with parameter PROGRAM = 'ZCL.....CP', it searches in global variables (which does not exist in a class) and for that reason, my text symbol is deleted. I do have tried:
* using a local variable of the same name in my method
* using a class-data public variable of the same name in my global class
What can I do, now?
09-29-2015 9:34 AM
You could use in sequence
and send the final html in mail body
Regards,
Raymond
09-29-2015 9:39 AM
This is the same Calling Chain, TEXT_SYMBOL_REPLACE uses.... What could I win by calling them manually?
09-29-2015 9:47 AM
You can "manually" get yourself the fields required and pass them to sapscript using SET_TEXTSYMBOL.
09-29-2015 10:01 AM
As you can see, the following code row shows, that TEXT_SYMBOL_REPLACE can not used in any type of classes - because a dirty assign will never run into a class:
If THIS is the way, SAP wants to power OO coding, it will fail. According to the coding, it detects ONLY "tables" (which are forbidden in classes) and "global variables" (which are also forbidden in classes). This results into the fact, that this FB will NEVER run properly, if it's called from a method.
So, I have to write a procedural function module, just for transporting my variables to this TEXT_SYMBOL_REPLACE.
I won't write here, what I shouted through the room, when I saw this, SCN would ban me.
09-29-2015 5:20 PM
Hi,
Provided you can pass the text lines on to mail processing dynamically, and the subsequent text processing is "SapScript conform", the easiest to quickly put something together (while staying in OO) would probably be to use the trick CL_SAPSCRIPT_LONGTEXT->ADD_PLACEHOLDER_VALUES is using. Namely, prepend the text with the lines containing SapScript symbol and formatted value pair definitions.
One could verify if the subsequent processing is "SapScript conform" by adding some symbol definitions to the text manually; something like this:
The symbol table can be collected using FM TEXT_SYMBOL_COLLECT, and it's entirely up to you where the values are gonna come from. There are limitations on the length of formatted values: 60 characters, or 80 - when the value contains another symbol.
cheers
Janis
09-29-2015 5:37 PM
09-30-2015 5:06 PM
The problem is, that this method adds the DEFINEs into the text, but I don't believe, that the CL_BCS-classes will replace the symbols by the values (which you called "SAPscript conformity"
10-01-2015 9:02 AM
The symbol replacement kind of "works" for both the attachment (I_ATTACHMENT_TYPE = 'SCR'; see TSOTD entry) and the body (I_TYPE = 'SCR'):
but:
- the result is IMO unusable, because there is no way to supply the style definition to BCS (formatting lost in SAPConnect) or the layout information;
- our SAPConnect settings would turn SapScript body into pdf anyway,
- SOST display is not correct (line breaks around variable):
However, the text so prepared can be converted using FM 'CONVERT_ITF_TO_HTML' (I_REPLACE = 'X', I_PRINT_COMMANDS = space), and would display properly in SOST (would preserve at least basic formatting):
What I have problem with is that the html (apart from the opening <html> tag) would apparently get taken out both from the body and the attachment somewhere during sending... (I believe this is SAPConnect setup problem at our place). There are discussions on SCN about this, but, as with so many topics on SCN, I wasn't able to find a solution thus far...
"Fazit": SapScript symbol replacement would work properly on a text so prepared. How useful SapScript text would be in mail or other processing, considering the meager "API" for these texts that can be found in SAP (I would not use word "offered" here...), is... *ahem* open for debate.
Frankly, I'd be messing with SapScript text only if it's processed via PWB Application Form (or at least "naked" Smartform)...
cheers
Jānis
10-05-2015 3:33 PM
It seems to work - with a litte problem:
CONVERT_ITF_TO_HTML creates a HTML text with surplus paragraph-tags:
How can I avoid this? There is no reason to create a special paragraph for '12345'....
10-06-2015 6:54 AM
Hi,
No idea where the extra paragraph comes from. The TEXT_SYMBOL_REPLACE would work on a text with DEFINEs - that's what the CONVERT_ITF_TO_HTML calls internally (among other stuff; see Form REPLACE_ITF_TEXT in LSTXNF05).
cheers
Jānis
10-07-2015 12:01 PM
The problem is, that each symbol is included in <P>-tags, which results into separate paragraphs for each symbol.
Example:
This is an example text with a symbol &xmpl&
Result from CONVERT_ITF_TO_HTML:
<P>This is an example text with a symbol</P>
<P> &xmpl&</P>
This kind of text is unusable......
10-01-2015 5:56 PM
Ralf, I'm not sure how complex your standard text is, but maybe a simple solution would be to just read the text and do some kind of DIY symbol replacement? If it's just a few variables then simple string search/replace would do.
Or consider using something else entirely (again - depends on how complex the text is).
10-05-2015 3:59 PM
Hi Ralf,
i have done some replacements using CONVERT_ITF_TO_HTML.
your HTLM can just have simple formatings. as far as i know floating-text should work, never tried more than just simple symbol replacements. i dont think something like "DEFINE" or "IF" gets translatet correctly. in this case its no sap-script, its just a simple SO10-Text that can be used for your email-Body. if you need something more complex you will have to "build" your own HTML-Code.
Maybe you can call "TEXT_SYMBOL_REPLACE" befor CONVERT_ITF_TO_HTML. looking to the interface of TEXT_SYMBOL_REPLACE looks like it would also translate SAP-SCRIPT-Statements.
Regards
Stefan Seeburger
10-05-2015 4:04 PM
As I wrote: TEXT_SYMBOL_REPLACE does not work properly in methods, because it makes a dirty assign into the main program (which does not exist for a method).
See my posting above ( Sep 29, 2015 11:02 AM )
10-06-2015 11:44 AM
Hi,
there is always a main programm... maybe support it to your method via interface-parameter, or do an external assign.
regards
Stefan Seeburger
10-06-2015 11:58 AM
10-06-2015 8:57 AM
Hi,
Thinking aloud....
If you call a function from your method...
In the function group at the top you put your variable data.
And my test: (very crud)
Function group top include
FUNCTION y_r_eitan_tests_06.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"----------------------------------------------------------------------
DATA: st_thead TYPE thead .
DATA: it_lines TYPE tline_tab .
st_thead-tdobject = 'TEXT' .
st_thead-tdname = 'Y_R_EITAN_01' .
st_thead-tdid = 'ST' .
st_thead-tdspras = 'E' .
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = st_thead-tdid
language = st_thead-tdspras
name = st_thead-tdname
object = st_thead-tdobject
IMPORTING
header = st_thead
TABLES
lines = it_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc NE 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
st_makt-matnr = '1234567890' .
st_makt-maktx = 'I am a description !!!' .
* Not used !!!!!!!!!!
* CALL FUNCTION 'TEXT_SYMBOL_REPLACE'
* EXPORTING
* header = st_thead
* INIT = ' '
* option_dialog = abap_true
* program = sy-repid
* REPLACE_PROGRAM = 'X'
* REPLACE_STANDARD = 'X'
* REPLACE_SYSTEM = 'X'
* REPLACE_TEXT = 'X'
* STARTLINE = 1
* ENDLINE = 99999
* IMPORTING
* CHANGED =
* NEWHEADER =
* TABLES
* lines = it_lines .
DATA: st_options TYPE itcpo.
st_options-tdprogram = sy-repid .
CALL FUNCTION 'PRINT_TEXT'
EXPORTING
OPTIONS = st_options
dialog = abap_true
header = st_thead
TABLES
lines = it_lines
EXCEPTIONS
canceled = 1
device = 2
form = 3
OPTIONS = 4
unclosed = 5
unknown = 6
format = 7
textformat = 8
communication = 9
bad_pageformat_for_print = 10
OTHERS = 11.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFUNCTION.
Note that the use of PRINT_TEXT .
You can suspend the dialog and get your OTFDATA from there.
Regards.
10-06-2015 11:57 AM
10-06-2015 12:09 PM
10-06-2015 12:24 PM
I am not joking - as you can see in my Posting at Oct 5, 2015 4:33 PM there are surplus <p>-Tags, that cuts my rows....
10-07-2015 12:27 PM
10-07-2015 4:21 PM
Hi,
DATA: st_options TYPE itcpo.
st_options-TDGETOTF = abap_true .
CALL FUNCTION 'PRINT_TEXT'
EXPORTING
OPTIONS = st_options
dialog = abap_false
header = st_thead
TABLES
lines = it_lines
See:
PRINT_TEXT - BC SAPscript: Printing with Forms - SAP Library
Regards.
10-07-2015 6:23 PM
Finally, this worked very well. This was a long way to get the solution and I want to thank all of you.
10-07-2015 4:52 AM
Hi,
I just noticed that you keep HTML in your standard text (I am getting old ) .
HTML is a long string (the rendering is done by the client) see CLASS cl_htm here
So in your case try:
FUNCTION y_r_eitan_tests_06.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" REFERENCE(EX_RESULT_STRING) TYPE STRING
*"----------------------------------------------------------------------
DATA: st_thead TYPE thead .
DATA: it_lines TYPE tline_tab .
st_thead-tdobject = 'TEXT' .
st_thead-tdname = 'Y_R_EITAN_01' .
st_thead-tdid = 'ST' .
st_thead-tdspras = 'E' .
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = st_thead-tdid
language = st_thead-tdspras
name = st_thead-tdname
object = st_thead-tdobject
IMPORTING
header = st_thead
TABLES
lines = it_lines
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc NE 0 .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
st_makt-matnr = '1234567890' .
st_makt-maktx = 'I am a description !!!' .
CALL FUNCTION 'TEXT_SYMBOL_REPLACE'
EXPORTING
header = st_thead
program = sy-repid
TABLES
lines = it_lines.
FIELD-SYMBOLS: <st_lines> LIKE LINE OF it_lines .
ex_result_string = '' .
LOOP AT it_lines ASSIGNING <st_lines> .
CONCATENATE ex_result_string <st_lines>-TDLINE INTO ex_result_string SEPARATED BY ' ' .
ENDLOOP.
ENDFUNCTION.
EX_RESULT_STRING can be converted to SOLI using CL_BCS_CONVERT .
Regards.
10-07-2015 11:57 AM
Edited (wrong thread):
As I said: TEXT_SYMBOL_REPLACE does not work, called from a method, because it works with a dirty assign. The main program of a method is it's class, which does not allow dirty assigns.
10-07-2015 12:20 PM
Hi,
The idea is to create an environment where TEXT_SYMBOL_REPLAC can work.
You need to pass your variable to the function as import parameters .
Those parameters needs to go to data statements defined at the top include .
A function is a program.
So
CALL FUNCTION 'TEXT_SYMBOL_REPLACE'
EXPORTING
header = st_thead
program = sy-repid (the FunctionPool name )
TABLES
lines = it_lines.
And TEXT_SYMBOL_REPLACE will have no problem to find the variables it needs .
There is no need to do any dirty stuff .
Regards.
10-07-2015 12:25 PM
Is this the concept of ABAP OO? That I have to call a function module from my method, using global variables?
Could it be possible, that there is NO WAY to replace text symbols within a method w/o using a function module with global (=obsolete!) variables?
10-07-2015 4:31 PM
Hi,
I assume that SAP is not your first and only career experience .
SAP is far for being perfect .
I started programing 1973.
I started with SAP at 2006 and I am still under culture shock....
When SAP will allow for more then one line of headings in “CL_GUI_ALV_GRID”
there will be a special holiday on this planet......
Enjoy.
10-07-2015 4:41 PM