‎2005 Dec 29 6:40 AM
Hi all,
I've been reading some of the earlier threads on READ_TEXT FM and so far i have only managed to find out what fields i need:
CLIENT = SY-MANDT
ID = 'BEST'
LANGUAGE = 'EN'
OBJECT = 'MATERIAL'
As for NAME, i know that i want to send the Material Code (ITAB-MATNR) to the call function, but how do i do it?
This is to extract the PO Material Text and be filled into ITAB-MAT_TXT which i have defined...
Where do i go from here?
‎2005 Dec 29 11:07 AM
‎2005 Dec 30 7:20 AM
yup, i tried directly running the FM and it works...i looked into the return table of MAT_TXT, the text was retrieved...but the problem is that it is not being displayed or moved to ITAB-MTEXT successfully
‎2005 Dec 30 7:25 AM
Good,
loop that mat_txt and concatenate the text.
loop at mat_txt.
concatenate itab-mtext mat_txt-tdline into itab-mtext .
endloop.try this
this will work..
‎2005 Dec 30 7:48 AM
when i tried running the FM directly by using an example, i got the result that looked like this:
--------------------------------------------------------------
|TD | TDLINE
--------------------------------------------------------------
|* | "<-- LINE 1
|* | A-HS340MP150HS340 "<-- LINE 2
|* | L - 956MM W - 352MM H - 82MM "<-- LINE 3
|* | CUSION G71160, CUSHION 671161, "<-- LINE 4
|* | POLYFOAM 75X50X43, 2 PCS WOOD 343X38X11 "<-- LINE 5
|* | "<-- LINE 6
So i need to display all 6 lines...however, only the first line (which is a blank) is retrieved into ITAB-MTEXT and being displayed...
I would like to be able to display all the text in the 6 lines in that order
‎2005 Dec 30 7:56 AM
Hi, I think you are using read.
instead use loop at mat_txt.
**itab-mtext should be of type string.
loop at mat_txt.
concatenate mat_txt-tdline itab-mtext into itab-mtext.
endloop.
the above will give continuous,
if you want to print line by line
then
loop at mat_txt.
write:/ mat_txt-tdline.
endloop.
vijay
‎2005 Dec 30 9:30 AM
Refer the example below :
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'GRUN'
LANGUAGE = SY-LANGU
NAME = G_PROD
OBJECT = 'MATERIAL'
TABLES
LINES = WAONE.
LOOP AT WAONE.
CASE SY-TABIX.
WHEN '1'.
G_TEXT1 = WAONE-TDLINE.
WHEN '2'.
G_TEXT2 = WAONE-TDLINE.
WHEN '3'.
G_TEXT3 = WAONE-TDLINE.
ENDCASE.
ENDLOOP.
CONCATENATE G_TEXT1 G_TEXT2 G_TEXT3 INTO G_MAKTX2 SEPARATED BY SPACE.
If its not working there may be one problem, the NAME G_PROD may not be in the required format. In debugging mode just check wat value it holds (it may have unnecessary leading zeroes or the necessary leading zeroes may be missing). So, u need to find out ( in se37 ) which format of NAME actually works. u can copy it then into a character variable, convert it into necesary format and the call the function 'READ_TEXT'. wats the required format, u can also check in debugging mode by changing it there itself n seeing the output.
eg if the value of name is 1012 it has to be changed into
000000000000001012 for the output to come. verify the no.of zeroes. For this u can also go to the editor of the text, goto ->header-> there u ll get the name value..
Hope i cud help,
Regards,
Bikash
‎2005 Dec 30 4:09 PM
Bernard,
Happy new year to you too. Hopefully we will resolve this before the new year starts.
There are a couple of things in the program that I think are an issue. Your ITAB-MTEXT is defined as TYPE C with no length specification. As a result, only one character of the text will be there in this field. Next, you are calling READ_TXT without a LOOP AT ITAB. So only the last IATB-MATNR is probably what you are fetching the PO text for. Please make the following changes and hopefully that resolves.
I don't know how you want to manage the PO text length, because as you can see, it can one word or ten lines. Even if you want to concatenate, you need to define your field to the maximum possible over which you have no control. This is because someone can write a book in that PO text. What I would suggest is to define a new internal table that has three fields as follows.
DATA: BEGIN OF MTXT_TAB OCCURS 0,
MATNR LIKE MARA-MATNR,
POSNR TYPE I,
LINE LIKE TLINE-TDLINE.
DATA: END OF MTXT_TAB.Then change your READ_TXT code as follows
Change your FORM READ_TXT as follows.
*&---------------------------------------------------------------------*
*& FORM READ_TXT *
*&---------------------------------------------------------------------*
FORM read_txt.
DATA: l_name LIKE thead-tdname.
LOOP AT itab.
CLEAR: mat_txt, mat_txt[].
l_name = itab-matnr.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'BEST'
name = l_name
object = 'MATERIAL'
language = sy-langu
TABLES
lines = mat_txt
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
LOOP AT MAT_TXT.
*--> Need move the text retrieved in MAT_TXT into ITAB-MTEXT
MOVE: ITAB-MATNR TO MTXT_TAB-MATNR,
SY-TABIX TO MTXT_TAB-POSNR,
MAT_TXT-TDLINE TO MTXT_TAB-LINE.
APPEND MTXT_TAB.
CLEAR MTXT_TAB.
ENDLOOP.
ENDLOOP.
ENDFORM. "READ_TXT
‎2005 Dec 29 4:57 PM
Change your FORM READ_TXT as follows.
*&---------------------------------------------------------------------*
*& FORM READ_TXT *
*&---------------------------------------------------------------------*
FORM read_txt.
DATA: l_name LIKE thead-tdname.
LOOP AT itab.
CLEAR: mat_txt, mat_txt[].
l_name = itab-matnr.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'BEST'
name = l_name
object = 'MATERIAL'
language = sy-langu
TABLES
lines = mat_txt
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
* LOOP AT MAT_TXT.
*--> Need move the text retrieved in MAT_TXT into ITAB-MTEXT
* ENDLOOP.
ENDLOOP.
ENDFORM. "READ_TXT
‎2005 Dec 30 4:17 PM
hi,
Here is a sample code for using READ_TEXT.
clear : gv_hdrtxt1, gv_hdrtxt2, gv_hdr.
thead-tdid = 'Z508'.
thead-tdname = omcs_tab-belnr.
thead-tdobject = 'VBBK'.
call function module to read header texts
perform read_text using thead-tdid thead-tdname thead-tdobject.
gv_hdrtxt1 = ws-text_line.
************************************************************************
form read_text
************************************************************************
FORM READ_TEXT USING X_ID X_NAME X_OBJECT.
refresh it_lines.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = X_ID
LANGUAGE = 'E'
NAME = X_NAME
OBJECT = X_OBJECT
ARCHIVE_HANDLE = 0
TABLES
lines = it_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.
read table it_lines index 1.
ws-text_line = it_lines-tdline.
ENDIF.
ENDFORM.
Regards,
Sailaja.
‎2006 Jan 03 3:46 AM
I'm sorry guys but its just not working. Could any of you try copying and pasting the code i posted earlier and see if you guys manage to get any output? I tried all of the sample codes posted but although some of them work, it still only retrieves and displayes the first line of the PO Text instead of the 6 or so lines that are suppose to be displayed
Sorry for ruining the new year by giving bad new
‎2006 Jan 03 4:02 AM
Hi Bernard,
Can you tell us about the runtime error. What does it say?
Regards,
Raj
‎2006 Jan 03 4:08 AM
Bernard,
You are not paying attention to my previous post. You are calling READ_TXT only once and you are passing ITAB-MATNR in this routine. You need to call this for every ITAB entry in a loop which is what is missing. <b>Please go through my previous post and let me know if you have any questions with regards to that.</b>
Srinivas
‎2006 Jan 03 4:46 AM
oh...ok...i missed that part on the PERFORM statement during the loop at ITAB...you were right...almost done now...