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

read_text function for multiple id and multiple languages

manole_apetroaie
Participant
0 Likes
8,594
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.
21 REPLIES 21
Read only

SimoneMilesi
Active Contributor
0 Likes
6,087

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.

Read only

manole_apetroaie
Participant
0 Likes
6,087

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.

Read only

RaymondGiuseppi
Active Contributor
6,087

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.

Read only

0 Likes
6,087

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

Read only

0 Likes
6,087

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.
Read only

0 Likes
6,087

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

Read only

0 Likes
6,087

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.

Read only

0 Likes
6,087

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.

Read only

0 Likes
6,087

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.
Read only

0 Likes
6,087

(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.
Read only

0 Likes
6,087

Hi Raymond,

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

Read only

0 Likes
6,087

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

Read only

0 Likes
6,087
"Declared and selected as below , still doesn`t do nothing

TYPES: BEGIN OF ty_stxl_raw,
clustr TYPE stxl-clustr,
tdid TYPE stxl-tdid,
clustd TYPE stxl-clustd,
END OF ty_stxl_raw,

BEGIN OF ty_stxl,
tdname TYPE stxl-tdname,
tdid TYPE stxl-tdid,
clustr TYPE stxl-clustr,
clustd TYPE stxl-clustd,
END OF ty_stxl.


SELECT l~tdid 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>.

   "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.
Read only

0 Likes
6,087

Pls remove tid from ty_syxl_raw, and (...) paste the correct parts of your previous code to replace my 'Your current code to...goes here' comment.

Read only

0 Likes
6,087

Hi Giuseppi,

I am confused , at the beginning i wanted to use read_text, then i searched for READ_MULTIPLE_TEXTS .Now i found this partial code on which i am confused. Please tell me what do you mean by :1 .Your current code to add report records goes here and

2:Your current code to add report records goes here. Sorry to be a pain:(

Read only

0 Likes
6,087

You copy in those place the code you used to fill the internal tables in your initial versions. (1) the code to fill the t_styxl_raw table from stxl data (2) the code to add record to it_report from t_tline data.

Read only

0 Likes
6,087

Hi, i think is like this,but it doesn`t show up nothing on screen,thank you :

LOOP AT t_stxl ASSIGNING <stxl>.

*   New text

  AT NEW tdid.

    REFRESH: t_stxl_raw, t_tline.

  ENDAT.
  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.

*  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

       wa_Report-TEXT = <tline>-TDLINE.

      append wa_Report to it_Report.

    ENDLOOP.

  ENDAT.

ENDLOOP.<br>
Read only

0 Likes
6,087

Hi, like below?

Read only

0 Likes
6,087

Try some debug.

Read only

0 Likes
6,087

Dear Raymond, i think i will stick with read_text or read_multiple_text.Do you have any example for read_text or read_multiple_text for which i could read more multiple ID on all languages maintained?

Read only

SimoneMilesi
Active Contributor
6,087

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