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

Probelm with SAVE_TEXT

Former Member
0 Likes
1,062

Hi,

this is code i am using the to save the address into the text id Z007.

it is working fine in Va02 but it is not working with VA01.

it is dispalying onlt last five lines of the table .( table has got 11 lines)

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

client = sy-mandt

header = l_ithead( i am passing object name and obj id and vbeln and posnr into tdname and language)

insert = space

savemode_direct = ' '

TABLES

lines = li_tline1( internal table containing addresss)

EXCEPTIONS

id = 1

language = 2

name = 3

object = 4

OTHERS = 5.

IF sy-subrc <> lc_null.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

  • / Use the FM COMMIT_TEXT to commit the details into the database /

CALL FUNCTION 'COMMIT_TEXT'

EXPORTING

object = VBBP

id = Z007

language = sy-langu

name = lw_ithead-tdname(vbeln na dposnr)

savemode_direct = lc_true.

ENDIF.

Please can any one help in getting the right code for SAVE_TEXT so that it should work for VA01.

regards

paveee...

Hi,

this is code i am using the to save the address into the text id Z007.

it is working fine in Va02 but it is not working with VA01.

it is dispalying onlt last five lines of the table .( table has got 11 lines)

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

client = sy-mandt

header = l_ithead( i am passing object name and obj id and vbeln and posnr into tdname and language)

insert = space

savemode_direct = ' '

TABLES

lines = li_tline1( internal table containing addresss)

EXCEPTIONS

id = 1

language = 2

name = 3

object = 4

OTHERS = 5.

IF sy-subrc <> lc_null.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

  • / Use the FM COMMIT_TEXT to commit the details into the database /

CALL FUNCTION 'COMMIT_TEXT'

EXPORTING

object = VBBP

id = Z007

language = sy-langu

name = lw_ithead-tdname(vbeln na dposnr)

savemode_direct = lc_true.

ENDIF.

Please can any one help in getting the right code for SAVE_TEXT so that it should work for VA01.

regards

paveee...

6 REPLIES 6
Read only

Former Member
0 Likes
966

Hi,

Here is the simple example

report ZMPPC016

no standard page heading

line-size 120.

  • Constants

constants : c_r type c value 'R', " PLNTY Value

C_X TYPE C VALUE 'X', " Value for dynbegin.

c_tcode like tstc-tcode value 'CA22', " Transaction code

c_mode(1) type c value 'A', " BDC Mode

c_tdformat type tline-tdformat value '*',"Tag column

c_tdid type thead-tdid value 'PLPO', " Text ID

c_tdform type thead-tdform value 'SYSTEM'." Form name

  • Variables

data : v_date like sy-datum, " date

v_date1(4) type c,

v_date2(2) type c,

v_date3(2) type c,

TNAME LIKE THEAD-TDNAME,

v_mandt(3) type c,

v_matnr(18) type c,

flag type c.

  • Internal table for file

data : begin of t_file occurs 0,

matnr(18) type c, " Material Number

werks(4) type c, " Plant

vornr(4) type c, " Operation Number

tseq(3) type n, " Line number in the long text

text1(70) type c, " Long text

plnal(2) type n, " Group counter

end of t_file.

data : begin of t_text occurs 0,

matnr(18) type c, " Material Number

werks(4) type c, " Plant

plnal(2) type n, " Group counter

vornr(4) type c, " Operation Number

tseq(3) type n, " Line number in the long text

text1(70) type c, " Long text

end of t_text.

  • Internal table for MAPl

data : begin of t_mapl occurs 0,

plnnr like mapl-plnnr,

end of t_mapl.

  • Internal Table for PLAS and PLPO Table

data : begin of t_plpo occurs 0,

mandt like plpo-mandt,

plnty like plpo-plnty,

plnnr like plpo-plnnr,

plnkn like plpo-plnkn,

zaehl like plpo-zaehl,

end of t_plpo.

data t_long like tline occurs 0 with header line.

  • Work area for t_text Internal table

data : wa_text like t_text.

data: t_header like thead. " long text

  • Internal table for BDCDATA Structure

data : begin of itab_bdc_tab occurs 0.

include structure bdcdata.

data : end of itab_bdc_tab.

  • Selection-screen

selection-screen : begin of block blk with frame .

parameter : P_file like rlgrap-filename obligatory.

selection-screen : end of block blk.

initialization.

p_file = 'C:\My Documents\InputFile.txt'.

at selection-screen on value-request for p_file.

  • F4 value for file

perform file_get.

start-of-selection.

  • Get file data into Internal Table.

perform get_data.

sort t_text by matnr werks vornr plnal tseq.

  • Save the long text into CA22 Transaction

perform load_data.

top-of-page.

CALL FUNCTION 'Z_HEADER'

  • EXPORTING

  • FLEX_TEXT1 =

  • FLEX_TEXT2 =

  • FLEX_TEXT3 =

.

skip 1.

&----


*& Form file_get

&----


  • F4 Value for file

----


FORM file_get.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

DEF_PATH = 'C:\Temp\'

MASK = ',.,..'

MODE = 'O'

TITLE = 'Select File'(007)

IMPORTING

FILENAME = P_file

EXCEPTIONS

INV_WINSYS = 1

NO_BATCH = 2

SELECTION_CANCEL = 3

SELECTION_ERROR = 4

OTHERS = 5.

ENDFORM. " file_get

&----


*& Form get_data

&----


  • Get file data into Internal Table.

----


FORM get_data.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = p_file

FILETYPE = 'DAT'

TABLES

DATA_TAB = t_file

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

OTHERS = 10.

if sy-subrc eq 0.

sort t_file by matnr werks plnal vornr tseq.

delete t_file where matnr = ''.

loop at t_file.

  • Get the material number from tables ZMSMI_FERR_RAW,

  • ZMSMI_SNAP_RAW and ZMSMI_SIMP_RAW

perform get_matnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = t_file-vornr

IMPORTING

OUTPUT = t_file-vornr.

move : t_file-matnr to t_text-matnr,

t_file-werks to t_text-werks,

t_file-vornr to t_text-vornr,

t_file-tseq to t_text-tseq,

t_file-text1 to t_text-text1,

t_file-plnal to t_text-plnal.

append t_text.

clear t_text.

endloop.

else.

WRITE: / 'Error reading input file'.

stop.

endif.

ENDFORM. " get_data

&----


*& Form call_bdc

&----


  • BDC Script for CA22 Transaction

----


FORM call_bdc.

  • Screen 1010

perform bdc_screen using 'SAPLCPDI' '1010'.

perform bdc_field using 'BDC_OKCODE' '=VOUE'.

perform bdc_field using 'RC27M-MATNR' SPACE.

perform bdc_field using 'RC27M-WERKS' SPACE.

perform bdc_field using 'RC271-VBELN' SPACE.

perform bdc_field using 'RC271-POSNR' SPACE.

perform bdc_field using 'RC271-PLNNR' T_PLPO-PLNNR.

perform bdc_field using 'RC271-AENNR' SPACE.

clear : v_date,

v_date1,

v_date2,

v_date3.

v_date1 = sy-datum+0(4).

v_date2 = sy-datum+4(2).

v_date3 = sy-datum+6(2).

concatenate v_date2 v_date3 v_date1 into v_date.

perform bdc_field using 'RC271-STTAG' v_date .

perform bdc_field using 'RC271-REVLV' SPACE.

perform bdc_field using 'RC271-WERKS' SPACE.

perform bdc_field using 'RC271-PLNAL' WA_TEXT-PLNAL.

perform bdc_field using 'RC271-STATU' SPACE.

perform bdc_field using 'RC271-VAGRP' SPACE.

perform bdc_field using 'RC271-PROFIDNETZ' SPACE.

  • Screen 5400

perform bdc_screen using 'SAPLCPDI' '5400'.

perform bdc_field using 'BDC_OKCODE' '=OSEA'.

  • Screen 1010

perform bdc_screen using 'SAPLCP02' '1010'.

perform bdc_field using 'BDC_OKCODE' '=ENT1'.

perform bdc_field using 'RC27H-VORNR' WA_TEXT-VORNR.

  • Screen 5400

perform bdc_screen using 'SAPLCPDI' '5400'.

perform bdc_field using 'BDC_OKCODE' '=LTXT'.

perform bdc_field using 'RC27X-FLG_SEL(01)' C_X.

  • Screen 1100

perform bdc_screen using 'SAPLSTXX' '1100'.

perform bdc_field using 'BDC_OKCODE' '=XEIN'.

  • Screen 0999

perform bdc_screen using 'SAPLWB_CUSTOMIZING' '0999'.

perform bdc_field using 'BDC_OKCODE' '=CONT'.

PERFORM BDC_FIELD USING 'RSEUMOD-GRA_EDITOR' SPACE.

  • Screen 1100

perform bdc_screen using 'SAPLSTXX' '1100'.

perform bdc_field using 'BDC_CURSOR' 'RSTXT-TXPARGRAPH'.

perform bdc_field using 'BDC_OKCODE' '=TXBA'.

perform bdc_field using 'RSTXT-TXPARGRAPH(03)' '*'.

perform bdc_field using 'RSTXT-TXLINE(03)'

'*****'.

  • Screen 5400

perform bdc_screen using 'SAPLCPDI' '5400'.

perform bdc_field using 'BDC_OKCODE' '=BU'.

call transaction c_tcode

using itab_bdc_tab mode 'N'

update 'S'.

refresh itab_bdc_tab.

if sy-subrc eq 0 and sy-msgty ne 'E'.

v_mandt = t_plpo-mandt.

CONCATENATE v_mandt

t_plpo-plnty

t_plpo-plnnr

t_plpo-plnkn

t_plpo-zaehl into tname.

commit work.

CALL FUNCTION 'DELETE_TEXT'

EXPORTING

CLIENT = SY-MANDT

ID = c_tdid

LANGUAGE = 'E'

NAME = TNAME

OBJECT = 'ROUTING'

SAVEMODE_DIRECT = 'X'

  • TEXTMEMORY_ONLY = ' '

  • LOCAL_CAT = ' '

EXCEPTIONS

NOT_FOUND = 1

OTHERS = 2

.

if sy-subrc ne 0.

write:/3 wa_text-matnr,24 wa_text-werks,

30 t_mapl-plnnr,44 wa_text-plnal,48 wa_text-vornr,

60 ' -',

67 'Error Deleting Existing Long Text'.

endif.

else.

write:/3 wa_text-matnr,24 wa_text-werks,

30 t_mapl-plnnr,44 wa_text-plnal,48 wa_text-vornr,

60 ' -',

67 'Error Executing BDC'.

endif.

ENDFORM. " call_bdc

&----


*& Form bdc_screen

&----


  • BDC Script for Screen fields

----


  • -->P_PROG Program name

  • -->P_SCRN Screen Number

----


FORM bdc_screen USING p_prog

p_scrn.

clear itab_bdc_tab.

itab_bdc_tab-program = p_prog.

itab_bdc_tab-dynpro = p_scrn.

itab_bdc_tab-dynbegin = c_x.

append itab_bdc_tab.

ENDFORM. " bdc_screen

&----


*& Form bdc_field

&----


  • BDC Script for Screen fileds

----


  • -->P_NAM Field name

  • -->P_VAL Field value

----


FORM bdc_field USING p_nam

p_val.

clear itab_bdc_tab.

itab_bdc_tab-fnam = p_nam.

itab_bdc_tab-fval = p_val.

append itab_bdc_tab.

ENDFORM. " bdc_screen

&----


*& Form load_data

&----


  • Save the long text into CA22 Transaction

----


FORM load_data.

loop at t_text.

move t_text to wa_text.

at new vornr.

  • Read the data in MAPL Table

select single plnnr from mapl into t_mapl-plnnr

where matnr = wa_text-matnr

and werks = wa_text-werks

and plnty = c_r

and loekz = space.

if sy-subrc eq 0.

  • Read the data from PLAS and PLPO Table

select SINGLE a~mandt

a~plnty

a~plnnr

a~plnkn

a~zaehl into t_plpo

from plpo as a inner join plas as b on aplnty = bplnty

and aplnnr = bplnnr

and aplnkn = bplnkn

where b~plnty = c_r

and b~plnnr = t_mapl-plnnr

and b~plnal = wa_text-plnal

and b~loekz = space

and a~vornr = wa_text-vornr

and a~loekz = space.

if sy-subrc eq 0.

perform call_bdc.

else.

flag = 'X'.

write:/3 wa_text-matnr,24 wa_text-werks,

30 t_mapl-plnnr,44 wa_text-plnal,48 wa_text-vornr,

60 ' -',

67 'Matching routing group\Operation not found'.

continue.

endif.

else.

flag = 'X'.

write:/3 wa_text-matnr,24 wa_text-werks,

40 ' -',

45 'Material Does not Exists or Material',

82 'not Available in MAPL Table'.

continue.

endif.

endat.

if flag ne 'X'.

t_long-tdline = wa_text-text1.

t_long-tdformat = c_tdformat.

append t_long.

endif.

at end of vornr.

if flag ne 'X'.

v_mandt = t_plpo-mandt.

CONCATENATE v_mandt

t_plpo-plnty

t_plpo-plnnr

t_plpo-plnkn

t_plpo-zaehl into tname.

T_HEADer-TDOBJECT = 'ROUTING'.

t_HEADer-TDNAME = tname.

T_HEADer-TDID = c_tdid.

t_header-tdform = c_tdform.

T_HEADer-TDSPRAS = 'E'.

  • Save the text

CALL FUNCTION 'SAVE_TEXT'

EXPORTING

CLIENT = SY-MANDT

HEADER = t_header

SAVEMODE_DIRECT = 'X'

  • OWNER_SPECIFIED = ' '

  • LOCAL_CAT = ' '

  • IMPORTING

  • FUNCTION =

  • NEWHEADER =

TABLES

LINES = t_long

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

OBJECT = 4

OTHERS = 5

.

if sy-subrc eq 0.

CALL FUNCTION 'COMMIT_TEXT'

EXPORTING

OBJECT = t_header-TDOBJECT

NAME = t_header-TDNAME

ID = t_header-TDID

LANGUAGE = t_header-TDSPRAS.

write:/3 wa_text-matnr,24 wa_text-werks,

30 t_mapl-plnnr,44 wa_text-plnal,48 wa_text-vornr,

60 ' -',

67 'Long Text Loaded Successfully'.

else.

write:/3 wa_text-matnr,24 wa_text-werks,

30 t_mapl-plnnr,44 wa_text-plnal,48 wa_text-vornr,

60 ' -',

67 'Error Uploading Long Text'.

endif.

refresh t_long.

else.

write:/3 wa_text-matnr, 24 wa_text-werks,

45 'Long text not uploaded'.

clear flag.

endif.

endat.

endloop.

ENDFORM. " load_data

&----


*& Form get_matnr

&----


  • Get the material number from tables ZMSMI_FERR_RAW,

----


FORM get_matnr.

clear v_matnr.

case t_file-werks.

when '0101'.

select single cmatnr from zmsmi_simp_raw

into v_matnr where matnr = t_file-matnr.

  • if sy-subrc eq 0.

if not v_matnr is initial.

clear t_file-matnr.

t_file-matnr = v_matnr.

endif.

when '0103'.

select single cmatnr from zmsmi_ferr_raw

into v_matnr where matnr = t_file-matnr.

  • if sy-subrc eq 0.

if not v_matnr is initial.

clear t_file-matnr.

t_file-matnr = v_matnr.

endif.

when '0102' or '0110' or '0111' or '0112' or '0113'

or '0114' or '0115' or '0116' or '0117'.

select single cmatnr from zmsmi_snap_raw

into v_matnr where matnr = t_file-matnr.

  • if sy-subrc eq 0.

if not v_matnr is initial.

clear t_file-matnr.

t_file-matnr = v_matnr.

endif.

endcase.

ENDFORM. " get_matnr

Read only

0 Likes
966

Hi,

My requirement is to copy the installer address and ship to-party address into the text object .the code that i have pasted is working for VA02 perfectly.But in VA01 it is copying the last five lines only.

my question is there any configuration has been done for the Obejct id Z007VBBP to occupy the number of lines ? .if where i can override that numbers ?

please help me...

regards

pavee....

Read only

0 Likes
966

Hi Praveen,

For VA01 -> you should use CREATE_TEXT FM

For VA02 -> You should use SAVE_TEXT FM

Basically we never create text for Creation mode,always we create sales order ,then we create text based on order number

Thanks

Seshu

Read only

0 Likes
966

Hi seshu,

I tried with ur suggestion. But still i am getting the last five lines only....

I am not getting the correct result.

CALL FUNCTION 'CREATE_TEXT'

EXPORTING

fid = Z007

flanguage = sy-langu

fname = tdname( vebln and posnr number)

fobject = lc_tdobject

SAVE_DIRECT = 'X'

  • FFORMAT = '*'

tables

flines = l_tline1( table containing 11 lines).

  • EXCEPTIONS

  • NO_INIT = 1

  • NO_SAVE = 2

  • OTHERS = 3

kindly help me...

regards

pave.......

.

Read only

0 Likes
966

Hi Praveen,

Did you use l_tline1-tdformat = '*'.

See the example one :

loop at itab_d. <b>-> this will have number of lines</b>

t_line-tdformat = '*'. -> use this one

t_line-tdline = itab_d-str.

append t_line.

clear t_line.

endloop.

call function 'CREATE_TEXT'

exporting

fid = p_id

flanguage = language

fname = p_matnr

fobject = 'MATERIAL'

tables

flines = t_line

exceptions

no_init = 1

no_save = 2

others = 3.

if sy-subrc <> 0.

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

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

endif.

Thanks

Seshu

Read only

0 Likes
966

Hi seshu,

No.it is not working .

If i execute the same sales order with one more entry it is displaying the result.

But problem with only Va01 . is it copying only last five lines of table li_tline.

is there any configuration part which is affecting the number of lines to added into the text object.

please let me know how many lines of table lines that i can add into the corresponding object type.

please help me...its urgent

regards

pave.....