Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Read Text

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

In todays tutorial, I want to show you how to use the READ_TEXT function module to read

SAP long text. Every text in SAP has its own ID and NAME, by passing these parameters into
the READ_TEXT function, we can get all the text in the SAP long text object.
Heres how to do it, for example well be using long text from Sales Order.
1. Execute tcode VA02 and enter the Sales Order number.

2. Press enter to display the Sales Order data. Choose GoTo -> Header -> Texts

3. Double click the Header Note text and enter the long text in the text editor.

4. Click CTRL+S to save the Sales Order data.


5. Now that we need to get the ID, NAME and OBJECT of the text object to be used as
the input parameters of READ_TEXT function module, to get this information, you can execute
VA02 or VA03 and enter the Sales Order number again.
Choose GoTo -> Header -> Texts
6. Now double click inside the long text editor.

7. Choose Goto -> Header.

8. On the next window screen, you will see all the parameters required for the READ_TEXT
function. (Name, Language, ID, Object)

9. Now lets get the text using ABAP, open your ABAP editor (SE38), copy this code below.
"A sample code to use READ_TEXT FM
"www.freesaptutorial.com
data:

BEGIN OF header OCCURS 0,


ld_txt1(163),
ld_txt2(163),
ld_txt3(163),
END OF header.
DATA: li_lines LIKE STANDARD TABLE OF tline WITH HEADER LINE,
ID like THEAD-TDID,
TNAME LIKE THEAD-TDNAME,
TDOBJECT like THEAD-TDOBJECT.
ID = '0001'.
TNAME = '1820000009'.
TDOBJECT = 'VBBK'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id
= id
language = sy-langu
name
= TNAME
object
= TDOBJECT
TABLES
lines
= li_lines.
READ TABLE li_lines INDEX 1.
IF sy-subrc = 0.
header-ld_txt1 = li_lines-tdline.
ENDIF.
READ TABLE li_lines INDEX 2.
IF sy-subrc = 0.
header-ld_txt2 = li_lines-tdline.
ENDIF.
READ TABLE li_lines INDEX 3.
IF sy-subrc = 0.
header-ld_txt3 = li_lines-tdline.
ENDIF.
WRITE:/ header-ld_txt1.
WRITE:/ header-ld_txt2.
WRITE:/ header-ld_txt3.

10. Now execute the program (F8), you will see the long text from the header note text object.

how can i read text and display in smartform?


Posted: Aug 28, 2007 6:48 AM
Reply
hi guru's.
i am working with purchase order smartform in ME22N or ME23N in header text ->shipping
instruction is there .So i want to read the text and display it in a window
of smartform.
How can i proceed? please explain me
Re: how can i read text and display in
smartform?
Posted: Aug 28, 2007 6:54 AM in response
to: satheesh sath
Reply
Hi,
for readiing the texts you have to use the fm
read_text
this will give the header texts and any texts
related to that
table is STXH in which all texts wil be stored
CALL FUNCTION 'READ_TEXT'
EXPORTING
* CLIENT = SY-MANDT
id = depends on your requirements
language = 'EN'
name = depends on your requirements ( foreg
purchase or der number
object = 'KNMT' (depends on your requirements
)
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
tables
lines = IT_TLINE
* EXCEPTIONS
* ID = 1
* LANGUAGE = 2

* NAME = 3
* NOT_FOUND = 4
* OBJECT = 5
* REFERENCE_CHECK = 6
* WRONG_ACCESS_TO_ARCHIVE = 7
* OTHERS = 8
thanks & regards,
Venkatesh
Sai
Ram
Redd
y N...
Posts: 2,249
Registered: 12/22/05
Forum Points: 3,392

Re: how can i read text and display in


smartform?
Posted: Aug 28, 2007 7:38 AM in response
to: satheesh sath
Reply
We use function module to read header text or
item level text... try to create program lines and
use FM READ_TEXT
Ex: (sample example)
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'Z006'
language = 'E'
name = w_textname
object = 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = i_tlines.
* 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.
READ TABLE i_tlines INDEX 1.
t_in-m1 = i_tlines-tdline.
ENDIF.
Regards,
SaiRam

READ_TEXT IN SMARTFORM-urgent
Posted: Sep 25, 2007 4:15 PM
Reply
HI
I am using the read_text fm for reading the standard text in smartform please tell me the fm
parameters based on the text.i
NAVEEN
KUMAR
GU...

Re: READ_TEXT IN SMARTFORM-urgent


Posted: Sep 25, 2007 4:29 PM in response to:
varsha

Posts: 2,280
Registered: 2/3/06
Forum Points: 3,638

Reply
Hi Varsha,
Check this sample code...
DATA: leng TYPE thead-tdspras,
l_fname TYPE thead-tdname.
DATA: il_tline LIKE tline OCCURS 0 WITH
HEADER LINE.
leng = 'ES'.
l_fname = is_dlv_delnote-hd_gen-deliv_numb.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = '0001'
language = leng
name = l_fname

object = 'VBBK'
TABLES
lines = il_tline.
comentario = ''.
LOOP AT il_tline.
CONCATENATE comentario il_tline-tdline
INTO comentario SEPARATED BY space.
ENDLOOP.
My suggestion would be....
Instead of using the FM, Use the standard
functionality to print the required text provided
by Smartforms.
Create a text element, in the left top...in the drop
down there is an option of include text...
something like...
id = '0001'
language = 'E'
name = '0080000055'
object = 'VBBK'
u will get the dessired output
NW
Posts: 696
Registered: 5/8/06
Forum Points: 718

Re: READ_TEXT IN SMARTFORM-urgent


Posted: Sep 25, 2007 8:38 PM in response to:
varsha
Reply
Varsha,
You can use the "Include Text" option while
adding the text element in any template or
window. that will do the work READ_TEXT
does by itself. Just pass the params like Object
Id, mandt, langu, etc.
regards,
K

long text in smartform


Posted: Feb 24, 2007 3:44 PM

Reply
Hi,
I have a field in smartform,which has to pick data (long text).
Pick up the data from long text by passing following values. Pick up only 2 lines from long text.
Exclude the administrative information from long text
Text Name: 16 digit value. Initial 3 digits are Client (QAVE-MANDANT). Subsequent 12 digits
are Inspection lot number along with preceding zeros (QALS- PRUEFLOS). Last digit to be
picked up from QAVE-KZART. Concatenate these 3 values and then pass in to field Text
name
Language: EN
Text ID: QAVE
Text Object: QPRUEFLOS
I am able to pick data,but I have to exclude the adminstrative data.Please guide me as I am
clueless about it.
Thanks
Subbu P
Posts: 1,709
Registered: 4/29/05
Forum Points: 2,792

Re: long text in smartform


Posted: Feb 24, 2007 6:08 PM
p317980

in response to:

Reply
HI,
I presume, you are using read_text to read the
long text.
Now loop at the internal table which you get as
a result from read_text and move the desired
lines into another internal table.
Pass this internal table to smartforms through
the TABLES parameter.
Regards
Subramanian
Laxmi.Suryadevar
a
Posts: 291
Registered: 1/8/07
Forum Points: 320

Re: long text in smartform


Posted: Feb 25, 2007 1:11 AM
p317980
Reply

in response to:

Hi,
If you are using the FM read_text then you will
be getting an internal table as an output of
read_text.
To take first 2 rows only do the following.
take this in the table and keep a condition on the
table as sy-tabix < = 2.
&wa_text&.
Br,
Laxmi.
p317980
Posts: 522
Registered: 12/31/06
Forum Points: 50

Re: long text in smartform


Posted: Feb 25, 2007 8:22 AM

in response to: Subbu P


Reply

No i am not using the FM read_text,I am just passing the parameters into


the smartform directly.& i need the remarks lines,not the adminstrative
details.
Laxmi.Suryadevar
a
Posts: 291
Registered: 1/8/07
Forum Points: 320

Re: long text in smartform


Posted: Feb 25, 2007 10:14 AM
to: p317980

in response

Reply
Hi,
When you get the values Textname, text id,
textobject to the smartform.
call the FM read_text in the programing lines to
get the long text in the internal table. Another
way to retrieve the long text is to use INCLUDE
but for your requirement is better to uses
READ_TEXT function module.
Once you get the data in the internal table.
Create table and loop the long text internal
table. Now in the table when create a text node,
keep a condition on the text node in the
conditions column that when sy-tabix = 3.
Which means you are skipping two lines

(Administrative data).
Procedure:
1. Right click --> create---> programming lines.
2. In the Input parameters pass TEXT NAME,
TEXT ID, Text Object and Interanal table(itab)
and In output paramaeters the Internal table
(itab).
3. call function Read_text and pass the values.
4. create a table for Itab.
5. create a text node.
6. Keep a condition on the text node sy-tabix =
3 in the condition tab of the text node.
7. &itab-line&
Br,
Laxmi.Suryadevara
Haryati
Sulaiman

Re: long text in smartform


Posted: Mar 29, 2007 5:29 AM

Posts: 9
Registered: 12/28/05
Forum Points: 0

in response to: p317980


Reply

Hi,
I'm having the quite similar problem but my form is developed using
Sapscript. I'm using an 'INCLUDE' command but not sure what to put
into the text name as it consists of the 15 digit value.
Text Name : 999999999999999
Language : EN
Text ID : QALS
Text Object : QPRUEFLOS
INCLUDE <???> OBJECT QPRUEFLOS ID QALS LANGUAGE
&QALS-SPRACHE& PARAGRAPH ST
What should I put into <???> for the text name? TQ.
zarina
begum
Posts: 173
Registered: 4/25/07

Re: long text in smartform


Posted: Mar 29, 2007 2:18 PM
to: Haryati Sulaiman

in response

Forum Points: 284

Reply
hi Sulaiman
you can use a subroutine for getting values from
a function module.
here is the way to do it.
hope this may be helpful for you.
inside the script write these coding lines, this is
to call a subroutine inside the script from a
report program.
/: PERFORM <form> IN PROGRAM <prog>
/: USING &INVAR1&
......
/: CHANGING &OUTVAR1&
......
/: ENDPERFORM
INVAR1is variable symbol and may be of any
of the four SAPscript symbol types.
OUTVAR1is local text symbol and must
therefore be character strings.
In the program (zprog which u specified in the
subroutine call) of se38 write this.
FORM READ_TEXTS TABLES IN_PAR
STRUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
Data : v_id type LIKE THEAD-TDID VALUE
0001, (EXAMPLE)
V_LANG LIKE THEAD-TDSPRAS VALUE
EN, (EXAMPLE)
V_NAME LIKE THEAD-TDNAME,
V_OBJECT LIKE THEAD-TDOBJECT
VALUE VBBK, (Example).
DATA : T_LINES LIKE TABLE OF TLINE
WITH HEADER LINE.

READ TABLE IN_PAR WITH KEY


'V_NAME' .
CHECK SY-SUBRC = 0.
V_NAME = IN_PAR-VALUE.
call function 'READ_TEXT'
exporting
* CLIENT = SY-MANDT
id = v_id
language = v_lang
name = v_name
object = v_object
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER = HEADER
tables
lines = t_lines
* 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 SYMSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3
SY-MSGV4.
endif.
Read table t_lines index 1.
If sy-subrc eq 0.
OUT_PAR-VALUE = t_lines-tdline..
MODIFY OUT_PAR INDEX SY-TABIX.
endif.
enform.
here it ends.
and for those inputs for header text ,the Id,object
and name language, you can give in your won

data
Please close the thread if your problem is solved
Reward points if helpful.
Regards
Zarina
p317980
Posts: 522
Registered: 12/31/06
Forum Points: 50

Re: long text in smartform


Posted: May 29, 2007 6:12 AM

in response to: p317980


Reply

Thanks for all the replies.

You might also like