Hierarchy in ALV Table
Hello everyone!
Could anybody advise good article about hierarchy in ALV? I saw some example on help.sap.com, but it's too short and useless.
I can't figure out whether ALV has the same flexibility as Table component in terms of hierarchy. I need to present hierarchy from BW, based on parent-child relationship.
Edited by: Konstantin Milutin on Jul 26, 2010 8:35 AM
Hi , Check out this article about hierarchy in ALV
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c060fcb4-2c62-2b10-d2b2-f32407a5cc6f
Regards
Chinnaiya P
Similar Messages
-
Download Hierarchial List ALV to excel
Hi all,
Please provide me the solution on using download button in Hierarchial List ALV to download to excel.The output of excel need to be exacted as the output of ALV (All header and items details).
Please suggest the solution and sample code ASAP.
Thanks and Regards.Hello,
Find the code where method set_table_for_first_display of tree object (CL_GUI_ALV_TREE) used in your program,
and learn table of tree from there :
CALL METHOD g_tree->set_table_for_first_display
EXPORTING
i_structure_name = g_structname
is_hierarchy_header = g_hierarchy_header
CHANGING
it_fieldcatalog = g_fieldcat
it_outtab = it_result . "<-- this table contains hierarchical data
And than download this table using class CL_GUI_FRONTEND_SERVICES
and methods FILE_SAVE_DIALOG and GUI_DOWNLOAD or function GUI_DOWNLOAD
you can find too many of examples in forum. -
Need a sample program for hierarchial oops ALV report
Hello experts,
I Need a sample program for hierarchial oops ALV report.Hi,
Check the following sample code...
T A B L E S
tables : ekko.
data definition
types : begin of ty_ekko,
ebeln type ekko-ebeln,
lifnr type ekko-lifnr,
bsart type ekko-bsart,
aedat type ekko-aedat,
ernam type ekko-ernam,
end of ty_ekko.
types : begin of ty_eket,
ebeln type ekpo-ebeln,
ebelp type ekpo-ebelp,
werks type ekpo-werks,
matnr type ekpo-matnr,
menge type eket-menge,
wamng type eket-wamng,
netpr type ekpo-netpr,
end of ty_eket.
data : it_ekko type table of ty_ekko,
it_eket type table of ty_eket.
data: ob_hieralv type ref to cl_salv_hierseq_table.
data: it_binding type salv_t_hierseq_binding,
is_binding type salv_s_hierseq_binding.
S E L C T O P T I O N S
select-options : s_ebeln for ekko-ebeln.
S T A R T O F S E L E C T I O N
start-of-selection.
select ebeln
lifnr
bsart
aedat
ernam from ekko
into corresponding fields of table it_ekko
where ebeln in s_ebeln.
if sy-subrc eq 0.
select aebeln aebelp
awerks amatnr
bmenge bwamng
a~netpr from ekpo as a join eket as b
on amandt = bmandt
and aebeln = bebeln
and aebelp = bebelp
into corresponding fields of table it_eket
where a~ebeln in s_ebeln.
endif.
is_binding-master = 'EBELN'.
is_binding-slave = 'EBELN'.
append is_binding to it_binding.
*TRY.
call method cl_salv_hierseq_table=>factory
exporting
t_binding_level1_level2 = it_binding
importing
r_hierseq = ob_hieralv
changing
t_table_level1 = it_ekko
t_table_level2 = it_eket .
*CATCH cx_salv_data_error .
*CATCH cx_salv_not_found .
*ENDTRY.
call method ob_hieralv->display( ).
Cheers,
Ram -
hi friendz
i am new to abap.i tried executing the hierarchial display alv, but i did not get the output.though i got the field names in the output but there are no contents displayed.i am including the code here.please help me out.
rg
sandeep
REPORT ZVV_ALV_HIERARCHIAL .
*--type pools
TYPE-POOLS: slis.
*--tables declaration
TABLES: SFLIGHT,SPFLI.
*--types declaration
DATA: BEGIN OF i_SFLIGHT OCCURS 0,
CARRID LIKE SFLIGHT-CARRID,
CONNID LIKE SFLIGHT-CONNID,
FLDATE LIKE SFLIGHT-FLDATE,
END OF i_SFLIGHT.
DATA: BEGIN OF i_SPFLI OCCURS 0,
CARRID LIKE SPFLI-CARRID,
CONNID LIKE SPFLI-CONNID,
AIRPFROM LIKE SPFLI-AIRPFROM,
AIRPTO LIKE SPFLI-AIRPTO,
DISTANCE LIKE SPFLI-DISTANCE,
END OF i_SPFLI.
*--variables
DATA: i_repid LIKE sy-repid.
i_repid = sy-repid.
DATA: i_field TYPE slis_t_fieldcat_alv.
DATA: G_TABNAME_HEADER TYPE SLIS_TABNAME.
DATA: G_TABNAME_ITEM TYPE SLIS_TABNAME.
DATA: G_KEYINFO TYPE SLIS_KEYINFO_ALV.
*--select options
SELECT-OPTIONS : S_CARRID FOR SFLIGHT-CARRID .
*--initialosation
INITIALIZATION.
*--selection screen on
AT SELECTION-SCREEN .
*--start of selection
START-OF-SELECTION.
SELECT CARRID
CONNID
FLDATE
FROM SFLIGHT INTO TABLE i_SFLIGHT
WHERE CARRID IN S_CARRID.
IF NOT i_SFLIGHT IS INITIAL.
SELECT CARRID
CONNID
DISTANCE
INTO TABLE i_SPFLI FROM SPFLI
FOR ALL ENTRIES IN I_SFLIGHT
WHERE CARRID = i_SFLIGHT-CARRID.
ENDIF.
PERFORM fill_fieldcatalog1.
PERFORM fill_fieldcatalog2.
PERFORM HIERARCHY_ALV.
PERFORM alv_events.
G_KEYINFO-header01 = 'CARRID'.
G_KEYINFO-item01 = 'CONNID'.
G_TABNAME_HEADER = 'I_SFLIGHT'.
G_TABNAME_ITEM = 'I_SPFLI'.
*& Form fill_fieldcatalog
FORM fill_fieldcatalog1 .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'I_SFLIGHT'
i_structure_name = EKPO
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = i_repid
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ''
CHANGING
ct_fieldcat = i_field
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.
ENDFORM. " fill_fieldcatalog
*& Form fill_fieldcatalog2
form fill_fieldcatalog2 .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'I_SPFLI'
i_structure_name = EKPO
I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = i_repid
I_BYPASSING_BUFFER = 'X'
I_BUFFER_ACTIVE = ''
CHANGING
ct_fieldcat = i_field
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.
endform. " fill_fieldcatalog2
*& Form HIERARCHY_ALV
form HIERARCHY_ALV .
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = I_REPID
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
IS_LAYOUT =
IT_FIELDCAT = I_FIELD
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_DEFAULT = 'X'
I_SAVE = 'A '
IS_VARIANT =
IT_EVENTS = I_EVENTS
IT_EVENT_EXIT =
i_tabname_header = G_TABNAME_HEADER
i_tabname_item = G_TABNAME_ITEM
I_STRUCTURE_NAME_HEADER =
I_STRUCTURE_NAME_ITEM =
is_keyinfo = G_KEYINFO
IS_PRINT =
IS_REPREP_ID =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
tables
t_outtab_header = I_SFLIGHT
t_outtab_item = I_SPFLI
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.
endform. " HIERARCHY_ALVThe program works fine if there is no data in the I_SPFLI. But if the table I_SPFLI is populated it shows an error like 'Unable to interpret "AA " as a number' where AA is the CARRID.
If the header01 is changed to CONNID the program works well. Here is the program.
TYPE-POOLS: slis.
*--tables declaration
TABLES: SFLIGHT,SPFLI.
*--types declaration
DATA: BEGIN OF i_SFLIGHT OCCURS 0,
CARRID LIKE SFLIGHT-CARRID,
CONNID LIKE SFLIGHT-CONNID,
FLDATE LIKE SFLIGHT-FLDATE,
END OF i_SFLIGHT.
DATA: BEGIN OF i_SPFLI OCCURS 0,
CARRID LIKE SPFLI-CARRID,
CONNID LIKE SPFLI-CONNID,
* AIRPFROM LIKE SPFLI-AIRPFROM,
* AIRPTO LIKE SPFLI-AIRPTO,
DISTANCE LIKE SPFLI-DISTANCE,
END OF i_SPFLI.
*--variables
DATA: i_repid LIKE sy-repid.
i_repid = sy-repid.
DATA: i_field TYPE slis_t_fieldcat_alv.
DATA: i_field2 TYPE slis_t_fieldcat_alv.
DATA: G_TABNAME_HEADER TYPE SLIS_TABNAME.
DATA: G_TABNAME_ITEM TYPE SLIS_TABNAME.
DATA: G_KEYINFO TYPE SLIS_KEYINFO_ALV.
*--select options
SELECT-OPTIONS : S_CARRID FOR SFLIGHT-CARRID .
*--initialosation
INITIALIZATION.
*--selection screen on
AT SELECTION-SCREEN .
*--start of selection
START-OF-SELECTION.
SELECT CARRID
CONNID
FLDATE
FROM SFLIGHT INTO TABLE i_SFLIGHT
WHERE CARRID IN S_CARRID.
IF i_SFLIGHT[] IS NOT INITIAL.
SELECT CARRID
CONNID
DISTANCE
INTO TABLE i_SPFLI FROM SPFLI
FOR ALL ENTRIES IN I_SFLIGHT
WHERE CARRID = i_SFLIGHT-CARRID.
IF sy-subrc NE 0.
MESSAGE e001(z538msg).
ENDIF.
ENDIF.
PERFORM fill_fieldcatalog1.
PERFORM fill_fieldcatalog2.
PERFORM HIERARCHY_ALV.
* PERFORM alv_events.
G_KEYINFO-header01 = 'CARRID'.
G_KEYINFO-item01 = 'CONNID'.
G_TABNAME_HEADER = 'I_SFLIGHT'.
G_TABNAME_ITEM = 'I_SPFLI'.
*& Form fill_fieldcatalog
FORM fill_fieldcatalog1 .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'I_SFLIGHT'
* i_structure_name = EKPO
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = i_repid
* I_BYPASSING_BUFFER = 'X'
* I_BUFFER_ACTIVE = ''
CHANGING
ct_fieldcat = i_field
* 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.
ENDFORM. " fill_fieldcatalog
*& Form fill_fieldcatalog2
form fill_fieldcatalog2 .
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = i_repid
i_internal_tabname = 'I_SPFLI'
* i_structure_name = EKPO
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = i_repid
* I_BYPASSING_BUFFER = 'X'
* I_BUFFER_ACTIVE = ''
CHANGING
ct_fieldcat = i_field
* 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.
endform. " fill_fieldcatalog2
*& Form HIERARCHY_ALV
form HIERARCHY_ALV .
<b>*G_KEYINFO-header01 = 'CARRID'.</b>
<b>G_KEYINFO-header01 = 'CONNID'.</b>
G_KEYINFO-item01 = 'CONNID'.
G_TABNAME_HEADER = 'I_SFLIGHT'.
G_TABNAME_ITEM = 'I_SPFLI'.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = I_REPID
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IS_LAYOUT =
IT_FIELDCAT = I_FIELD
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* I_DEFAULT = 'X'
I_SAVE = 'A'
* IS_VARIANT =
* IT_EVENTS = I_EVENTS
* IT_EVENT_EXIT =
i_tabname_header = G_TABNAME_HEADER
i_tabname_item = G_TABNAME_ITEM
* I_STRUCTURE_NAME_HEADER =
* I_STRUCTURE_NAME_ITEM =
is_keyinfo = G_KEYINFO
* IS_PRINT =
* IS_REPREP_ID =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
tables
t_outtab_header = I_SFLIGHT
t_outtab_item = I_SPFLI
* 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.
endform. " HIERARCHY_ALV -
How to link a tree to a ALV table
Hi Experts,
I have a tree node on the left side of my display.
Now according to the user selection on the tree node,
i need to populate the ALV table on the right.
That means selected value by the user is the input parameter
and should fetch the corresponding data accordingly and displays on the ALV table on the right.
Please advise.
Regards,
ChitrasenHi,
Define the ON_FUNCTION event in the view controller. This is an event of your ALV. In the coding of this event handler method put code like:
METHOD on_select .
DATA: temp TYPE string.
temp = r_param->id.
IF temp = 'LBUTTON'.
wd_comp_controller->get_selected_line_via lead_selection( ).
ENDIF.
ENDMETHOD.
What also needed is next code to be placed in method wdoinit of the component controller:
METHOD wddoinit .
DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage,
l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table.
DATA: lr_column TYPE REF TO cl_salv_wd_column.
l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
l_ref_cmp_usage->create_component( ).
ENDIF.
l_ref_interfacecontroller = wd_this->wd_cpifc_alv( ).
wd_this->l_value = l_ref_interfacecontroller->get_model( ).
*&- Specify the display type
wd_this->l_value->if_salv_wd_table_settings~set_display_type(
if_salv_wd_c_table_settings=>display_type_hierarchy ).
wd_this->l_value->if_salv_wd_table_settings~set_enabled( abap_true ).
*&- Specify a hierarchy columns Bucket, RE, PE and AE
lr_column = wd_this->l_value->if_salv_wd_column_settings~get_column( 'BUCKET' ).
lr_column->if_salv_wd_column_hierarchy~set_hierarchy_column( abap_true ).
lr_column = wd_this->l_value->if_salv_wd_column_settings~get_column( 'RE' ).
lr_column->if_salv_wd_column_hierarchy~set_hierarchy_column( abap_true ).
lr_column = wd_this->l_value->if_salv_wd_column_settings~get_column( 'PE' ).
lr_column->if_salv_wd_column_hierarchy~set_hierarchy_column( abap_true ).
lr_column = wd_this->l_value->if_salv_wd_column_settings~get_column( 'AE' ).
lr_column->if_salv_wd_column_hierarchy~set_hierarchy_column( abap_true ).
*&- Display data of the last hierarchy as leaf
wd_this->l_value->if_salv_wd_table_hierarchy~set_last_hier_column_as_leaf( abap_true ).
*&- Create function in toolbar
DATA lr_button TYPE REF TO cl_salv_wd_fe_button.
DATA button1 TYPE REF TO cl_salv_wd_function.
CREATE OBJECT lr_button.
lr_button->set_text( 'SELECT' ).
button1 = wd_this->l_value->if_salv_wd_function_settings~create_function( id = 'LBUTTON' ).
button1->set_editor( lr_button ).
ENDMETHOD.
Cheers, John -
ABAP WD: TreeByKeyTableColumn in ALV table (SALV_WD_TABLE)
Hello,
is is possible to add a TreeByKeyTableColumn object to a ALV table created
using the SALV_WD_TABLE interface?
I know that this question has already been posted several times - but the general answer ("use hierarchy columns and set_display_type( ..)") is not satisfying, since I have got the following:
The context node of cardinality 0..n which corresponds to the "column tree" to be displayed has got
- one KEY attribute
- one PARENT_KEY attribute
- one NODE_TEXT attribute
- several attributes which correspond to the table lines (respectively tree lines)
Example:
The context of cardinality 0..n has got six attributes:
KEY, PARENT_KEY, NODE_TEXT, col1 col2 col3.
During runtime, there are five "lines" in this node:
KEY PARENT_KEY NODE_TEXT col1 col2 col3
1 (none) "node1" a a a
2 1 "node2" b b b
3 2 "node3" c c c
4 1 "node4" d d d
5 (none) "node5" e e e
The result should be in this case as if I'd have
- a table with the columns col1, col2, col3 and
- a TreeByKeyTableColumn with
-- ROW_KEY bound to KEY
-- PARENT_KEY bound to PARENT_KEY
-- containing a TextView with TEXT bound to NODE_TEXT
Result in Display:
-> node1 a a a <= Top level node
---> node2 b b b <= child of node with text "node1"
> node3 c c c <= child of node with text "node2"
---> node4 d d d <= child of node with text "node1"
-> node5 e e e <= Top level node
Can this be established with the built in hierarchy functionality of the SALV_WD_TABLE interface, too?
When playing around with the hierarchy columns functionality of SALV_WD_TABLE, I always got extra lines for the tree nodes with empty cells to the right (which I definitly don't want), and I was not able to use the parent_key<->key information already contained in the context node attributes.
But perhaps I have overlooked something?
Or is it possible to get somehow, by wild navigation through the available objects/classes/interfaces of the SALV_WD_TABLE interface, a reference to the corresponding table UI element to be able to dynamically add a TreeByKeyTableColumn with the wanted bindings?
Regards & thanks for your help
--UteOnce you have created a boolean attribute 'DAYS_READONLY' in the node bound to the DATA node of ALV, you need to set this attribute to false (for that row) if you want DAYS field to be editable when the user creates another row. In the method where you have populated the data which is being displayed make this attribute as true for those rows.
After this where you have made the ALV config settings write the following code.
DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
lr_column = lr_column_settings->get_column( 'DAYS' ).
CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'DAYS'.
lr_column->set_cell_editor( lr_input_field ).
lr_input_field->set_read_only_fieldname( value = 'DAYS_READONLY' ).
CALL METHOD lr_column_settings->delete_column
EXPORTING
id = 'DAYS_READONLY'
In this code you are creating input field as a cell editor and assigning it to DAYS column. After this you are setting the readonly property of the column DAYS to the value of the column 'DAYS_READONLY'. Since this column can have different values for each row, the column DAYS will be made readonly/editable accordingly. Finally you are deleting the column DAYS_READONLY from ALV output as we do not want to display its value to the user.
For more info you can refer to thread: [ALV List in the same Column for the row CELL i need button or value;
Edited by: Pooja Patodia on Mar 16, 2011 9:54 AM -
hi everyone,
i need to develop a hierarchial interactive alv program,
how do i start,
if anyone has a simplest program,
please forward it to me.
rgds.HI
STRUCTURE DECLARATIONS
INTERNAL TABLE DECLARATIONS
WORKAREA DECLARATIONS
TYPE-POOLS DECLARATION
TYPE-POOLS : slis.
*TYPES : BEGIN OF st_ekko,
ebeln TYPE ekko-ebeln, "Purchasing Document Number
bstyp TYPE ekko-bstyp, "Purchasing Document Category
bsart TYPE ekko-bsart, "Purchasing Document Type
aedat TYPE ekko-aedat, "record created on
ernam TYPE ekko-ernam, "Person who Created the Object
END OF st_ekko.
*TYPES : BEGIN OF st_ekpo,
ebeln TYPE ekko-ebeln, "Purchasing Document Number
ebelp TYPE ekpo-ebelp, "Item Number of Purchasing Document
ematn TYPE ekpo-ematn, "Material number
matkl TYPE ekpo-matkl, "Material group
netpr TYPE ekpo-netpr, "Net price in purchasing document
END OF st_ekpo.
TYPES : BEGIN OF st_ebeln,
ebeln TYPE ekpo-ebeln,
END OF st_ebeln.
DATA : IT_EKPO TYPE STANDARD TABLE OF EKPO WITH HEADER LINE,
IT_EKKO TYPE STANDARD TABLE OF EKKO WITH HEADER LINE,
it_ekpo TYPE STANDARD TABLE OF st_ekpo with header line,
wa_ekpo TYPE st_ekpo,
it_ekko TYPE STANDARD TABLE OF st_ekko with header line,
wa_ekko LIKE LINE OF it_ekko,
it_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat LIKE LINE OF it_fieldcat,
wa_layout TYPE slis_layout_alv,
it_events TYPE slis_t_event,
st_event LIKE LINE OF it_events,
st_keyinfo TYPE slis_keyinfo_alv,
it_ebeln TYPE STANDARD TABLE OF st_ebeln.
DATA : v_ebeln TYPE ekko-ebeln.
SELECTION-SCREEN
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE tit.
SELECT-OPTIONS: so_ebeln FOR v_ebeln OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b.
INITIALIZATION
INITIALIZATION.
tit = text-000.
AT SELECTION-SCREEN ON
AT SELECTION-SCREEN ON so_ebeln.
PERFORM validate_ebeln.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM get_data.
END-OF-SELECTION
END-OF-SELECTION.
PERFORM populate_fcat using 'IT_EKKO' 'EKKO'.
PERFORM populate_fcat using 'IT_EKPO' 'EKPO'.
PERFORM fill_keyinfo.
PERFORM display_alv.
*& Form validate_ebeln
FORM validate_ebeln.
SELECT ebeln
FROM ekpo
INTO TABLE it_ebeln
WHERE ebeln IN so_ebeln.
IF sy-subrc NE 0.
MESSAGE e020(z50871) WITH 'Purchase Document Number Is Invalid'.
ENDIF.
ENDFORM. "validate_ebeln
*& Form get_data
FORM get_data .
SELECT ebeln bstyp bsart aedat ernam
FROM ekko
INTO TABLE it_ekko
WHERE ebeln IN so_ebeln.
IF NOT it_ekko[] IS INITIAL.
SELECT ebeln ebelp ematn matkl netpr
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln EQ it_ekko-ebeln.
ENDIF.
SELECT *
FROM ekko
INTO TABLE it_ekko
WHERE ebeln IN so_ebeln.
IF NOT it_ekko[] IS INITIAL.
SELECT *
FROM ekpo
INTO TABLE it_ekpo
FOR ALL ENTRIES IN it_ekko
WHERE ebeln EQ it_ekko-ebeln.
ENDIF.
ENDFORM. " get_data
*& Form POPULATE_FCAT
FORM POPULATE_FCAT USING P_TABNAME TYPE SLIS_TABNAME
P_STRUCTURE LIKE DD02L-TABNAME.
CLEAR wa_fieldcat.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-tabname = 'it_ekko'.
wa_fieldcat-seltext_l = 'Purchase document number'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'BSTYP'.
wa_fieldcat-tabname = 'it_ekko'.
wa_fieldcat-seltext_l = 'Purchasing Document Category'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'BSART'.
wa_fieldcat-tabname = 'it_ekko'.
wa_fieldcat-seltext_l = 'Purchasing Document Type'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-tabname = 'it_ekko'.
wa_fieldcat-seltext_l = 'Created On'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'ERNAM'.
wa_fieldcat-tabname = 'it_ekko'.
wa_fieldcat-seltext_l = 'Created By'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-tabname = 'it_ekpo'.
wa_fieldcat-seltext_l = 'Purchase document number'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-tabname = 'it_ekpo'.
wa_fieldcat-seltext_l = 'Item Number'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'EMATN'.
wa_fieldcat-tabname = 'it_ekpo'.
wa_fieldcat-seltext_l = 'Material Number'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'MATKL'.
wa_fieldcat-tabname = 'it_ekpo'.
wa_fieldcat-seltext_l = 'Material group'.
APPEND wa_fieldcat TO it_fieldcat.
wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-tabname = 'it_ekpo'.
wa_fieldcat-seltext_l = 'Net price in purchasing document'.
APPEND wa_fieldcat TO it_fieldcat.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = P_TABNAME
I_STRUCTURE_NAME = P_STRUCTURE
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME = I_INCLNAME
I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
I_BUFFER_ACTIVE = I_BUFFER_ACTIVE
CHANGING
ct_fieldcat = It_fieldcat
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.
ENDFORM. " POPULATE_FCAT
*& Form fill_keyinfo
FORM fill_keyinfo.
CLEAR st_keyinfo.
st_keyinfo-header01 = 'EBELN'.
st_keyinfo-item01 = 'EBELN'.
ENDFORM. " fill_keyinfo
*& Form DISPLAY_ALV
FORM display_alv .
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
i_callback_program = sy-repid
i_callback_pf_status_set = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = ' '
IS_LAYOUT = IS_LAYOUT
it_fieldcat = it_fieldcat
IT_EXCLUDING = IT_EXCLUDING
IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
IT_SORT = IT_SORT
IT_FILTER = IT_FILTER
IS_SEL_HIDE = IS_SEL_HIDE
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
I_DEFAULT = 'X'
I_SAVE = ' '
IS_VARIANT = IS_VARIANT
IT_EVENTS = IT_EVENTS[]
IT_EVENT_EXIT = IT_EVENT_EXIT
i_tabname_header = 'IT_EKKO'
i_tabname_item = 'IT_EKPO'
I_STRUCTURE_NAME_HEADER = I_STRUCTURE_NAME_HEADER
I_STRUCTURE_NAME_ITEM = I_STRUCTURE_NAME_ITEM
is_keyinfo = st_keyinfo
IS_PRINT = IS_PRINT
IS_REPREP_ID = IS_REPREP_ID
I_BYPASSING_BUFFER = I_BYPASSING_BUFFER
I_BUFFER_ACTIVE = I_BUFFER_ACTIVE
IR_SALV_HIERSEQ_ADAPTER = IR_SALV_HIERSEQ_ADAPTER
IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
IMPORTING
E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
TABLES
t_outtab_header = it_ekko
t_outtab_item = it_ekpo
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.
ENDFORM. " DISPLAY_ALV
*& Form SET_PF_STATUS
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD'. "Copy from SALV .
ENDFORM. "SET_PF_STATUS -
Displaying default value for a field in ALV table
Hai all,
I am having an ALV table in which I want to display Requisition number by default using a value which i generated randomly and it is stored in a variable.
While displaying ALV table my req number field should display that value by default when ever user is inserting a row( all the coloumns n my alv are editable.
Is it possible??
Kindly give some suggestions.
Thanks in Advance,
Nalla.BHai Kris,
I took help from ur link and i declared a global attribute request_number.
and i created an event handler ON_ALV_INSERT and did the follwing coding for giving default value wen ever am inserting new row.
FIELD-SYMBOLS: <wa_row> LIKE LINE OF r_param->t_inserted_rows.
DATA bill_details TYPE REF TO zdom_bill_detail.
LOOP AT r_param->t_inserted_rows ASSIGNING <wa_row>.
bill_details ?= <wa_row>-r_value.
IF bill_details->REQ_NUMBER IS INITIAL.
DATA lo_nd_bill_detail TYPE REF TO if_wd_context_node.
DATA lo_el_bill_detail TYPE REF TO if_wd_context_element.
DATA ls_bill_detail TYPE wd_this->Element_bill_detail.
navigate from <CONTEXT> to <BILL_DETAIL> via lead selection
lo_nd_bill_detail = wd_context->get_child_node( name = wd_this->wdctx_bill_detail ).
lo_el_bill_detail = lo_nd_bill_detail->get_element( index = <wa_row>-index ).
lo_el_bill_detail->set_attribute(
EXPORTING
name = 'REQ_NUMBER'
value = wd_comp_controller->request_number
Wen am setting the value of wd_comp_controller->request_number to my context attribute am getting NULL object ref error.
lo_el_bill_detail->set_attribute(
name = `REQ_NUMBER`
value = wd_comp_controller->request_number ).
Pls give some suggestions,
Thanks in Advance,
Nalla.B -
How can i change the column label text in a alv table display
how can i change the column label text in a alv table display??
A similar kinda of question was posted previuosly where the requirement was the label text was needed and following below code was given as solution :
<i>* declare column, settings, header object
DATA: lr_column TYPE REF TO cl_salv_wd_column.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
DATA: lr_column_header type ref to CL_SALV_WD_COLUMN_HEADER.
get column by specifying column name.
lr_column = lr_column_settings->get_column( 'COLUMN_NAME1' ).
set Header Text as null
lr_column_header = lr_column->get_header( ).
lr_column_header->set_text( ' ' ).</i>
My specific requirement is i have an input field on the screen and i want reflect that value as the column label for one of the column in the alv table. I have used he above code with slight modification in the MODIFYVIEW method of the view since it is a process after input. The component gets activated without any errors but while run time i get an error stating
<i>"The following error text was processed in the system CDV : Access via 'NULL' object reference not possible."</i>
i have checked in debugging and the error occured at the statement :
<i>lr_column = lr_column_settings->get_column( 'CURRENT_YEAR' ).</i>Please can you provide me an alternative for my requirement or correct me if i have done it wrong.
Thanks,
SuriI found it myself how to do it. The error says that it is not able to find the reference object i.e it is asking us to refer to the table. The following piece of code will solve this problem. Have to implement this in WDDOMODIFYVIEW method of the view. This thing works comrades enjoy...
DATA : lr_cmp_usage TYPE REF TO if_wd_component_usage,
lr_if_controller TYPE REF TO iwci_salv_wd_table,
lr_cmdl TYPE REF TO cl_salv_wd_config_table,
lr_col TYPE REF TO cl_salv_wd_column.
DATA : node_year TYPE REF TO if_wd_context_node,
elem_year TYPE REF TO if_wd_context_element,
stru_year TYPE if_alv_layout=>element_importing,
item_year LIKE stru_year-i_current_year,
lf_string TYPE char(x),
DATA: lr_column TYPE REF TO cl_salv_wd_column.
DATA: lr_column_header TYPE REF TO cl_salv_wd_column_header.
DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings.
Get the entered value from the input field of the screen
node_year = wd_context->get_child_node( name = 'IMPORTING_NODE' ).
elem_year = node_year->get_element( ).
elem_year->get_attribute(
EXPORTING
name = 'IMPORT_NODE-PARAMETER'
IMPORTING
value = L_IMPORT_PARAM ).
WRITE L_IMPORT_PARAM TO lf_string.
Get the reference of the table
lr_cmp_usage = wd_this->wd_cpuse_alv( ).
IF lr_cmp_usage->has_active_component( ) IS INITIAL.
lr_cmp_usage->create_component( ).
ENDIF.
lr_if_controller = wd_this->wd_cpifc_alv( ).
lr_column_settings = lr_if_controller->get_model( ).
get column by specifying column name.
IF lr_column_settings IS BOUND.
lr_column = lr_column_settings->get_column( 'COLUMN_NAME').
set Header Text as null
lr_column_header = lr_column->get_header( ).
lr_column_header->set_text( lf_string ).
endif. -
How to delete a particular row in ALV table
Hi,
How to delete a particular row in ALV table based on some condition(by checking value for one of the columns in a row)
Thanks
Bala DuvvuriHello Bala,
Can you please be a bit more clear as to how you intend to delete the rows from your ALV? By the way deleting rows from an ALV is no different from deleting rows from a normal table. Suppose you have enabled selection property in ALV & then select multiple rows and click up on a button to delete the rows then below would be the coding: (Also keep in mind that you would have to maintain the Selection property of the context node that you are binding to your ALV to 0..n)
data : lr_table_settings TYPE REF TO if_salv_wd_table_settings,
lr_config TYPE REF TO cl_salv_wd_config_table.
lr_table_settings ?= lr_config.
** Setting the ALV selection to multiple selection with no lead selection
lr_table_settings->set_selection_mode( value = cl_wd_table=>e_selection_mode-multi_no_lead ).
Next delete the selected rows in the action triggered by the button:
METHOD onactiondelete_rows .
DATA: wd_node TYPE REF TO if_wd_context_node,
lt_node1 TYPE ig_componentcontroller=>elements_node,
wa_temp TYPE REF TO if_wd_context_element,
lt_temp TYPE wdr_context_element_set,
row_number TYPE i VALUE 0.
wd_node = wd_context->get_child_node( name = 'NODE' ).
CALL METHOD wd_node->get_selected_elements
RECEIVING
set = lt_temp.
LOOP AT lt_temp INTO wa_temp.
wd_node->remove_element( EXPORTING element = wa_temp ).
ENDLOOP.
CALL METHOD wd_node->get_static_attributes_table
EXPORTING
from = 1
to = 2147483647
IMPORTING
table = lt_node1.
wd_node->bind_table( new_items = lt_node1 ).
ENDMETHOD.
If in case this isn't your requirement please do let me know so that I can try come up with another analysis.
Regards,
Uday -
Hi Experts,
I need single column to be selected from a ALV table...selected in da sense to be highlighted....as it happens..by default for a row.....
I hope u understood my query...
Please help me out in this..
I know u all will surely help me...
Thks and Regards,
Runali.Hi Runali,
Get the reference to the column settings of your ALV Model. Then you can get the reference of each column by passing the column ID. There is a method set_selected_state in the column class, but that does not highlight the column as it does for a row. So what you can use is a cell design for a column that will highlight the column with a color or whatever.
lr_column = lr_column_settings->get_column( ID = id ).
lr_column->set_cell_design( preferred design ).
Hope this helps. Please award points if it solves your purpose.
Regards,
Nithya -
UI Element : MessageArea : How to I show a ALV table instead of messages
UI Element : MessageArea : How to I show a ALV table (Message Log) instead of all the messages.
Hi,
Create a View Container UI Element at the bottom of the View and Embed ALV into it. Catch the Errors and populate into ALV instead of report message.
hope this helps u.,
Thanks & Regards,
Kiran -
How To Edit Selected Row In ALV Table
Hello Experts,
In My Webdynpro Application, I am displaying records from database table into an ALV Table.
I want to edit only selected record from ALV table.
Please Suggest How to achieve this.
Thanks,
PratibhaThe link given above is for the UI element 'Table' and does not pertain to ALV.
To Make an ALV Editable on lead selection for that particular lead selected row.
1. The ALV should be made lead selectable, when initializing
2. The ON_LEAD_SELECT function should be invoked.
3. Withing this function the index has to be retrieved to know which row was selected.
4. Based on the index retrived all the columns have to pass FALSE to read_only in the column properties.
Regards,
Pramod -
Hi,
Does any one have a code sample for the ALV Table Delete button? When I hit the DELETE button the selected row gets deleted but how can I save this deletion to the database table so that when I do a refresh the deleted row does not re-appear.
Thanks. KimHi Kim,
i am sorry but I dont have a sample code for this .. but yes i can tell you a very simple logic here that should work fine ..
When the user clicks on Delete Entry call method say "Delete_entry" and within this you can write code based on this logic..
1) On_Action_Lead_Select should copy the content of that row to another context node say "Selected_Entry"
2) Search for this entry in your internal table/database that was bound to the ALVs context node(data source) and remove it using standard functions
3) again read the database/internal table data and bind it to the context node ..
Your changes will be reflected in your ALV..
I hope this helps and if it does please do award points
Also please close the thread if the issue gets resolved ..
Regards,
Anoop -
How to create a context menu in ALV table cell editor(Webdynpro abap )
Hello Experts,
I am having a problem in creating a context menu in a table cell editor in the ALV table output.I have assigned a 'lta' as the cell editor.But befor assigning the lta as cell editor I have assigned the menu to the lta.But when the view is rendered I can see the lta with the actioned assigned to it.But I cannot see the context menu.
The code snippet below:
"Create menu for each coloumn
create OBJECT lo_menu_actions type CL_SALV_WD_VE_MENU EXPORTING
id = 'MITM_ACTIONS'.
lo_menu_actions->set_visible( value = abap_true ).
lo_menu_actions->set_visible_fieldname( value = 'ACTIONS' ).
"ADd menu items
CREATE OBJECT lo_menu_item_create type CL_SALV_WD_VE_MENU
exporting
id = 'MITM_CREATE_EXPRESSION'.
lo_menu_item_create->set_visible( value = abap_true ).
lo_menu_item_create->set_visible_fieldname( value = 'Create' ).
"Add item 1
lo_menu_actions->ADD_ITEM( VALUE = lo_menu_item_create ).
" Set the cell editor for each column cell(link to an action)
LOOP AT lt_node_dec_tab_cols INTO ls_node_dec_tab_cols .
lv_column_name = ls_node_dec_tab_cols-object_name.
lr_column = lr_column_settings->get_column( lv_column_name ).
"Create 'lta' Ui item
CREATE OBJECT lo_lta TYPE cl_salv_wd_uie_link_to_action.
lo_lta->set_menu( value = lo_menu_actions ).
lo_lta->set_text_fieldname( lv_column_name ).
lr_column->set_cell_editor( lo_lta ).
IF ls_node_dec_tab_cols-is_result EQ abap_true.
lr_column->set_cell_design( value =
cl_wd_table_column=>e_cell_design-key_medium ).
ENDIF.
ENDLOOP.Hi Prakash,
I have not come across this requirement till now to have context menu in a cell editor of alv.
Unfortunately the implementation of method SET_MENU of alv ui elements ( ex: cl_salv_wd_uie_text_view ) is not updating alv configurable table, instead it just stores in a global attribute as string. Hence has no effect on context menu.
If your user is very particular about this requirement of having context menu in cell editor, you can go for a normal table. Because, normal table's cell editor has the property to set the menuID as we do it for other ui elements.
Regards,
Rama
Maybe you are looking for
-
Java.lang.InternalError: need dictionary
Hi, i am trying to decode a byte [] to an object in an MDB. But when doing that i am getting the following exception, java.lang.InternalError: need dictionary at java.util.zip.Inflater.inflateBytes(Native Method) at java.util.zip.Inflater.i
-
am i able to delet a hd version but keep a sd?
-
ID3 Printing issue-multiple pages per sheet mirror image printing
So, like the title says, I'm trying to print 4 up per sheet out of ID CS3. The first page prints fine, but all pages that follow print as mirror images. I have gone through all the print settings for InDesign and specific to the printer (Xerox 7665)
-
I know that there are advantages to using the vNIC capabilities of the VIC M81KR along with the 2100 IO Module up to the 6100 series Fiber Interconnect. But If the customer was not convinced of the management advantages of the 6100 and the UCS Manage
-
Variation of NthLargest - how to extract from a different field
Relative beginner with Crystal and 1st post here - please excuse if answer obvious: I have 2 tables, one with static data describing contractors, the other with a table of rate history. So multiple rows per user, each with a start date and the corre