Change an ALV list to ALV grid !!
Hi Everybody!
Please, I need some ideas to change an ALV List to an ALV Grid. I think its not to difficult but I don´t now how to do it. I'm newbie
Or if you have some manual or function.. or anythink
Thanks so much !!
JC
Hey.. thanks to all of you.. IT Works !! lol.. i'm happy.. my first modifying program..
First I use a radio button to select a list or a grid..
<i>selection-screen begin of block blk3 with frame title text-002.
parameter:
Lista radiobutton group g1,
Grid radiobutton group g1.
selection-screen end of block blk3.</i>
then use a, if
<i>if ALV = 'X'.
PERFORM REPORT_ALV.
PERFORM DATOS_ALV.
Else.
LOOP AT ZPERNR.</i>
then..
<i>PERFORM DATOS_ALV.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
bla bla..</i>
and each field like this..
<i>FORM ALV_RUT.
ADD 1 TO COL_POS.
CLEAR FIELDCAT_LN.
fieldcat_LN-DDICTXT = 'L'.
fieldcat_LN-OUTPUTLEN = 12.
fieldcat_LN-SELTEXT_L = 'RUT'.
fieldcat_LN-SELTEXT_M = 'RUT'.
fieldcat_LN-SELTEXT_S = 'RUT'.
FIELDCAT_LN-REF_TABNAME = 'ZPERNR'.
FIELDCAT_LN-FIELDNAME = 'RUT'.
APPEND FIELDCAT_LN TO FIELDCAT.
ENDFORM.</i>
It took me some time and need some improve, but works
Once more, Thanks to all. For your help.
Regards,
Jessica
Similar Messages
-
Whi is the winner? ALV LIst or ALV Grid OO?
Hi Guys,
Hope you are all well.
My company is still mostly using the ALV List Function Modules when creating reports. Yes, they are using the SLIS pools.
I have written a template program for them to start doing things the OO way. That is to say, using ALV Grid Objects.
We are now thinking of COMPLETELY going over into ALV Grid Objects, but some of us are still arguing which one is best?
The biggest argument is :
Is ALV too "expensive" with regards to using system recources?
Please give me your thoughts as Im all for going for OO, but I would understand if it would make things slower.
Points will be awarded for useful arguments.
tks
ChristiaanSLIS is OLD, OBSOLETE DINOSAUR technology.
With the new classes you can create new reports really quickly and easily and add all sorts of functionality to them.
There's a small learning curve -- but what ought to appeal to management is that once you get the hang of it you can produce a report in hours (or even minutes) which done in the old way could take a week or more.
These days Human development time is far far more expensive than machine time so there's NO CONTEST.
The advantages in general of OO are too numerous to list here but if you look at the sample code I've listed here you can see how easy and quicklly you can get an application up and running even if you haven't got my Z_class definition listed in the program (it's a global class now defined with SE24).
With either cl_gui_alv_grid or even easier (if you don't need edit capability) the salv_table type class it only takes a few lines to code your program and display the grid.
All you ever now need to do in an alv program is the following.
1) define your data structures
2) use RTTI to generate dynamic field catalog from your data structures
3) create dynamic table
4) populate it
5) display grid.
You should have all the events etc you need such as cell selection etc etc.
Your whole code could be quite small.
For example I've got a generalized Z_cLass for my alv grid.
Now here's a sample program to display program names in the system. When I double click a program SE38 is entered and on exit unlike the standard sap transaction my list is re-displayed where I can choose another program.
Note how small the code is.
You won't be able to copy and run this program directly as you'll need the Z_class definitions.
In this Z_class there's also functionality for ON data change, multiple cell selection , toolbar additions etc.
These methods are available to EVERY program calling the class.
If you need the extra functionality using SLIS you have to program it in every time for each individual program.
You can therefore concentrate in your application program on just getting the data and displaying it. All the complicated functionality is in the Z_class.
Incidently using ALV classes can also render the whole idea of classical dynpros with Table controls as also obsolete.
program zzjimboprogs.
tables : trdirt.
include my_zdata. "data references to my Z_Class etc.
* Front end to call SE38 Program list
* When you use the search Program facility in SE38
* the system loses the LIST after you choose a program and enter
* transaction SE38
* double click on the Program module you want SE38 to use.
* After exiting SE38 you will return to the list .
types: begin of s_elements,
name type trdirt-name,
text type trdirt-text,
end of s_elements.
data: progname type trdirt-name.
data: wa_elements type s_elements.
selection-screen begin of block one with frame title text-t01.
select-options: s_prog for trdirt-name obligatory.
selection-screen end of block one.
at selection-screen.
initialization.
invoker = sy-repid. "Name of calling program for alv class.
start-of-selection.
create data dref type s_elements.
assign dref->* to <fs>.
i_gridtitle = 'Program List'.
invoker = sy-repid.
i_zebra = ' '.
i_edit = 'X'.
create object z_object
exporting
z_object = z_object
cfname = 'CCONTAINER1'.
assign z_object to <fs1>.
i_object = <fs1>.
call method i_object->build_dynamic_structures
exporting
my_line = <fs>
calling_program = invoker
importing
dy_table = dy_table
changing
it_fldcat = it_fldcat.
perform populate_dynamic_itab
changing dy_table.
perform modify_fldcat.
i_screen = '100'.
i_text = 'Prog List'.
perform display_grid
using
i_screen
i_text
it_fldcat
<dyn_table>.
end-of-selection.
form populate_dynamic_itab changing dy_table.
assign dy_table->* to <dyn_table>.
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
select *
from trdirt
into corresponding fields of table <dyn_table>
where name in s_prog
and sprsl eq sy-langu.
endform.
form display_grid
using i_screen
i_text
field_catalog
dynamic_table.
call method i_object->display_data
exporting
i_gridtitle = i_gridtitle
i_edit = ' '
i_zebra = ' '
i_opt = ' '
title_text = i_text
program = invoker
screen_number = i_screen
z_object = i_object
changing
it_fldcat = field_catalog
gt_outtab = dynamic_table
e_ucomm = e_ucomm.
if e_ucomm = 'BACK'.
leave to screen 0.
else.
leave program.
endif.
endform.
form verwerk.
endform.
form refresh.
call method i_object->refresh_grid.
endform.
form dubbelklik using
e_row type lvc_s_row
e_column type lvc_s_col
es_row_no type lvc_s_roid.
read table <dyn_table> index e_row into wa_elements.
progname = wa_elements-name.
set parameter id 'RID' field progname.
call transaction 'SE38'.
perform refresh.
row_number-row_id = e_row.
call method z_object->set_cell
exporting
e_column = e_column
es_row_no = row_number.
endform.
form modify_fldcat.
col_name it_fldcat 1 'Programe' 25.
col_name it_fldcat 2 'description' 50.
endform. -
Problems converting ALV LIST to ALV GRID
Hey guys
when i changed the name of the function REUSE_ALV_LIST_DISPLAY to REUSE_ALV_GRID_DISPLAY..in a report..I get the GRID in next page..
whys is it so??
like the rpeort has the the ALV to be displayed in END_OF_LIST event...(the report has oen HIERARCHIAL ALV as the main ALV LIST and in the END OF LIST it has another ALV)
when i change LIST to GRID ...
the GRID gets itno 2nd page while the rest of the report gets into page 1...
i want both these in 1st page onlyyou can do it with blocks, but the whole thing will be in list mode
REUSE_ALV_BLOCK_LIST_INIT
REUSE_ALV_BLOCK_LIST_HS_APPEND (for hierarchical list)
REUSE_ALV_BLOCK_LIST_APPEND (for simple grid list)
REUSE_ALV_BLOCK_LIST_DISPLAY -
Question reg. converting code from ALV list to ALV grid
I created a report based on a code posted by an SDN user in ABAP forums. The code is below. Now I want to create the same functionality using ALV grid and not simple ALV list. Can you please tell me what modifications to be done to the below coding?
Appreciate your help and input.
Thanks a lot,
Krishen
******************Code start*******************
**Change required before executing the report..
1)
Create a GUI status for the program in SE41 by copying
from the program SAPLKKBL and Status 'STANDARD'..
and store the resulting in status 'TEST2'.
2)
I have used table name as ZTABLE..Change accordingly
to your ztable name..
**Endchange
declarations.
TABLES: ztable.
TYPE-POOLS: slis.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA: s_layout TYPE slis_layout_alv.
DATA: BEGIN OF t_ztable OCCURS 0.
INCLUDE STRUCTURE ztable.
DATA: BOX TYPE c,
END OF t_ztable.
DATA: v_repid TYPE syrepid.
selection screen
SELECT-OPTIONS so_id for ztable-id.
SELECT-OPTIONS so_date for ztable-date.
start-of-selection.
Get the data.
SELECT * FROM ztable
INTO TABLE t_ztable.
where id in so_id
and date in so_date.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'No data found'.
LEAVE LIST-PROCESSING.
ENDIF.
v_repid = sy-repid.
Get the field catalog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = v_repid
i_structure_name = 'ZTABLE'
CHANGING
ct_fieldcat = t_fieldcatalog.
Set the layout.
s_layout-box_fieldname = 'BOX'.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fieldcatalog[]
TABLES
t_outtab = t_ztable.
FORM SET_PF_STATUS *
--> EXTAB *
FORM set_pf_status USING extab TYPE slis_t_extab.
SET PF-STATUS 'TEST2'.
ENDFORM.
FORM user_command *
--> UCOMM *
--> SELFIELD *
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
Check the ucomm.
IF ucomm = 'DELETE'.
LOOP AT t_ztable WHERE box = 'X'.
DELETE FROM ztable WHERE matnr = t_ztable-matnr.
COMMIT WORK.
DELETE t_ztable.
ENDLOOP.
ENDIF.
selfield-refresh = 'X'.
ENDFORM.
**********Code ending**********************I believe that the only change would be to replace the work LIST with GRID in the function call.
CALL FUNCTION 'REUSE_ALV_<b>GRID</b>_DISPLAY'
EXPORTING
i_callback_program = v_repid
is_layout = s_layout
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
it_fieldcat = t_fieldcatalog[]
TABLES
t_outtab = t_ztable.
The function module interface should be exactly the same.
Regards,
Rich Heilman -
Need class name to display ALV list (not Grid) in objects..
hi,
i need to display ALV list ( not ALV Grid ) in objects.. i dont the class name for tat.. so plz can anyone help me out for the same..
thanks in advance..With cl_salv_table you can have both grid or list, depending what you want.
cl_salv_table=>factory(
EXPORTING
list_display = 'X' "when space then GRID, when 'X' then LIST
IMPORTING
r_salv_table = ref_table
CHANGING
t_table = gt_sflight ).
Regards
Marcin -
ALV Grid and ALV List difference?
Hello,
Can you help me differentiate ALV List and ALV grid and the low-level definition or context of each?
Also, can you give me a transaction code that outputs an ALV list as well as a tcode for ALV grid?
Thanks,
JennahHi Kirtish,
Thanks but I havent done any function module stuff as I am not an ABAPer but anyway can you guide me through thios?
"I hope this might slove your query. For more please refer to documentation on ALV and also implement the ALV LIST and GRID reports. By using class Class CL_GUI_ALV_GRID, Function module REUSE_ALV_LIST_DISPLAY , REUSE_ALV_GRID_DISPLAY and some more functions like that only."
I will give you some tcode can you please try tcode FBL1n? then execute the report. What is the output is it an ALV list?
I wish to see an ALV list also an ALV grid to see difference.
Tjhakns,
Jennah -
How can I fixed alv list?
how can I fixed alv list?
alv list always change size(scaled) I mean cannot fixed
I did using some parameters following .I want to fixed the length of ALV column but still not work.
fieldcat_ln-intlen = 13
fieldcat_ln-outputlen = 13.
becuase I need to know print size and so on etc..
What I have to do? anything wrong?Hi Yi,
1. If u are talking about fixing
the size of the column,
then u are right.
outputlen is the right property.
2. Along with that we need to do one more thing.
This is regarding the column heading
which appears either LONG, SHORt, MEDIUM,
from the data element defition.
set ddictxt = M
or L, S (short)
Regards,
Amit M. -
Dear Expert,
I am new to OOPS ,
I want to display drop down list for a particular field in my output, so I am using OOPS but in my below code
I am facing problem in displaying the output as I am getting the error message
Field catalog not found...
Also advice me how to display drop down list in a particular field.
Please advice
MODULE pbo OUTPUT.
SET PF-STATUS 'ZTEST'.
IF g_custom_container IS INITIAL.
DATA: lt_exclude TYPE ui_functions,
lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
CREATE OBJECT g_custom_container
EXPORTING
container_name = g_container.
CREATE OBJECT g_grid
EXPORTING
i_parent = g_custom_container.
PERFORM field_catalog TABLES it_lvc_t_fcat
USING: 'S_FINAL' 'MATNR' ' ' 'Part Number' ' ' ' ',
'S_FINAL' 'MAKTX' ' ' 'Part Description' ' ' ' ',
'S_FINAL' 'MBLNR' ' ' 'Document No' ' ' ' ',
'S_FINAL' 'BLDAT' ' ' 'Document date' ' ' ' ',
'S_FINAL' 'LIFNR' ' ' 'Vendor Number' ' ' ' ',
'S_FINAL' 'STATUS' ' ' 'Acknowledgement' ' ' 'X',
'S_FINAL' 'REMARKS' ' ' 'Remarks' ' ' 'X'.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
* I_STRUCTURE_NAME =
is_layout = it_lvc_s_layo
CHANGING
it_outtab = i_final
it_fieldcatalog = it_lvc_t_fcat
ENDIF.
ENDMODULE. " PBO OUTPUT
FORM field_catalog TABLES t_field_catalog STRUCTURE wt_lvc_s_fcat
USING fp_tabname TYPE any
fp_fieldname TYPE any
fp_key TYPE any
fp_text TYPE any
fp_do_sum TYPE any
fp_edit TYPE any.
t_field_catalog-tabname = fp_tabname.
t_field_catalog-fieldname = fp_fieldname.
t_field_catalog-key = fp_key.
t_field_catalog-seltext = fp_text.
t_field_catalog-do_sum = fp_do_sum .
t_field_catalog-edit = fp_edit .
ENDFORM. "field_catalog
Edited by: Karthik R on Mar 15, 2010 6:11 PMHi Karthik,
Below mentioned is a Simple code for creating dropdown lists for columns in ALV grid output
REPORT z_alv_dropdown.
*Type pools declarations for ALV
TYPE-POOLS : slis.
*data declarations for ALV container, ALV grid, Field catalogues & layout
DATA: g_grid TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container,
gt_fieldcat TYPE lvc_t_fcat,
gs_layout TYPE lvc_s_layo.
*INTERNAL TABLE AND WA DECLARATIONS FOR t517 A table
DATA: gt_outtab TYPE STANDARD TABLE OF t517a INITIAL SIZE 0,
wa_outtab TYPE t517a.
*initialisation event
INITIALIZATION.
*Start of selection event
START-OF-SELECTION.
*Call to ALV
CALL SCREEN 600.
*On this statement double click it takes you to the screen painter SE51.
*Create a Custom container and name it CCONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.
PBO of the actual screen , Here we can give a title and customized menus
Here we also call the subroutine for ALV output.
MODULE PBO OUTPUT *
MODULE pbo OUTPUT.
set pf-status 'xxx'.
set titlebar 'MAIN100'.
Subroutine to display the output in alv
PERFORM alv_output.
ENDMODULE. "pbo OUTPUT
PAI module of the screen created. In case we use an interactive ALV or
*for additional functionalities we can create OK codes and
based on the user command we can do the coding.
MODULE PAI INPUT *
MODULE pai INPUT.
ENDMODULE. "pai INPUT
*& Form BUILD_FIELDCAT
FORM build_fieldcat.
DATA ls_fcat TYPE lvc_s_fcat.
*Build the field catalogue
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'T517A'
CHANGING
ct_fieldcat = gt_fieldcat.
To assign dropdown in the fieldcataogue
LOOP AT gt_fieldcat INTO ls_fcat.
CASE ls_fcat-fieldname.
WHEN 'SLART'.
*drdn-hndl = '1' is the first list box
ls_fcat-drdn_hndl = '1'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
*drdn-hndl = '2' is the second list box
WHEN 'ABART'.
ls_fcat-drdn_hndl = '2'.
ls_fcat-outputlen = 15.
MODIFY gt_fieldcat FROM ls_fcat.
ENDCASE.
ENDLOOP.
ENDFORM. "build_fieldcat
*& Form ALV_OUTPUT
FORM alv_output .
*Create object for container
CREATE OBJECT g_custom_container
EXPORTING container_name = 'CCONT'.
*create object for grid
CREATE OBJECT g_grid
EXPORTING i_parent = g_custom_container.
Build fieldcat and set column
*Assign a handle for the dropdown listbox.
PERFORM build_fieldcat.
*Build layout
PERFORM build_layout.
Define a drop down table.
PERFORM dropdown_table.
*fetch values from the T517A table
SELECT * FROM t517a INTO TABLE gt_outtab.
*Display ALV output
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab.
ENDFORM. "ALV_OUTPUT
*& Form dropdown_table
text
--> p1 text
<-- p2 text
FORM dropdown_table.
*Declarations for drop down lists in ALV.
DATA: lt_dropdown TYPE lvc_t_drop,
ls_dropdown TYPE lvc_s_drop.
First SLART listbox (handle '1').
ls_dropdown-handle = '1'.
ls_dropdown-value = '01 Pink'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '02 Yellow'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '03 Green'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '04 Black'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '05 White'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '06 Blue'.
APPEND ls_dropdown TO lt_dropdown.
ls_dropdown-handle = '1'.
ls_dropdown-value = '09 Other Colors'.
APPEND ls_dropdown TO lt_dropdown.
*method to display the dropdown in ALV
CALL METHOD g_grid->set_drop_down_table
EXPORTING
it_drop_down = lt_dropdown.
ENDFORM. " dropdown_table
*& Form build_layout
text
*layout for ALV output
FORM build_layout .
gs_layout-cwidth_opt = 'X'.
gs_layout-grid_title = 'ALV DROPDOWN LISTS'.
gs_layout-no_toolbar = 'X'.
ENDFORM. " build_layout
Hope it is helpful,
Regards,
Soundarya. -
Hi,
My program output is in ALV format either LIST or GRID based on Sy-batch.
In that program they are using table Z1021.
They are retreiving data from Z1021 table based on selection screen parameters like werks, bukrs, vkorg,
auart and date and passing that data to one internal table.
SELECT * FROM Z1021 INTO TABLE i_z1021
WHERE werks in s_werks
AND bukrs in s_bukrs
AND vkorg in s_vkorg
AND auart in s_auart
AND pgi_date in s_date.
SORT i_z1021 BY werks bukrs vkorg auart pgi_date.
For fieldcatlog they used function module REUSE_ALV_FIELDCATALOG_MERGE'.
passing only i_structure_name = c_struct_name in Exporting parameters
retreive to i_fieldcat from Changing parameters.
from above both they are passing i_z1021 table data and i_fieldcat to function module
'REUSE_ALV_GRID_DISPLAY' OR 'REUSE_ALV_LIST_DISPLAY' based on sy-batch.
That is my current program.
My new requirement is given below.
Additional and change to fields:
1) Add Intercompany purchase order number
From the document flow table VBFA.
The field name is VBFA-VBELN when Subs.doc.categ (VBFA-VBTYP_N) equal to "V" after sales order line item.
2) Change field name u2018Customeru2019 to u2018Ship-tou2019
From VBFA table need to retrieve VBELN value based on VBELN_VA and POSNR_VA from Z1021 table
where VBFA-VBELV = Z1021-VBELN_VA and VBFA-POSNV = Z1021-POSNR_VA.
This is the condition to fetch that data.
And I want to change the description of Field 'CUSTOMER'( Z1021-KUNNR) to' Ship-to'.
Is it possible to do without changing the original logic.
IF it is possible what is the solution ?
If it is not possible without changing the original code then what is the solution for that also.
Current Code:
Some code i am giving here.
TABLES: Z1021.
DATA: i_z1021 LIKE z1021 OCCURS 0.
CONSTANTS: c_struct_name LIKE dd02l-tabname VALUE 'Z1021'.
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION.
PERFORM list_display.
FORM get_data.
SELECT * FROM Z1021 INTO TABLE i_z1021
WHERE werks in s_werks
AND bukrs in s_bukrs
AND vkorg in s_vkorg
AND auart in s_auart
AND pgi_date in s_date.
SORT i_z1021 BY werks bukrs vkorg auart pgi_date.
ENDFORM.
FORM list_display.
PERFORM create_fieldcatalog.
< another performs>
PERFORM display_list.
ENDOFRM.
FORM create_fieldcatalog.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = c_struct_name
CHANGING
ct_fieldcat = i_fieldcat.
ENDFORM.
FORM display_list.
CASE sy-batch.
WHEN 'X'.
CALL FUNCTION ;REUSE_ALV_LIST_DISPLAY'
WHEN ' '.
CALL FUNCTION ;REUSE_ALV_GRID_DISPLAY'
ENDCASE
ENDFORM.
Could you please suggest on this.
Thanks & Regards.
VSRHi
After fill the field catalog table by function module MERGE, u can modify the value before moving it to ALV LIST/GRID display fm:
FORM create_fieldcatalog.
DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = c_struct_name
CHANGING
ct_fieldcat = i_fieldcat.
LOOP AT I_FIELDCAT INTO LS_FIELDCAT.
CASE LS_FIELDCAT-FIELDNAME.
WHEN 'KUNNR'.
LS_FIELDCAT-SELTEXT_L = <new descrip.>.
LS_FIELDCAT-SELTEXT_M = <new descrip.>.
LS_FIELDCAT-SELTEXT_S = <new descrip.>.
MODIFY I_FIELDCAT FROM LS_FIELDCAT.
ENDCASE.
ENDLOOP.
ENDFORM.
Max
Edited by: max bianchi on Jan 29, 2009 8:15 PM -
How to change sub total value in ALV Grid.
Hi All,
Can u please explain how to change SUBTOTAL Value in ALV Grid display based on another field value.
EX; F1 subtotal is initial then we have to modify the F2 sub total to 9999.9.
Thanks
Radha.Hi Radha,
I doubt if that can be changed....because the event that i was referring to in my previous post works with ALV List display...But in any case you can try that.....
There is an event in SLIS....(As i told you, i dont remember the name and currently i dont have access to SAP system, so i am not able to verify and let you know that event name).....
Other thatn TOP and END of PAGE events, there is an event for sub-total text......i think it would start with "SUBTOTAL"...
you need to use that event in your events table and pass it to ALV Grid display.
Then create a sub-routine with that name (As you do for TOP-OF-PAGE event)....and in this event you can change the values in runtime (PROVIDED, this event gets triggered for ALV GRID).....
If this does not work, i think calculating sub-totals while you build the internal table would be a better option....(If you have time constraint....else you can do some more research on the same)........
Best Regards,
Ram. -
Hi Guys,
I need to display data in a ALV list and grid in the following format.
GI----
Delivery-
Document Year PostDate Item Plnt Stlc CoCd Document Item
Could anyone please tell me how do i get the Header Part (GI and Delivery that spans the below columns). GI will be header for the Document Year PostDate Item..etc.....and Delivery should be the header for document and Item columns in alv.
Please give me an idea......
Sanhi San,
You can write the GI----------------Delivery part in top of page
chk this
REPORT ztest.
TABLES : mara.
TYPE-POOLS: slis.
DATA : w_repid LIKE sy-repid.
w_repid = sy-repid.
DATA : BEGIN OF it_mara OCCURS 0,
matnr LIKE mara-matnr,
END OF it_mara.
*layout
DATA: wa_layout TYPE slis_layout_alv.
*field catalog
DATA: it_fieldcat_wrt_off TYPE slis_t_fieldcat_alv,
wa_fieldcat_wrt_off TYPE slis_fieldcat_alv.
START-OF-SELECTION.
SELECT matnr FROM mara INTO CORRESPONDING FIELDS OF TABLE it_mara.
END-OF-SELECTION.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = w_repid
i_internal_tabname = 'IT_MARA'
* i_structure_name = 'IT_MARA'
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = w_repid
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = it_fieldcat_wrt_off[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = w_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
is_layout = wa_layout
it_fieldcat = it_fieldcat_wrt_off
TABLES
t_outtab = it_mara
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Form TOP-OF-PAGE *
* ALV Report Header *
FORM top-of-page.
*ALV Header declarations
DATA: t_header TYPE slis_t_listheader,
wa_header TYPE slis_listheader,
t_line LIKE wa_header-info,
ld_lines TYPE i,
ld_linesc(10) TYPE c.
* Title
wa_header-typ = 'H'.
wa_header-info = ' REPORT'.
APPEND wa_header TO t_header.
CLEAR wa_header.
* Date
* wa_header-typ = 'S'.
* wa_header-key = 'Date: '.
* CONCATENATE sy-datum+6(2) '.'
* sy-datum+4(2) '.'
* sy-datum(4) INTO wa_header-info. "todays date
* APPEND wa_header TO t_header.
* CLEAR: wa_header.
wa_header-typ = 'S'.
wa_header-key = '--'.
CONCATENATE '-----------GI--------------------------------------'
'delivery---------------------------------'
INTO wa_header-info.
APPEND wa_header TO t_header.
CLEAR: wa_header.
* Total No. of Records Selected
* describe table it_ekko lines ld_lines.
* ld_linesc = ld_lines.
* concatenate 'Total No. of Records Selected: ' ld_linesc
* into t_line separated by space.
* wa_header-typ = 'A'.
* wa_header-info = t_line.
* append wa_header to t_header.
* clear: wa_header, t_line.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
* i_logo = 'Z_LOGO'.
ENDFORM. "top-of-page -
Dynamic Change of FieldCatalog in OO ALV Secondary List
Dear All,
i have Scenario like when i go to secondary list on some event, the fieldcatlog for the info is generated. then again i go back and choose some other event, now the secondary fieldcatalog list should contain few extra fields which are not being displayed. i am refreshing the fieldcatalog and filling the fieldcatalog table with new fields everytime. but the system displays only the first generated fieldcatalog.
any ideas what can be done?
Thanks & Regards
RahulHello Rahul
The following sample report <b>ZUS_SDN_TWO_ALV_GRIDS_A</b> shows how to dynamically change the fieldcatalog of the second ALV list depending on which customer has been selected (by double-clicking) on the first ALV list.
*& Report ZUS_SDN_TWO_ALV_GRIDS_A
*& Screen '0100' contains no elements.
*& ok_code -> assigned to GD_OKCODE
*& Flow logic:
* PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
* PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
REPORT zus_sdn_two_alv_grids_a.
" Dynamic fieldcatalog on second ALV list
DATA:
gd_okcode TYPE ui_func,
go_docking TYPE REF TO cl_gui_docking_container,
go_splitter TYPE REF TO cl_gui_splitter_container,
go_cell_top TYPE REF TO cl_gui_container,
go_cell_bottom TYPE REF TO cl_gui_container,
go_grid1 TYPE REF TO cl_gui_alv_grid,
go_grid2 TYPE REF TO cl_gui_alv_grid,
gs_layout TYPE lvc_s_layo.
DATA:
gt_knb1 TYPE STANDARD TABLE OF knb1,
gt_knvv TYPE STANDARD TABLE OF knvv.
* CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
PUBLIC SECTION.
CLASS-DATA:
md_row TYPE i.
CLASS-METHODS:
handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING
e_row
e_column
es_row_no
sender.
ENDCLASS. "lcl_eventhandler DEFINITION
* CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
METHOD handle_double_click.
* define local data
DATA:
ls_knb1 TYPE knb1.
CHECK ( sender = go_grid1 ).
READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
md_row = e_row-index.
CALL METHOD go_grid1->set_current_cell_via_id
EXPORTING
* IS_ROW_ID =
* IS_COLUMN_ID =
is_row_no = es_row_no.
* Triggers PAI of the dynpro with the specified ok-code
CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
ENDMETHOD. "handle_double_click
ENDCLASS. "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
SELECT * FROM knb1 INTO TABLE gt_knb1
WHERE bukrs = '1000'.
* Create docking container
CREATE OBJECT go_docking
EXPORTING
parent = cl_gui_container=>screen0
ratio = 90
EXCEPTIONS
OTHERS = 6.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Create splitter container
CREATE OBJECT go_splitter
EXPORTING
parent = go_docking
rows = 2
columns = 1
* NO_AUTODEF_PROGID_DYNNR =
* NAME =
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Get cell container
CALL METHOD go_splitter->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = go_cell_top.
CALL METHOD go_splitter->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = go_cell_bottom.
* Create ALV grids
CREATE OBJECT go_grid1
EXPORTING
i_parent = go_cell_top
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Set event handler
SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.
CREATE OBJECT go_grid2
EXPORTING
i_parent = go_cell_bottom
EXCEPTIONS
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Display data
gs_layout-grid_title = 'Customers'.
CALL METHOD go_grid1->set_table_for_first_display
EXPORTING
i_structure_name = 'KNB1'
is_layout = gs_layout
CHANGING
it_outtab = gt_knb1
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
gs_layout-grid_title = 'Customers Details (Sales Areas)'.
CALL METHOD go_grid2->set_table_for_first_display
EXPORTING
i_structure_name = 'KNVV'
is_layout = gs_layout
CHANGING
it_outtab = gt_knvv " empty !!!
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Link the docking container to the target dynpro
CALL METHOD go_docking->link
EXPORTING
repid = syst-repid
dynnr = '0100'
* CONTAINER =
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* NOTE: dynpro does not contain any elements
CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
*PROCESS AFTER INPUT.
* MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*& Module STATUS_0100 OUTPUT
* text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS_0100'. " contains push button "DETAIL"
* SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
CALL METHOD go_grid2->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
MODULE user_command_0100 INPUT.
CASE gd_okcode.
WHEN 'BACK' OR
'END' OR
'CANC'.
SET SCREEN 0. LEAVE SCREEN.
* User has pushed button "Display Details"
WHEN 'DETAIL'.
PERFORM entry_show_details.
WHEN OTHERS.
ENDCASE.
CLEAR: gd_okcode.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form ENTRY_SHOW_DETAILS
* text
* --> p1 text
* <-- p2 text
FORM entry_show_details .
* define local data
DATA:
ld_row TYPE i,
ls_knb1 TYPE knb1,
ls_fcat TYPE lvc_s_fcat,
lt_fcat TYPE lvc_t_fcat.
CALL METHOD go_grid1->get_current_cell
IMPORTING
e_row = ld_row.
READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
CHECK ( syst-subrc = 0 ).
SELECT * FROM knvv INTO TABLE gt_knvv
WHERE kunnr = ls_knb1-kunnr.
CALL METHOD go_grid2->get_frontend_fieldcatalog
IMPORTING
et_fieldcatalog = lt_fcat.
" Logic of fieldcatalog modification:
" 1st customer selected -> show 1 column only
" 2nd customer selected -> show 2 columns only
" 3rd customer selected -> show 3 columns
LOOP AT lt_fcat INTO ls_fcat.
IF ( syst-tabix <= ld_row ).
ls_fcat-no_out = ' '.
ELSE.
ls_fcat-no_out = 'X'.
ENDIF.
MODIFY lt_fcat FROM ls_fcat.
ENDLOOP.
go_grid2->set_frontend_fieldcatalog( lt_fcat ).
ENDFORM. " ENTRY_SHOW_DETAILS
Regards
Uwe -
Add(Copy)/Change/Delete in editable ALV list
I want to add a column to my ALV list where the user can enter an 'A' to Copy, 'C' to Change or 'D' to Delete. If the user enters an 'A', the code needs to insert a new line into the ALV list. After the user makes the changes on the screen and selects Save, I need the program to perform different functions depending on whether the user entered an 'A', 'C' or 'D' in the column. I have never used an editable ALV list and would like to have some sample code to get started. Does anyone have any code similar to what I am trying to do?
Thanks.
SandyHi,
check this code... if you trying with ALV FM, and editable grid then check this code.
REPORT ZTESTDFALV1 .
*Data Declaration
DATA: BEGIN OF T_EKKO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
* FLAG TYPE C,
* HANDLE_STYLE TYPE LVC_T_STYL,
END OF T_EKKO.
DATA: GD_REPID LIKE SY-REPID, "Exists
REF_GRID TYPE REF TO CL_GUI_ALV_GRID. "new
DATA: BEGIN OF IT_EKKO OCCURS 0.
INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_EKKO.
DATA: BEGIN OF IT_BACKUP OCCURS 0.
INCLUDE STRUCTURE T_EKKO.
DATA: END OF IT_BACKUP.
*ALV data declarations
TYPE-POOLS: SLIS. "ALV Declarations
DATA: FIELDCATALOG TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV.
*Start-of-selection.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
IT_BACKUP[] = IT_EKKO[].
PERFORM DISPLAY_ALV_REPORT.
*& Form build_fieldcatalog
* text
FORM BUILD_FIELDCATALOG.
REFRESH FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELN'.
FIELDCATALOG-SELTEXT_M = 'Purchase Order'.
FIELDCATALOG-INPUT = 'X'.
FIELDCATALOG-EDIT = 'X'.
FIELDCATALOG-COL_POS = 2.
APPEND FIELDCATALOG.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELP'.
FIELDCATALOG-SELTEXT_M = 'PO Item'.
FIELDCATALOG-COL_POS = 3.
APPEND FIELDCATALOG.
CLEAR FIELDCATALOG.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
FORM BUILD_LAYOUT.
"Permet d'ajuster les colonnes au text
* gd_layout-colwidth_optimize = 'X'.
* GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).
* gd_layout-box_fieldname = 'SELECT'.
* gd_layout-box_tabname = 'IT_EKKO'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
* Display report using ALV grid
FORM DISPLAY_ALV_REPORT .
GD_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = GD_REPID
* i_callback_top_of_page = 'TOP-OF-PAGE'
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* i_grid_title = 'My Title'
IS_LAYOUT = GD_LAYOUT
IT_FIELDCAT = FIELDCATALOG[]
TABLES
T_OUTTAB = IT_EKKO
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
WRITE:/ SY-SUBRC.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM DATA_RETRIEVAL.
SELECT EBELN EBELP
UP TO 10 ROWS
FROM EKPO
INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.
ENDFORM. " DATA_RETRIEVAL
* FORM SET_PF_STATUS *
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD_FULLSCREEN1' EXCLUDING RT_EXTAB.
ENDFORM. "set_pf_status
*& Form user_command
* text
* -->R_UCOMM text
* -->RS_SELFIELDtext
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
<b>
*then insert the following code in your USER_COMMAND routine...
IF REF_GRID IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = REF_GRID.
ENDIF.
IF NOT REF_GRID IS INITIAL.
CALL METHOD REF_GRID->CHECK_CHANGED_DATA
ENDIF.</b>*modify
CASE R_UCOMM.
WHEN '&IC1'.
CHECK RS_SELFIELD-TABINDEX > 0.
IF RS_SELFIELD-VALUE EQ '6000000001'.
CALL TRANSACTION 'ZDF2'.
ENDIF.
WHEN 'REFRESH'.
READ TABLE IT_EKKO INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
READ TABLE IT_BACKUP INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
IF IT_EKKO <> IT_BACKUP.
* then do your check
ENDIF.
ENDIF.
ENDIF.
PERFORM DATA_RETRIEVAL.
RS_SELFIELD-REFRESH = 'X'.
ENDCASE.
ENDFORM. "user_command
regards
vijay -
What is the difference between list display and grid display in alv report
Hai genious
i am a new of the abap, i dont know the alv report, i have a small doubt, can u please tell me what is the main difference between list display and grid display in alv report
thanks®ards
chinnuHi ,
1. For all practical purposes, they are the same.
2. Some differences:
a) from abap coding point of view,
alv list is done with Function modules,
alv gris can also be done with FM,
but can also be done using OO concepts.
b) Alv grid (using oo concept) requires
designing the screen layout .
Hence, in one screen, we can show more
then one alv grid
(we cannot show more than
one alv list on one screen)
c) ALV grid uses ActiveX controls
present on the Presentation Server.
Hence, it consumes More Memory
on the presentation server.
d) ALV LIST is Display Only.
Whereas
ALV Grid Can Be made EDITABLE for entry purpose.
e) In alv grid, these options are possible,
but not in alv list.
without horizontal lines
without vertical lines
without cell merging during sorts
display total lines above the entries
I hope it helps.
Regards,
Mamta
Edited by: Mamta Verma on Nov 27, 2008 6:41 AM -
How to Change Column header in ALV List
hello,
is there a way to change the column header/label of an ALV list other than inheriting it from the source table it is bound to?
thanks,
sidYes, you can. If you are using a field catalog, you can change the field labels in your program.
For example.
data: fc_tmp type slis_fieldcat_alv .
clear: fieldcat. refresh: fieldcat.
clear: fc_tmp.
<b> fc_tmp-reptext_ddic = 'Material Number'.</b>
fc_tmp-fieldname = 'MATNR'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '18'.
fc_tmp-col_pos = 2.
append fc_tmp to fieldcat.
If you are using the MERGE funciton module to get your field catalog, then you just need to loop thru it and change the field which is holding the description, then modify the line of the field catalog.
REgards,
Rich Heilman
Maybe you are looking for
-
HP laserjet p1102 not recognized after installati​on on windows 7 - 32bit
Hello I need help with my hp laserjet p1102 installation, it's not working after installation. I get a message say's(usb device not recognized) can any one here get me a hint please??
-
Hi Guys, I copied my iPhoto library to a second external disk. Now my version of iPhoto (5.0.4) does not display the original library on the orignal external drive. I have reinstalled the iPhoto and it seems to make 2 attempts to find the library but
-
The title says it all.
-
OBXZ - Can it be defined at Company Code level
Dear All, The account maintained in OBXZ is at chart of accounts level i.e. for multiple company code Is it possible to maintain it seperately for say one company code with a different account numbers ? If yes how... Thanks in advance... MS
-
Hi, I'm trying to understand and do research on Oracle RDBMS. Does anyone know how Oracle fulfills the mission of a DBMS such as hardware independence and scalability or can point me to a site which gives me some more information? Thanks in advance.