on 01-27-2005 8:09 PM
I have created an ALV report . In the report, the requirement is to display the material name and its description whenever it changes. How can i use the at new matnr...or on change of matnr in an ALV report ..
Please help me out..
Thanking you in advance ,
Shankar
Sort your ALV by using the IT_SORT parameter. This will help you with the ALV grid. This will not help you if you want this functionality in the LIST display of the ALV grid. You cannot use the AT NEW functionality with ALV grid.
Here is a short sample of what I'm talking about.
report zrich_0007.
tables: mara.
* Global ALV Data Declarations
type-pools slis.
* Miscellanous Data Declarations
data: fieldcat type slis_t_fieldcat_alv.
* Internal Tables
data: begin of ialv occurs 0,
matnr type mara-matnr,
mtart type mara-mtart,
werks type marc-werks,
maktx type makt-maktx,
end of ialv .
select-options: s_mtart for ialv-mtart.
start-of-selection.
perform get_data.
perform call_alv.
*********************************************************************
* FORM GET_DATA.
*********************************************************************
form get_data.
select * into corresponding fields of table ialv
from mara
inner join marc
on mara~matnr = marc~matnr
where mara~mtart in s_mtart.
loop at ialv.
* Get material description
select single maktx into ialv-maktx
from makt
where matnr = ialv-matnr
and spras = sy-langu.
modify ialv.
endloop.
sort ialv ascending by matnr werks.
endform.
************************************************************************
* CALL_ALV
************************************************************************
form call_alv.
data: it_sort type slis_t_sortinfo_alv.
data: wa_sort like line of it_sort.
wa_sort-spos = '1'.
wa_sort-fieldname = 'MATNR'.
wa_sort-tabname = 'IALV'.
wa_sort-up = 'X'.
append wa_sort to it_sort.
wa_sort-spos = '2'.
wa_sort-fieldname = 'MAKTX'.
wa_sort-tabname = 'IALV'.
wa_sort-up = 'X'.
append wa_sort to it_sort.
perform build_field_catalog.
* Call ABAP List Viewer (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = fieldcat
it_sort = it_sort
tables
t_outtab = ialv.
endform.
************************************************************************
* Form BUILD_Fieldcatalog - Set Up Columns/Headers
************************************************************************
form build_field_catalog.
data: ls_fcat type slis_t_fieldcat_alv with header line.
data: columnno(3) type n value '0'.
refresh: fieldcat.
clear: ls_fcat.
ls_fcat-reptext_ddic = 'Material'.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-outputlen = '18'.
columnno = columnno + 1.
ls_fcat-col_pos = columnno.
ls_fcat-ref_fieldname = 'MATNR'.
ls_fcat-ref_tabname = 'MARA'.
append ls_fcat to fieldcat.
clear: ls_fcat.
ls_fcat-reptext_ddic = 'Plant'.
ls_fcat-fieldname = 'WERKS'.
ls_fcat-outputlen = '4'.
columnno = columnno + 1.
ls_fcat-col_pos = columnno.
append ls_fcat to fieldcat.
clear: ls_fcat.
ls_fcat-reptext_ddic = 'Description'.
ls_fcat-fieldname = 'MAKTX'.
ls_fcat-outputlen = '30'.
columnno = columnno + 1.
ls_fcat-col_pos = columnno.
append ls_fcat to fieldcat.
endform.
Regards,
Rich Heilman
Message was edited by: Rich Heilman
Message was edited by: Rich Heilman
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shankara,
Use the event 'BEFORE_LINE_OUTPUT' and write a small routine to verify if it is the same or different material and based on that you can enable or disable the description.
Another way would be to modify your internal table in such a way that only the first record per material will have the description and all other records for that material are blanked out.
Srinivas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Shankara,
Here is what you need to do.
This is the section where you will prepare the events that need to be passed on to the ALV function module.
FORM prepare_events.
data: ls_events type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
* EXPORTING
* I_LIST_TYPE = 0
importing
et_events = i_events
exceptions
list_type_wrong = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type 'I' number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
v_proceed_further = c_no.
else.
v_proceed_further = c_yes.
endif.
read table i_events into ls_events
with key name = 'BEFORE_LINE_OUTPUT'.
if sy-subrc = 0.
move 'CHECK_IF_NEW_MATERIAL' to ls_events-form.
modify i_events from ls_events transporting form
where name = 'BEFORE_LINE_OUTPUT'.
endif.
ENDFORM. " PREPARE_EVENTS
Your routine to implement the at new logic will be as follows.
FORM CHECK_IF_NEW_MATERIAL using rs_lineinfo type slis_lineinfo.
clear itab.
read table itab index rs_lineinfo-tabindex.
if sy-subrc = 0.
move itab-field to v_current_value.
if v_previous_value <> v_current_value.
write description.
else.
Do not output description.
endif.
v_previous_value = v_current_value.
endif.
ENDFORM.
I actually jumped to the conclusion that this may be helpful to you but here I used this method to force new-page in an AT-NEW situation, but I didn't think of how you will be able to modify the display record while writing out.
Regards,
Srinivas
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.