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

FM :READ_TEXT

Former Member
0 Likes
1,712

Hi all,

Wht values should i pass to get this fmodule working ie wht import parameters should i pass.

Thanks in advance,

Alex.

Hi all,

Wht values should i pass to get this fmodule working ie wht import parameters should i pass.

Thanks in advance,

Alex.

7 REPLIES 7
Read only

Former Member
0 Likes
1,332

hi,

if the field length in the data dictioray is unlimited .

you need to create text object and link this object

with key fields of the table and reading this text and storing this text you need to use SAVE_TEXT and READ_TEXT fm's.

<u>chk the sample code below.</u>

A. create a text object using SE75 transaction .

B. Use FM : SAVE_TEXT to save this data with text object id.(data will be stored into STXH table).

C. Use READ_TEXT to retrive data.

sample code :

DATA: ws_thead LIKE thead,
i_tline LIKE TABLE OF tline WITH HEADER LINE.
data : x_matnr like mara-matnr.

c_mara(4) type c value 'MARA',
c_zid(4) type c value 'Z001'.


MOVE : x_matnr TO ws_thead-tdname, <-moving MATNR to store data 
c_mara TO ws_thead-tdobject,
sy-langu TO ws_thead-tdspras,
c_zid TO ws_thead-tdid.

CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = ws_thead
savemode_direct = 'X'
TABLES
lines = i_tline
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.

IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

DATA: lws_id LIKE thead-tdid,
lws_name LIKE thead-tdname,
lws_object LIKE thead-tdobject.

lws_id = c_zid.
lws_name = x_matnr. <- reading data using key field(MATNR) 
lws_object = c_mara.


CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = lws_id
language = sy-langu
name = lws_name
object = lws_object
TABLES
lines = li_tline
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

Regards

Reshma

Read only

Former Member
0 Likes
1,332

ID - Text ID of the Text

Language - Language in which text is maintained

Name - Name of the Object

Object - Object name for which you are reading the text.

All this information you can get in the text of that particular document.

For Ex. Go To change mode of Sales order. Select any text and double click on text editor. You will divert to text editor. go to menu GOTO and select Header. All required information for the READ_TEXT FM you will get here.

Read only

Former Member
0 Likes
1,332

Lokale Schnittstelle:

*" IMPORTING

*" VALUE(CLIENT) LIKE SY-MANDT DEFAULT SY-MANDT

*" VALUE(ID) LIKE THEAD-TDID

*" VALUE(LANGUAGE) LIKE THEAD-TDSPRAS

*" VALUE(NAME) LIKE THEAD-TDNAME

*" VALUE(OBJECT) LIKE THEAD-TDOBJECT

*" VALUE(ARCHIVE_HANDLE) LIKE SY-TABIX DEFAULT 0

*" VALUE(LOCAL_CAT) DEFAULT SPACE

*" EXPORTING

*" VALUE(HEADER) LIKE THEAD STRUCTURE THEAD

*" TABLES

*" LINES STRUCTURE TLINE

*" EXCEPTIONS

*" ID

*" LANGUAGE

*" NAME

*" NOT_FOUND

*" OBJECT

*" REFERENCE_CHECK

*" WRONG_ACCESS_TO_ARCHIVE

<b> Rewrads pouint if useful................</b>

Regards...

Abhay Singh.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,332

refer this program .....will be helpful

REPORT zpm308_notifictn_list_daily_wk

NO STANDARD PAGE HEADING

MESSAGE-ID zpm.

TYPE-POOLS: slis.

tables: qmel,viqmel.

*----


Normal Variables and ALV Declarations

DATA: diff TYPE p DECIMALS 2, wkline(55) type c.

DATA: alvfld TYPE slis_fieldcat_alv,

fieldcat TYPE slis_t_fieldcat_alv,

v_events TYPE slis_t_event WITH HEADER LINE,

wk_events LIKE LINE OF v_events,

it_list_comments TYPE slis_t_listheader,

wk_layout TYPE slis_layout_alv,

i_sort type slis_t_sortinfo_alv,

w_sort like line of i_sort,

wk_list_comments LIKE LINE OF it_list_comments.

CONSTANTS: c_formname_top_of_page TYPE slis_formname

VALUE 'F_TOP_OF_PAGE'.

*----


Internal Tables used

DATA BEGIN OF it_thline OCCURS 1.

INCLUDE STRUCTURE tline.

DATA END OF it_thline.

DATA : BEGIN OF st_qmel,

qmnum LIKE qmel-qmnum, "notification number

qmart LIKE qmel-qmart, "notification type

qmdat LIKE qmel-qmdat, "notification date

qmtxt LIKE qmel-qmtxt, "short text

strmn LIKE qmel-strmn, "required start date

strur LIKE qmel-strur, "required start time

ltrmn LIKE qmel-ltrmn, "required end date

ltrur LIKE qmel-ltrur, "required end date-time

ernam LIKE viqmel-qmnam, "name of person reporting notification

kzmla LIKE qmel-kzmla, "primary langauge indicator for test segm

iwerk LIKE viqmel-iwerk, "plant for material

fetxt LIKE qmfe-fetxt, "notification item short text

fecod LIKE qmfe-fecod, "problem

fegrp LIKE qmfe-fegrp, "code group - problem

equnr LIKE viqmel-equnr, "equipment number

ingrp LIKE viqmel-ingrp, "planner group for customer service &PM

eqktx LIKE eqkt-eqktx, "description of technical object

spras LIKE eqkt-spras, "langauge key

tplnr LIKE viqmel-tplnr, "functional location

pltxt LIKE iflotx-pltxt, "description of functional location

diff LIKE qmel-strur, "duration

wk_line(70),

END OF st_qmel.

data: it_qmel like sorted table of st_qmel with unique key qmnum with

header line.

data: vqmel like table of it_qmel with header line.

DATA: thead-tdobject LIKE thead-tdobject,

thead-tdspras LIKE thead-tdspras,

thead-tdname LIKE thead-tdname,

thead-tdid LIKE thead-tdid.

SELECTION-SCREEN BEGIN OF BLOCK notification WITH FRAME TITLE text-023.

PARAMETERS: plant LIKE t001w-werks OBLIGATORY.

SELECT-OPTIONS: so_qmart FOR qmel-qmart,

so_qmnum FOR qmel-qmnum,

so_qmdat FOR qmel-qmdat OBLIGATORY,

so_ingrp FOR viqmel-ingrp,

so_equnr FOR viqmel-equnr,

so_tplnr FOR viqmel-tplnr.

PARAMETERS: name LIKE qmel-qmnam.

SELECTION-SCREEN END OF BLOCK notification.

initialization.

diff = 0.

START-OF-SELECTION.

PERFORM get-data.

PERFORM display-data.

end-of-selection.

PERFORM f_event_build.

**MB Kesav

perform f_layout_build.

**MB Ends

PERFORM display_alv.

**************************************************************

FORM get-data.

****MB Kesav ( for fetching all the data from viqmel...

****Modified the earlier fetch from qmel via viqmel)

IF name = ' '.

SELECT viqmelqmnum viqmelqmart viqmelqmdat viqmelqmtxt

viqmelstrmn viqmelstrur viqmelltrmn viqmelltrur

viqmelernam viqmelkzmla viqmelequnr viqmelingrp viqmel~iwerk

viqmelqmtxt viqmelqmart viqmeltplnr eqkteqktx iflotx~pltxt

FROM viqmel inner join eqkt on viqmelequnr = eqktequnr inner join

iflotx on viqmeltplnr = iflotxtplnr

INTO CORRESPONDING FIELDS OF TABLE it_qmel

WHERE viqmel~qmnum IN so_qmnum

AND viqmel~qmdat IN so_qmdat

AND viqmel~qmart IN so_qmart

AND ( viqmelqmart EQ 'GG' OR viqmelqmart EQ 'HD' OR viqmel~qmart EQ

'M1' OR viqmelqmart EQ 'M2' OR viqmelqmart EQ 'M3' OR

viqmelqmart EQ 'M4' OR viqmelqmart EQ 'TB' )

AND viqmel~ingrp IN so_ingrp

AND viqmel~equnr IN so_equnr

AND viqmel~tplnr IN so_tplnr.

ELSE.

SELECT viqmelqmnum viqmelqmart viqmelqmdat viqmelqmtxt

viqmelstrmn viqmelstrur viqmelltrmn viqmelltrur

viqmelernam viqmelkzmla viqmelequnr viqmelingrp viqmel~iwerk

viqmelqmtxt viqmelqmart viqmeltplnr eqkteqktx iflotx~pltxt

FROM viqmel inner join eqkt on viqmelequnr = eqktequnr inner join

iflotx on viqmeltplnr = iflotxtplnr

INTO CORRESPONDING FIELDS OF TABLE it_qmel

WHERE viqmel~qmnum IN so_qmnum

AND viqmel~qmdat IN so_qmdat

AND viqmel~qmart IN so_qmart

AND ( viqmelqmart EQ 'GG' OR viqmelqmart EQ 'HD' OR viqmel~qmart EQ

'M1' OR viqmelqmart EQ 'M2' OR viqmelqmart EQ 'M3' OR

viqmelqmart EQ 'M4' OR viqmelqmart EQ 'TB' )

AND viqmel~ingrp IN so_ingrp

AND viqmel~equnr IN so_equnr

AND viqmel~tplnr IN so_tplnr

AND viqmel~ernam EQ name.

ENDIF.

if sy-subrc <> 0.

message i036.

stop.

endif.

****MB Ends

LOOP AT it_qmel.

it_qmel-diff = ( it_qmel-strur ) - ( it_qmel-ltrur ).

MODIFY it_qmel .

ENDLOOP.

ENDFORM. " get-data

********************************************************

FORM display-data.

CLEAR it_qmel.

LOOP AT it_qmel.

REFRESH IT_THLINE.

thead-tdobject = 'QMEL'.

thead-tdspras = sy-langu.

thead-tdname = it_qmel-qmnum.

thead-tdid = 'LTXT'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

id = thead-tdid

language = thead-tdspras

name = thead-tdname

object = thead-tdobject

TABLES

lines = it_thline

EXCEPTIONS

id = 1

language = 2

name = 3

not_found = 4.

****MB Kesav ( for printing the header text against a notification No.)

loop at it_thline.

move: it_qmel-qmnum to vqmel-qmnum,it_thline-tdline to vqmel-wk_line.

append vqmel. clear:vqmel.

endloop.

clear: it_thline,it_qmel.

ENDLOOP.

sort vqmel by qmnum.

loop at vqmel.

wkline = vqmel-wk_line.

at new qmnum.

read table it_qmel with table key qmnum = vqmel-qmnum.

if sy-subrc = 0.

move: it_qmel-qmart to vqmel-qmart,it_qmel-qmdat to vqmel-qmdat,

it_qmel-qmtxt to vqmel-qmtxt,it_qmel-strmn to vqmel-strmn,

it_qmel-strur to vqmel-strur,it_qmel-ltrmn to vqmel-ltrmn,

it_qmel-ltrur to vqmel-ltrur,it_qmel-ernam to vqmel-ernam,

it_qmel-kzmla to vqmel-kzmla,it_qmel-iwerk to vqmel-iwerk,

it_qmel-fetxt to vqmel-fetxt,it_qmel-fecod to vqmel-fecod,

it_qmel-fegrp to vqmel-fegrp,it_qmel-equnr to vqmel-equnr,

it_qmel-ingrp to vqmel-ingrp,it_qmel-eqktx to vqmel-eqktx,

it_qmel-spras to vqmel-spras,it_qmel-tplnr to vqmel-tplnr,

it_qmel-pltxt to vqmel-pltxt,it_qmel-diff to vqmel-diff,

wkline to vqmel-wk_line.

modify vqmel.

delete it_qmel where qmnum = it_qmel-qmnum.

endif.

clear: vqmel,it_qmel.

endat.

endloop.

loop at it_qmel.

move-corresponding it_qmel to vqmel.

append vqmel.clear: vqmel,it_qmel.

endloop.

****MB Ends

ENDFORM. " display-data

*******************************************************************

FORM display_alv.

alvfld-col_pos = 1.

alvfld-fieldname = 'QMNUM'.

alvfld-fix_column = 'X'.

alvfld-seltext_m = 'NOTIF.NO'.

alvfld-outputlen = '17'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 2.

alvfld-fieldname = 'QMART'.

alvfld-seltext_m = 'NOTIF.TYPE'.

alvfld-outputlen = '17'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 3.

alvfld-fieldname = 'INGRP'.

alvfld-seltext_m = 'PLANNER GRP'.

alvfld-outputlen = '25'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 4.

alvfld-fieldname = 'QMDAT'.

alvfld-seltext_m = 'DATE'.

alvfld-outputlen = '11'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 5.

alvfld-fieldname = 'EQUNR'.

alvfld-seltext_m = 'EQPMNT NO'.

alvfld-outputlen = '20'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 6.

alvfld-fieldname = 'EQKTX'.

alvfld-seltext_m = 'M/C NAME'.

alvfld-outputlen = '30'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 7.

alvfld-fieldname = 'TPLNR'.

alvfld-seltext_m = 'FUNCT LOC'.

alvfld-outputlen = '21'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 8.

alvfld-fieldname = 'PLTXT'.

alvfld-seltext_m = 'FUN LOC DESC'.

alvfld-outputlen = '25'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 9.

alvfld-fieldname = 'QMTXT'.

alvfld-seltext_m = 'PROBLEM'.

alvfld-outputlen = '23'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 10.

alvfld-fieldname = 'STRMN'.

alvfld-seltext_m = 'START DATE'.

alvfld-outputlen = '11'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 11.

alvfld-fieldname = 'STRUR'.

alvfld-no_zero = 'X'.

alvfld-seltext_m = 'START TIME'.

alvfld-outputlen = '11'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 12.

alvfld-fieldname = 'LTRMN'.

alvfld-seltext_m = 'END DATE'.

alvfld-outputlen = '11'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 13.

alvfld-fieldname = 'LTRUR'.

alvfld-no_zero = 'X'.

alvfld-seltext_m = 'END TIME'.

alvfld-outputlen = '11'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 14.

alvfld-fieldname = 'DIFF'.

alvfld-no_zero = 'X'.

alvfld-seltext_m = 'DURATION'.

alvfld-outputlen = '9'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 15.

alvfld-fieldname = 'ERNAM'.

alvfld-seltext_m = 'CREATED BY'.

alvfld-outputlen = '13'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

alvfld-col_pos = 16.

alvfld-fieldname = 'WK_LINE'.

alvfld-seltext_m = 'PROBLEM LONG TEXT'.

alvfld-fix_column = 'X'.

alvfld-outputlen = '70'.

APPEND alvfld TO fieldcat.

CLEAR alvfld.

w_sort-spos = 1.

w_sort-fieldname = 'QMNUM'.

w_sort-up = 'X'.

APPEND w_sort TO i_sort.

CLEAR w_sort.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

i_background_id = 'ALV_BACKGROUND'

it_fieldcat = fieldcat[]

it_events = v_events[]

is_layout = wk_layout

it_sort = i_sort

TABLES

t_outtab = vqmel

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDFORM. "DISPLAY_ALV

*********************************************************

FORM f_top_of_page.

DATA: wk_fmdate(10),wk_todate(10).

CLEAR: it_list_comments[].

DATA: wk_docu(10) TYPE c,wk_lines(5) TYPE c,lines(5) TYPE c.

CLEAR: it_list_comments[].

wk_list_comments-typ = 'H'. "H=Header, S=Selection, A=Action

wk_list_comments-key = ''.

wk_list_comments-info =

'BREAKDOWN HISTORY REPORT'.

APPEND wk_list_comments TO it_list_comments.

CLEAR wk_list_comments.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

i_logo = 'ENJOYSAP_LOGO'

it_list_commentary = it_list_comments.

ENDFORM. "F_TOP_OF_PAGE

*********************************************************

FORM f_event_build .

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = v_events[].

READ TABLE v_events WITH KEY name = slis_ev_top_of_page

INTO wk_events.

IF sy-subrc = 0.

MOVE c_formname_top_of_page TO wk_events-form.

MODIFY v_events FROM wk_events INDEX sy-tabix.

ENDIF.

ENDFORM. " F_EVENT_BUILD

********************************************************

form f_layout_build .

wk_layout-zebra = 'X'.

wk_layout-colwidth_optimize = 'X'.

wk_layout-detail_initial_lines = 'X'.

endform. " f_layout_build

Read only

Former Member
0 Likes
1,332

go to se37. type in the FM name and have a look at the import parameters.

for the documentation on any FM go to www.se37.com

regards,

srinivas

<b>*reward for useful answers*</b>

Read only

Former Member
0 Likes
1,332

Alex,

You can read long text by using this FM,

u can get

*. Header level long text and

*. Item level long text with this FM

And the type of long text depends on the values u pass to the FM.

Suppose, U want to read long text of sales Order,

I am explaining you step by step.

Goto VA02

Give a Sales order number, and enter.

Now follow the menu path : Goto - > Header - > Texts

You vl get long texts that, can be mentioned for that slaes order (remember these are header level long texts)

Now just select any 'Text Type' and Press Details icon.

You are now directed to Text Editor,

Now follow the menu path : Goto -> Header.

Now u will get all the details that has to be passed to this FM.

ID = Text ID

LANGUAGE = Sy-Langu

NAME = Sales Doc Number

OBJECT = Text Object

These are the inputs u have to pass to that FM.

When comes to Item level Long texts,

Follow the menu path to get item level text objects :

Goto - > Item - > Texts.

Now the same procedure as mentioned above.

I hope ur issues wil have an answer with this.

Regards,

Sujatha.

Read only

Former Member
0 Likes
1,332

hi,

FOUR Parameters are Mandatory

OBJECT ,NAME ,ID,LANGUAGE.

Below is the sample code.

REPORT ZTEST123456.

parameter : P_VBELN LIKE VBRK-VBELN,

P_POSNR LIKE VBRP-POSNR.

DATA :w_matno TYPE vbrk-vbeln,

w_itmno TYPE vbrp-posnr,

w_matdesc TYPE string.

DATA: BEGIN OF TABLE_HEADER. " define a local table header

INCLUDE STRUCTURE THEAD. " using SAPSCRIPT structure

DATA: END OF TABLE_HEADER.

DATA: BEGIN OF TABLE_LINES OCCURS 0. " define a local text lines

INCLUDE STRUCTURE TLINE. " using SAPSCRIPT structure

DATA: END OF TABLE_LINES.

DATA: TEXT_OBJECT LIKE THEAD-TDOBJECT VALUE 'VBBP',

TEXT_NAME LIKE THEAD-TDNAME,

TEXT_ID LIKE THEAD-TDID VALUE '0007',

PRINT_LANGUAGE LIKE THEAD-TDSPRAS.

START-OF-SELECTION.

SELECT SINGLE vbeln

posnr

FROM vbrp

INTO (w_matno,w_itmno)

WHERE vbeln EQ p_vbeln

AND posnr = p_posnr.

IF sy-subrc EQ 0.

CONCATENATE w_matno w_itmno INTO TEXT_NAME .

ENDIF.

PRINT_LANGUAGE = 'EN'.

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = TEXT_ID

LANGUAGE = PRINT_LANGUAGE

NAME = TEXT_NAME

OBJECT = TEXT_OBJECT

IMPORTING

HEADER = TABLE_HEADER

TABLES

LINES = TABLE_LINES

EXCEPTIONS

ID = 01

LANGUAGE = 02

NAME = 03

NOT_FOUND = 04

OBJECT = 05

REFERENCE_CHECK = 06.

LOOP AT TABLE_LINES.

WRITE 😕 TABLE_LINES-TDLINE .

ENDLOOP.