04-21-2008 2:45 PM
Hi freinds,
I have a problem that i had made a text editor and retrived its text data which ever i'm wrting in that in a internal table it_text
but i have to save it in a Ztable which have three fields vblen posnr and text , text must be save each time for these key fields but the problem is only last line which i wrote on text editor is saved in Ztable by inserting values of these three fields by workarea of ztable type . what i doing is i'm first moving corresponding vblen and posnr to workarea and than i'm moving text from text table to waorkarea-text field and than inserting it to ztable but than it only insert last line of text
how can i insert entire text data of editor into table please help me useful answer will be rewarded.
abhishek
04-21-2008 3:36 PM
How have you defined the text field in your database table? When entering data into a text editor, remember that this data can have quite some lenght.
How are you retrieving the data from the text editor? I mean when entering the data into your z-table, have you actually seen that the work area is filled with all (three in this case) lines in it?
04-21-2008 3:36 PM
How have you defined the text field in your database table? When entering data into a text editor, remember that this data can have quite some lenght.
How are you retrieving the data from the text editor? I mean when entering the data into your z-table, have you actually seen that the work area is filled with all (three in this case) lines in it?
04-21-2008 3:44 PM
yes workarea is filled with all three fields but when i'm trying to fill last field i.e. text it only filed by last line value of editor
04-21-2008 3:54 PM
that's what I meant, by 'are all three lines from the text editor' transferred to the workarea. Obviously not, bu this probably due to the fact that you are not retrieving the data correctly or due to the fact that the table field is not typed correctly.
Post (part of) your coding and we might see what the problems is.
04-21-2008 3:56 PM
it is evident that it will save only 1 line of your text , right ?
else, you have to do it like, concatenate, line 1 line 2 line 3.... line n into var1.
and pass this to your database table...
but how can you predict that only this many lines will be there in text..it can be any number of lines, right ?
so the whole approach is wrong..
what you can do is use create_text, save_text function module..and save this as some texts in to table stxh, stxl.
you can concatenate vbeln and posnr to tdname.
if you are particular about doing it to your z table, then declare 1 more field as key, say lineno or so..
so the keys will be vbeln, posnr and lineno
and increment lineno ...
so each line of your text will be saved..
let me know, if u need further assistance
04-21-2008 3:59 PM
class main definition.
public section.
methods: select_data,
alv_data.
*hotspot(to open dialog box)
methods: handle_hot_spot
for event hotspot_click of cl_gui_alv_grid
importing
e_row_id e_column_id es_row_no.
METHODS: handle_button_click
FOR EVENT button_click OF cl_gui_alv_grid
IMPORTING
es_col_id
es_row_no .
endclass. "MAIN DEFINITION
----
CLASS MAIN IMPLIMENTATION
----
*
----
class main implementation.
*--- METHOD SELECT_DATA
method select_data.
perform select_data1 changing
it_vbak[]
it_vbap[]
it_vbuk[]
it_vbpa[]
it_vbep[]
it_vbfa[]
it_likp[]
it_lips[]
it_kna1[]
it_sales[].
perform select_data2 changing
it_ekko[]
it_ekpo[]
IT_EKET[]
it_ekbe[]
it_likp[]
it_lips[]
it_kna1[]
it_purchase[].
PERFORM COLLECT_DATA1 changing it_final[].
endmethod. "select_data
*--- METHOD ALV_DATA
method alv_data.
perform alv_data1.
endmethod. "alv_data
*--- METHOD HANDLE_HOT_SPOT
method handle_hot_spot .
perform hot_spot
using e_row_id e_column_id es_row_no.
endmethod. "HANDLE_DOUBLE_CLICK
*--- METHOD handle_button_click
method handle_button_click.
perform get_value
using es_col_id es_row_no.
PERFORM BUTTON_Function.
endmethod. "handle_button_click
&----
*& Include Z11_ABHISHEK_ASSIGNMENT8_PBO *
&----
&----
*& Module STATUS_2000 OUTPUT
&----
text
----
module STATUS_2000 output.
SET PF-STATUS 'MAIN'.
SET TITLEBAR 'ALV for Goods Issue using OOPS'.
endmodule. " STATUS_2000 OUTPUT
&----
*& Module alv_display OUTPUT
&----
text
----
module alv_display output.
data:obj3 type ref to main.
if w_custom_container is initial.
*creating an object for custom container of header
create object w_custom_container
exporting
container_name = w_custom_control.
*creating an object for grid1
create object w_grid
exporting
I_SHELLSTYLE = 0
I_LIFETIME =
i_parent = w_custom_container
I_APPL_EVENTS = space
I_PARENTDBG =
I_APPLOGPARENT =
I_GRAPHICSPARENT =
I_NAME =
I_FCAT_COMPLETE = SPACE
exceptions
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
others = 5
.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
*Perform for filling field-Layout
perform prepare_fld_layout changing w_layout.
*Perform for filling field-catalog
perform prepare_field_catalog_1 changing t_fldcat.
*calling method for first display
perform call_method_display changing it_final[]
t_fldcat[].
create object obj3.
*setting handler for the events
set handler obj3->handle_hot_spot for w_grid. "HOTSPOT
data:obj4 type ref to main.
CREATE object obj4.
SET HANDLER obj4->handle_button_click FOR w_grid. "BUTTON
endif.
endmodule. " alv_display OUTPUT
&----
*& Module init_2001 OUTPUT
&----
text
----
module init_2001 output.
PERFORM initialize_text_editor_2001.
PERFORM set_text_in_editor_2001.
&----
*& Include Z11_ABHISHEK_ASSIGNMENT8_PAI *
&----
&----
*& Module USER_COMMAND_2000 INPUT
&----
text
----
module USER_COMMAND_2000 input.
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
ENDCASE.
endmodule. " USER_COMMAND_2000 INPUT
&----
*& Module text_editor_retrieve_2001 INPUT
&----
text
----
module text_editor_retrieve_2001 input.
PERFORM text_editor_retrieve_2001.
endmodule. " text_editor_retrieve_2001 INPUT
&----
*& Module USER_COMMAND_2001 INPUT
&----
text
----
module USER_COMMAND_2001 input.
case ok_code.
when 'EXT1'.
leave to screen 2000.
when 'SAV1'.
select single vbeln
posnr into wa_final
from z11_abhi_text
where vbeln = wa_editor-vbeln
and posnr = wa_editor-posnr.
if sy-subrc <> 0.
insert z11_abhi_text from table it_editor.
else.
modify z11_abhi_text from table it_editor .
endif.
message i016.
endcase.
endmodule. " USER_COMMAND_2001 INPUT
&----
*& Form initialize_text_editor_2001
&----
text
----
--> p1 text
<-- p2 text
----
form initialize_text_editor_2001 .
IF g_editor4 IS INITIAL.
repid = sy-repid.
CREATE OBJECT custom_container
EXPORTING
container_name = 'MYCONTAINER'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
CREATE OBJECT g_editor4
EXPORTING
parent = custom_container
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
ENDIF. "editor is initial
endform. " initialize_text_editor_2001
&----
*& Form set_text_in_editor_2001
&----
text
----
--> p1 text
<-- p2 text
----
form set_text_in_editor_2001 .
CALL METHOD g_editor4->set_text_as_r3table
EXPORTING table = it_pi_text " Text internal table.
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
MESSAGE i015 WITH
repid 'Error in set_text_as_r3table'.
ENDIF.
endform. " set_text_in_editor_2001
&----
*& Form text_editor_retrieve_2001
&----
text
----
--> p1 text
<-- p2 text
----
form text_editor_retrieve_2001 .
CHECK NOT g_editor4 IS INITIAL.
CALL METHOD g_editor4->get_text_as_r3table
IMPORTING table = it_pi_text
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
MESSAGE i015 WITH
repid 'Error in get_text_as_r3table'.
ENDIF.
loop at it_pi_text into wa_wk_text .
wa_editor-text = wa_wk_text .
modify it_editor from wa_editor transporting text where vbeln = wa_editor-vbeln
and posnr = wa_editor-posnr.
endloop.
endform. " text_editor_retrieve_2001
&----
*& Form get_value
&----
text
----
-->P_ES_COL_ID text
-->P_ES_ROW_NO text
----
form get_value using p_es_col_id
p_es_row_no type LVC_S_ROID.
data: l_row type i.
*write: p_es_row_no-row_id to l_row.
l_row = p_es_row_no-row_id.
clear wa_final.
Read table it_final into wa_final index l_row .
wa_editor-vbeln = wa_final-vbeln.
wa_editor-posnr = wa_final-posnr.
append wa_editor to it_editor.
04-21-2008 4:10 PM
loop at it_pi_text into wa_wk_text .
wa_editor-text = wa_wk_text .
modify it_editor from wa_editor transporting text where vbeln = wa_editor-vbeln
and posnr = wa_editor-posnr.
endloop.
If this is your code for retrieving the data, then sure, you will only retrieve the last line of the text editor.
Like I already said before (and which is also said by Sujamol), the approach is not correct, since you shouldn't store data in a db table like this. But if you really want to do it like this, use (like Sujamol also replies) the concatenate statement AND use a dataelement with built in type STRING. Fields of this type have no lenght limitation, so you can concatenate the whole text from your editor into your z-table.