Vous êtes sur la page 1sur 12

17/01/14

How to Upload Long Text into SAP Using Excel Sh... | SCN
Getting Started New sletters Store

Welcome, Guest

Login

Register

Search the Community

Products Industries Lines of Business

Services & Support Training & Education University Alliances

About SCN Partnership Events & Webinars

Downloads Developer Center Innovation


Activity Brow se Communications Actions

How to Upload Long Text into SAP Using Excel Sheet and SAVE_TEXT Function Module
Share 0 Tw eet 7

Version 11

created by Smruti Ranjan Mohanty on Aug 20, 2013 12:00 PM, last modified by Smruti Ranjan Mohanty on Oct 18, 2013 9:55 AM

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.

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 .

Screen Shot # 2

scn.sap.com/docs/DOC-45423

1/12

17/01/14

How to Upload Long Text into SAP Using Excel Sh... | SCN

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 .

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 IT_EXLOAD TYPE STANDARD TABLE OF TY_ITAB INITIAL SIZE 0, 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, W_END TYPE I OBLIGATORY. 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 DYNPRO_NUMBER = SYST-CPROG = SYST-DYNNR Excel Row beginning Excel End Row

scn.sap.com/docs/DOC-45423

2/12

17/01/14
IMPORTING FILE_NAME ENDFORM. = PFILE .

How to Upload Long Text into SAP Using Excel Sh... | SCN

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' I_BEGIN_ROW = W_BEGIN I_END_COL = '002' I_END_ROW = W_END TABLES INTERN ENDFORM. Excel Beginning Column Excel End Column

= IT_EXLOAD. " 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. WHEN '0002'. WA-LMAKTX = IT_EXLOAD-VALUE. ENDCASE. AT END OF ROW1. WA-TSIZE = STRLEN( WA-LMAKTX ) . WA-ROW = IT_EXLOAD-ROW1 . APPEND WA TO I_TAB. CLEAR WA . ENDAT. ENDLOOP. ENDFORM. " EXCEL_TO_INT Material Number Leading with Zero Material Long Text

Finding String Length using STRLEN Adding Current Row Num into Internal table

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'. MOVE WA-TSIZE TO LEN . LEN = LEN / 53 + 1. Finding Number of Rows taken by Long Text Text Object

Note : Number of Row Required for Long Text Display = Total length of long text / Number Characters 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 LANGUAGE NAME OBJECT =1 =2 =3 =4

scn.sap.com/docs/DOC-45423

3/12

17/01/14
OTHERS = 5. * Check the Return Code IF SY-SUBRC <> 0.

How to Upload Long Text into SAP Using Excel Sh... | SCN

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. Output " CONTOL_PARAMETER

Screen Shot # 13

Screen Shot # 14

Screen Shot # 15

Reference :
scn.sap.com/docs/DOC-45423 4/12

17/01/14

How to Upload Long Text into SAP Using Excel Sh... | SCN

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

3440 View s Tags: scn, bi, sap, pm, srm, update, w iki, upload, abap, beginner, erp, sap_developer_netw ork, crm, bw , scm, hr, excel, rfc, alv, material, mm, qm, fica, ole, sd, bapi, purchasing, bdc, function_module, fi, abap_objects, lsmw , ms_excel, ole2, abap_oo, dataw arehouse, oo_abap, abap_object, po_printing, po_print

Average User Rating (29 ratings)

Share

Tw eet

79 Comments
Bisw esw ar Sahu Aug 20, 2013 12:50 PM

Hi, Nice Document for Go-Live Phase. Thanks Bisweswar


Like (1)

Smruti Ranjan Mohanty Aug 20, 2013 12:59 PM (in response to Bisw esw ar Sahu)

thanks Bisweswar ... Regard's Smruti


Like (0)

Ramesh T Aug 20, 2013 1:00 PM

Hi Smruti.. Good Document.... Thanks for sharing.... Regards, Ramesh.T


Like (1)

Smruti Ranjan Mohanty Aug 20, 2013 1:05 PM (in response to Ramesh T)

Thanks Ramesh.. Regard's Smruti


Like (0)

Asif Mohammad Aug 20, 2013 1:13 PM

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
Like (1)

Smruti Ranjan Mohanty Aug 20, 2013 1:19 PM (in response to Asif Mohammad)

scn.sap.com/docs/DOC-45423

5/12

17/01/14
Yeah Sure .. Thanks Asif ..

How to Upload Long Text into SAP Using Excel Sh... | SCN

Like (0)

Naresh Krishnamoorthy Aug 22, 2013 6:27 AM

Good One...Many Thanks. Best Regards, Naresh K.


Like (1)

Smruti Ranjan Mohanty Aug 22, 2013 6:43 AM (in response to Naresh Krishnamoorthy)

Thamks Regard's Smruti


Like (0)

Ravi Sankar Venna Aug 22, 2013 2:50 PM

Good work Smruti. This is the one which is always missed by LSMW. Surely helpful. Regards, Ravi
Like (1)

Smruti Ranjan Mohanty Aug 23, 2013 6:29 AM (in response to Ravi Sankar Venna)

Thanks Ravi Regard's Smruti


Like (0)

Jrgen L Aug 22, 2013 3:09 PM

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.
Like (5)

Ravi Sankar Venna Aug 22, 2013 3:19 PM (in response to Jrgen L)

Good advice Jurgen.


Like (0)

Smruti Ranjan Mohanty Aug 23, 2013 6:31 AM (in response to Jrgen L)

Thanks for Good Advice Regard's Smruti

, Now the Document is Updated .

Like (0)

Jrgen L Aug 23, 2013 7:45 AM (in response to Smruti Ranjan Mohanty)

Thumbs up, much better now.


Like (0)

Amala Srinivasa Rao Aug 22, 2013 3:17 PM

Good effort dear Smruti !!!


Like (1)

Smruti Ranjan Mohanty Aug 23, 2013 6:32 AM (in response to Amala Srinivasa Rao)

Thanks Amala Regard's Smruti


Like (0)

Shashi Kanth Aug 23, 2013 6:47 AM

Hi Smruthi,

scn.sap.com/docs/DOC-45423

6/12

17/01/14
Nice Document....thanks for sharing. Best Regard's, Shashi Kanth

How to Upload Long Text into SAP Using Excel Sh... | SCN

Like (1)

Smruti Ranjan Mohanty Aug 23, 2013 6:54 AM (in response to Shashi Kanth)

Thanks Shashi Regard's Smruti


Like (0)

Bisw esw ar Sahu Aug 23, 2013 8:30 AM

Now it really helpful to copy & use. Regards, Bisweswar


Like (0)

Eduardo Hinojosa Aug 23, 2013 1:59 PM

Excellent !!!
Like (1)

Smruti Ranjan Mohanty Aug 23, 2013 2:09 PM (in response to Eduardo Hinojosa)

Thanks Regard's Smruti


Like (0)

Jothivenkatesh M Sep 3, 2013 8:25 AM

Good detailed document there.


Like (1)

Smruti Ranjan Mohanty Sep 3, 2013 8:31 AM (in response to Jothivenkatesh M)

Thanks Jothivenkatesh.. Regard's Smruti


Like (0)

Hai Wang Sep 4, 2013 2:50 AM

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

Smruti Ranjan Mohanty Sep 4, 2013 4:48 AM (in response to Hai Wang)

Thanks Wang... Regard's Smruti


Like (0)

Akberhusain Ajmeri Sep 5, 2013 9:13 AM

Nice Article. Thanks for sharing


Like (1)

Smruti Ranjan Mohanty Sep 5, 2013 10:40 AM (in response to Akberhusain Ajmeri)

Thanks Akberhusain .. Regard's Smruti


Like (0)

Erek Herpich Sep 5, 2013 9:41 AM

Well done! Thanks.


Like (1)

Smruti Ranjan Mohanty Sep 5, 2013 10:41 AM (in response to Erek Herpich)

scn.sap.com/docs/DOC-45423

7/12

17/01/14
Thanks Erek Regard's Smruti

How to Upload Long Text into SAP Using Excel Sh... | SCN

Like (0)

Mohammed Jaffer Sep 5, 2013 12:11 PM

Thanks for sharing .Nice one.


Like (1)

Smruti Ranjan Mohanty Sep 5, 2013 2:29 PM (in response to Mohammed Jaffer)

Thanks Jaffer .. Regard's Smruti


Like (0)

Hiriyappa Myageri Sep 5, 2013 3:45 PM (in response to Smruti Ranjan Mohanty)

Very Nice Regard's, Hiriz


Like (0)

Uday Kiran Rayapudi Sep 5, 2013 6:34 PM

Nice Job!.
Like (1)

Smruti Ranjan Mohanty Sep 9, 2013 5:06 AM (in response to Uday Kiran Rayapudi)

Thanks Uday Regard's Smruti


Like (0)

JINTO JOY Sep 12, 2013 9:06 AM

smruti bhaiyaa.... GOOD ONE....!!!!


Like (1)

Smruti Ranjan Mohanty Sep 24, 2013 5:43 AM (in response to JINTO JOY)

Thanks Jinto... Regard's Smruti


Like (0)

Farid Hasan Sep 12, 2013 2:08 PM

Helpful..thanks for sharing


Like (1)

Smruti Ranjan Mohanty Sep 24, 2013 5:44 AM (in response to Farid Hasan)

Thanks Farid Regard's Smruti


Like (0)

Krishna Chaitanya Sep 24, 2013 5:40 AM

Hi Smruti, Nice Job...Great Work...Thanks for sharing. Regards, Krishna Chaitanya.


Like (1)

Smruti Ranjan Mohanty Sep 24, 2013 5:44 AM (in response to Krishna Chaitanya)

Thanks Krishna Regard's

scn.sap.com/docs/DOC-45423

8/12

17/01/14
Smruti

How to Upload Long Text into SAP Using Excel Sh... | SCN
Like (0)

OmChandra L Sep 24, 2013 6:45 AM

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
Like (1)

Smruti Ranjan Mohanty Sep 26, 2013 4:58 AM (in response to OmChandra L)

Thanks Om Regard's Smruti


Like (0)

Ashish Mahakul Sep 24, 2013 8:33 AM

Very good article on using of FM SAVE_TEXT


Like (1)

Smruti Ranjan Mohanty Sep 26, 2013 4:58 AM (in response to Ashish Mahakul)

Thanks Ashish Regard's Smruti


Like (0)

German Meyer Sep 25, 2013 2:05 PM

Thanks for your contribution to the Community.


Like (1)

Smruti Ranjan Mohanty Sep 26, 2013 4:59 AM (in response to German Meyer)

Thanks German Meyer Regard's Smruti


Like (0)

Anoop Thankappan Sep 26, 2013 2:17 PM

Well explained. Thanks for sharing Regards Anoop


Like (1)

Smruti Ranjan Mohanty Sep 27, 2013 4:52 AM (in response to Anoop Thankappan)

Thanks Anoop Regard's Smruti


Like (0)

KIRAN RAJAN Sep 26, 2013 2:24 PM

Hi , Helpful document
Like (1)

Smruti Ranjan Mohanty Sep 27, 2013 4:52 AM (in response to KIRAN RAJAN)

Thanks Kiran Regard's Smruti


Like (0)

Riju Thomas Oct 1, 2013 11:51 AM

Hi, Very helpful document and thanks a lot sharing knowledge.

scn.sap.com/docs/DOC-45423

9/12

17/01/14
Thanks, Riju.

How to Upload Long Text into SAP Using Excel Sh... | SCN

Like (1)

Smruti Ranjan Mohanty Oct 1, 2013 12:48 PM (in response to Riju Thomas)

Thanks Riju Thomas.. Regard's Smruti


Like (1)

priyaranjan choudhury Oct 9, 2013 2:11 PM

Hi, Its very Help full document for Functional Consultant. Thanx for Sharing. Regards Priyaranjan
Like (1)

Smruti Ranjan Mohanty Oct 10, 2013 5:33 AM (in response to priyaranjan choudhury)

Thanks Priyaranjan ... Regard's Smruti


Like (0)

Modadugu Hemanth Kumar Oct 9, 2013 2:23 PM

Informative information

Smruti Ranjan Mohanty


Like (1)

Smruti Ranjan Mohanty Oct 10, 2013 5:34 AM (in response to Modadugu Hemanth Kumar)

Thanks Hemanth.. Regard's Smruti


Like (0)

SG Sg Oct 10, 2013 6:54 AM

Simple and useful INFO, Thanks For Sharing. Regards, Giri


Like (1)

Smruti Ranjan Mohanty Oct 10, 2013 8:16 AM (in response to SG Sg)

Thanks Giri Peram... Regard's Smruti


Like (0)

Martin Grob Oct 10, 2013 1:12 PM

nice article thanks Martin


Like (1)

Smruti Ranjan Mohanty Oct 10, 2013 1:38 PM (in response to Martin Grob)

Thanks Martin Regard's Smruti


Like (0)

Erw in Leitner Oct 17, 2013 5:52 PM

Hello, Thank you for sharing knowledge! Perfect and excellent. Thank you very much. all the best Erwin
Like (1)

scn.sap.com/docs/DOC-45423

10/12

17/01/14

How to Upload Long Text into SAP Using Excel Sh... | SCN

Smruti Ranjan Mohanty Oct 18, 2013 7:44 AM (in response to Erw in Leitner)

Thanks Regard's Smruti

Erwin Leitner

Like (1)

rajesh bethamcharla Oct 18, 2013 5:58 AM

Good Article ... Thanks for sharing...


Like (1)

Smruti Ranjan Mohanty Oct 18, 2013 7:45 AM (in response to rajesh bethamcharla)

Thanks Regard's Smruti

rajesh bethamcharla

Like (0)

Amaranatha Madhaba Oct 18, 2013 8:50 AM

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

Smruti Ranjan Mohanty Oct 18, 2013 9:57 AM (in response to Amaranatha Madhaba)

Yeah Sure. Regard's Smruti

Amaranatha Madhaba..Thanks

Like (0)

Modadugu Hemanth Kumar Oct 18, 2013 8:56 AM

Nice document with detailed steps.


Like (1)

Smruti Ranjan Mohanty Oct 18, 2013 9:57 AM (in response to Modadugu Hemanth Kumar)

Thanks Regard's Smruti

Modadugu Hemanth Kumar

Like (0)

Ravindra Devarapalli Oct 18, 2013 6:39 PM

Nice document

..............
Like (1)

Smruti Ranjan Mohanty Oct 21, 2013 6:33 AM (in response to Ravindra Devarapalli)

Thanks Regard's Smruti

ravindra devarapalli

Like (0)

Suman Sardar Oct 20, 2013 6:54 AM

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$
Like (1)

Smruti Ranjan Mohanty Oct 21, 2013 6:41 AM (in response to Suman Sardar)

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

scn.sap.com/docs/DOC-45423

11/12

17/01/14

How to Upload Long Text into SAP Using Excel Sh... | SCN
Like (0)

Suman Sardar Oct 21, 2013 7:23 AM (in response to Smruti Ranjan Mohanty)

Thanks for the expalnation Smruti Ranjan Mohanty Anyway great to know such things.
Like (0)

Srinu S Oct 25, 2013 8:23 AM

Nice document. thanks for sharing.


Like (1)

Smruti Ranjan Mohanty Oct 25, 2013 10:40 AM (in response to Srinu S)

Thanks Regard's Smruti

Srinivas S

Like (0)

Chandra Agarw al Oct 25, 2013 10:43 AM

Useful one!!!
Like (1)

Smruti Ranjan Mohanty Oct 28, 2013 3:55 AM (in response to Chandra Agarw al)

Thanks Regard's Smruti

Chandra Agarwal

Like (0)

rajesh bethamcharla Nov 8, 2013 1:06 PM

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
Like (0)

Smruti Ranjan Mohanty Nov 8, 2013 1:17 PM (in response to rajesh bethamcharla)

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
Like (0)

Site Index Privacy

Contact Us Terms of Use

SAP Help Portal Legal Disclosure

Copyright

Follow SCN

scn.sap.com/docs/DOC-45423

12/12

Vous aimerez peut-être aussi