Application Development 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: 

How to create a new long text?

Former Member
0 Kudos

Hallo guys, I am creating a single screen aplication. After pressing a button I have to create a long text do the document which I am creating. How to do this?

I have tried FM 'CREATE_TEXT' but I dont know which values have to be passed into this FM. What is fid, fname and fobject? I have created also a long text objects for order header but how to use it? Thank you

1 ACCEPTED SOLUTION

Former Member
0 Kudos

refer to the below code to create long text

pa_objtyp type thead-tdobject

pa_objtxt type thead-tdname

pa_objid type thead-tdid

changing pa_error.

call function 'CREATE_TEXT'

exporting

fid = pa_objid

flanguage = sy-langu

fname = pa_objtxt

fobject = pa_objtyp

tables

flines = gt_long_text

exceptions

no_init = 1

no_save = 2

others = 3.

if sy-subrc <> 0.

move 'Long text creation failed.'

endif.

reward points if helpful

7 REPLIES 7

Former Member
0 Kudos

refer to the below code to create long text

pa_objtyp type thead-tdobject

pa_objtxt type thead-tdname

pa_objid type thead-tdid

changing pa_error.

call function 'CREATE_TEXT'

exporting

fid = pa_objid

flanguage = sy-langu

fname = pa_objtxt

fobject = pa_objtyp

tables

flines = gt_long_text

exceptions

no_init = 1

no_save = 2

others = 3.

if sy-subrc <> 0.

move 'Long text creation failed.'

endif.

reward points if helpful

amit_khare
Active Contributor
0 Kudos

Use SAVE_TEXT instead -

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = thead

SAVEMODE_DIRECT = 'X'

insert = ' '

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = it_lines

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

OBJECT = 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.

then Call COMMIT_TEXT.

Regards,

Amit

reward all helpful replies.

0 Kudos

Yes, OK, but how to fill the thead structure? Which values has to be filled? Do I have to use something from Long text object created using se75?

0 Kudos

Below code will help u know the values that need to be paassed.

CONSTANTS:

c_TDOBJECT like thead-tdobject value 'VBBK',

c_TDID like thead-tdid value 'Z109',

c_TDSPRAS like thead-tdspras value 'E',

c_ecn_status1(1) type c value '1' .

data: l_TDNAME like thead-tdname,

l_function(1) type c.

data begin of tbl_lines occurs 0.

include structure tline.

data end of tbl_lines.

  • If we are creating the document and the documnet needs an ecn

if t180-trtyp = 'H'

and LIKP-/RIO/ZZECNSTATUS = c_ecn_status1.

  • VBELN is used for the object name

move lips-vbeln to l_tdname.

  • Move the status to tbl_lines for inserting into the editor

move '*' to tbl_lines-tdformat.

move c_ecn_status1 to tbl_lines-tdline.

append tbl_lines.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

FID = c_tdid

FLANGUAGE = c_tdspras

FNAME = l_tdname

FOBJECT = c_tdobject

  • SAVE_DIRECT = 'X'

  • FFORMAT = '*'

TABLES

FLINES = tbl_lines

EXCEPTIONS

NO_INIT = 1

NO_SAVE = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

endif.

Reward if helpful

0 Kudos

Thanks for help but it seems like I have to have a document number to create a long text for it. Am I rigth? But what happens when I don't have doc. number because I am just creating one... ? Not possible to create a Long text? Thank you.

Former Member
0 Kudos

Find sample coding

DATA: p_orden TYPE aufk-aufnr,

p_tdname TYPE thead-tdname,

p_tdid TYPE thead-tdid,

p_tdobject TYPE thead-tdobject,

p_header TYPE thead,

it_tline TYPE STANDARD TABLE OF tline

WITH HEADER LINE,

p_function.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = aufnr

IMPORTING

output = p_orden.

CONCATENATE sy-mandt

p_orden

INTO p_tdname.

it_tline-tdline = 'Some Text...'.

APPEND it_tline.

p_tdid = 'KOPF'.

p_tdobject = 'AUFK'.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

fid = p_tdid

flanguage = sy-langu

fname = p_tdname

fobject = p_tdobject

save_direct = 'X'

fformat = '*'

TABLES

flines = it_tline

EXCEPTIONS

no_init = 1

no_save = 2

OTHERS = 3.

ENDFUNCTION.

Former Member
0 Kudos

Thanks I found the solution.