Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
JL23
Active Contributor
90,494

This blog shall explain how to load long text with LSMW direct input method.

It does not really matter if the long text belongs to material master or vendor master, customer master or even to transactional data like contracts or bill of materials.

Long text to any object is stored in the SAP's long text tables STXH (header) and STXL.(lines)

Most objects do not have any indicator that tells about existing long text, It is just a piece of code that is executed when you go to the text screens and retrieves the text from STXH and STXL table if present.  Hence inserting text with the correct key into these tables will automatically make this text available when you e.g. go MM02 Material master change transaction into the purchase order text view.

Our business case here is to add purchase order long text to material masters that got migrated earlier.

The source file is prepared in Excel and has just 3 columns: old material number, purchase order long text and line number

I do not explain any single LSMW step in this blog in deep detail as I described it in in my other blogs:

LSMW Material master by BAPI method - Part 1

LSMW Material master by BAPI method - Part 2

So i am just focusing here on the difference to these other blogs and the specifics with the direct input method and how do deal with long text.

I am continuing in my existing project SCN, with subproject MATERIAL and create a new object called MM_PO_TEXT

LSMW Step 1 Maintain object attributes

Set the radio button to Standard/Direct Input Import Method

Then move the cursor into the Object field and use F4 to find the object for Long texts

Do the same for the Method.

The Program name and the program type will then be defaulted by SAP itself.

The icon with the glasses allows you to display the source code of this program (I have used twice in lifetime, but only to answer a question in the forum, I never needed it for myself, especially not to execute this LSMW method)

LSMW Step 2 Maintain Source Structures

My source file is just a flat file without deeper structure, so only one entry in this step needed. I name my structure LONGTEXT

LSMW Step 3 Source Fields

Now I am adding the fields to this structure. As I have only a few fields I am doing it using the table icon.

Defining the fields in the same sequence as they appear in my source file

Define them as character fields, with a field length like it was in the legacy system,

The length of the old material number does not matter in this case as the  material number itself was never that long in the legacy system.

The attentive reader will see that I just entered 2 fields in the source field definitions while my source file has 3 fields.

Reason: I am lazy. To be honest I do not make use of the content of the line number field in this upload program.

I only require this line number in the Excel file as an objective evidence for the sequence of lines in case there are multiple lines.

LSMW Step 4 Maintain Structure Relations

The target structure is automatically proposed based on the chosen import method in LSMW step 1.

I assign my source structure to both structures, header and row.

LSMW Step 5 Maintain Field Mapping and Conversion Rules

To keep my program flexible for any language that need to be loaded (per source file one language)

I am adding a selection parameter in the __GLOBAL_DATA__ section.

Just double click the light blue field with the name  __GLOBAL_DATA__ to get into the code editor

Enter here a statement   PARAMETER: PSPRAS like MAKT-SPRAS

PSPRAS is my field name and with the LIKE MAKT-SPRAS I tell the program that it shall be like the language field from MAKT table.

Further I add a data declaration for 2 other fields:

W_SKIP TYPE i. this is an integer number field that I want to use to count the records I cannot convert

and

W_SKIP_FLAG type C VALUE ' '  which describes a character field with no initial content. I will use this to trigger the event to skip the transaction.

In the header structure I assign a constant "MATERIAL" to the object field, and a constant "BEST" to the ID field

(You can obtain these values if you go into the text view of existing data and click there the text editor icon. After you are taken to the text editor chose from menu Goto > header and you will see the key fields and its content)

The NAME field shall get the new material number. But my source file has only the old material number.

Hence I need to add coding to determine the material number based on the old number.

As you know, the old material number is stored in the basic data view of material master. Go into the material master Press F1 in that field and then the icon for technical field help and you can see the field name and the table.

With this information we can create the coding to get the material number.

First I add a data declaration to define a workarea. which will receive the found data.I could have done this already in the __GLOBAL_DATA__ section, but it can be done everywhere in the source.

Then a select statement to find a record in table MARA that matches with my old material number.

If a record is found, then the material number is moved to the target field /SAPDMC/LTXTH-NAME

If not found, then I write a message into the conversion log to know which old material number could not be converted. And I move a Y (for YES) into my help field w_skip_flag: This is as well for safety reasons. The direct input will not check if your material exists. It will just post what you deliver, regardless if correct or nonsense. So you can create a lot of ghost texts if you do not care enough. Hence you need to control it yourself.


SELECT  single  * FROM  MARA into WA_MARA

       WHERE  BISMT  = longtext-old_number.

if sy-subrc = 0. "record found

  /SAPDMC/LTXTH-NAME = WA_MARA-MATNR.

else.

  WRITE:/ longtext-old_number , 'not in MARA-BISMT'.

  w_skip_flag = 'Y'.

endif.

Next is the language field which needs some attention. You remember, I had defined a selection parameter for the language to be flexible and to use the same LSMW object for whatever language that will be loaded.

I start again with a data declaration for a workarea for the language, because I need to check that I do not enter nonsense into the language parameter field.

So I verify the entered language if it is available in the language table T002.

If the entered language cannot be found, then I skip the record from being loaded. Which is then the case for all records as the language parameter is only entered once. And in that case I write as well a small message into the conversion log.

Now look what I have done at the __END_OF_RECORD__   processing time.

I changed the default "transfer_record" into "on_change_transfer_record"

This little change controls that the header record is only written when the material number changes (material number is the only variable in the header structure)

This means I write just one header record while I write several rows.

In the structure for the row I only assign my long text line. SAP is processing the source file from the first record in sequence to the last record, thus I do not need the line number from my source file.

Now to the final manipulations. in the processing time __END_OF_TRANSACTION__ I check my help field. This help field has the value 'Y' in case the material number could not be found for the given old material number, hence I have to skip this transaction from posting.

And at the __END_OF_PROCESSING__ I write the numbers of skipped records to the conversion log.

which will then look like in this screenshot:

LSMW Step 6 Maintain fixed values, Translations , user defined routines

Not necessary for this business case

LSMW Step 7 - Specify files

Save the Excel source file as Unicode Text. Then specify this text file in step 7.

LSMW Step 8 - Assign Files

As there is only one source structure and one source file, SAP does the proposal and you only need to click save

LSMW Step 9 - Read Data

SAP generates the read program, you can execute it for the entire file or just for a selection of records.

SAP will give you a summary of read records and read transactions.

Compare it with your source file to be certain that everything was read.

LSMW Step 10 - Display read data

Important step to check that you data was correct read and that it was transferred to the fields defined in step 3.

From the overview click a line to get to its detail view..

LSMW Step 11 - Convert Data

In the conversion step you can execute the conversion for all records that where read from your source file, or just for a selection for a test case.

Here you can see the parameter PSPRAS for the language, that I defined in step 5 Mapping rules.

LSMW Step 12 - Display converted data

In this screenshot of the converted data you can see that the new material number is assigned.

The yellow lines represent the header, and the blue lines the text lines.

So you see that we have 2 materials with just one long text line followed by a material with 6 lines

LSMW Step 13 - Execute Direct Input

In this step you execute, post the data to your SAP system.

SAP defaults all data. you only need to click execute

The long text upload is really done in a few seconds for many hundred records, don't be surprised, nothing wrong.

When finished SAP gives you this summary:

Loading long text means that SAP does REPLACE existing text with the same key.

Even the old text has many hundred lines and the new text just one, all lines of old text are deleted and then the new text written.

73 Comments
JL23
Active Contributor
0 Kudos

The objects are programmed by different people in SAP, while the material master directly checks for long text the task list needs an indicator that tells the program that it has long text and  triggers the program to look into the long text tables.

The direct input for long text as described in this blog cares only about long text in tables STXH and STXL, it does not do any update in any other table.

To make the text visible you would need to update the task list table.

Option 1 is that you do that with a Z-program

Option 2 is that you set this indicator already when loading the task list while you have not yet any text. Just to prepare for the separate text load.


Since your task lists exists already you will not have the chance to use option 2. Its too late for that. You have to go with option 1

Former Member
0 Kudos

Thanks again for your quick response,

Sorry that i didn´t mention in the project explanation, but i made this legacy to create task list (since it only work for creation transactions) so, i forget about modifyng my old task list without long text and I decide to create a new ones from zero loading the long text.

For that reason I´m taking option 2. So my question is in this scenario.

JL23
Active Contributor
0 Kudos

If you are allowed to do table updates from the LSMW conversion program then you can place your code in the end_of _transaction section.

In the narrow sense you are programming a kind of trojan and bypass the usual approval and transport procedures for Z-Programs.

It had cost me a lot of energy to convince our auditors and security guys that I need the flexibility of the export/import feature to be fast in critical times of data migration. I would not risk this privilege with such program code. 

At the end it is nothing else than the Z-program does, but these kind of people are doctrinaire.

Former Member
0 Kudos

I am going to thank you everytime you make a response, hope this don't bother you,

I understand that the option that i'm asking is not very 'clean' , i also think that z-programs generally cause more damages than their thought benefits. Nevertheless, thinking in the option 1,  right now our abap time is very overcharged.

I will take again the option of loading the New task list by object 0470. One question about this method, i assume that this program deal with the long text existence indicator, as i said i have all the task lists operations in txt files in natural language, do you now a way to make the legacy able to transform and read the text? ( if i try to convert each One in sa text editor format i will never finish, 3 thousands aprox)

JL23
Active Contributor
0 Kudos

this requirement goes again towards ABAP, see this document How to Upload Long Text into SAP Using Excel Sheet and SAVE_TEXT  Function Module

Former Member
0 Kudos

Thanks for all Juergen. Your responses really guide me.

Former Member
0 Kudos

Hi Juergen,

More kudos sir.  I was struggling to load PO header texts on multiple lines and just your one tip about "on_change_transfer_record" solved my issue.

Thank you.

lars_birk3
Explorer
0 Kudos

Hi Juergen,

I have tried to create a LSMW, based on your instruction, but when I run the input, it shows that it transfered, but when I  check my material, the text is not uploaded.

I try to load Basic text on the Material master, via the material no MATNR.

My mapping looks like this

When I have done the convertion the upload file look like this

I also get a ok on the upload, but the material master is not updated with my text.

I think that it could the way I have mapped the material no, but I'm sure can you pls help here

Thanks Lars

JL23
Active Contributor
0 Kudos

It worked for so many people as you could see on previous comments, so you must have overseen something.

Unfortunately I am already over 50 and can't read anything in your screenshots, not even with zoom of 500%

But looking at the structure of your first screenshot I am very certain that you have not followed every detail in my blog.  Please go through my blog LSMW Material master by BAPI method - Part 1 to know how a professional does setup his LSMW, which is the basis to succeed with the approach in this blog.

lars_birk3
Explorer
0 Kudos

Hi Juergen,

Thanks for your quick reply, I can see that these are small pictures 🙂 I tried to do a new

I think that I have followed your instruction, but I have not used the coding in the Name field only mapped the material no. 

Could this be the problem, I can see any other field to map the material no mara-matnr to.

Regards, Lars 

JL23
Active Contributor
0 Kudos

There were more places with coding in my blog, and they all have their meaning.

In step "Display converted data" you can see how your data looks, you can see if you have the correct material number for each text and of course if the material number is in the right format, to much people forget that a material number usually has leading zeros in a standard SAP system, so just mapping a material number from an Excel sheet which has no leading zeros will certainly cause that you loaded the data to exact this number, but your material has a different number since it has leading zeros . Use SE16, there choose from menu Settings > user settings and in the tab data browser remove the flag for "consider conversion exit", then check your MARA table and see how the material number is. If that does not match with your source then your load is not visible in the material master, but is certainly loaded to the STXH/STXL table (warning was given in my blog)

lars_birk3
Explorer
0 Kudos

Hi Juergen,

your right the problem was the format, when I've added the missing zero's it work fine.

Can I ask one more thing, can you by coding add the missing zero's to the material no I'm coming with in my excel sheet, or should I just add in excel.

Thanks for help.

Regards, Lars 

JL23
Active Contributor
0 Kudos

you can convert the number via calling function module CONVERSION_EXIT_MATN1_INPUT

into the internal format.

You can as well just use the  "concatenate" to add leading zeros (in case all numbers have the same length) in LSMW or in your Excel source

0 Kudos
Hy Jürgen,

great job, many thanks for this useful Guide.

Do you know if there is a possibility for a change log when using the LSMW direct input method for (e.g. Material) long texts? (if i do it manually via MM02, a change log is created, just to inform that a certain text type has been changed).

 

BR,

Gregor
JL23
Active Contributor
0 Kudos
the direct input touches only STXH and STXL tables. it is just the text object and ID that makes the text visible from material master. So there is technically no option to see change history in the material master.

 
Former Member
0 Kudos
Hi Jurgen,

I want to migrate service master records into an SAP system. I already managed to migrate the fields of interest using an LSMW recording with transaction AC02, however long texts are ignored from recording the field.

How I can proceed with that?

 

 
JL23
Active Contributor
0 Kudos
I had written this blog to tell you how to load long text- try it.
0 Kudos
Thanks Jurgen for your presentation.

What I actually have is creating Purchase Orders with very long header texts. Some of them are as long as 80 lines.  I don't know if LSMW would be an efficient method. Would you happen to know what other methods that can be used. Please don't ask me what they are doing with 80 lines of text. I have asked the business that and they seem to think that is what they want. But I have explored cover letter options for them and this is just an extra layer of last resort.

Thanks.
JL23
Active Contributor
0 Kudos
just 80 lines and you already doubt on the capability of SAP?

 
former_member452208
Discoverer
0 Kudos
Hi Jurgen,

I have followed your step and everything works for all the long text into additional data (BEST, GRUN, PRUE, IVER... however for the text that you can find into the MRP4 view (LTXT, object MDTXT instead of Material. I am facing some issues because it needs the plant.  So I followed your program but add colomn ID (BEST, GRUN...) OJBECT (MATERIAL, MDTXT..) but still the text doesn't get loaded for the MRP one because of the plant.  It doesnt give me error however, it just doesnt get loaded.  Its probably due to the code of MATNR... but do you have any idea what more I could code for this?  Thank you.
former_member214131
Active Contributor
0 Kudos
Hi Jurgen,

Do you have any idea how we process the long texts on S4 1709 - on premise setup? I dont see any migration object listed in Migration Cockpit for Long texts.

Best Regards, Murugesh
0 Kudos
Hi Jurgen

It works, done for sales material text and after having correct format of field NAME, no problems.

Thank you,

 

Regards,

Chema
m77
Explorer
0 Kudos
Hi Juergen,

Thank you very much for your efforts and time!

I am facing difficulty with customer sales text upload whereby I get the message " Ensure field sequence is correct for data for multiple source structures" at Read Data and cannot overcome this problem.

Can you give me a hint at what might be going wrong in the template? If you need more info or pictures, let me know.

MfG,

Miroslav

Labels in this area