Skip to Content
Author's profile photo Former Member

How to Upload Long Text into SAP Using Excel Sheet and SAVE_TEXT Function Module

Many times user may have requirement during uploading the data into SAP as below points.


  • Upload the Long Text into SAP Using Excel Sheet (i.e. here I am explaining about a PO Text in MM Screen).
  • Long Text Readable within text area no need to use horizontal bar

/wp-content/uploads/2013/08/l0_295342.png

Screen Shot # 1

Solution:

  •   Create a Copy of “ALSM_EXCEL_TO_INTERNAL_TABLE” SAP Standard Function Module

           into Custom Function Module “YALSM_EXCEL_TO_INTERNAL_TABLE” .

L1.png

Screen Shot # 2

L2.png

Screen Shot # 3

Create a “Z” Copy of “ALSMEX_TABLINE” and Increase the “Value” Field Size i.e. here I am use 2000 character , you can take as per your requirement .

L3.png

Screen Shot # 4

  •   Create Custom Upload Program using above Custom Functional Module.

“Data Declaration

  TYPES: BEGIN OF TY_ITAB ,

         MATNR(18)    TYPE C,

         LMAKTX(2000) TYPE C,

         ROW TYPE I,

         TSIZE TYPE I,

         END OF TY_ITAB.

Data Declarations – Internal Tables

DATA: I_TAB          TYPE STANDARD TABLE OF TY_ITAB  INITIAL SIZE 0,

       IT_EXLOAD      LIKE ZALSMEX_TABLINE  OCCURS 0 WITH HEADER LINE,

       IT_LINES       LIKE STANDARD TABLE OF TLINE WITH HEADER LINE,

       IT_TEXT_HEADER LIKE STANDARD TABLE OF THEAD WITH HEADER LINE,

       WA             TYPE TY_ITAB ,

       P_ERROR TYPE  SY-LISEL ,

       LEN TYPE I .

“Selection Screen

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-002.

PARAMETERS:PFILE TYPE RLGRAP-FILENAME OBLIGATORY, “Excel File Name with Path

           W_BEGIN TYPE I OBLIGATORY,                                      “Excel Row beginning

           W_END TYPE I OBLIGATORY.                                          “Excel End Row     

SELECTION-SCREEN END OF BLOCK B1.

AT SELECTION-SCREEN.

  IF PFILE IS INITIAL.

    MESSAGE S368(00) WITH ‘Please input filename’. STOP.

  ENDIF.

START-OF-SELECTION.

REFRESH:I_TAB.

  PERFORM EXCEL_DATA_INT_TABLE.   

  PERFORM EXCEL_TO_INT.

  PERFORM CONTOL_PARAMETER.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR PFILE.

  PERFORM F4_FILENAME.

“ F4 Help getting Excel File Name with Comlete Path

FORM F4_FILENAME .

  CALL FUNCTION ‘F4_FILENAME’

  EXPORTING

    PROGRAM_NAME        = SYST-CPROG

    DYNPRO_NUMBER       = SYST-DYNNR

  IMPORTING

    FILE_NAME                  = PFILE .

ENDFORM. 

“Read Legacy Data Transfer from Excel using Custom Function Module

FORM EXCEL_DATA_INT_TABLE .

  CALL FUNCTION ‘YALSM_EXCEL_TO_INTERNAL_TABLE

    EXPORTING

      FILENAME    = PFILE

      I_BEGIN_COL = ‘0001’               “Excel Beginning Column           

      I_BEGIN_ROW = W_BEGIN     

      I_END_COL   = ‘002’                  “Excel End Column    

      I_END_ROW   = W_END                                  

    TABLES

      INTERN      = IT_EXLOAD.

ENDFORM.                    ” EXCEL_DATA_INT_TABLE

“Transfer Excel data into internal table

FORM EXCEL_TO_INT .

  LOOP AT IT_EXLOAD .

    CASE  IT_EXLOAD-COL1.

      WHEN ‘0001’.

        WA-MATNR   = IT_EXLOAD-VALUE.        “Material Number Leading with Zero

      WHEN ‘0002’.

        WA-LMAKTX   = IT_EXLOAD-VALUE.      “ Material Long Text

    ENDCASE.

    AT END OF ROW1.

      WA-TSIZE = STRLEN( WA-LMAKTX ) .         “Finding String Length using STRLEN

      WA-ROW = IT_EXLOAD-ROW1 .                  “Adding Current Row Num into Internal table    

      APPEND WA TO I_TAB.

      CLEAR WA .

    ENDAT.

  ENDLOOP.

ENDFORM.                    ” EXCEL_TO_INT

“Maintain Header, Item data and pass into “SAVE_TEXT” to save to Long Text

FORM CONTOL_PARAMETER.

  DATA OFF TYPE I VALUE ‘0’.

  LOOP AT I_TAB INTO WA.

    * Create Header

    IT_TEXT_HEADER-TDID     = ‘BEST’.                 “ Text ID for Material Master

    IT_TEXT_HEADER-TDSPRAS  = SY-LANGU .    “ Login Language Key

    IT_TEXT_HEADER-TDNAME   = WA-MATNR.     “Material Number leading with Zero 

    IT_TEXT_HEADER-TDOBJECT = ‘MATERIAL’.     “ Text Object

    MOVE WA-TSIZE TO LEN .    

    LEN =  LEN / 53  + 1.                                           “Finding Number of Row’s taken by Long Text

    “ Note :  Number of Row Required for Long Text Display

              = Total length of long text / Number Character’s in one Row + 1 

               Here I am taken 53 number of character in each row ,

               because in Material Master Long Text Area Display 53 Character without using Horizontal Bar . “

    DO LEN TIMES .

      MOVE ‘*’ TO IT_LINES-TDFORMAT.

      MOVE  WA-LMAKTX+OFF(53) TO IT_LINES-TDLINE.

      SHIFT IT_LINES-TDLINE LEFT DELETING LEADING ‘ ‘.

      OFF = OFF + 53 .

      APPEND IT_LINES.

      CLEAR IT_LINES .

    ENDDO.

Using SAVE_TEXT Functional Module Save Long Text to SAP

    AT END OF ROW.

      CALL FUNCTION ‘SAVE_TEXT’                  

        EXPORTING

          CLIENT                     = SY-MANDT

          HEADER                   = IT_TEXT_HEADER

          INSERT                     = ‘ ‘

          SAVEMODE_DIRECT = ‘X’

        TABLES

          LINES                        = IT_LINES

        EXCEPTIONS

          ID                              = 1

          LANGUAGE               = 2

          NAME                        = 3

          OBJECT                     = 4

          OTHERS                    = 5.

* Check the Return Code

      IF SY-SUBRC <> 0.

        MESSAGE ID SY-MSGID TYPE SY-MSGTY

            NUMBER SY-MSGNO

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

        EXIT.

      ENDIF.

      CLEAR: WA ,LEN , OFF.

      REFRESH IT_LINES .

    ENDAT.

  ENDLOOP.

ENDFORM.                    ” CONTOL_PARAMETER

  • Output

L12.png

Screen Shot # 13

L13.png

Screen Shot # 14

/wp-content/uploads/2013/08/l00_264600.png

Screen Shot # 15

Reference :

Note – 933420 – ALSM_EXCEL_TO_INTERNAL_TABLE

Source Code Available in Wiki : How to Upload Long Text into SAP Using Excel Sheet and SAVE_TEXT Function Module – ABAP Developme…

Regard’s

Smruti



Assigned Tags

      83 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Bisweswar Sahu
      Bisweswar Sahu

      Hi,

      Nice Document for Go-Live Phase.

      Thanks

      Bisweswar

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      πŸ™‚ thanks Bisweswar ...

      Regard's

      Smruti

      Author's profile photo Ramesh .
      Ramesh .

      Hi Smruti..

      Good Document.... Thanks for sharing....

      Regards,

      Ramesh.T

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Ramesh.. πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Thanks Smruti  πŸ™‚

      Thanks for sharing Good Document.......

      This document is helpful for us, we work on the similar concept.!

      Keep posting.....   with New Ideas......

      Regards,

      Asif

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Yeah Sure ..

      Thanks Asif .. πŸ™‚

      Author's profile photo Former Member
      Former Member

      Good One...Many Thanks.

      Best Regards,

      Naresh K.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thamks πŸ™‚

      Regard's

      Smruti

      Author's profile photo Ravi Sankar Venna
      Ravi Sankar Venna

      Good work Smruti. This is the one which is always missed by LSMW.

      Surely helpful.

      Regards,

      Ravi

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Ravi πŸ™‚

      Regard's

      Smruti

      Author's profile photo JΓΌrgen L
      JΓΌrgen L

      It could have been a real good document.

      But somehow the new style of documenting seems to be to just post screen shots of content that could easily posted as text in the document itself

      No explaining words, of course an ABAPer can read the screen shots, but you tagged it as well for beginners... beginner would need some explanation

      And not to forget the SCN search searchs for words, it is not able to search by words that are contained in screen shots.

      Author's profile photo Ravi Sankar Venna
      Ravi Sankar Venna

      Good advice Jurgen.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks for Good Advice πŸ™‚ , Now the Document is Updated .

      Regard's

      Smruti

      Author's profile photo JΓΌrgen L
      JΓΌrgen L

      Thumbs up, much better now.

      Author's profile photo Former Member
      Former Member

      Good effort dear Smruti !!! πŸ™‚

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Amala πŸ™‚

      Regard's

      Smruti

      Author's profile photo Shashi Kanth
      Shashi Kanth

      Hi Smruthi,

      Nice Document....thanks for sharing.

      Best Regard's,

      Shashi Kanth

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Shashi πŸ™‚

      Regard's

      Smruti

      Author's profile photo Bisweswar Sahu
      Bisweswar Sahu

      Now it really helpful to copy & use.

      Regards,

      Bisweswar

      Author's profile photo Eduardo Hinojosa
      Eduardo Hinojosa

      Excellent !!!

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks πŸ™‚

      Regard's

      Smruti

      Author's profile photo Jothivenkatesh M
      Jothivenkatesh M

      Good detailed document there.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Jothivenkatesh.. πŸ™‚

      Regard's

      Smruti

      Author's profile photo Hai Wang
      Hai Wang

      It's a great article to share. Thanks, and hopefully you would be able to bring out more!

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Wang... πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Nice Article.

      Thanks for sharing

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Akberhusain .. πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Well done! Thanks.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Erek πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Thanks for sharing .Nice one.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Jaffer .. πŸ™‚

      Regard's

      Smruti

      Author's profile photo Hiriyappa Myageri
      Hiriyappa Myageri

      Very Nice πŸ™‚

      Regard's,

      Hiriz

      Author's profile photo Uday Kiran Rayapudi
      Uday Kiran Rayapudi

      Nice Job!.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Uday πŸ™‚

      Regard's

      Smruti

      Author's profile photo J J
      J J

      smruti bhaiyaa....

      GOOD ONE....!!!!

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Jinto... πŸ˜‰

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Helpful..thanks for sharing πŸ™‚

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Farid πŸ™‚

      Regard's

      Smruti

      Author's profile photo Krishna Chaitanya
      Krishna Chaitanya

      Hi Smruti,

      Nice Job...Great Work...Thanks for sharing.

      Regards,

      Krishna Chaitanya.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Krishna πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Hi Smruti,

      You have done good document. many of them geting problem with uploading the long text so it will use ful for us.

      Regards,

      OmChandra

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Om πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Very good article on using of FM SAVE_TEXT

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Ashish πŸ™‚

      Regard's

      Smruti

      Author's profile photo German Meyer
      German Meyer

      Thanks for your contribution to the Community.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks German Meyer πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Well explained. Thanks for sharing

      Regards

      Anoop

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Anoop πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Hi ,

      Helpful document πŸ™‚

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Kiran πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Hi,

      Very helpful document and thanks a lot sharing knowledge.

      Thanks,

      Riju.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Riju Thomas.. πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Hi,

      Its very Help full document for Functional Consultant. Thanx for Sharing.

      Regards

      Priyaranjan

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Priyaranjan ... πŸ™‚

      Regard's

      Smruti

      Author's profile photo Modadugu Hemanth Kumar
      Modadugu Hemanth Kumar

      Informative information Smruti Ranjan Mohanty

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Hemanth.. πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Simple and useful INFO, Thanks For Sharing.

      Regards,

      Giri

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Giri Peram... πŸ™‚

      Regard's

      Smruti

      Author's profile photo Martin Grob
      Martin Grob

      nice article thanks

      Martin

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Martin πŸ™‚

      Regard's

      Smruti

      Author's profile photo Erwin Leitner
      Erwin Leitner

      Hello,

      Thank you for sharing knowledge! ➕

      Perfect and excellent. Thank you very much. πŸ™‚

      all the best Erwin

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Erwin Leitner πŸ™‚

      Regard's

      Smruti

      Author's profile photo rajesh bethamcharla
      rajesh bethamcharla

      Good Article ... Thanks for sharing... πŸ™‚

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks rajesh bethamcharla πŸ™‚

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Thanks for sharing...learned a lot.Was very interesting. Looking forward for some more doc like this in near future.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Yeah Sure.Amaranatha Madhaba..Thanks πŸ™‚

      Regard's

      Smruti

      Author's profile photo Modadugu Hemanth Kumar
      Modadugu Hemanth Kumar

      Nice document with detailed steps.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Modadugu Hemanth Kumar πŸ™‚

      Regard's

      Smruti

      Author's profile photo Ravindra Devarapalli
      Ravindra Devarapalli

      Nice document πŸ™‚ ..............

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks   ravindra devarapalli  πŸ™‚

      Regard's

      Smruti

      Author's profile photo Suman Sardar
      Suman Sardar

      Good to know such functionality.Really helpful dear Smruti Ranjan Mohanty.

      But I have one question when you are uploading the long text it is going to save in which PO as I not found any PO no in the upload screen.

      Thanks,

      Suman$

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Suman Sardar πŸ™‚

      As per your question , i am used above example to uploading 'Long Text' to Material Master (i.e. MM02 ), here you find Material Number , Not PO Number .

      Note: The main focus area How To Upload Long Text in to SAP Using Excel Sheet .

      Regard's

      Smruti

      Author's profile photo Suman Sardar
      Suman Sardar

      Thanks for the expalnation Smruti Ranjan Mohanty πŸ™‚

      Anyway great to know such things.

      Author's profile photo Srinu S
      Srinu S

      Nice document. thanks for sharing.

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks  Srinivas S   πŸ™‚

      Regard's

      Smruti

      Author's profile photo Chandra Shekhar Agarwal
      Chandra Shekhar Agarwal

      Useful one!!! πŸ™‚

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Chandra Shekhar Agarwal πŸ™‚

      Regard's

      Smruti

      Author's profile photo rajesh bethamcharla
      rajesh bethamcharla

      Hi Ranjan,

      Thanks for sharing such a useful info.

      I don't know how many people tried this logic, but when I tried you logic i am unable to upload more than 255 character from excel into internal table

      Can you please share sample code as in ZIP format that really helps to me.

      Regards,

      Rajesh

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      How to Upload Long Text into SAP Using Excel Sheet and SAVE_TEXT Function Module - ABAP Developme...

      Check above Wiki link. and you need create some custom objects ..for Refer this Document Screen Shot # 2, 3, 4.

      Regard's

      Smruti

      Author's profile photo Former Member
      Former Member

      Good Work. Thank you for sharing Knowledge!

      Regards,

      Sharda

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks SHARDA DAS  ..

      Author's profile photo James Wambulwa
      James Wambulwa

      Thanks Smruti for sharing the document. Its reall informative.

      However, i when i upload the long text, i cannot see it in po text view in mm03 but when i use READ_TEXT FM i can see the Uploaded text.

      what could be issue?

      regards,

      James.

      Author's profile photo Former Member
      Former Member

      My question relates to the long text, but it does not relate with extraction or anything like that.Β  I'm drawing blanks on how to activate the long text button located in document data tab inside of the material master??Β  I need to get this activated in order to input information relating between the document that's listed in that particular material master.