2014 Jan 16 4:40 AM
I am using Function module SAVE_TEXT to update the 'short text' field in Basic data2 tab in BATCH . t code (msc2n)
I checked the below link.
http://scn.sap.com/thread/3145197
I have used the below code:
REPORT ZTESTM2.
DATA: l_tdname LIKE thead-tdname,
li_tdline TYPE STANDARD TABLE OF tline,
ls_tdline TYPE tline,
ls_header LIKE thead.
DATA : p_kztxt LIKE dfbatch-kztxt VALUE 'Test by me'.
CONSTANTS: cl_tdobj LIKE thead-tdobject VALUE 'CHARGE',
cl_tdspr LIKE thead-tdspras VALUE 'E',
cl_tdid LIKE thead-tdid VALUE 'VERM'.
DATA: l_matnr type mchb-matnr,
l_werks type mchb-werks,
l_charg type mchb-charg.
select single matnr werks charg from mchb into (l_matnr,l_werks,l_charg)
where matnr = '00004'.
IF SY-SUBRC EQ 0.
CONCATENATE l_matnr l_werks l_charg INTO l_tdname.
ENDIF.
*l_tdname = '00004 0AG19459'.
ls_header-tdobject = cl_tdobj.
ls_header-tdname = l_tdname.
ls_header-mandt = sy-mandt.
ls_header-tdid = cl_tdid.
ls_header-tdspras = cl_tdspr.
*--- Text Lines
REFRESH li_tdline.
ls_tdline-TDFORMAT = '*'.
ls_tdline-tdline = p_kztxt.
APPEND ls_tdline TO li_tdline.
*=========================================*
* Save Text
*=========================================*
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = ls_header
insert = ''
savemode_direct = ''
TABLES
lines = li_tdline
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc EQ 0.
ENDIF.
But its not updating the Short text. even though FM 'SAVE_TEXT' is returing sy-subrc = 0.
Any idea what may be wrong?
2014 Jan 16 5:19 AM
Hi Manjunath,
pass 'X' to insert & savemode_direct in FM CALL FUNCTION 'SAVE_TEXT'.
Thanks,
Anil
2014 Jan 16 4:55 AM
Hi try to pass header....sample code
DATA wa_thead TYPE THEAD.
wa_thead-mandt = sy-mandt.
wa_thead-tdobject = 'EKKO'.
wa_thead-tdid = 'F01'.
wa_thead-tdname = P_PONO.
wa_thead-tdspras = sy-langu.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
CLIENT = SY-MANDT
header = WA_Thead
INSERT = 'X'
SAVEMODE_DIRECT = 'X'
* OWNER_SPECIFIED = ' '
* LOCAL_CAT = ' '
* IMPORTING
* FUNCTION =
* NEWHEADER =
tables
lines = LINES
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
OBJECT = 4
OTHERS = 5
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
Thanks
Ram.
2014 Jan 16 5:06 AM
2014 Jan 16 5:19 AM
Hi Manjunath,
pass 'X' to insert & savemode_direct in FM CALL FUNCTION 'SAVE_TEXT'.
Thanks,
Anil
2014 Jan 16 5:28 AM
Hi Anil,
i tried this its not working.
I debugged MSC2N, it's not passing to TDNAME as below
if material = xyz(3characters)
TDNAME = xyz(15spaces)+4spaces(for plant)+Batch no.
Meaning to say its adding spaces to the right of material and 4 spaces for material.
Dont know if this is something to do with SAP system.
2014 Jan 16 5:35 AM
Hi Manju,
Please use the material for conversion exit ( it should be 18 chars)
Text name : Material + plant + batch
text ID : VERM
Text Object: CHARGE
can you try!
Please check the piece of code from standard Msc2n! how to update the text:
Include : LCHRGI02
PERFORM create_new_text.
txhead_str-tdspras = dfbatch-spras.
CALL FUNCTION 'INIT_TEXT'
EXPORTING
id = txhead_str-tdid
language = txhead_str-tdspras
name = txhead_str-tdname
object = txhead_str-tdobject
IMPORTING
header = thead
TABLES
lines = txt_lines
EXCEPTIONS
OTHERS = 99.
IF NOT sy-subrc IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno "#EC *
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR txt_lines.
txt_inlines-tdformat = '*'.
txt_inlines-tdline = dfbatch-kztxt.
APPEND txt_inlines TO txt_inlines.
APPEND txt_inlines TO txt_lines.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = thead
IMPORTING
function = txt_funct
newheader = thead
TABLES
lines = txt_lines
EXCEPTIONS
OTHERS = 99.