Application Development 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: 

pblm with FM 'READ_TEXT'

Former Member
0 Kudos

Hi everyone,

please take a look at this code

data delvryacct like thead occurs 2 with header line.

data line like tline occurs 2 with header line.

data: txtid like rstxt-tdid,

lang like rstxt-tdspras,

txtname like rstxt-tdname,

txtobj like rstxt-tdobject.

txtid = ekpo-werks. (passing default during run time as 340b)

lang = 'E'.

txtname = ekko-lifnr. (passing during run time or debug mode 112456)

txtobj = 'LFA1'.

call function 'READ_TEXT'

exporting

id = txtid

language = lang

name = txtname

object = txtobj

importing

header = delvryacct

tables

lines = line

exceptions not_found = 1 others = 2.

case sy-subrc.

when 0.

read table line index 1.------- line is empty sy-subrc = 0

move line-tdline to e1edka1-ablad.

endcase.

Please let me know if iam missing anything

14 REPLIES 14

Former Member
0 Kudos

Swathi,

What is the issue you are facing here?

If you are not sure of the parameter values, just go the transaction where you can fill this text online and double click on the editor so that it opens in the full screen mode. Now, in the menu Go To-->Header, you can find the parameter values for TDOBJECT and TDID. TDNAME might be the vendor id like you are passing here.

Regards,

Ravi

Note : Please mark the helpful answers

0 Kudos

Hi Swathi,

Check this out

http://www.sapdevelopment.co.uk/fmodules/fms_readtext.htm

Regards,

Santosh

Former Member
0 Kudos

HI,

look at the below code...

REPORT ZTEXT . 

TABLES: PBIM. 

* stxh, stxl, stxb - trans tables for text 
* ttxit - text on text-ids 
* ttxot - Short texts on text objects 
* Transaction MD63 
SELECT-OPTIONS: S_MATNR FOR PBIM-MATNR, 
                S_WERKS FOR PBIM-WERKS. 

DATA: BEGIN OF HTEXT. 
        INCLUDE STRUCTURE THEAD. 
DATA: END OF HTEXT. 

DATA: BEGIN OF LTEXT OCCURS 50. 
        INCLUDE STRUCTURE TLINE. 
DATA: END OF LTEXT. 

DATA: BEGIN OF DTEXT OCCURS 50. 
DATA:   MATNR LIKE PBIM-MATNR. 
        INCLUDE STRUCTURE TLINE. 
DATA: END OF DTEXT. 

DATA: TNAME LIKE THEAD-TDNAME. 

SELECT * FROM PBIM WHERE WERKS IN S_WERKS. 
  MOVE PBIM-BDZEI TO TNAME. 
  CALL FUNCTION 'READ_TEXT' 
       EXPORTING 
*           CLIENT                  = SY-MANDT 
          ID                      = 'PB' 
          LANGUAGE                = 'E' 
          NAME                    = TNAME 
          OBJECT                  = 'PBPT' 
*         ARCHIVE_HANDLE          = 0 
     IMPORTING 
          HEADER                  = HTEXT 
     TABLES 
          LINES                   = LTEXT 
     EXCEPTIONS 
          ID                      = 1 
          LANGUAGE                = 2 
          NAME                    = 3 
          NOT_FOUND               = 4 
          OBJECT                  = 5 
          REFERENCE_CHECK         = 6 
          WRONG_ACCESS_TO_ARCHIVE = 7 
          OTHERS                  = 8. 
  LOOP AT LTEXT. 
    IF LTEXT-TDLINE NE ''. 
      MOVE LTEXT-TDLINE TO DTEXT-TDLINE. 
      MOVE PBIM-MATNR TO DTEXT-MATNR. 
      APPEND DTEXT. 
    ENDIF. 
  ENDLOOP. 
ENDSELECT. 
LOOP AT DTEXT. 
  WRITE:/ DTEXT-MATNR, DTEXT-TDLINE. 
ENDLOOP.

Thanks

Sudheer

Former Member
0 Kudos

hi swathi,

try

case sy-subrc.

when 0.

loop at line.

read table line index 1.

endloop.

hope this helps,

priya.

Former Member
0 Kudos

Are you sure your TDID is plant id? I haven't seen such configuration anywhere. Also, for text name, enter LIFNR in internal format '0000112456' instead of '112456'. Can you check in any standard transaction for this text? If so, go to the long text view of this text and in the menu, 'Go to-->Header' should tell you how the text name should be, what the text id is and what the text object is.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Pretty sure that this is not right.

TXTIS = EKPO-WERKS.

The object LFA1 has only two txtid associated with it and they are(in 46c system) .

0001     Accounting note        
0002     Purchasing memo

You txtid parameters must be one of these, if using the LFA1 object.

Regards,

Rich Heilman

Former Member
0 Kudos

hI gUYS WHEN I CHANGED THE

txtid = ekpo-werks. TO TXTID = '340'.

txtname = ekko-lifnr to txtname = '0000112456'.

I got the internal table populated . i want to know what if i want to use another vendor number .

so i can give only hard core values or is there any way i declared in the first method

txtid = ekpo-werks.

txtname = ekko-lifnr

so that it would cover all vendors.

Thanks in advance.

0 Kudos

Swathi, did you guys create custom IDs under the LFA1 text object?

Regards,

Rich Heilman

0 Kudos

As I said, you have to find that out from the transaction where you enter this text.

TEXT ID, TEXT OBJECT will not change. You will only change the LIFNR which will be your TEXT NAME and I don't know why you want to use WERKS.

What texts are these, vendor, material master, PO header, PO item which one?

0 Kudos

Nope Rich,

I just took 1 value from lfa1 table.

Rich can you tell me how to pass all the possiblities i.e for different vendors rather than a single vendor

Thanks

0 Kudos

You can only read the text for one vendor at a time, so you must do this in a loop. Here is a sample program illitrating this.

report zrich_0001.

data: ilfa1 type table of lfa1 with header line.
data: lines type table of tline with header line.
data: objkey like thead-tdname.

select-options: s_lifnr for ilfa1-lifnr.

start-of-selection.

  select * into table ilfa1 from lfa1
               where lifnr in s_lifnr.

  loop at ilfa1.

    objkey = ilfa1-lifnr.

    clear lines.  refresh lines.
    perform read_text  tables lines
                       using '0001'                         " Or '0002'
                             'LFA1'
                             objkey.

    if not lines[] is initial.
      write:/ 'This is text for vendor', ilfa1-lifnr.
      loop at lines.
        write:/ lines-tdline.
      endloop.
    endif.

  endloop.


*---------------------------------------------------------------------*
*       FORM read_text                                                *
*---------------------------------------------------------------------*
form read_text  tables lines
             using id
                   object
                   name.

* Read SAPscript Text
  call function 'READ_TEXT'
       exporting
            client                  = sy-mandt
            id                      = id
            language                = sy-langu
            name                    = name
            object                  = object
       tables
            lines                   = lines
       exceptions
            id                      = 1
            language                = 2
            name                    = 3
            not_found               = 4
            object                  = 5
            reference_check         = 6
            wrong_access_to_archive = 7
            others                  = 8.

endform.

Regards,

Rich Heilman

0 Kudos

Thanks Rich,

I have one more Rich,

Iam creating a requistion using bapi_requistion_create and then creating po using ME59 . Iam not mentioning vendor number at anywhere in my program.but when i check that purchasing order i see a vendor no and for that vendor i need text. can you please let me know how to proceed about this.

MY question

1)how the vendor number is getting

2)how to retrieve text for that vendor

Thannks

0 Kudos

My guess is that the vendor is being derived from a source list. You can know the source lists by looking at table EORD. Hit this table with MATNR and WERKS and it will give you the LIFNR vendors tied to the MATNR.

Regards,

Rich Heilman

0 Kudos

Hi Rich,

I don't see any vendor assigned in EORD TABLE FOR WHICH IAM TRYING TO CREATE PO.bUT WHEN I CREATE A PURCHASE ORDER FOR THIS PARTICULAR MATERIAL ITS DISPLAYS A VENDOR WHICH I CHECKED IN EORD TABLE IS ASSIGNED TO ANOTHER MATERIAL.

pLEASE LET ME KNOW