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: 

save longtext in text editor

Former Member
0 Kudos

hi,

i wrote a bdc program to upload long text into MM01 for PO text.

it goes something like this:

DATA: BEGIN OF record OCCURS 10,

matnr_001(018),

werks_003(004),

vkorg_004(004),

vtweg_005(002),

maktx_006(500),

END OF record.

START-OF-SELECTION.

PERFORM upload.

LOOP AT record.

PERFORM bdc_dynpro USING 'SAPLMGMM' '0060'.

-


-


PERFORM bdc_dynpro USING 'SAPLMGMM' '4040'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=TEAN'.

PERFORM save_data.

ENDLOOP.

FORM save_data.

l_head-tdid = '0001'.

l_head-tdspras = 'E'.

l_head-tdname = record-matnr_001.

l_head-tdobject = 'MVKE'.

n = n + 1.

T_LINES-TDLINE = record-maktx_006.

t_lines-tdformat = n.

append t_lines.

clear t_lines.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

header = L_HEAD

SAVEMODE_DIRECT = 'X'

OWNER_SPECIFIED = 'X'

tables

lines = T_LINES

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

OBJECT = 4.

ENDFORM. "SAVE_DATA

The problem here is:

in the text editor of sales text in MM01 the longtext which i have it in T_LINES is not getting saved.

What is the mistake pls help me.

John.

12 REPLIES 12

Former Member
0 Kudos

After Save_text call function module COMMIT_TEXT.

Former Member
0 Kudos

HI

the Save_text should be

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

header = L_HEAD[]

SAVEMODE_DIRECT = 'X'

OWNER_SPECIFIED = 'X'

tables

lines = T_LINES

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

OBJECT = 4.

ENDFORM. "SAVE_DATA

regards

kishore

Former Member
0 Kudos

Hi John,

put a breakpoint at SAVE_TEXT. run ur program n c the value of l_head-tdname at the point of calling save_text. now goto the screen wherein u wud ve manually entered the long text. there goto the sapscript editor of the text>header> there u ll c the name. now u need to c if ur variable (l_head-tdname) matches exactly with this(including leading zeroes).. if not, then it wont be saved here.

hope it helps,

Regards,

Bikash

Former Member
0 Kudos

hi bikash

u r right.

l_head-tdname does not match with sapscript header.

How to get the value of tdname which is in the script header to l_head-tdname.

bcos i had assigned only material code to l_head-tdname.

pls help me.

John

0 Kudos

Hi

John the name of your text should be the code of material, use a fm to convert the material code for input format: CONVERSION_EXIT_MATN1_INPUT

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

INPUT = <MATNR>

IMPORTING

OUTPUT = <MATNR>.

Anyway make sure which is the name of your text.

Max

0 Kudos

just chk out wat the header name contains.. if its the leading zeroes that is creating the problem, then do wat Max has specified.

if its a combination of matnr n something else, then u need to analyse it..let us know wats there in ur header so that we can suggest something.

Hope it helps,

Regards,

Bikash

Hi John,

if u observe properly, u ll c that for materials with only numbers, leading zeroes will be there before the material....and for materials with alphanumeric value, blank spaces will be present...

field matnr is 18 characters long...so zeroes & blanks r filled accordingly to make up all the 18 characters..

so chk if ur matnr has any alphabets in it...n in that case use this:

l_name(18) = matnr.

l_name+18(4) = plant

l_name+22 = dist channel.

put l_name as ur tdname now..

Hope it helps,

Regards,

Bikash

Message was edited by: Bikash Agarwal

Former Member
0 Kudos

hi,

the text name in the header of sapscript is very peculiar.

For some materials

it is a combination of leading zeros, material name, plant and distribution channel.

but for some other materials it is a combination of

material name, blank space, plant and distribution channel.

the above two combination can occur even for the same material type.

It is very weired.

Thought MAX's solution helped for the first combination it did not help for second combination

suggest me a solution for this.

Thanks

John

0 Kudos

Hi

I believe the name of text is the key of MVKE, so

MATNR, VKORG and VTWEG.

You need only to convert material code

0 Kudos

Hi

I believe the name of text is the key of MVKE, so

MATNR, VKORG and VTWEG.

You need only to convert material code:

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

INPUT = matnr

IMPORTING

OUTPUT = matnr.

CONCATENATE MATNR VKORG VTWEG INTO l_head-tdname

Max

Former Member
0 Kudos

I am guessing that you have some materials that are alphanumeric and others that are purely numeric. In either case, you have to use the conversion exit call. But just before you do that, please add this additional line.

SHIFT record-matnr_001 LEFT DELETING LEADING SPACE.

0 Kudos

Also, if you are using the function module, why are you doing a BDC? You cannot do a BDC and call this funciton module in the middle. All you have to do is to call the SAVE_TEXT function module after you fill in the appropriate parameters.

Former Member
0 Kudos

John,

The function SAVE_TEXT is independent of the BDC process - you don't need the BDC logic before you call it.

Depending on your version of SAP the language key might be EN instead of E. Just use

l_head-tdspras = sy-langu.

to get the right one.

The easiest way to verify that you're using the correct ID and OBJECT is to manually change the text in MM02, then use SE16 to view the STXH table. Query STXH with TDNAME = <your material number>. Then confirm the values of TDOBJECT and TDID.

If you want the history of your text change to be saved you should actually use function BAPI_MATERIAL_SAVEDATA (passing the data in internal table MATERIALLONGTEXT).