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

saving long text - problem

Former Member
0 Likes
3,378

Hi,

I am having a long text which has 10lines.. i need to save that long text from a file using migration.

first i need to store that text in a field for of an internal table & then save it in a long text ..

can any one help me out in providing the soln/alternatives to fix this..

Pls. do the needful.

thanks

john

12 REPLIES 12
Read only

former_member647955
Participant
0 Likes
2,339

Hi John,

From what I know about long text in SAP is that they are stored based on ID, Object and Language. First you probabaly need to set them using tcode SE75(Change / Add New Object and ID)

Then in your program you can use several FM that process long text.

My favorite is

CALL FUNCTION 'LANGTEXT_ONLY'

EXPORTING

object = *Object

object_nr = *Object_no

spras = *language

txtid = *ID

x_xaktyp = *aktyp

  • save_mode = 'X'

  • text_history = 'x'

  • text_property = 'x'

IMPORTING

ind_inv = *line

inv_exist = *exist

TABLES

t_inlines = t_linetab.

This FM will call longtext editor and also set the mode

aktyp = H => create new,

aktyp = V => change

aktyp = A => read only

Another useful FM is READ_TEXT and SAVE_TEXT. Try to experiment with it and see any documentation for detail.

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = *ID

language = *Language

name = *Name

object = *Object

IMPORTING

header = t_headltx

TABLES

lines = t_linetab

EXCEPTIONS

not_found = 1.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

header = t_headltx

savemode_direct = 'X'

TABLES

lines = t_linetab.

Hope it helps

Regards

Hadi

Read only

0 Likes
2,339

thanks for the response hadi wijaya !!!

but how to store 10lines of long text ( i mean line-by-line in the long text ) ....snce tdline only has 132chars ....and my long text has 10lines which is more than 132 char..........

first, i need to store it in a field of an internal table ( how we can store 10lines in a field of internal table ?)

second, i need to move that field (containing long text ) in the respective long text of a transaction...

thanks

john

Read only

0 Likes
2,339

Hi,

You need to pass the the 10 lines to the Table parameter LINES of the FM SAVE_TEXT

You will notice that the table parameter LINES is of the data type tline which contains two fields

For each line you need to pass '*" to the field TDFORMAT of the TLINE structure and the content of the line to the field TDLINE of the TLINE structute.

In your case you will now have ten lines of the internal table passed to the table parameter LINES.

In case your line has more than 132 characters break the line down at 132 characters and add the remaining to the next line of the internal table. The value '*' in the field TDFORMAT will ensure that there is no break in the line when you finally save.

Hope this helps and search the forum for the FM SAVE_TEXT for more examples.

Note: You can pass '/' to the field TDFORMAT if you want the line to be separate from the previous line. Use '*' if you want it to be continuous.

Regards,

Dominic

Edited by: Dominic Pappaly on Feb 10, 2011 10:11 AM

Read only

0 Likes
2,339

Domnic,

thanks for the response..,

but how to stored those tines in a field of an internal table ??

and also * indicates a new line???

i.e.., * line1

  • line2

  • line3

  • line4

  • line5

  • line6

  • line7

  • line8

  • line9

  • line10

i can stored in TLINE ??

Read only

0 Likes
2,339

Hi John,

Consider that you only have two lines .

DATA: gs_tline type tline,

gt_tline type standard table of tline.

gs_tline-tdformat = '*' (For those cases where you want one continuos line) or '/' (for new line)

gs_tline-tdline = ' Your line 1'.

APPEND gs_tline to gt_tline.

CLEAR gs_tline.

gs_tline-tdformat = '*' (For those cases where you want one continuos line) or '/' (for new line)

gs_tline-tdline = ' Your line 2'.

APPEND gs_tline to gt_tline.

CLEAR gs_tline.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

header = gs_head ( Head information contains the long text name and so on)

TABLES

lines = gt_tline.

Hope this helps.

Regards,

Dominic

Read only

0 Likes
2,339

Hi,

You can append records to tline.

Regards,

Nagaraj

Read only

0 Likes
2,339

again thanks for the response..

but how to store 10-20lines of long text in a field of an intenal tables..because finally i need to move from internal table to gt_line ....

regrds

john

Read only

0 Likes
2,339

Ok.

So you are talking about the first step as to how to upload the data file into SAP. For that you can use the FM GUI_UPLOAD or if you are in earlier versions WS_UPLOAD or UPLOAD.

You can ask the Data extractor if possible to limit it to 132 characters if possible and use agreed special characters to differentiate in case of line breakages . For e.g use '#' to say that the line here is broken down due to space limitations and '$' could mean end of line and so on.

Once the FM GUI_UPLOAD is used the data will be stored in the internal table of the TABLES parameter DATA_TAB.

Using your agreed special characters you can now create the long text (FM SAVE_TEXT) and use the correct formatting(TDFORMAT).

Dominic

Read only

0 Likes
2,339

Hi John,

I think you should use long text editor so when end user type the long text, it will automatically stored in tdlines.

I am assuming that you are using standard input/output field. Try to put a button and when it is pressed it will open long text editor. It will be more easier to store long text.

However if you want to keep using 10 fields, probably you can limit each field to be 132 characters and then you need to have them inserted to internal table with standard syntax APPEND.

Hope it helps.

Thanks

Hadi

Read only

0 Likes
2,339

Hi John,

if you need all the lines in just one field of one record the internal table, then you have two choices: The field may be table-type field ( <field> TYPE TABLE OF ...) or you can concatenate all the text lines into a string separated by a special character that can be used to split the line later into a table. For both cases, the internal table will appear as 'DEEP' which may cause difficulties in interfaces.

Regards,

Clemens

Read only

Former Member
0 Likes
2,339

Thanks for providing necessary soln's

Read only

0 Likes
2,339

Hi John,

Thanks you for sharing your solution. The community appreciates it.

Regards

Clemens