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: 

how to increase the length of field in report to display full text

Former Member
0 Kudos

hi experts,

i have created the ALV grid report for Purchase order . I need to display the item text of PO in the report,i have used the READ_TEXT FM and it is displaying item text but of only 50 characters. i assigned the text to MSEG-SGTXT field which is of 50 length. I want to display full text of item in the report so what i have to do to achieve this.

i have tried declaring the variable of char with 150 length but it is displaying only 70 char's

please suggest me the solution.

regards

Shambuling 

1 ACCEPTED SOLUTION

amy_king
Active Contributor
0 Kudos

Hi Shambuling,

The maximum number of characters that may be displayed in a single ALV cell is 128. One option for your scenario could be to show the first n characters of the text inside the ALV, and have a button in the ALV row which the user may click to see the full text if they want. On click of this button, you could call function EDIT_TEXT to display the full text in the SAP text editor (in either edit or read-only mode).

If you are seeing only the first 70 characters of a text, this may be because the text includes a line break after character 70 and you need to handle the line break when you write the text contents to your ALV field.

Cheers,

Amy

18 REPLIES 18

amy_king
Active Contributor
0 Kudos

Hi Shambuling,

The maximum number of characters that may be displayed in a single ALV cell is 128. One option for your scenario could be to show the first n characters of the text inside the ALV, and have a button in the ALV row which the user may click to see the full text if they want. On click of this button, you could call function EDIT_TEXT to display the full text in the SAP text editor (in either edit or read-only mode).

If you are seeing only the first 70 characters of a text, this may be because the text includes a line break after character 70 and you need to handle the line break when you write the text contents to your ALV field.

Cheers,

Amy

Former Member
0 Kudos

hi Amy

Thanks for reply.

please suggest me how to show first n characters and how to specify the button.

i have taken sgtxt field of mseg which has length 50, to this how i need to write the code which shows first n characters and specify the button.

please suggest how i need to handle the line break.

regards

Shambuling

Former Member
0 Kudos

You could create a substring of your first row of long text with something like:

read table my_text into ws_text index 1.  (both described like tline).

if sy-subrc eq 0.

     my_output-text = ws_text-tdline(50).  "into your initial ALV display.

endif.

Then if you have a lot of texts, or multiple POs you might want to copy your texts into another table that had a document number, tdformat and tdline....this would allow you to retrieve again without having to go back to read_text.

then in your grid, create a column with a pushbutton, or add a function button to your GUI to display the text.  When the user chooses a row and presses the pushbutton on the row (or the function button on the GUI), call your code to get the row the user selected, then get that text and format your text as you like ( I often create a long string by looping and concatenating, then call FM RKD_WORDWRAP to put the text into a table with a line size that I want to display), call a popup screen and display the table of text that you have created for user display.  Be sure to clear the content of the text display table after you call the screen, or before you rebuild for the next text display.

amy_king
Active Contributor
0 Kudos

Hi Shambuling,

You're already showing the first n characters in your existing ALV cell. Just decide how many characters you want to display in that cell then...

  1. use a data element with an appropriate length, and
  2. move that many characters from the standard text object to that cell. Function module READ_TEXT returns a table of text lines, so you need to loop through that table and concatenate as much text as will fit into your ALV text cell. You could do this manually with a LOOP...ENDLOOP statement or you could use a function module like SWA_STRING_FROM_TABLE to convert your table of text lines to a single string variable.

CALL FUNCTION 'SWA_STRING_FROM_TABLE'
     EXPORTING
       character_table      = lt_table
     IMPORTING
       character_string     = lv_string
     EXCEPTIONS
       OTHERS               = 0.

   CONDENSE lv_string.

To create a button in one of the ALV table cells, check out demo program SALV_DEMO_TABLE_COLUMNS in your system, and look especially at creating the button column or the hotspot column.

Cheers,

Amy

Former Member
0 Kudos

hi David

Thanks for reply .

i have tried it by giving the length to 120 but it is not displaying.

now i have taken the another field with the length of 132 i.e LFA1-LFURL but it is displaying 70 characters ..

regards

Shambuling

Former Member
0 Kudos

hi Amy

i have taken the data element LFA1-LFURL which has 132 length. I am passing the text to it as i did for MSEG-SGTXT but for MSEG-SGTXT it is displaying 45 characters and for LFA1-LFURL it is displaying 70.

Is any mistake we did while entering the text?

please suggest me ..

Former Member
0 Kudos

Hi ,

Can we try to increse the Field Length in the Field catalogue  to the Max Length you want.

Also Set the Col Width optmised = 'X' in the Layout.

In Field Cat

ls_fcat-output_len = 132.

Regards,

Amit

Former Member
0 Kudos

hi Amit

i have tried with ls_fcat-output_len = 132 and Col Width optmised = 'X' .its not working its just increasing the cell width not displaying the text.

regards

Shambuling

Former Member
0 Kudos

Hi Shambuling,

Can you check the field value in the dedugger mode .

Also try to capture the same value in the field of type char 132 .

If the char 132 field shows all the desired characters , try replacing you output table field with a variable of type char 132.

Hope this will help.

Regards,

Amit

amy_king
Active Contributor
0 Kudos

Hi Shambuling,

When you write, "I am passing the text to it as i did for MSEG-SGTXT", how are you passing the text to the ALV field? You've mentioned that you read the long text with READ_TEXT, but how do you process the text table returned by READ_TEXT to move its text to the ALV field? Are you taking just the first row of the text table? If yes, how many characters does that first row contain? When you step through debugging, is the assignment of text from READ_TEXT to the ALV field behaving as expected?

Cheers,

Amy

Former Member
0 Kudos

hi Amy

here is the read_text FM i have written

DATA: lv_tdobname TYPE tdobname,

        lt_lines TYPE TABLE OF tline,

        ls_lines TYPE tline.

  lv_tdobname+0(10) = i_ekpo-ebeln.

  lv_tdobname+10(5) = i_ekpo-ebelp.

  CALL FUNCTION 'READ_TEXT'

   EXPORTING

     id             = 'F01'

     language       = sy-langu

     name           = lv_tdobname

     object         = 'EKPO'

*      archive_handle = gf_archive_handle

   TABLES

     lines          = lt_lines

   EXCEPTIONS

     OTHERS         = 1.

  READ TABLE  lt_lines  INTO ls_lines INDEX 1.

  IF sy-subrc = 0.

    gt_data-LFURL = ls_lines-tdline.

  ENDIF.

Former Member
0 Kudos

Hi ,

Dont just read the internal table with index 1.

Bu instead loop on it and conctat into one field.

like this

data: lv_char type char 'Your Desired field length or the Max to be displayed'

loop at  lt_lines  INTO ls_lines.

concatnate lv_char ls_lines-tdline into lv_char.

endloop.

Now check

if lv_char is not initial

pass lv_char to your final output table.

endif.

Hope this will help you more.

Regards,

Amit

amy_king
Active Contributor
0 Kudos

Hi Shambuling,

By writing...

  READ TABLE  lt_lines INTO ls_lines INDEX 1.

  IF sy-subrc = 0.

    gt_data-lfurl = ls_lines-tdline.

  ENDIF.

You are assigning only the first row of the text table to gt_data-lfurl and ignoring all the rest of the text table lines. Imagine that the text table holds four lines of text...

  1. The quick red fox
  2. jumps over the
  3. lazy brown
  4. dog.

If you read only the first line of this table, you will get only the text "The quick red fox". Even though gt_data-lfurl is capable of accepting more characters, you have not written code to move more lines of text from the text table into gt_data-lfurl.

Please read my earlier post which suggested either looping through the text table and concatenating its contents together or calling function module SWA_STRING_FROM_TABLE to do the concatenation for you.

Cheers,

Amy

Former Member
0 Kudos

hi Amit

thank you very much its working and displaying the full text.

but we have concatenated so it not displaying the space bwt those two words

EX: if we have the sentence "working on SAP ABAP development" it is displaying "working on SAPABAP development" it is not displaying the space between sap ans abap.

please suggest me wht to do.?

regards

Shambuling

Former Member
0 Kudos

hi Amy

Thank you for help.

ya i got it . i followed the steps suggested by amit now its working

but we have concatenated so it not displaying the space bwt those two words

EX: if we have the sentence "working on SAP ABAP development" it is displaying "working on SAPABAP development" it is not displaying the space between sap and abap.

please suggest me wht to do.?

regards

Shambuling

Former Member
0 Kudos

Hi Shambuling,

try this,

concatnate lv_char ls_line-tdline into lv_char separated by SPACE.

Let us know if this resolves you problem.

Regards,

Amit

Former Member
0 Kudos

HI AMIT

Thank you very much for help .

its working fine.

thank you once again....

cheers

Shambuling

Former Member
0 Kudos

check your concatenate keyword.....

concatenate   .... separated by space or concatenate .... respecting blanks (use with caution).