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: 

Upload long text for a field

Former Member
0 Kudos
138

hello experts,

I am uploading the data for open AR items. In that i have to upload the data for long text for one field. From the legacy system the data coming as 4000 charecters for one field.

Can anyone guide me how to upload the data into that specific field........

Field should contain total 4000 chars without splitting the data.....

Please any one guide me how to do it

SRI

1 ACCEPTED SOLUTION

Former Member
0 Kudos
98

You have to call SAVE_TEXT, but before that you have to know the document number that you just created. In the corresponding transaction, go to the long text entry screen and in the menu go to header. You will see there, object ID, object type etc. Use them to call this function module.

13 REPLIES 13

Former Member
0 Kudos
99

You have to call SAVE_TEXT, but before that you have to know the document number that you just created. In the corresponding transaction, go to the long text entry screen and in the menu go to header. You will see there, object ID, object type etc. Use them to call this function module.

0 Kudos
98

Srini,

here is my code... can you check this once and can you lemme know what r the changes i need to do ... so that it can work for the long text also...........

  • GET THE SAP DOCUMENT NUMBER USING THE

SELECT SINGLE * INTO LS_BKPF FROM BKPF

WHERE XBLNR = I_LONGTEXT-P_XBLNR

AND BKTXT = I_LONGTEXT-P_KUNNR.

CHECK SY-SUBRC = 0.

GS_THEAD-TDID = '0001'. " TEXT-ID

GS_THEAD-TDSPRAS = SY-LANGU.

CONCATENATE LS_BKPF-BUKRS LS_BKPF-BELNR LS_BKPF-GJAHR INTO GS_THEAD-TDNAME.

GS_THEAD-TDOBJECT = 'BELEG'.

*-- GET ALL TEXT (THIS CAN BE MULTIPLE LINES)

GT_TLINE-TDLINE = 'TEST AR CONVERSATION'.

APPEND GT_TLINE.

*-- AT THE END OF EACH ACTIVITY ENTER THE TEXT DATA

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

HEADER = GS_THEAD

INSERT = 'X'

SAVEMODE_DIRECT = 'X'

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = GT_TLINE

  • 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.

REFRESH GT_TLINE.

CLEAR :GT_TLINE, GS_THEAD.

COMMIT WORK.

SRI

0 Kudos
98

This is how you have to do it. Just add all the lines to the TLINE internal table before calling the FM.

*-- GET ALL TEXT (THIS CAN BE MULTIPLE LINES)

LOOP AT text_lines.

GT_TLINE-TDLINE = text_lines-line.

APPEND GT_TLINE.

ENDLOOP.

0 Kudos
98

srini,

what is this text_lines

I didn't get what u r trying to say...

can u explain bit clearly,

I_LONGTEXT is the internal table where i am getting the long text

and P_DLONG this is the field in to which long text is coming...

so please can u tell me the modification to my code srini

SRI

SRI

Message was edited by:

Sri Y

0 Kudos
98

text_lines is nothing but your internal table having the long text.

0 Kudos
98

I_LONGTEXT is the internal table where i am getting the long text

and P_DLONG this is the field in to which long text is coming...

0 Kudos
98

So you have one field that is 1000 characters long. OK, in that case, you will have to do something like below. I may have missed something here as I typed the code directly here, but I think you get the idea.

DATA: startpos type i,

text_length type i.

text_length = strlen( I_LONGTEXT-P_DLONG ).

start_pos = 0.

DO.

IF text_length <= 0.

EXIT.

ENDIF.

IF text_length <= 132.

move I_LONGTEXT-P_DLONG+startpos(text_length) to tlines-tdline.

startpos = startpos + text_length.

ELSE.

move I_LONGTEXT-P_DLONG+startpos(132) to tlines-tdline.

startpos = startpos + 132.

ENDIF.

append tlines.

clear tlines.

text_length = text_length - 132.

ENDDO.

0 Kudos
98

Srini,

If i do those changes what ever u specified does my code will read the that long text and upload the 4000 chars text.

SRI

0 Kudos
98

Where is your code where you are reading 4000 character long text? As long as you read the long text into your internal table field, then this code should work.

0 Kudos
98

I get the data into the internal table I_LONGTEXT. I wrote that logic in another routine.

So once i get the data i have to concatenate those fields and pass that value..

So Srini, the code is bit confusing... please can do the modifications in my code and can u let me know what to pass in the save_text fm

I really appreciate your valuabel time

SRI

0 Kudos
98

SRINI,

Can u check this modified code once.....

does it work

DATA: START_POS TYPE I,

TEXT_LENGTH TYPE I.

  • GET THE SAP DOCUMENT NUMBER USING THE

SELECT SINGLE * INTO LS_BKPF FROM BKPF

WHERE XBLNR = I_LONGTEXT-P_XBLNR

AND BKTXT = I_LONGTEXT-P_KUNNR.

CHECK SY-SUBRC = 0.

GS_THEAD-TDID = '0001'. " TEXT-ID

GS_THEAD-TDSPRAS = SY-LANGU.

CONCATENATE LS_BKPF-BUKRS LS_BKPF-BELNR LS_BKPF-GJAHR INTO GS_THEAD-TDNAME.

GS_THEAD-TDOBJECT = 'BELEG'.

TEXT_LENGTH = STRLEN( I_LONGTEXT-P_DLONG ).

START_POS = 0.

DO.

IF TEXT_LENGTH <= 0.

EXIT.

ENDIF.

IF TEXT_LENGTH <= 132.

MOVE I_LONGTEXT-P_DLONG+START_POS(TEXT_LENGTH) to GT_TLINE-TDLINE.

START_POS = START_POS + TEXT_LENGTH.

ELSE.

MOVE I_LONGTEXT-P_DLONG+START_POS(132) to GT_TLINE-TDLINE.

START_POS = START_POS + 132.

ENDIF.

APPEND GT_TLINE.

CLEAR GT_TLINE.

TEXT_LENGTH = TEXT_LENGTH - 132.

ENDDO.

**-- GET ALL TEXT (THIS CAN BE MULTIPLE LINES)

  • LOOP AT I_LONGTEXT.

  • GT_TLINE-TDLINE = I_LONGTEXT-P_DLONG.

  • APPEND GT_TLINE.

  • ENDLOOP.

*-- AT THE END OF EACH ACTIVITY ENTER THE TEXT DATA

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

HEADER = GS_THEAD

INSERT = 'X'

SAVEMODE_DIRECT = 'X'

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = GT_TLINE

  • 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.

REFRESH GT_TLINE.

CLEAR :GT_TLINE, GS_THEAD.

COMMIT WORK.

SRI

0 Kudos
98

Are you already looping at I_LONGTEXT, because I see that you are using it in your SELECT statement? If you are in fact looping at it, then why are you again looping at it after the DO loop? Is one record in I_LONGTEXT correspond to one document? If so, you can do something like this.

LOOP AT I_LONGTEXT.

  • GET THE SAP DOCUMENT NUMBER USING THE

SELECT SINGLE * INTO LS_BKPF FROM BKPF

WHERE XBLNR = I_LONGTEXT-P_XBLNR

AND BKTXT = I_LONGTEXT-P_KUNNR.

CHECK SY-SUBRC = 0.

GS_THEAD-TDID = '0001'. " TEXT-ID

GS_THEAD-TDSPRAS = SY-LANGU.

CONCATENATE LS_BKPF-BUKRS LS_BKPF-BELNR LS_BKPF-GJAHR INTO GS_THEAD-TDNAME.

GS_THEAD-TDOBJECT = 'BELEG'.

TEXT_LENGTH = STRLEN( I_LONGTEXT-P_DLONG ).

START_POS = 0.

DO.

IF TEXT_LENGTH <= 0.

EXIT.

ENDIF.

IF TEXT_LENGTH <= 132.

MOVE I_LONGTEXT-P_DLONG+START_POS(TEXT_LENGTH) to GT_TLINE-TDLINE.

START_POS = START_POS + TEXT_LENGTH.

ELSE.

MOVE I_LONGTEXT-P_DLONG+START_POS(132) to GT_TLINE-TDLINE.

START_POS = START_POS + 132.

ENDIF.

APPEND GT_TLINE.

CLEAR GT_TLINE.

TEXT_LENGTH = TEXT_LENGTH - 132.

ENDDO.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

  • CLIENT = SY-MANDT

HEADER = GS_THEAD

INSERT = 'X'

SAVEMODE_DIRECT = 'X'

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = GT_TLINE

  • 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.

REFRESH GT_TLINE.

CLEAR :GT_TLINE, GS_THEAD.

COMMIT WORK.

ENDLOOP.

0 Kudos
98

Thank you very much srini.,

I really appreciate your valuable time.

SRI