0

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 click here for output

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.
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
dragospirnut
  • 13
  • 1
  • 8
  • What needs to work when `cID = PRUE ,cID =0001, cID = IVER`? – forgetaboutme Nov 02 '17 at 15:25
  • When values exist for any of below: cID =0001. cObject = 'MVKE', cID = IVER. cObject = 'MATERIAL, cID = 'GRUN'. cObject = 'MATERIAL' . cID = PRUE. cObject = 'MATERIAL' . I want to show them in my output table lt_join with whom i already show other fields in an ALV. – dragospirnut Nov 03 '17 at 06:06

2 Answers2

1

You cannot do like this. Function modules in SAP accept only single parameter at one time, unless this parameter is specified as a table type or in TABLES section.

However, here is workaround from my previous answer you can use to get rid of READ_TEXT at all.

  1. As forgetaboutme said, put you cIDs into itab together with TDNAMEs:

    wa_cids-cid = 'GRUN'.
    wa_cids-cobject = 'MATERIAL'.
    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.
    
  2. Select texts from db table considering your itab.

    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 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.
    
  3. Convert them from raw form into readable form

    CLEAR: t_stxl_raw[], t_tline[].
    APPEND VALUE ty_stxl_raw( clustr = <stxl>-clustr clustd = <stxl>-clustd ) TO t_stxl_raw.
    IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw.
    
  4. Read them

    LOOP AT t_tline ASSIGNING <tline>.
     wa_Report-TEXT = <tline>-TDLINE.
    append wa_Report to it_Report.
    ENDLOOP.
    
Suncatcher
  • 10,355
  • 10
  • 52
  • 90
  • Dear Suncatcher ,thank you for your response, i did as instructed but still facing an error : Fields -CLUSTR is unknown. It is neither in one of the specified tables nor defined by a " DATA" statement.Please see my code modified in my initial question: – dragospirnut Nov 03 '17 at 12:47
  • The errros is on line : w_stxl_raw-clustr = -clustr. – dragospirnut Nov 03 '17 at 13:13
  • You should run pts. 3 and 4 **inside a loop** through `t_stxl` table, `LOOP AT t_stxl ASSIGNING .`, where `` should have type of line of t_stx. Get all DATA definitions from my previous answer I provided. – Suncatcher Nov 03 '17 at 13:41
  • Thank you again .I have done what you advised and still the same errorr : LOOP AT t_stxl ASSIGNING . CLEAR: t_stxl_raw[], t_tline[]. w_stxl_raw-clustr = -clustr. w_stxl_raw-clustd = -clustd. APPEND w_stxl_raw TO t_stxl_raw. IMPORT tline = t_tline FROM INTERNAL TABLE t_stxl_raw. LOOP AT t_tline ASSIGNING . wa_Report-TEXT = -TDLINE. append wa_Report to it_Report. ENDLOOP. ENDLOOP. – dragospirnut Nov 03 '17 at 13:58
  • The same means what? Did you declare `` field-symbol? Try `LOOP AT t_stxl ASSIGNING FIELD-SYMBOL().` – Suncatcher Nov 03 '17 at 14:24
  • Thank you for your answer.You were right i didn`t declared . i have declared it now and i don`t get any errors but my program doesn`t do what is expected regarding this function. – dragospirnut Nov 06 '17 at 07:14
  • @Suncatcher.Please find above in the initial code an update, but still no output .If you have some advice :) – dragospirnut Nov 06 '17 at 14:11
  • @dragospirnut, you fill `wa_cids` structure wrong: you fill on line 56 `lTDNAME`, but there should be `wa_cids-lTDNAME`, alike line 54. And there should be **single APPEND** for all that stuff, not two! Also check that your logon language (`sy-langu` on line 73) is identical with your texts language. All other is fine. – Suncatcher Nov 06 '17 at 16:19
  • @dragospirnut, if you wanna fetch all languages, just remove line 73. – Suncatcher Nov 06 '17 at 16:23
  • i updated as below still no output :( IF wa_cids-cid = 'GRUN'. wa_cids-cobject = 'MATERIAL'. elseif cID = '0001'. concatenate lMVKE-MATNR lMVKE-VKORG lMVKE-VTWEG into wa_cids-lTDNAME. else. wa_cids-lTDNAME = lMVKE-MATNR. endif. append wa_cids to it_cids. – dragospirnut Nov 07 '17 at 06:47
  • then your cID never equals 0001 and never GRUN or there could be thousands reasons. Just remove all conditions, fill the structure with literals ans its **just works ©** – Suncatcher Nov 07 '17 at 09:20
  • Thank you for your reply. I think is too complicate. I am thinking of returning to read_text and do somehow to call the function read_text with a case code. – dragospirnut Nov 07 '17 at 10:11
  • @Suncatcher.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? – dragospirnut Nov 07 '17 at 11:50
0

You can create an internal table of cIDs & cObjects like this:

types: begin of cids,
         cid(4)      type c,
         cobject(10) type c,
       end of cids.

data: wa_cids type cids.
data: it_cids type standard table of cids.

Then you can simply append all the different types of cIDs/cObjects you have to your internal table:

wa_cids-cid = 'GRUN'.
wa_cids-cobject = 'MATERIAL'.

append wa_cids to it_cids.

Then loop over your internal table calling function 'READ_TEXT'

loop at it_cids into wa_cids.
  call function 'READ_TEXT'
    exporting
      client   = sy-mandt
      id       = wa_cids-cid
      language = lt002-spras  "p_SPRAS
      name     = ltdname
      object   = wa_cids-cobject
    tables
      lines    = it_tline
    exceptions
      id       = 1
      others   = 8.

* Do what you need to do with it_tline here.

endloop.

* Rest of code here
forgetaboutme
  • 613
  • 1
  • 6
  • 18