Application Development and Automation 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: 
Read only

SAVE_TEXT FM

Former Member
0 Likes
594

HI i have to upload long text for mm02 from flat file using " save_text" FM. Data in flat file is like

100-100;en;1;text1

100-100;en;2;text2

100-100;fr;1;text1

for that i have wrote a code as follows.

TYPES: BEGIN OF struct,

matnr TYPE mara-matnr,

spras TYPE t002-spras,

num TYPE I,

str TYPE string,

END OF struct.

DATA: SYM TYPE C VALUE ';'.

DATA: itab TYPE TABLE OF struct,

wa TYPE struct.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\Documents and Settings\eccadm\Desktop\MAT1.TXT'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

TABLES

DATA_TAB = itab

.

LOOP AT ITAB INTO WA.

WRITE:/10 WA-MATNR,20 WA-SPRAS,30 WA-NUM LEFT-JUSTIFIED,40 WA-STR.

ENDLOOP.

DATA: IT_HD TYPE STANDARD TABLE OF THEAD INITIAL SIZE 0 WITH HEADER LINE,

IT_LINE TYPE STANDARD TABLE OF TLINE INITIAL SIZE 0 WITH HEADER LINE.

LOOP AT ITAB INTO WA.

IT_HD-TDOBJECT = 'MATERIAL'.

IT_HD-TDNAME = WA-MATNR.

IT_HD-TDID = WA-NUM.

IT_HD-TDSPRAS = WA-SPRAS.

APPEND IT_HD.

IT_LINE-TDFORMAT = '*'.

IT_LINE-TDLINE = WA-STR.

APPEND IT_LINE.

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = IT_HD

INSERT = 'X'

SAVEMODE_DIRECT = 'X'

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = IT_LINE

  • EXCEPTIONS

  • ID = 1

  • LANGUAGE = 2

  • NAME = 3

  • OBJECT = 4

  • OTHERS = 5

.

IF SY-SUBRC <> 0.

SET SCREEN 0.

ENDIF.

ENDLOOP.

WRITE:/ 'SUCCESSFULLY UPLOADED'.

But.its not working and its showing error like I/O error.

thanks and regards:

Kangarun.

Edited by: KangAruN on Nov 1, 2011 11:15 AM

3 REPLIES 3
Read only

former_member222709
Contributor
0 Likes
547

Hi KangAruN,

You need to change the definition of your structure as follows:


TYPES: BEGIN OF struct,
matnr TYPE mara-matnr,
spras TYPE t002-spras,
num TYPE I,
str TYPE TLINE-TDLINE,
END OF struct.

The structure should of the same data types.

Regards,

Pranav.

Read only

0 Likes
547

hi thanks for ur reply

after modifying like that, I am getting error like "Text id 1 for material object doesn't exist'.

Read only

0 Likes
547

Hi KangAruN,

The text-id is available with your Functional Consultant. If you have access to SPRO, then you can verify the text-id for the material that you want to add the text for.

The text-id also needs to be complete e.g. '001' and if you pass only '1', then, the system generates an error.

Regards,

Pranav.