05-21-2014 3:00 PM
Hello masters of abap development!
I'm having trouble with this screen 01, when I select a row and click on the edit button, I want a popup to appear (screen 02) and the coming of the text I had selected on the previous screen so I can edit it then OK to give that text to be updated on the screen 01.
Screen 01
Screen 02
problem:
Looking at the screens 01 and 02, we can analyze that when I click on a row to edit the popup opens correctly with the text I want to change, and when I click OK, this text should be updated on the screen 01 and then I click the SAVE button is done and saving the information.
The problem is when I go back to the screen 01 and want to edit another line ... The text that is displayed on the screen 02 is the line that I had chosen to edit earlier, see the screen 03 with the selection of another line:
Code to call popup passing the line that was selected:
t_score_out_aux[] = t_score_out[].
DELETE t_score_out_aux[] WHERE mark NE 'X'.
DESCRIBE TABLE t_score_out_aux LINES lv_lines.
IF lv_lines NE 1.
MESSAGE i135(ypcad) DISPLAY LIKE 'I'.
CLEAR sy-ucomm.
ELSE.
READ TABLE t_score_out_aux INTO e_score_out_aux WITH KEY mark = 'X'.
IF sy-subrc = 0.
MOVE-CORRESPONDING e_score_out_aux TO e_score_out.
CALL SCREEN '0302' STARTING AT 100 100.
ENDIF.
ENDIF.
Code that populates the text popup screen 02: (this code is in PROCESS BEFORE OUTPUT screen 02)
MODULE m_area_texto_descricao OUTPUT.
clear: lv_description.
CONCATENATE e_score_out-description e_score_out-description_cont INTO lv_description.
PERFORM f_exibe_area_texto.
ENDMODULE.
Code PERFORM f_exibe_area_texto. :
* Cria objeto para Container
IF o_container IS INITIAL.
CREATE OBJECT o_container
EXPORTING
container_name = 'CONT_DESCRICAO'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
ENDIF.
* Cria objeto para o texto a ser inserido na tela
IF o_text IS INITIAL.
CREATE OBJECT o_text
EXPORTING
parent = o_container
max_number_chars = 500
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
OTHERS = 6.
IF sy-subrc EQ 0.
CALL METHOD o_text->set_wordwrap_behavior
EXPORTING
wordwrap_mode = '2'
wordwrap_position = '120'
wordwrap_to_linebreak_mode = 0
EXCEPTIONS
error_cntl_call_method = 1
OTHERS = 2.
CALL METHOD o_text->set_toolbar_mode
EXPORTING
toolbar_mode = 0.
CALL METHOD o_text->set_statusbar_mode
EXPORTING
statusbar_mode = 0.
CALL METHOD o_text->set_textstream
EXPORTING
text = lv_description
EXCEPTIONS
error_cntl_call_method = 1
not_supported_by_gui = 2
OTHERS = 3.
CALL METHOD cl_gui_cfw=>flush.
ENDIF.
ENDIF.
Big question:
I am passing the selected line right through the Debug, the CONCATENATE is also right and passes to the lv_description variable, but why is not updating the screen 02?
Sorry peopple, but I can not see the problem with that.
05-23-2014 8:00 AM
Hi Fabina,
Since you are checking whether the O_TEXT object is initial or not, you shoul be calling the set_textstream method on the ELSE part of IF O_TEXT IS INITIAL, if you are clearing the object O_TEXT.
REgards,
Abijith
05-22-2014 3:45 AM
Hello Fabiana.
In PBO of screen 02, try making use of DYNP_VALUES_UPDATE function by passing lv_description.
(OR)
Write the business logic to fetch description from screen 01 in PAI of screen 01 instead of PBO.
Regards.
05-22-2014 4:38 PM
Hello K.Arun, thank you for your reply!
My text of container has not been updated with DYNP_VALUES_UPDATE...
I dont know what i do
05-22-2014 6:17 AM
It looks like you are only calling "set_textstream" method inside the "IF" that creates the textedit control - therefore it's not refilling the text edit on the second call. So either fill the text outside the "IF", or destroy the control at the end of the popup logic (i.e. call textedit->free and clear o_text in the PAI user command before leaving the screen).
Jonathan
05-22-2014 4:40 PM
I did what you said, but the problem is that once destroyed the object, the next time I try to edit again calling popup, the text box to edit the popup disappears ...
05-22-2014 11:24 PM
Your code "if o_text is initial" should get triggered if you have put a "clear: o_text." in your PAI user-command - can you check this is so via debug? If you prefer to leave the o_text instance filled, then you'll need to push the lv_description into the textedit control outside of the "if o_text is initial" block - currently the "set_textstream" method is only being called when you create the text editor instance.
Jonathan
p.s. in general, rather than "is initial" try using "is bound" for object references.
05-22-2014 4:48 PM
if your lv_description is a local variable, change it to a global one. Enjoy controls can't handle local variables when flush( ) takes place.
05-22-2014 5:04 PM
05-23-2014 8:00 AM
Hi Fabina,
Since you are checking whether the O_TEXT object is initial or not, you shoul be calling the set_textstream method on the ELSE part of IF O_TEXT IS INITIAL, if you are clearing the object O_TEXT.
REgards,
Abijith
05-23-2014 8:11 PM
Hello guys, thanks for the help!
Unable to resolve the problem by wiping the o_text and o_container in PAI of the screen 302:
IF NOT o_container IS INITIAL.
CALL METHOD o_container->free
EXCEPTIONS
OTHERS = 1.
FREE o_container.
ENDIF.
FREE o_text.
05-26-2014 4:29 AM
I've had a look at some similar code we wrote a few years ago and our logic for "destroying" the editor in PAI goes along the lines of (this is pseudo code, not 100% ABAP)..
form d0100_editor_destroy.
if go_textedit is bound. "destroy textedit
call method go_textedit->free
...
free go_textedit.
endif.
if go_container is bound. "destroy container
call method go_container
...
endif.
call method cl_gui_cfw=>flush
...
endform.
Key differences seem to be (a) destroying textedit before destroying the container and (b) the flush - maybe try these?
Jonathan