Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Read text fun module

Hi I have developed a report to display all the long texts like Sales text, Basic text , PO text using material in seleciton screen. For this i have used READ_TEXT funcmodule and able to display on the output screen. But the problem is , In the output display last part of the long text is missing ...but it is there in final internal table..it is only allowing 128 characters long inthe output field and remaining was not printing .

field catalog i have adjusted the size but it is not working....

the entire code is this:

&----


*& Report ZSG_READ_LONG_TEXT

&----


*&

&----


REPORT ztext .

----


  • PROGRAM ID : ZSG_READ_LONG_TEXT

  • TITLE : Display text field for download

  • CREATE DATE : 17-10-2008

  • AUTHOR : Suresh Nittala

----


  • DESCRIPTION : To be able to download and view long text

----


  • Authorisation checks

  • -----------------------------------------------------------------------*

  • Object Authority Fields ABAP Fields

  • -----------------------------------------------------------------------*

  • | |

----


  • CHANGE HISTORY

----


  • DATE | NAME | DESCRIPTION | Reference

----


  • | |

----


TABLES: mara,

marc,

t001k,

makt,

tvkwz.

TYPE-POOLS: slis.

DATA : BEGIN OF it_mara OCCURS 0,

matnr LIKE mara-matnr,

mtart LIKE mara-mtart,

matkl LIKE mara-matkl,

werks LIKE marc-werks,

maktx LIKE makt-maktx,

END OF it_mara.

DATA : wa_mara LIKE LINE OF it_mara.

DATA: BEGIN OF it_text OCCURS 0,

matnr LIKE marc-matnr, "Materia No

maktx LIKE makt-maktx, "Material Desc

vkorg LIKE tvkwz-vkorg,

vtweg LIKE tvkwz-vtweg,

ltext TYPE string,

END OF it_text.

DATA : wa_text LIKE LINE OF it_text.

DATA : lv_obj_name LIKE thead-tdname,

lv_obj_id LIKE thead-tdid,

lv_object LIKE thead-tdobject,

lv_vkorg LIKE tvkwz-vkorg,

lv_vtweg LIKE tvkwz-vtweg,

it_line LIKE tline OCCURS 0 WITH HEADER LINE.

DATA : wa_line LIKE LINE OF it_line.

DATA : gv_maktx1 TYPE string,

gv_maktx2 TYPE string,

gv_maktx TYPE string,

gv_text TYPE string,

gv_language TYPE ddlanguage,

gv_lines TYPE i.

DATA : it_fieldcat TYPE slis_t_fieldcat_alv,

i_fieldcat LIKE LINE OF it_fieldcat,

k_repid LIKE sy-repid,

v_events TYPE slis_t_event,

wa_event TYPE slis_alv_event.

DATA : gt_list_top_of_page TYPE slis_t_listheader,

gt_events TYPE slis_t_event,

gc_formname_top_of_page TYPE slis_formname VALUE 'ALV_TOP_OF_PAGE',

c_save TYPE c VALUE 'A',

c_alv_struct LIKE dd02l-tabname VALUE 'TYP_FINAL',

gs_layout TYPE slis_layout_alv,

c_alv_command TYPE slis_formname VALUE 'ALV_USER_COMMAND'.

*----


  • SELECTION-SCREEN

*----


SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.

SELECT-OPTIONS : so_matnr FOR mara-matnr , "material

so_mtart FOR mara-mtart, "MaterialType

so_matkl FOR mara-matkl. "Material group

SELECTION-SCREEN END OF BLOCK blk1.

SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-002.

PARAMETERS : rb_btext RADIOBUTTON GROUP rad1,

rb_stext RADIOBUTTON GROUP rad1,

rb_ptext RADIOBUTTON GROUP rad1.

PARAMETERS : p_langu LIKE sy-langu DEFAULT 'EN'. "Companycode

SELECTION-SCREEN END OF BLOCK blk2.

----


  • INITIALIZATION

----


INITIALIZATION.

  • PERFORM build_top_of_page.

*

  • PERFORM alv_build_event.

----


  • START-OF-SELECTION

----


START-OF-SELECTION.

PERFORM build_top_of_page.

PERFORM alv_build_event.

PERFORM get_data.

----


  • END-OF-SELECTION

----


END-OF-SELECTION.

  • Display data on ALV screen

PERFORM display_output.

&----


*& Form GET_DATA

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data .

  • Get the material.

SELECT amatnr amtart amatkl bwerks c~maktx INTO CORRESPONDING

FIELDS OF TABLE it_mara FROM mara AS a

INNER JOIN marc AS b ON bmatnr = amatnr

INNER JOIN makt AS c ON cmatnr = amatnr

WHERE a~matnr IN so_matnr AND

a~mtart IN so_mtart AND

a~matkl IN so_matkl AND

c~spras = p_langu.

CLEAR : wa_mara.

LOOP AT it_mara INTO wa_mara.

IF rb_stext = 'X'. " FOR SALES TEXT

SELECT SINGLE vkorg vtweg INTO (lv_vkorg, lv_vtweg)

FROM tvkwz WHERE vtweg = '01' AND

werks = wa_mara-werks.

REFRESH it_line.

CLEAR : wa_text,lv_obj_id,lv_object,lv_obj_name,it_line,gv_text.

lv_obj_id = '0001'.

lv_object = 'MVKE'.

CONCATENATE wa_mara-matnr lv_vkorg lv_vtweg

INTO lv_obj_name RESPECTING BLANKS.

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = lv_obj_id

language = sy-langu

name = lv_obj_name

object = lv_object

archive_handle = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

lines = it_line

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.

LOOP AT it_line INTO wa_line.

IF wa_line-tdline IS NOT INITIAL.

CONCATENATE gv_text wa_line-tdline

INTO gv_text RESPECTING BLANKS.

ENDIF.

ENDLOOP.

CONDENSE gv_text.

ENDIF.

ELSEIF rb_btext = 'X'. " FOR BASIC TEXT

REFRESH it_line.

CLEAR : wa_text,lv_obj_id,lv_object,lv_obj_name,it_line,gv_text.

lv_obj_id = 'GRUN'.

lv_object = 'MATERIAL'.

lv_obj_name = wa_mara-matnr.

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = lv_obj_id

language = sy-langu

name = lv_obj_name

object = lv_object

archive_handle = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

lines = it_line

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.

LOOP AT it_line INTO wa_line.

IF wa_line-tdline IS NOT INITIAL.

CONCATENATE gv_text wa_line-tdline

INTO gv_text RESPECTING BLANKS.

ENDIF.

ENDLOOP.

CONDENSE gv_text.

ENDIF.

ELSEIF rb_ptext = 'X'. " PO TEXT

REFRESH it_line.

CLEAR : wa_text,wa_line, lv_obj_id, lv_object,gv_text.

lv_obj_id = 'BEST'.

lv_object = 'MATERIAL'.

lv_obj_name = wa_mara-matnr.

CALL FUNCTION 'READ_TEXT'

EXPORTING

client = sy-mandt

id = lv_obj_id

language = sy-langu

name = lv_obj_name

object = lv_object

archive_handle = 0

  • LOCAL_CAT = ' '

  • IMPORTING

  • HEADER =

TABLES

lines = it_line

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.

LOOP AT it_line INTO wa_line.

IF wa_line-tdline IS NOT INITIAL.

CONCATENATE gv_text wa_line-tdline

INTO gv_text RESPECTING BLANKS.

ENDIF.

ENDLOOP.

CONDENSE gv_text.

ENDIF.

ENDIF.

MOVE wa_mara-matnr TO wa_text-matnr.

MOVE wa_mara-maktx TO wa_text-maktx.

MOVE gv_text TO wa_text-ltext.

MOVE lv_vkorg TO wa_text-vkorg.

MOVE lv_vtweg TO wa_text-vtweg.

APPEND wa_text TO it_text.

CLEAR : wa_text.

ENDLOOP.

ENDFORM. " GET_DATA

&----


*& Form DISPLAY_OUTPUT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM display_output .

k_repid = sy-repid.

PERFORM field_catalog.

  • PERFORM event_call.

PERFORM alv_display.

ENDFORM. " DISPLAY_OUTPUT

&----


*& Form FIELD_CATALOG

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM field_catalog .

DATA: lv_col TYPE i.

lv_col = 0.

IF rb_stext = 'X'.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 10.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'MATNR'.

i_fieldcat-seltext_l = 'material'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'C'.

APPEND i_fieldcat TO it_fieldcat.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 30.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'MAKTX'.

i_fieldcat-seltext_l = 'material description'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'C'.

APPEND i_fieldcat TO it_fieldcat.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 5.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'VKORG'.

i_fieldcat-seltext_l = 'Sales Org'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'C'.

APPEND i_fieldcat TO it_fieldcat.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 4.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'VTWEG'.

i_fieldcat-seltext_l = 'dis ch'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'C'.

APPEND i_fieldcat TO it_fieldcat.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 150.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'LTEXT'.

i_fieldcat-seltext_l = 'Long text'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'STRING'.

APPEND i_fieldcat TO it_fieldcat.

ELSEIF rb_btext = 'X'.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 10.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'MATNR'.

i_fieldcat-seltext_l = 'material'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'C'.

APPEND i_fieldcat TO it_fieldcat.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 30.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'MAKTX'.

i_fieldcat-seltext_l = 'material description'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'C'.

APPEND i_fieldcat TO it_fieldcat.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 150.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'LTEXT'.

i_fieldcat-seltext_l = 'Long text'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'STRING'.

APPEND i_fieldcat TO it_fieldcat.

  • lv_col = lv_col + 1.

  • CLEAR i_fieldcat.

  • i_fieldcat-col_pos = lv_col.

  • i_fieldcat-fieldname = 'LTEXT'.

  • i_fieldcat-tabname = 'IT_text'.

  • i_fieldcat-reptext_ddic = 'Value Total Cod 6190'(025).

  • i_fieldcat-outputlen = 150.

  • i_fieldcat-intlen = 150.

  • i_fieldcat-ddic_outputlen = 150.

  • APPEND i_fieldcat TO it_fieldcat.

ELSEIF rb_ptext = 'X'.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 10.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'MATNR'.

i_fieldcat-seltext_l = 'material'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'C'.

APPEND i_fieldcat TO it_fieldcat.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 30.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'MAKTX'.

i_fieldcat-seltext_l = 'material description'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'C'.

APPEND i_fieldcat TO it_fieldcat.

lv_col = lv_col + 1.

CLEAR i_fieldcat.

i_fieldcat-outputlen = 150.

i_fieldcat-tabname = 'IT_text'.

i_fieldcat-fieldname = 'LTEXT'.

i_fieldcat-seltext_l = 'Long text'.

i_fieldcat-col_pos = lv_col.

i_fieldcat-datatype = 'STRING'.

APPEND i_fieldcat TO it_fieldcat.

ENDIF.

ENDFORM. " FIELD_CATALOG

&----


*& Form ALV_BUILD_EVENT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM alv_build_event .

DATA: ls_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = gt_events.

READ TABLE gt_events WITH KEY name = slis_ev_top_of_page

INTO ls_event.

IF sy-subrc = 0.

MOVE gc_formname_top_of_page TO ls_event-form.

APPEND ls_event TO gt_events.

ENDIF.

ENDFORM. " ALV_BUILD_EVENT

&----


*& Form ALV_DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM alv_display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = k_repid

  • i_callback_user_command = c_alv_command

i_structure_name = c_alv_struct

is_layout = gs_layout

it_fieldcat = it_fieldcat[]

i_save = c_save

it_events = gt_events[]

TABLES

t_outtab = it_text

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDFORM. " ALV_DISPLAY

&----


*& Form BUILD_TOP_OF_PAGE

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_top_of_page .

DATA: ls_line TYPE slis_listheader.

CLEAR gt_list_top_of_page.

CLEAR ls_line.

ls_line-typ = 'H'.

ls_line-key = ''.

  • ls_line-info = 'Basic,Sales,PO Text'.

IF rb_btext EQ 'X'.

ls_line-info = 'Basic Text'.

ELSEIF rb_stext EQ 'X'.

ls_line-info = 'Sales Text'.

ELSEIF rb_ptext EQ 'X'.

ls_line-info = 'PO Text'.

ENDIF.

APPEND ls_line TO gt_list_top_of_page.

ls_line-typ = 'S'.

ls_line-key = 'User :'.

ls_line-info = sy-uname.

APPEND ls_line TO gt_list_top_of_page.

ls_line-typ = 'S'.

ls_line-key = 'Date :'.

WRITE sy-datum TO ls_line-info.

APPEND ls_line TO gt_list_top_of_page.

ENDFORM. " BUILD_TOP_OF_PAGE

&----


*& Form ALV_TOP_OF_PAGE

&----


  • ALV top of page

----


  • --> p1 text

  • <-- p2 text

----


FORM alv_top_of_page.

*Write the report header for event "top of page"

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = gt_list_top_of_page.

ENDFORM. " ALV_TOP_OF_PAGE

Tags:
Not what you were looking for? View more on this topic or Ask a question