Skip to Content
-4

read_text function for multiple id and multiple languages

Nov 02, 2017 at 01:20 PM

191

avatar image
Former Member
I have managed to make the READ_TEXT FM work only for one cID at a time on multiple calls of function read_text(for example I found out how to access it for cID = 'GRUN' cObject = 'MATERIAL'. Can anyone advise how to connect read_text function so that inspection text(cID = 'GRUN' cObject = 'MATERIAL') will be dispalyed in my alv grid on the same line with material details? Please see below output when running my program:

FORM READTEXT.
  data: it_MVKE type standard table of MVKE initial size 0.
  data: lMVKE like MVKE, lMAKT like MAKT, lT002 like T002 ,
        lTDNAME like THEAD-TDNAME,"text header

        it_TLINE type standard table of TLINE,
        wa_TLINE type TLINE.

  data: cObject(10) type c, cID(4) type c.


  select MATNR from MARA into corresponding fields of table it_MVKE
  where MATNR in Material order by MATNR.
  cID = 'GRUN'. cObject = 'MATERIAL'. "Text date principale "


  loop at it_MVKE into lMVKE.

    lTDNAME = lMVKE-MATNR.

    select spras from T002 into lT002.

      CALL FUNCTION 'READ_TEXT'
        EXPORTING
          CLIENT   = SY-MANDT
          ID       = cID
          LANGUAGE = lT002-SPRAS
          NAME     = lTDNAME
          OBJECT   = cObject
        TABLES
          LINES    = it_TLINE
        EXCEPTIONS
          ID       = 1
          OTHERS   = 8.

      IF SY-SUBRC EQ 0.

        select single * from MAKT into lMAKT where MATNR eq lMVKE-MATNR
         and SPRAS eq lT002-SPRAS.

        LOOP AT it_TLINE INTO wa_TLINE.
          wa_join-TEXTPRI = wa_TLINE-TDLINE.
          append wa_join to lt_join.
          clear wa_join.
        ENDLOOP.
      ENDIF.
    ENDSELECT.
  ENDLOOP.
ENDFORM.
capture.jpg (109.1 kB)
10 |10000 characters needed characters left characters exceeded

And which is the problem you are facing?

i do not see anything difficult in it, just a really wrong code structure from my point of view.

0
Former Member
Simone Milesi

Dear Simone,

I need to display in my alv at the same time cID = PRUE ,cID =0001, cID = IVER .At the moment i can make it work only individually.

0

And where is the problem?
Loop - Read_text- append -endloop.

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Raymond Giuseppi
Nov 03, 2017 at 06:55 AM
3

Just call READ_MULTIPLE_TEXTS or call READ_TEXT for each ID, what your exact concern. Have a coffee, walk around the block to clear your head and then get back to coding.

Show 17 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Raymond, thank you :)). Funny comment too.

0
Former Member

Hi Raymond , in the mean time i found some other way of doing it as i understand that i cannot do multiple calls on ID. Please find below,trouble is that i get an message error on line : w_stxl_raw-clustr = <stxl>-clustr saying : Fields <STXL>-CLUSTR is unknown. It is neither in one of the specified tables nor defined by a " DATA" statement

 data: it_MVKE type standard table of MVKE initial size 0.

data: lMVKE like MVKE, lMAKT like MAKT, lT002 like T002,

 lTDNAME like THEAD-TDNAME,

 it_TLINE type standard table of TLINE,

 wa_TLINE type TLINE, lText type string.



types: begin of i_Report,

        MATNR(18) type c,

        MAKTX like MAKT-MAKTX,

        VKORG(5) type c,

        VTWEG(5) type c,

        SPRAS(2) type c,

        Text type string,

       end of i_Report.



data: wa_Report type i_Report,

      it_Report type standard table of i_Report initial size 0.

data: cID(4) type c, cObject(10) type c.



types: begin of cids,

         cid(4)      type c,

         cobject(10) type c,

         lTDNAME(70) TYPE c,

       end of cids.



data: wa_cids type cids.

data: it_cids type standard table of cids.



TYPES: BEGIN OF ty_stxl_raw,

        clustr TYPE stxl-clustr,

        clustd TYPE stxl-clustd,

       END OF ty_stxl_raw,



       BEGIN OF ty_stxl,

        tdname TYPE stxl-tdname,

        clustr TYPE stxl-clustr,

        clustd TYPE stxl-clustd,

       END OF ty_stxl.



DATA:  t_stxl_raw TYPE STANDARD TABLE OF ty_stxl_raw,

       t_stxl     TYPE TABLE OF ty_stxl,

       w_stxl_raw TYPE ty_stxl_raw.



DATA:  t_tline TYPE STANDARD TABLE OF tline.

FIELD-SYMBOLS: <tline> TYPE tline,

              <stxl> LIKE LINE OF t_stxl.



wa_cids-cid = 'GRUN'.

wa_cids-cobject = 'MATERIAL'.

append wa_cids to it_cids.



if cID = '0001'.

 concatenate lMVKE-MATNR lMVKE-VKORG lMVKE-VTWEG into wa_cids-lTDNAME.

else.

 lTDNAME = lMVKE-MATNR.

endif.

append wa_cids to it_cids.



SELECT l~tdname l~clustr l~clustd

 INTO CORRESPONDING FIELDS OF TABLE t_stxl

 FROM stxl AS l

 JOIN stxh AS h

  ON h~tdobject = l~tdobject

   AND h~tdname   = l~tdname

   AND h~tdid     = l~tdid

   FOR ALL ENTRIES in it_cids

 WHERE l~relid    = 'TX'          "standard text

   AND h~tdobject = it_cids-cobject

   AND h~tdname   = it_cids-lTDNAME

   AND h~tdid     = it_cids-cid

   AND l~tdspras  = sy-langu.



LOOP AT t_stxl ASSIGNING <stxl>.





  CLEAR: t_stxl_raw[], t_tline[].

w_stxl_raw-clustr = <stxl>-clustr.

w_stxl_raw-clustd = <stxl>-clustd.

APPEND w_stxl_raw TO t_stxl_raw.

IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.





LOOP AT t_tline ASSIGNING <tline>.

 wa_Report-TEXT = <tline>-TDLINE.

append wa_Report to it_Report.

ENDLOOP.

  ENDLOOP.



  ENDFORM.
0

The code is rather unreadable, sorry (could you possibly change formatting?). But I don't see <stxl> assigned, so could that be a problem?

0

You forgot the LOOP AT t_stxl/ENDLOOP. Also use the Code option to add code in your post, post unformated code in the generated box.

0
Former Member
Raymond Giuseppi

I have , please see below:

LOOP AT t_stxl ASSIGNING <stxl>.

  CLEAR: t_stxl_raw[], t_tline[].

w_stxl_raw-clustr = <stxl>-clustr.

w_stxl_raw-clustd = <stxl>-clustd.

APPEND w_stxl_raw TO t_stxl_raw.

IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.

LOOP AT t_tline ASSIGNING <tline>.

 wa_Report-TEXT = <tline>-TDLINE.

append wa_Report to it_Report.

ENDLOOP.

  ENDLOOP.
0

(your posted source is hardly readable...)

You cannot use the import TLINE with two mixed set of lines, the IMPORT should be in the LOOP in a AT END OF step, internal table refreshed in the AT NEW)

LOOP AT t_stxl ASSIGNING <stxl>.
  " New text
  AT NEW tdid.
    REFRESH: t_stxl_raw, t_tline.
  ENDAT.  
  " > your current code to fill t_stxl_raw goes here
  " End of a text
  AT END OF tdid.
    IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.
    LOOP AT t_tline ASSIGNING <tline>.
    " > Your current code to add report records goes here    
    ENDLOOP.
  ENDAT.
ENDLOOP.
0
Former Member
Raymond Giuseppi

Hi Raymond,

Thank you , i`ve made the modifications advised and i get the error: "No component exists with the name "TDID"."

0

Add this field to your local TYPES definition for stxl data and in the SELECT FROM stxl statement too of course.

0
Show more comments
Former Member

Dear Jelena,

Thank you for your answer.You were right i didn`t declared <stxl> . i have declared it now and i don`t get any errors but my program doesn`t do what is expected regarding this function.

0