on 09-16-2014 7:50 AM
Hi Experts,
I want to read a very long text (may be of few thousand characters) from a text file and want to create text in the notes of a business transaction. Please let know what will be the best option to do for my requirement.
Hi Swarup,
You can set the notes using save_text fm. Try the below code afte reading text from file,
Assign your complete text data from file into this lv_value1 of string type.
if strlen( lv_value1 ) GT 132.
lv_strlen = 132.
ELSE.
lv_strlen = strlen( lv_value1 ).
ENDIF.
ls_notes-tdformat = '*'.
ls_notes-tdline = lv_value1+0(lv_strlen).
CLEAR ls_stream.
ls_stream = ls_notes-tdline.
APPEND ls_stream TO lt_stream.
SHIFT lv_value1 BY 132 PLACES.
IF lv_value1 IS NOT INITIAL.
DO .
IF strlen( lv_value1 ) EQ 0.
EXIT.
ENDIF.
IF strlen( lv_value1 ) GT 132.
lv_strlen = 132.
ELSE.
lv_strlen = strlen( lv_value1 ).
ENDIF.
IF lv_value1+0(lv_strlen) NE space.
ls_notes-tdformat = '='.
ls_notes-tdline = lv_value1+0(lv_strlen).
CLEAR ls_stream.
ls_stream = ls_notes-tdline.
APPEND ls_stream TO lt_stream.
SHIFT lv_value1 BY 132 PLACES.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CALL FUNCTION 'CONVERT_STREAM_TO_ITF_TEXT'
TABLES
text_stream = lt_stream
itf_text = lt_notes_format.
ls_header-tdobject = 'CRM_ORDERH'.
ls_header-tdname = lv_guid.
ls_header-tdid = ' '." Text Id,you can find the general text id in spro settings
ls_header-tdspras = sy-langu.
APPEND LINES OF lt_notes_format TO lt_notes_old.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = ls_header
TABLES
lines = lt_notes_old
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
* Commit the process
CALL FUNCTION 'COMMIT_TEXT'
EXPORTING
object = ls_header-tdobject
savemode_direct = abap_true.
Best Regards,
Dharmakasi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.