‎2007 Apr 11 12:34 PM
Hi ihave a problem in alv grid i want display the longtext which was very long in characters it contains of more than 20 lines as shown below now i want the output the <b>material number and shorttext description only one time</b> but not as many times as there are lines in the long text that is i want to delete the remaining short text and material number for a single material number.
I'm posting here my ALv grid code also pla consider it and give me solution
FORM field_catalog.
***MATERIAL NO no
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'MATNR'.
int_cat-reptext_ddic = 'MATERIAL NO'.
APPEND int_cat .
*vender name
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'MAKTX'.
int_cat-reptext_ddic = 'MATERIAL SHORT DESCRIPTION'.
APPEND int_cat .
PO No
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'TDLINE'.
int_cat-reptext_ddic = 'MATERIAL LONG DESCRIPTION'.
int_cat-outputlen = '100'.
APPEND int_cat .
endform.
&----
*& Form display_data
&----
text
----
FORM display_data.
DATA : X_SORT TYPE SLIS_SORTINFO_ALV.
DATA: IT_SORT TYPE SLIS_T_SORTINFO_ALV.
X_SORT-SPOS = '1'.
X_SORT-FIELDNAME = 'MATNR'.
X_SORT-TABNAME = 'INT_OUT'.
X_SORT-UP = 'X'.
APPEND X_SORT TO IT_SORT.
CLEAR X_SORT.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = int_cat[]
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = X_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EVENTS = IT_EVENT
IT_SORT = INT_OUT
TABLES
t_outtab = int_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "display_data
1000100000 Test material 1 1. DataSet vs DataReader
1000100000 Test material 1 # DataReader
1000100000 Test material 1 # Object to access data in a connected, forward-only, read-only
1000100000 Test material 1 fashion
1000100000 Test material 1
1000100000 Test material 1 # DataSet
1000100000 Test material 1 # Data structure to store schema and data in a disconnected fashion
1000100000 Test material 1 # Useful for editing data offline and later update to data source
1000100000 Test material 1
1000100000 Test material 1 2. What is Microsoft .NET?
1000100000 Test material 1 .NET represents an advanced new generation of software that will
1000100000 Test material 1 drive the Next Generation Internet. Its purpose is to make information
1000100000 Test material 1 available any time, any place, and on any device.
1000100000 Test material 1 Quick Definition
1000100000 Test material 1 .NET is an initiative to integrate all Microsoft products with
1000100000 Test material 1 the #Next Generation# web.
1000100000 Test material 1
1000100000 Test material 1 3. Recordset
1000100000 Test material 1
1000100000 Test material 1 ? Recordsets are generated one per table. This does not support
1000100000 Test material 1 hierarchical structure of data access. It will be programmer#s
1000100000 Test material 1 responsibility to define relationships among different recordsets.
1000100000 Test material 1 ? Rercordsets can not support data accessing from multiple sources.
1000100000 Test material 1
1000100000 Test material 1
1000100000 Test material 1 4. Connection-oriented Vs Connection-less
1000100000 Test material 1 ? Connection-oriented
1000100000 Test material 1 # Keeps the connection to the data base alive
1000100000 Test material 1 # Intended for applications with:
1000100000 Test material 1 ? short running transactions
1000100000 Test material 1 ? only a few parallel accesses
1000100000 Test material 1 ? up-to-date data
1000100000 Test material 1
1000100000 Test material 1 ? Connectionless
‎2007 Apr 11 1:11 PM
Hi Praveen,
do like this.
data: new(1).
SORT int_out.
LOOP AT int_out.
CLEAR new.
AT NEW matnr.
new = 'X'.
ENDAT.
IF new NE 'X'.
CLEAR it_out-matnr,it_out-maktx.
MODIFY it_out TRANSPORTING matnr maktx.
endif.
ENDLOOP.
‎2007 Apr 11 12:43 PM
Do u want to display the whole long text in ine field?
If so u have to increase the lenght of the field and move the text into the field.
else try giving an icon on alv and if the user clicks the icon.. displat the text in diffrent screen......
‎2007 Apr 11 1:33 PM
actually i want to display the long text and also i want only one material number and one short text that too in only 1st line as per my coding the output is displaying all the short text and material number for each and every line but i want only on 1st line can u give me suggestion plz
‎2007 Apr 11 1:45 PM
hi pavan ,
its better to go for what anil kumar reddy said for Long text and
coming to 2nd issue better to use declare a variant and pass it to function module
when write code like this after executing the programe you find one icon on top of the outdisplay in that you have to sort the fields as you want
‎2007 Apr 11 1:00 PM
Hi Pavan,
In u r code where ever u r using the long text insted of giving the text in Hot code u just give like this.
FORM field_catalog.
***MATERIAL NO no
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'MATNR'.
int_cat-reptext_ddic = 'MATERIAL NO'.
APPEND int_cat .
*vender name
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'MAKTX'.
int_cat-reptext_ddic = TEXT-001.
int_cat-datatype = 'CHAR'.
int_catt-outputlen = 132.
APPEND int_cat .
Double click on TEXT-001 and there u declare the
text : MATERIAL SHORT DESCRIPTION.
(Here Max length for text is 132 charectors)
PO No
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'TDLINE'.
int_cat-reptext_ddic = TEXT-002
int_cat-datatype = 'CHAR'.
int_catt-outputlen = 100.
APPEND int_cat .
Double click on TEXT-002 and there u declare the
text : 'MATERIAL LONG DESCRIPTION.
(Here Max length for text is 132 charectors)
endform.
Remaining Part of code is same as u done.
Give the Reward if Helpfull.
Thanks,
Anil.
‎2007 Apr 11 1:45 PM
Hi anil,
actually i want to display the long text and also i want only one material number and one short text that too in only 1st line as per my coding the output is displaying all the short text and material number for each and every line but i want only on 1st line but not to increase the length of the grid can u give me suggestion plz
‎2007 Apr 11 1:11 PM
Hi Praveen,
do like this.
data: new(1).
SORT int_out.
LOOP AT int_out.
CLEAR new.
AT NEW matnr.
new = 'X'.
ENDAT.
IF new NE 'X'.
CLEAR it_out-matnr,it_out-maktx.
MODIFY it_out TRANSPORTING matnr maktx.
endif.
ENDLOOP.
‎2007 Apr 11 1:44 PM
Hi vignesh,
i have tried with your code but the problem is by trying like that the long text has been deleted upto some extent and afterwards it has displayed again but i dont want to delete long text i want to delete short text and material no. I have to dispaly material number and short text only in the 1st line of the alv grid the remaining repeated part of the material number and short text should be deleted plzzz give me one more suggestion
‎2007 Apr 11 1:56 PM
matnr desc lontxt
001 desc1 DataSet vs DataReader
DataReader
Object to access data in
‎2007 Apr 11 1:59 PM
Hi praveen,
Can u show me the code which u have written
.Because It will not delete longtext.Please check it once again.
‎2007 Apr 11 2:15 PM
&----
*& Report ZREADTEXTTEST *
*& *
&----
*& *
*& *
&----
REPORT ZREADTEXTTEST .
tables: ekpo,MAKT.
TYPE-POOLS: slis.
DATA: thread LIKE thead.
data: P_MATNR1(15) type N.
DATA: BEGIN OF INT_MAKT OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE EKPO-WERKS,
END OF INT_MAKT.
DATA: BEGIN OF INT_EKPO OCCURS 0,
MATNR LIKE EKPO-MATNR,
WERKS LIKE EKPO-WERKS,
END OF INT_EKPO.
DATA: BEGIN OF INT_OUT OCCURS 0,
MATNR LIKE EKPO-MATNR,
MAKTX LIKE MAKT-MAKTX,
TDLINE LIKE TLINE-TDLINE,
END OF INT_OUT.
DATA: it_tlines LIKE tline OCCURS 10 WITH HEADER LINE.
**************************
****ALV list definintion
*************************
DATA: ws_cat TYPE slis_fieldcat_alv ,
int_cat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
g_custom_container TYPE REF TO cl_gui_custom_container.
*****************
*selection-screen
*****************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP 2.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 25(20) text-001.
SELECT-OPTIONS: S_MATNR FOR MAKT-MATNR obligatory.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 25(20) text-002.
*PARAMETERS:p_ebeln LIKE ekko-ebeln obligatory.
SELECT-OPTIONS: S_WERKS FOR EKPO-WERKS OBLIGATORY.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_data.
PERFORM field_catalog.
PERFORM display_data.
END-OF-SELECTION.
FORM GET_DATA.
SELECT * FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE
INT_EKPO
WHERE
EKPO~MATNR IN S_MATNR AND
EKPO~WERKS IN S_WERKS.
sort int_ekpo by werks.
delete adjacent duplicates from INT_EKPO .
SELECT MATNR MAKTX FROM MAKT
INTO CORRESPONDING FIELDS OF TABLE
INT_MAKT
FOR ALL ENTRIES IN INT_EKPO
WHERE MAKT~MATNR = INT_EKPO-MATNR.
loop at int_ekpo.
read table int_MAKT with key matnr = INT_EKPO-MATNR.
int_OUT-MATNR = INT_EKPO-MATNR.
INT_OUT-MAKTX = INT_MAKT-MAKTX.
ENDLOOP.
ENDIF.
**ENDIF.
*
**" Read text
*
*LOOP AT INT_EKPO.
thread-tdname = INT_EKPO-MATNR.
thread-tdid = 'BEST'.
thread-tdobject = 'MATERIAL'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = thread-tdid
LANGUAGE = sy-langu
NAME = thread-tdname
OBJECT = thread-tdobject
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
TABLES
LINES = it_tlines
*
.
loop at it_tlines.
IF INT_OUT-MATNR IS INITIAL.
CLEAR INT_OUT-MATNR .
ENDIF.
read table int_MAKT with key matnr = INT_EKPO-MATNR.
int_OUT-MATNR = INT_EKPO-MATNR.
INT_OUT-MAKTX = INT_MAKT-MAKTX.
int_OUT-MAKTX = int_EKPO-WERKS.
int_OUT-TDLINE = it_tlines-tdline.
APPEND INT_OUT.
endloop.
ENDFORM.
FORM field_catalog.
***MATERIAL NO no
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'MATNR'.
int_cat-reptext_ddic = 'MATERIAL NO'.
APPEND int_cat .
*material Short Description
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'MAKTX'.
int_cat-reptext_ddic = 'MATERIAL SHORT DESCRIPTION'.
APPEND int_cat .
Material Long Description
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'TDLINE'.
int_cat-reptext_ddic = 'MATERIAL LONG DESCRIPTION'.
int_cat-datatype = 'CHAR'.
int_cat-outputlen = '100'.
APPEND int_cat .
endform.
&----
*& Form display_data
&----
text
----
FORM display_data.
data: new(15) TYPE N.
*SORT int_out.
LOOP AT int_out.
CLEAR new.
AT NEW MATNR.
new = INT_OUT-MATNR.
ENDAT.
IF new = INT_OUT-MATNR.
CLEAR int_out-matnr.
clear int_out-maktx.
MODIFY int_out TRANSPORTING matnr maktx.
endif.
ENDLOOP.
*Loop at INT_OUT .
*
*if int_out-matnr = ' ' .
*data: temp like makt-matnr.
At new matnr.
*Temp = int_out-matnr.
*If int_out-matnr = temp.
clear int_out-matnr .
*Endif.
*
*Continue.
*Endat.
*
*endif.
*endloop.
*
*
*
*DATA : WTAB LIKE INT_OUT,
FLAG.
*LOOP AT INT_OUT.
*AT NEW MATNR.
*CLEAR FLAG .
*ENDAT.
*
*IF FLAG = 'X'.
*INT_OUT-MATNR = ''.
*INT_OUT-MAKTX = ''.
*clear int_out-matnr.
*MODIFY INT_OUT.
*ENDIF.
*FLAG = 'X'.
*
*ENDLOOP.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = int_cat[]
IT_SORT = IT_SORT
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = X_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EVENTS = IT_EVENT
IT_SORT = INT_OUT
TABLES
t_outtab = int_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "display_data
‎2007 Apr 11 2:32 PM
Hi..,
<b>Previously i got the same program from one of our users to my mail. and i have solved his problem...
am pasting here the same code that i have modified and solved in that program !!!
these two are same it seems !!
Check if both are equal..</b>
tables: ekpo,MAKT.
TYPE-POOLS: slis.
DATA: thread LIKE thead.
DATA: BEGIN OF INT_MAKT OCCURS 0,
MATNR LIKE MAKT-MATNR,
MAKTX LIKE MAKT-MAKTX,
END OF INT_MAKT.
DATA: BEGIN OF INT_EKPO OCCURS 0,
MATNR LIKE EKPO-MATNR,
WERKS LIKE EKPO-WERKS,
END OF INT_EKPO.
DATA: BEGIN OF INT_OUT OCCURS 0,
MATNR LIKE EKPO-MATNR,
MAKTX LIKE MAKT-MAKTX,
WERKS LIKE EKPO-WERKS,
TDLINE LIKE TLINE-TDLINE,
END OF INT_OUT.
DATA: it_tlines LIKE tline OCCURS 10 WITH HEADER LINE.
**************************
****ALV list definintion
*************************
DATA: ws_cat TYPE slis_fieldcat_alv ,
int_cat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',
g_custom_container TYPE REF TO cl_gui_custom_container.
*****************
*selection-screen
*****************
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP 2.
select-options: s_MATNR for EKPO-MATNR obligatory.
SELECT-OPTIONS: s_WERKS FOR EKPO-WERKS OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_data.
PERFORM field_catalog.
PERFORM display_data.
END-OF-SELECTION.
FORM GET_DATA.
SELECT MATNR WERKS FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE
INT_EKPO
WHERE
EKPO~WERKS in s_WERKS.
sort int_ekpo by werks.
delete adjacent duplicates from INT_EKPO .
SELECT * FROM MAKT INTO CORRESPONDING FIELDS OF TABLE
INT_MAKT
FOR ALL ENTRIES IN INT_EKPO
WHERE MAKT~MATNR = INT_EKPO-MATNR.
**" Read text
*
LOOP AT INT_EKPO.
thread-tdname = INT_EKPO-MATNR.
thread-tdid = 'BEST'.
thread-tdobject = 'MATERIAL'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = thread-tdid
LANGUAGE = sy-langu
NAME = thread-tdname
OBJECT = thread-tdobject
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
TABLES
LINES = it_tlines
*
.
loop at it_tlines.
read table int_MAKT with key matnr = INT_EKPO-MATNR.
int_OUT-MATNR = INT_EKPO-MATNR.
INT_OUT-MAKTX = INT_MAKT-MAKTX.
int_OUT-MAKTX = int_EKPO-WERKS.
int_OUT-TDLINE = it_tlines-tdline.
APPEND INT_OUT.
endloop.
ENDLOOP.
ENDFORM.
FORM field_catalog.
***MATERIAL NO no
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'MATNR'.
int_cat-reptext_ddic = 'MATERIAL NO'.
APPEND int_cat .
*vender name
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'MAKTX'.
int_cat-reptext_ddic = 'MATERIAL SHORT DESCRIPTION'.
APPEND int_cat .
PO No
int_cat-tabname = 'INT_OUT'.
int_cat-fieldname = 'TDLINE'.
int_cat-reptext_ddic = 'MATERIAL LONG DESCRIPTION'.
APPEND int_cat .
endform.
&----
*& Form display_data
&----
text
----
FORM display_data.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
it_fieldcat = int_cat[]
TABLES
t_outtab = int_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM. "display_data
regards,
sai ramesh
‎2007 Apr 11 2:38 PM
Hi praveen ,
just do like this this will work.And also There is no need for 'at new matnr' part of the code
which i said last time.
FORM get_data.
SELECT * FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE
int_ekpo
WHERE
ekpo~matnr IN s_matnr AND
ekpo~werks IN s_werks.
SORT int_ekpo BY werks.
DELETE ADJACENT DUPLICATES FROM int_ekpo .
SELECT matnr maktx FROM makt
INTO CORRESPONDING FIELDS OF TABLE
int_makt
FOR ALL ENTRIES IN int_ekpo
WHERE makt~matnr = int_ekpo-matnr.
LOOP AT int_ekpo.
READ TABLE int_makt WITH KEY matnr = int_ekpo-matnr.
int_out-matnr = int_ekpo-matnr.
int_out-maktx = int_makt-maktx.
thread-tdname = int_ekpo-matnr.
thread-tdid = 'BEST'.
thread-tdobject = 'MATERIAL'.
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = thread-tdid
language = sy-langu
name = thread-tdname
object = thread-tdobject
TABLES
lines = it_tlines.
LOOP AT it_tlines.
IF sy-tabix <> 1.
CLEAR :int_out-matnr, int_out-maktx.
ENDIF.
int_out-tdline = it_tlines-tdline.
APPEND int_out.
ENDLOOP.
ENDLOOP.
ENDFORM. "GET_DATA
‎2007 Apr 11 2:50 PM