Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem in table control

Former Member
0 Likes
639

Hii All,

I have a database table where i will save the Text entered by the user.

i need to give the option of the change of text so i am using a table control and getting the Text from the table and using it and displaying the text.

The problem is when i am going for the change iam unable to see the first line in the text.

Say if i have 3 lines of text : say it is like this

1) This

2) is

3) the text.

i am unable to see the first line "This" at the first shot. it is displayed like this

2) is

3) the text.

but if i scroll down and come back to the first line i can see the first line as shown below.

1) This

2) is

3) the text.

What could be the problem?

I am using internal table with header line.

Please help me.

Thanks,

Ravindra.

5 REPLIES 5
Read only

joginder_singh
Active Participant
0 Likes
617

Hi

If the user just enterederd the text then it would be best you use a text editor instead of going for table control ,it look good and user friendly from user point of view and it easy to create it and use the below code.

DATA: init,

container TYPE REF TO cl_gui_custom_container,

editor TYPE REF TO cl_gui_textedit.

DATA: event_tab TYPE cntl_simple_events,

event TYPE cntl_simple_event.

DATA: line(3000) TYPE c,

text_tab LIKE STANDARD TABLE OF line.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'SCREEN_100'.

SET TITLEBAR 'TITLE_100'.

IF init IS INITIAL.

init = 'X'.

CREATE OBJECT: container EXPORTING container_name = 'TEXTEDIT',

editor EXPORTING parent = container.

event-appl_event = 'X'. "application event

APPEND event TO event_tab.

CALL METHOD: editor->set_registered_events

EXPORTING events = event_tab.

ENDIF.

CALL METHOD editor->set_text_as_stream

EXPORTING

text = text_tab.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'SAVE'.

CALL METHOD editor->get_text_as_stream

IMPORTING

text = text_tab.

PERFORM save_text TABLES text_tab

USING wa_head-matnr .

WHEN 'BACK'.

LEAVE SCREEN.

WHEN OTHERS.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Form save_text

&----


  • text

----


  • -->P_TEXT_TAB text

  • -->P_WA_HEAD_MATNR text

----


FORM save_text TABLES p_tab LIKE text_tab

USING p_mard_matnr TYPE matnr.

DATA : lt_lines TYPE STANDARD TABLE OF tline,

wl_lines TYPE tline.

DATA : wa_head TYPE thead ,

wa_tab TYPE line.

data : vl_newline(1),

vl_cr_lf(1).

types : begin of txt,

line(130) type c,

end of txt.

data : wa_split type txt,

lt_split type standard table of txt.

vl_newline = cl_abap_char_utilities=>newline.

vl_cr_lf = cl_abap_char_utilities=>cr_lf.

read table p_tab into wa_tab index 1.

split wa_tab at vl_newline into table lt_split.

LOOP AT lt_split INTO wa_split.

replace vl_cr_lf in wa_split-line with ' '.

IF sy-tabix EQ 1.

wl_lines-tdformat = '*'.

ELSE.

wl_lines-tdformat = '/'.

ENDIF.

wl_lines-tdline = wa_split-line.

append wl_lines to lt_lines.

ENDLOOP.

wa_head-tdobject = 'MATERIAL'.

wa_head-tdname = p_mard_matnr.

wa_head-tdid = 'PRUE'.

wa_head-tdspras = 'E'.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

client = sy-mandt

header = wa_head

savemode_direct = 'X'

TABLES

lines = lt_lines

EXCEPTIONS

id = 1

language = 2

name = 3

object = 4

OTHERS = 5.

IF sy-subrc = 0.

CALL FUNCTION 'COMMIT_TEXT'

EXPORTING

object = wa_head-tdobject

name = wa_head-tdname

id = wa_head-tdid

language = wa_head-tdspras

savemode_direct = 'X'.

COMMIT WORK AND WAIT.

ENDIF.

ENDFORM. " save_text

And on the screen define a custom control with name TEXTEDIT .

Hope this help you .

Get back to me if you have any issue with the code.

Cheers

Joginder

Read only

0 Likes
617

Hi ,

I cant go for any other editor Because i have to display the text box dynamically.

here by using the Table control i am changing the length and no of lines of the text box based on the values from a table.

So please help me out using this table control only.

Thanks

Ravindra

Read only

Former Member
0 Likes
617

HI

How you are splitting the data into itab and how you are passing it to the table control on the screen.

try in PBO.

describe table itab lines tc-lines.

also how many rows are visible in table control?? at first

are you increasing them dinamically??

please refer to the Program RSDEMO02 for further info.

Read only

0 Likes
617

Hi,

Here is my code in screen.

LOOP AT I_fobpr into w_fobpr WITH CONTROL I_TCONTROL CURSOR

I_TCONTROL-CURRENT_LINE.

MODULE display_fobpr.

ENDLOOP.

and this module display_fobpr is as follows

Module display_fobpr output.

if i_fobpr[] is initial.

select single zzimprint_chars

zzimprint_lines

into (v_imprint_chars , v_imprint_lines)

from mara

where matnr = vbap-matnr.

if t180-trtyp = 'V' AND I_FOBPR[] IS INITIAL.

perform sub_get_zztext.

ENDIF.

*----Modify the table controls length and no of lines

loop at I_TCONTROL-cols into w_cols1.

if screen-name = 'I_FOBPR-ZZTEXT'.

w_cols1-vislength = v_imprint_chars. " No of characters " this gives the dynamic length

modify I_TCONTROL-cols from w_cols1.

modify screen.

endif.

endloop.

I_TCONTROL-lines = v_imprint_lines. " This give the dynamic No of lines

zhdi_fobpr-zztext = i_fobpr-zztext.

endmodule.

in perform perform sub_get_zztext. i am selecting the data from the table if the internal table i_fobpr is initial.

So everything is working fine except that i am unable to see the first line for the first time and if i scroll down and go up i can see it.

Thanks

Ravindra.

Read only

Former Member
0 Likes
617

Hii All,

Some one please answer my question.

Thanks

Ravindra