2011 May 11 6:10 PM
Hi ABAPers!!
First of all let me tell you that I'm working in ACCENTURE Casablanca(Morocco) and this is my first Job in my career.
I'm working on an ALV OO, the program consists on creating an ALV using OO, In my selection screen there's a parameter of type ddobjname I provide the name of table and it returns the table's fields in another dynpro (screen0100), To do this I used the FM: 'DDIF_FIELDINFO_GET' then I append the internal table returned in another one to add the field CB (CheckBox), and I add a button in the toolbar, the function of this button is to generate a MySQL script To create the table provided by the user in my parameter (Screen 1000), but the fields of this table(MySQL) in the generated script are only the selected ones by cheking the checkbox in the ALV.
I store my script in a string.
My problem is that I want to show my script in a text area, but I don't know how to create a multiline text area!!
And I want to use HTML tags in my string.
I don't want to my string like this :
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] SPFLI ( CONNID CHAR ( 4 ) NOT NULL PRIMARY KEY , FLTIME INT ( 10 ) , DEPTIME DATETIME ( 6 ) , DISTANCE DOUBLE ( 9 ) , FLTYPE VARCHAR ( 1 ));
But I want it to be shown like this:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] SPFLI (
CONNID CHAR ( 4 ) NOT NULL PRIMARY KEY ,
FLTIME INT ( 10 ) ,
DEPTIME DATETIME ( 6 ) ,
DISTANCE DOUBLE ( 9 ) ,
FLTYPE VARCHAR ( 1 ));
Thanks in advance
Regards
SMAALI Achraf
Edited by: SMAALI90 on May 11, 2011 7:12 PM
2011 May 11 9:20 PM
Hi SMAALI Achraf,
Well, difficult to understand where your issue really is. You are talking about ALV, checkboxes, table fields, etc., but they are not related to your issue... Maybe it's why nobody answered.
You may use the HTML viewer; have a look at demo program RSDEMO_HTML_VIEWER.
Best regards
Sandra
2011 May 12 9:03 AM
Hi SANDRA Rossi,
Thank you for your help, I've explained just to make you in the situation, my problem is that I want to use HTML tags in my string string which contain the script, and I want it to be shown in a multi line text area .
Regards
SMAALI Achraf
Edited by: SMAALI90 on May 12, 2011 10:03 AM
2011 May 12 9:10 AM
Hi SMAALI Achraf
please don't be offensed about how I name you, I'm not sure if I have to use your first or second name, it's why I copied your whole signature. Just call me "Sandra".
Well, about your question, does the HTML Viewer fit your requirement?
Best regards
Sandra
2011 May 12 11:06 AM
Hi Sandra!!
Don't worry 😛 I'm not offensed about how you name me I just want to be professional.
I didn't know how to use HTML Viewer, I know that it's an instantiation of cl_gui_html_viewer but I don't know which method I've to use to upload or export my string and import my text in a multiline text area.
Thanks for your collaboration
Cordially
SMAALI Achraf
2011 May 12 11:31 AM
Hi again!!
You know what!! let's forget the HTML and focuse on what I want to show.
As I told you, I've a string which contains my script.
I don't want that it will be shown as a simple line like this :
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] SPFLI ( CONNID CHAR ( 4 ) NOT NULL PRIMARY KEY , FLTIME INT ( 10 ) , DEPTIME DATETIME ( 6 ) , DISTANCE DOUBLE ( 9 ) , FLTYPE VARCHAR ( 1 ));
But I want it to be shown as follows:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] SPFLI (
CONNID CHAR ( 4 ) NOT NULL PRIMARY KEY ,
FLTIME INT ( 10 ) ,
DEPTIME DATETIME ( 6 ) ,
DISTANCE DOUBLE ( 9 ) ,
FLTYPE VARCHAR ( 1 ));
and finally I want to show it in a multiline text area.
Plz what shud I do?!!! If possible I need a piece of code.
PS : I create a HTML Viewer using this code :
DATA : go_conteneur TYPE REF TO cl_gui_docking_container,
go_controle_html TYPE REF TO cl_gui_html_viewer.
CREATE OBJECT go_conteneur
EXPORTING
repid = sy-repid
dynnr = '0100'
side = go_conteneur->dock_at_bottom
extension = 1000
name = 'CONTENEUR'
EXCEPTIONS
OTHERS = 1.
CREATE OBJECT go_controle_html
EXPORTING
parent = go_conteneur
EXCEPTIONS
OTHERS = 1.
But when it's shown my ALV disappears!!!
2011 May 12 1:10 PM
Okay, so 2 requirements :
1) display both the ALV and the DDL on the same screen (I hope you don't mean displaying the DDL inside a cell of the ALV, it's not possible)
2) display the DDL (CREATE ...) on several lines
There are many solutions, but I don't know which ALV technology you use.
a) If it's the ALV grid control, then you can display 2 controls on the same screen using. To display text inside a control, you may use the textedit control or the HTML viewer.
b) You may also use the ALV header section to include a text (works for all ALV technologies, it will be either text or HTML)
c) You may also use one dynpro, with a table control and a custom container in which you'll place the ALV grid control.
Note that the algorithm for splitting the text on several lines depends on the technology you use. If it's HTML, you'll have to place <BR> tags between each line, if it's a textedit control, you must use CL_ABAP_CHAR_UTILITIES=>CR_LF if you use *STREAM methods. For a table control, each line is a line of an internal table.
Tell me what you prefer, then I'll be able to answer more precisely.
Sandra
2011 May 12 2:32 PM
Hi,
If your problem is to reformat your string, then have a look to the following code.
What it does is quite easy: a newline character is inserted at the relevant places, then the new string it splitted at the newline characters into a table which is then displayed.
You may of course adapt this coding to the way you're wishing to display your data.
PARAMETERS: p_sql TYPE string
DEFAULT `CREATE [TEMPORARY] TABLE [IF NOT EXISTS] SPFLI (` &
`CONNID CHAR ( 4 ) NOT NULL PRIMARY KEY , ` &
`FLTIME INT ( 10 ) , ` &
`DEPTIME DATETIME ( 6 ) , ` &
`DISTANCE DOUBLE ( 9 ) , ` &
`FLTYPE VARCHAR ( 1 ));`.
DATA: gv_sql TYPE string,
gt_sql TYPE stringtab,
gr_sql TYPE REF TO string.
gv_sql = p_sql.
REPLACE ALL OCCURRENCES OF
REGEX `(?: *(,) *)|(CREATE +(?:\[TEMPORARY\])? +TABLE +(?:\[IF NOT EXISTS\])? +(?:[^(]*)\()`
IN gv_sql WITH `$1$2\n` IGNORING CASE.
SPLIT gv_sql AT cl_abap_char_utilities=>newline INTO TABLE gt_sql.
LOOP AT gt_sql REFERENCE INTO gr_sql.
WRITE: / gr_sql->*.
ENDLOOP.
Regards
Dominique
2011 May 12 2:43 PM
Hi gurus!!
I found what I was looking for, I created a new container in my screen and I used this method :
cl_abap_browser=>show_html(
EXPORTING
html_string = script
title = 'Script'
buttons = cl_abap_browser=>navigate_html
format = cl_abap_browser=>landscape
size = cl_abap_browser=>medium
container = gr_scriptcontainer ).
after this code of course(I new that the code need some revision)
CONCATENATE '<html>CREATE [TEMPORARY] TABLE [IF NOT EXISTS]'
p_nomtab '(<BR></BR>'
INTO script SEPARATED BY space.
LOOP AT gt_script INTO wa_script.
" Pour supprimer les 0 (Afin d'éviter les exp comme varchar(0000003))
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = wa_script-leng
IMPORTING
output = wa_script-leng.
CONCATENATE script wa_script-fieldname
wa_script-DRPDWN '(' wa_script-leng ')'
INTO script
SEPARATED BY space.
"On traite que les zones clés
IF ( wa_script-keyflag = 'X' ).
"si le nom de table ref est vide on considère la zone comme une
" clé primaire sinon on la considère une clé étrangère
IF wa_script-checktable IS INITIAL.
CONCATENATE script 'NOT NULL PRIMARY KEY '
INTO script
SEPARATED BY space.
ELSE.
CONCATENATE script 'REFERENCES' wa_script-checktable
'(' wa_script-fieldname ')'
INTO script
SEPARATED BY space.
ENDIF.
ENDIF. "Fin de traitement des zones clés
CONCATENATE script ',<BR></BR>'
INTO script
SEPARATED BY space.
ENDLOOP.
CLEAR len.
len = strlen( script ) - 1.
Finally, Thanks for your collaboration and your time which you spent with my thread
Cordially
SMAALI Achraf
2011 May 12 2:44 PM
I found the solution by my self :
cl_abap_browser=>show_html(
EXPORTING
html_string = script
title = 'Script'
buttons = cl_abap_browser=>navigate_html
format = cl_abap_browser=>landscape
size = cl_abap_browser=>medium
container = gr_scriptcontainer ).