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: 

Sales Text of Material Master

Former Member
0 Kudos
1,306

Hi All,

I need to upload the Sales text of existing Materials in Material master.

When i use Function Module SAVE_TEXT, i can upload the text successfully.

But after upload process, i can not see the text in mm03 screen for the same materials. But i can retrieve the same text for corresponding materials using READ_TEXT function module.

Now i would like to know whether we have any other option to upload the sales text for materials and see it in MM03 screen?

I mean once upload is completed, the text should be visible in the MM03 screen, so that End User can refer the sales text....

Your Help will be highly appreciated, as its very much critical...

Regards

Pavan

Edited by: Pavan Sanganal on Jan 11, 2008 4:34 PM

1 ACCEPTED SOLUTION

Former Member
0 Kudos
361

hi,

use the function module create_text.

after uploading through this function module u can view the text in mm03.

check the sample code

check this code for create_text, similarly use function read_text to extract long text,

in ur transaction in longtext screen go to script editor and go for go to header option there u can get details like text id,object id,name etc u pass this in function module.

check this sample code for creating long text for po

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR, " MATERIAL NUMBER

TEXT(5000) TYPE C, " Long Text

END OF ITAB.

DATA: BEGIN OF ITAB1 OCCURS 0,

MATNR LIKE MARA-MATNR, " Material No

SEQU TYPE I, " Text Sequence

TEXT(5000) TYPE C, " Long Text

END OF ITAB1.

DATA:BEGIN OF DT_LINES OCCURS 0.

INCLUDE STRUCTURE TLINE. " Long Text

DATA:END OF DT_LINES.

DATA : P_FILE1 TYPE STRING.

DATA : DL_NAME TYPE THEAD-TDNAME, " Object Name(material no)

DL_LAN TYPE THEAD-TDSPRAS. " Language

CONSTANTS:C_BEST TYPE THEAD-TDID VALUE 'BEST',

C_MATERIAL TYPE THEAD-TDOBJECT VALUE 'MATERIAL'. " OBJECT

DATA: START TYPE I,

LEN TYPE I VALUE 92,

TOTLEN TYPE I,

N TYPE I.

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

PARAMETERS P_FILE LIKE RLGRAP-FILENAME."input file

SELECTION-SCREEN : END OF BLOCK B1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM FETCH_FILE USING P_FILE.

&----


*& Form fetch_file

&----


text

-


-->P_FILE text

-


FORM FETCH_FILE USING P_FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

IMPORTING

FILE_NAME = P_FILE.

ENDFORM. "fetch_file

START-OF-SELECTION.

PERFORM UPLOAD USING P_FILE. " *To Upload Flat file

PERFORM UPLOAD_TEXT.

&----


*& Form UPLOAD

&----


text

-


-->P_FILE text

-


FORM UPLOAD USING P_FILE.

P_FILE1 = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = P_FILE1

FILETYPE = 'DAT'

HAS_FIELD_SEPARATOR = ' '

HEADER_LENGTH = 0

READ_BY_LINE = 'X'

DAT_MODE = ' '

CODEPAGE = ' '

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = '#'

CHECK_BOM = ' '

VIRUS_SCAN_PROFILE =

NO_AUTH_CHECK = ' '

IMPORTING

FILELENGTH =

HEADER =

TABLES

DATA_TAB = ITAB

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF SY-SUBRC EQ 0.

*message i001 with p_file .

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

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

ENDIF.

ENDFORM. "UPLOAD

&----


*& Form UPLOAD_TEXT

&----


text

-


FORM UPLOAD_TEXT.

LOOP AT ITAB.

ITAB1-MATNR = ITAB-MATNR.

CLEAR: TOTLEN,N, START.

TOTLEN = STRLEN( ITAB-TEXT ).

N = TOTLEN / LEN.

N = N + 1.

DO N TIMES.

ITAB1-TEXT = ITAB-TEXT+START(LEN).

ITAB1-SEQU = SY-INDEX.

START = START + LEN.

APPEND ITAB1.

ENDDO.

ENDLOOP.

DELETE ITAB1 WHERE TEXT IS INITIAL.

SORT ITAB1 BY MATNR SEQU.

LOOP AT ITAB1.

DT_LINES-TDFORMAT = '*'.

DT_LINES-TDLINE = ITAB1-TEXT.

APPEND DT_LINES.

AT END OF MATNR.

DL_LAN = SY-LANGU.

WRITE : / itab-MATNR.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = ITAB1-MATNR

IMPORTING

OUTPUT = ITAB1-MATNR.

MOVE ITAB1-MATNR TO DL_NAME.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

FID = C_BEST

FLANGUAGE = DL_LAN

FNAME = DL_NAME

FOBJECT = C_MATERIAL

SAVE_DIRECT = 'X'

FFORMAT = '*'

TABLES

FLINES = DT_LINES

EXCEPTIONS

NO_INIT = 1

NO_SAVE = 2

OTHERS = 3.

IF SY-SUBRC 0.

WRITE:/10 'Long Text Creation failed for Material No', ITAB1-MATNR.

ELSE.

WRITE:/10 'Long Text Created Successfully for Material No', ITAB1-MATNR.

ENDIF.

REFRESH DT_LINES.

ENDAT.

ENDLOOP.

regards

siva

Edited by: siva prasad on Jan 12, 2008 11:01 AM

7 REPLIES 7

arpit_shah
Contributor
0 Kudos
361

Hi,

Try to use LSMW.

for uploading sales text.

Regards,

Arpit

0 Kudos
361

Hi Arpit,

When i do recording in LSMW, i can upload the text and save it. But the recording code will not generate the field and details like other data (materia, name, acct assgnment group etc) for this field.

Even tried with BDC... Same problem...!!!!

Regards

Pavan

Edited by: Pavan Sanganal on Jan 11, 2008 7:12 PM

Former Member
0 Kudos
361

Hi Pavan,

Have you called function module COMMIT_TEXT after the SAVE_TEXT call.

Try that and check.

Regards,

Aditya

Former Member
0 Kudos
361

Please keep in mind that the Sales Text is Sales org Specific. What Sales Org Levels did you Load and what Sales Org are you trying to view in MM03?

0 Kudos
361

I do agree that the Sales text will be Sales Organization specific.

Now i would like to add sales text for existing materials.

If i do recording, i can enter the sales text and save it properly. But when i come out of Recording, the field pertaining to Sales text is invisible in the record code.

Hence thought of uploading the Sales Text using save_text function module.

But if i upload the sales text using save_text, the same text is not visible in mm02/mm03 screens.

My client wish to see the sales text of each material in mm02/mm03 screen.

In such scenarios, how to handle the sales text upload activity....?????

Regards

Pavan

Edited by: Pavan Sanganal on Jan 12, 2008 2:46 PM

0 Kudos
361

Hi pavan,

Just check whether ur saving the text with correct parameters or not.

Text Name: Concatenation of Material(18char), Sales Org(4), Distribution channel(2).

Language : EN

Text ID: 0001

Text Object: MVKE.

Otherwsie use the below code to update through BDC.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4040'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=LTEX'.

L_LEN = STRLEN( WA_FILE-STEXT ).

IF L_LEN < 69.

PERFORM BDC_DYNPRO USING 'SAPLSTXX' '1100'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=TXVB'.

PERFORM BDC_FIELD USING 'RSTXT-TXLINE(02)' WA_FILE-STEXT+0(69). " 'First Line'.

ELSE.

PERFORM BDC_DYNPRO USING 'SAPLSTXX' '1100'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=EDNP'.

PERFORM BDC_FIELD USING 'RSTXT-TXLINE(02)' WA_FILE-STEXT+0(69). " 'First Line'.

ENDIF.

IF L_LEN > 139.

PERFORM BDC_DYNPRO USING 'SAPLSTXX' '1100'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=EDNP'.

PERFORM BDC_FIELD USING 'RSTXT-TXLINE(02)' WA_FILE-STEXT+0(69).

PERFORM BDC_FIELD USING 'RSTXT-TXLINE(03)' WA_FILE-STEXT+70(69).

ELSE.

PERFORM BDC_DYNPRO USING 'SAPLSTXX' '1100'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=TXVB'.

PERFORM BDC_FIELD USING 'RSTXT-TXLINE(02)' WA_FILE-STEXT+0(69).

PERFORM BDC_FIELD USING 'RSTXT-TXLINE(03)' WA_FILE-STEXT+70(69).

ENDIF.

IF L_LEN > 139.

PERFORM BDC_DYNPRO USING 'SAPLSTXX' '1100'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=TXVB'.

PERFORM BDC_FIELD USING 'RSTXT-TXLINE(02)' WA_FILE-STEXT+0(69).

PERFORM BDC_FIELD USING 'RSTXT-TXLINE(03)' WA_FILE-STEXT+70(69).

PERFORM BDC_FIELD USING 'RSTXT-TXLINE(04)' WA_FILE-STEXT+140(69).

ENDIF.

PERFORM BDC_DYNPRO USING 'SAPLSTXX' '1100'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=TXVB'.

PERFORM BDC_DYNPRO USING 'SAPLSTXX' '1100'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=TXBA'.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4040'.

PERFORM BDC_FIELD USING 'BDC_OKCODE' '=SP12'.

Rewards points if helpful.

Regards,

Srinivas Ch

Former Member
0 Kudos
362

hi,

use the function module create_text.

after uploading through this function module u can view the text in mm03.

check the sample code

check this code for create_text, similarly use function read_text to extract long text,

in ur transaction in longtext screen go to script editor and go for go to header option there u can get details like text id,object id,name etc u pass this in function module.

check this sample code for creating long text for po

DATA: BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR, " MATERIAL NUMBER

TEXT(5000) TYPE C, " Long Text

END OF ITAB.

DATA: BEGIN OF ITAB1 OCCURS 0,

MATNR LIKE MARA-MATNR, " Material No

SEQU TYPE I, " Text Sequence

TEXT(5000) TYPE C, " Long Text

END OF ITAB1.

DATA:BEGIN OF DT_LINES OCCURS 0.

INCLUDE STRUCTURE TLINE. " Long Text

DATA:END OF DT_LINES.

DATA : P_FILE1 TYPE STRING.

DATA : DL_NAME TYPE THEAD-TDNAME, " Object Name(material no)

DL_LAN TYPE THEAD-TDSPRAS. " Language

CONSTANTS:C_BEST TYPE THEAD-TDID VALUE 'BEST',

C_MATERIAL TYPE THEAD-TDOBJECT VALUE 'MATERIAL'. " OBJECT

DATA: START TYPE I,

LEN TYPE I VALUE 92,

TOTLEN TYPE I,

N TYPE I.

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

PARAMETERS P_FILE LIKE RLGRAP-FILENAME."input file

SELECTION-SCREEN : END OF BLOCK B1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM FETCH_FILE USING P_FILE.

&----


*& Form fetch_file

&----


text

-


-->P_FILE text

-


FORM FETCH_FILE USING P_FILE.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

IMPORTING

FILE_NAME = P_FILE.

ENDFORM. "fetch_file

START-OF-SELECTION.

PERFORM UPLOAD USING P_FILE. " *To Upload Flat file

PERFORM UPLOAD_TEXT.

&----


*& Form UPLOAD

&----


text

-


-->P_FILE text

-


FORM UPLOAD USING P_FILE.

P_FILE1 = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = P_FILE1

FILETYPE = 'DAT'

HAS_FIELD_SEPARATOR = ' '

HEADER_LENGTH = 0

READ_BY_LINE = 'X'

DAT_MODE = ' '

CODEPAGE = ' '

IGNORE_CERR = ABAP_TRUE

REPLACEMENT = '#'

CHECK_BOM = ' '

VIRUS_SCAN_PROFILE =

NO_AUTH_CHECK = ' '

IMPORTING

FILELENGTH =

HEADER =

TABLES

DATA_TAB = ITAB

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF SY-SUBRC EQ 0.

*message i001 with p_file .

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

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

ENDIF.

ENDFORM. "UPLOAD

&----


*& Form UPLOAD_TEXT

&----


text

-


FORM UPLOAD_TEXT.

LOOP AT ITAB.

ITAB1-MATNR = ITAB-MATNR.

CLEAR: TOTLEN,N, START.

TOTLEN = STRLEN( ITAB-TEXT ).

N = TOTLEN / LEN.

N = N + 1.

DO N TIMES.

ITAB1-TEXT = ITAB-TEXT+START(LEN).

ITAB1-SEQU = SY-INDEX.

START = START + LEN.

APPEND ITAB1.

ENDDO.

ENDLOOP.

DELETE ITAB1 WHERE TEXT IS INITIAL.

SORT ITAB1 BY MATNR SEQU.

LOOP AT ITAB1.

DT_LINES-TDFORMAT = '*'.

DT_LINES-TDLINE = ITAB1-TEXT.

APPEND DT_LINES.

AT END OF MATNR.

DL_LAN = SY-LANGU.

WRITE : / itab-MATNR.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = ITAB1-MATNR

IMPORTING

OUTPUT = ITAB1-MATNR.

MOVE ITAB1-MATNR TO DL_NAME.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

FID = C_BEST

FLANGUAGE = DL_LAN

FNAME = DL_NAME

FOBJECT = C_MATERIAL

SAVE_DIRECT = 'X'

FFORMAT = '*'

TABLES

FLINES = DT_LINES

EXCEPTIONS

NO_INIT = 1

NO_SAVE = 2

OTHERS = 3.

IF SY-SUBRC 0.

WRITE:/10 'Long Text Creation failed for Material No', ITAB1-MATNR.

ELSE.

WRITE:/10 'Long Text Created Successfully for Material No', ITAB1-MATNR.

ENDIF.

REFRESH DT_LINES.

ENDAT.

ENDLOOP.

regards

siva

Edited by: siva prasad on Jan 12, 2008 11:01 AM