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

Problem in reading long text

Former Member
0 Likes
5,980

Hi All,

for reading long text , for the description of a material i am using

READ_TEXT function module, but the problem is for a single PO,

there may have many line items, and the texts can be of any length,

I have to print it in my smartforms, where i may have many PO's

and  its related any no of line items.

Now the problem is that, through READ_TEXT, it is showing

only one line (probably upto 255 char long text).

But my texts could be so long, that it may splits into many lines,

So please tell me how could i get the long text for each line items

of all PO.

1 ACCEPTED SOLUTION
Read only

former_member187748
Active Contributor
0 Likes
5,928

Hi Srikant,

please create a structure in your program, with a variable of type string, ebeln, ebelp  ,

and declare these code

data:begin of dt_lines occurs 0,

     tdformat like tline-tdformat,

     tdline like tline-tdline,

   data:end of dt_lines.

Again, create a internal table of the same type as of the structure created earlier,

lets say the internal table is it_tab1,

then collect all these stuff in the internal table and, inside the text in your smartforms

loop into the internal table, you have created, you will get the desired result.


Hi,

you can define a variant with STRING type. Then using Kumar's suggestion loop the internal table and concatenate the lines to the variant.

Hope it help you.

Yawa

22 REPLIES 22
Read only

former_member188827
Active Contributor
0 Likes
5,928

READ_TEXT returns internal table "lines" which contains the whole text, so looping through the table will give all the text. However, smartforms also give option of "include text" in text node where you can give text name as variable, text object and text id and the long text is printed accordingly.

Regards

Read only

Former Member
0 Likes
5,928

Hi,

Your READ_TEXT FM returns the tables parameters lines.

data item_text(500) your varaible to display in form

LOOP at i_lines

CONCATENATE item_text i_lines-tdline into item_text

                         separated by space.

endloop.

Read only

0 Likes
5,928

Hi Kiran,

i have done as you have sujjested, but still it is showing only one line of text in output.

Read only

0 Likes
5,928

Hi,

put the break point on the statement and debug!

whether the item text is contains the all lines are not!

how you are displaying in smartform? can you paste the screen shot

Read only

0 Likes
5,928

Hi Kiran,

I have written these code lines, actaully i have some texts associated with these materials, which have to concatenate with READ_TEXT texts.

LOOP AT it_EKPO INTO wa_EKPO.
   CONCATENATE WA_EKPO-EBELN WA_EKPO-EBELP INTO V_NAM.

   CALL FUNCTION 'READ_TEXT'
         EXPORTING
*   CLIENT                        = SY-MANDT
           ID                            = 'A01'
           LANGUAGE                      = SY-LANGU
           NAME                          = V_NAM
           OBJECT                        = 'EKPO'
*   ARCHIVE_HANDLE                = 0
*   LOCAL_CAT                     = ' '
* IMPORTING
*   HEADER                        =
         TABLES
           LINES                         = DT_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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.
   IF NOT dt_lines[] IS  INITIAL.
     SELECT SINGLE TXZ01
       FROM EKPO
       INTO V_TXZ01
       WHERE EMATN = IT_EKPO-EMATN.

     LOOP AT DT_LINES.
          if not dt_lines-tdline is initial.
            it_req-ebeln = wa_ekpo-ebeln.
             it_req-txz01 = wa_ekpo-txz01.
            it_req-vname1 = v_nam.
            it_req-text  = dt_lines-tdline.
            append it_req.
           ENDIF.
           ENDLOOP.
           CLEAR DT_LINES[].
ENDIF.
ENDLOOP.

Read only

0 Likes
5,928

Hi Srikant

Can you please rephrase what exactly is the issue..? In case you want to print text for each line you can simply use include text or read_text and print it after every line in Main window inside table

Nabheet

Read only

0 Likes
5,928

Hi Nabheet,

i have a smartform in which i have to show all line items details, related to each PO

for a single PR, now for each line items, it has a material field matnr and its short

descriptions as txz01.

Now for each line item material i have some added text in terms of remarks that i wants

to read through READ_TEXT, but it could be of any length.

Now when i am going to print its text, it is printing only one line.

And for the same scenario i am struggling till now.

Read only

0 Likes
5,928

try using text node with type"include text" as shown in attached image.

Read only

0 Likes
5,928

For each line item which you are printing you must be looping on IT_EKPO in smartform table. so just need to read text and concatenate WA_EKPO-TXZ01.

After that make a loop in smartform on it_req and inside it write using text element

CONCATENATE WA_EKPO-EBELN WA_EKPO-EBELP INTO V_NAM.

   CALL FUNCTION 'READ_TEXT'

         EXPORTING

*   CLIENT                        = SY-MANDT

           ID                            = 'A01'

           LANGUAGE                      = SY-LANGU

           NAME                          = V_NAM

           OBJECT                        = 'EKPO'

*   ARCHIVE_HANDLE                = 0

*   LOCAL_CAT                     = ' '

* IMPORTING

*   HEADER                        =

         TABLES

           LINES                         = DT_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.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

   ENDIF.

   IF NOT dt_lines[] IS  INITIAL.

     SELECT SINGLE TXZ01

       FROM EKPO

       INTO V_TXZ01

       WHERE EMATN = IT_EKPO-EMATN.

     LOOP AT DT_LINES.

          if not dt_lines-tdline is initial.

            it_req-ebeln = wa_ekpo-ebeln.

             it_req-txz01 = wa_ekpo-txz01.

            it_req-vname1 = v_nam.

            it_req-text  = dt_lines-tdline.

            append it_req.

           ENDIF.

           ENDLOOP.

           CLEAR DT_LINES[].

ENDIF.

Read only

0 Likes
5,928

Hi,

i have tried by using this concept, but at the same place i have to show the text related to material

as its short texts too, so not working

Read only

0 Likes
5,928

Hi Nabheet,

should i use the addition of ebelp field in the following code or not, if not then how will i get it line item wise. As sujjested by 

LOOP AT DT_LINES.

          if not dt_lines-tdline is initial.

            it_req-ebeln = wa_ekpo-ebeln.

              it_req-ebelp = wa_ekpo-ebelp.

             it_req-txz01 = wa_ekpo-txz01.

            it_req-vname1 = v_nam.

            it_req-text  = dt_lines-tdline.

            append it_req.

           ENDIF.

           ENDLOOP.

           CLEAR DT_LINES[].

Read only

0 Likes
5,928

Hi Srikant

It depens on at what place you are determining the text. If you are determining it before loop of MAIN table then you need PO line item so that you can print the test for that line item. If you are determining it inside loop for each line item then you only need to do read_text and proceed ahead

Nabheet

Read only

Former Member
0 Likes
5,928


Hi,

you can define a variant with STRING type. Then using Kumar's suggestion loop the internal table and concatenate the lines to the variant.

Hope it help you.

Yawa

Read only

former_member187748
Active Contributor
0 Likes
5,929

Hi Srikant,

please create a structure in your program, with a variable of type string, ebeln, ebelp  ,

and declare these code

data:begin of dt_lines occurs 0,

     tdformat like tline-tdformat,

     tdline like tline-tdline,

   data:end of dt_lines.

Again, create a internal table of the same type as of the structure created earlier,

lets say the internal table is it_tab1,

then collect all these stuff in the internal table and, inside the text in your smartforms

loop into the internal table, you have created, you will get the desired result.

Read only

0 Likes
5,928

Hi Sanjeev,

i have done as you have sujjested, through it, also i am not able to get my problem resolved.

Please tell me what to do next, i have loop into the internal table having all texts.

I have written these code lines, actaully i have some texts associated with these materials, which have to concatenate with READ_TEXT texts.

LOOP AT it_EKPO INTO wa_EKPO.
   CONCATENATE WA_EKPO-EBELN WA_EKPO-EBELP INTO V_NAM.

   CALL FUNCTION 'READ_TEXT'
         EXPORTING
*   CLIENT                        = SY-MANDT
           ID                            = 'A01'
           LANGUAGE                      = SY-LANGU
           NAME                          = V_NAM
           OBJECT                        = 'EKPO'
*   ARCHIVE_HANDLE                = 0
*   LOCAL_CAT                     = ' '
* IMPORTING
*   HEADER                        =
         TABLES
           LINES                         = DT_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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   ENDIF.
   IF NOT dt_lines[] IS  INITIAL.
     SELECT SINGLE TXZ01
       FROM EKPO
       INTO V_TXZ01
       WHERE EMATN = IT_EKPO-EMATN.

     LOOP AT DT_LINES.
          if not dt_lines-tdline is initial.
            it_req-ebeln = wa_ekpo-ebeln.
             it_req-txz01 = wa_ekpo-txz01.
            it_req-vname1 = v_nam.
            it_req-text  = dt_lines-tdline.
            append it_req.
           ENDIF.
           ENDLOOP.
           CLEAR DT_LINES[].
ENDIF.
ENDLOOP.

Read only

0 Likes
5,928

Hi Srikant,

i have seen your code, you have missed one thing, while creating internal table where your all

texts you are appending, please take consideration of line items fields too.

Please modify your code as shown below

LOOP AT DT_LINES.

          if not dt_lines-tdline is initial.

            it_req-ebeln = wa_ekpo-ebeln.

              it_req-ebelp = wa_ekpo-ebelp.

             it_req-txz01 = wa_ekpo-txz01.

            it_req-vname1 = v_nam.

            it_req-text  = dt_lines-tdline.

            append it_req.

           ENDIF.

           ENDLOOP.

           CLEAR DT_LINES[].


Now debug your code, and see is your internal table it_req has all the text inside it.


If yes, go to your smartform, and under the text where you are showing your long text, create

a Program lines,  before this create a variable ltext of type string,

Use these programs lines to show your whole text for each line items


LOOP AT IT_REQ INTO IT_REQ WHERE EBELN WA_FINAL-EBELN

    and EBELP = WA_FINAL-EBELP .

CONCATENATE ltext  IT_REQ-TEXT  INTO ltext SEPARATED BY space.

ENDLOOP.

And in the general attribute of the text tab where you are showing these long text

use &ltext&

Hope you will get your requirements.

Read only

0 Likes
5,928

Hi Sanjeev,

thanks a lot, i have resolved my issue.

Read only

former_member196157
Active Participant
0 Likes
5,928

HIII,

data: v_lines2 type table of ty_tline,
       w_lines2 type ty_tline.
data: v_name2   type stxh-tdname,
       tdspras2  type stxh-tdspras,
       tdid2     type stxh-tdid,
       tdobject2 type stxh-tdobject.


data: text type CHAR1000.

          tdobject2 = 'EKKO'.
           tdid2     = '
F01'.
           tdspras2  = 'EN'.
           v_name2   = '
5500000012'.

      call function 'READ_TEXT'
      exporting
      id                            tdid2
      language                      tdspras2
      name                          v_name2
      object                        tdobject2
      tables
      lines                         v_lines2
      exceptions
      id                            = 1
      language                      = 2
      name                          = 3
      not_found                     = 4
      object                        = 5
      reference_check               = 6
      wrong_access_to_archive       = 7
      others                        = 8.


     loop at v_lines2 into w_lines2.
        concatenate TEXT w_lines2-tdline into TEXT separated by space.
        condense TEXT.
     endloop.



This may helps u....

Read only

RaymondGiuseppi
Active Contributor
0 Likes
5,928

Smartforms can solve it for you, don't use READ_TEXT but create a TEXT node of type "I Include text"

Regards,

Raymond

Read only

0 Likes
5,928

Another approach can be you create two text elements one is include text pass your text ids etc and beneath it have another text where you will print TXZ01 value A simple approach.

Thanks Raymond solution seem simpler now

Read only

0 Likes
5,928

Hi Raymond,

actually i have to show, one more text in the same place, so it was not useful (or i m not getting how to do it with include text)

Anyhow thanks a lot.

Read only

0 Likes
5,928

You can insert multiple text nodes one after the other in the same window and they can be dynamic text,; include text, text element or text module. With the checkbox to prevent error when no text exists, I find it much much easier.

Regards,

Raymond