Help - Dynamic ALV
Dear all,
I made some changes to this sample program from The specified item was not found.
My requirement now is the field-symbol should be generated from the internal table.
FORM CREATE_TABLE *
Create dynamic table *
FORM CREATE_TABLE USING MY_TAB TAB_NAME.
DATA L_STUFF TYPE TY_STUFF.
CREATE DATA DATAREF TYPE (MY_TAB).
ASSIGN DATAREF->* TO <FS>.
DESCR_STRUCT_REF ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <FS> ).
CLEAN_TABLE IT_FIELDCATALOG.
LOOP AT DESCR_STRUCT_REF->COMPONENTS ASSIGNING <COMPONENT>.
WA_FCAT-FIELDNAME = <COMPONENT>-NAME.
WA_FCAT-REF_TABLE = MY_TAB.
WA_FCAT-REF_FIELD = <COMPONENT>-NAME.
APPEND WA_FCAT TO IT_FIELDCATALOG.
ENDLOOP.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FIELDCATALOG
IMPORTING
EP_TABLE = DATAREF
EXCEPTIONS
OTHERS = 1.
ASSIGN DATAREF->* TO <DYN_TABLE>.
L_STUFF-TABNAME = TAB_NAME.
CREATE DATA L_STUFF-TDREF LIKE LINE OF <DYN_TABLE>.
ASSIGN L_STUFF-TDREF->* TO <DYN_WA>.
ENDFORM. "CREATE_TABLE
Anybody pls shows some light?
i've tried using LVC_FIELDCATALOG_MERGE , REUSE_ALV_FIELDCATALOG_MERGE ,LVC_TRANSFER_FROM_SLIS
but to no avail.........pls help,thank you.
DESCR_STRUCT_REF ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <FS> ).
CLEAN_TABLE IT_FIELDCATALOG.
"<--Are you getting the components in this, is the loop success....check it once also change the fieldcatalog code..
LOOP AT DESCR_STRUCT_REF->COMPONENTS ASSIGNING <COMPONENT>.
wa_fcat-fieldname = <component>-name .
wa_fcat-datatype = <COMPONENT>-_kind.
wa_fcat-inttype = <COMPONENT>--type_kind.
wa_fcat-intlen = <COMPONENT>--length.
wa_fcat-decimals = <COMPONENT>--decimals.
APPEND WA_FCAT TO IT_FIELDCATALOG.
ENDLOOP.
Similar Messages
-
Help: Dynamic ALV from an dynamic Node
Hi Expart,
I have a question. I need to create an dynamic context node, and depending upon that dynamic context node, I need to create an dynamic ALV in the View. Is it possible to create two level of dynamic implimentation in case of ALV ?
if possibel in that case, can ayn one give some hint, how to create ? or some document link to help me out. Any kind of help is mostly welcome.
thanks in advance.
Regards
Satrajit.Yes it is possible.
To create the dynamic node you can use the method ADD_NEW_CHILD_NODE of the node info object. You can use a ddic structure/table or an RTTI instance to supply the information for the node attributes.
rootnode_info = wd_context->get_node_info( ).
* Create dynamic sub node name TEST1 of structure (tablename)
dyn_node_info = rootnode_info->add_new_child_node(
static_element_type = tablename
name = tablename ). " Web Dynpro: Name of Context Node
You can then bind to the dynamic context node like normal:
* get instance of new node
dyn_node = wd_context->get_child_node( name = tablename ).
* Bind internal table to context node
dyn_node->bind_table( <tab> ).
Then connect the dynamic context node to an ALV component usage:
* Connect to the component Usage of the ALV
if wd_this->wd_cpuse_alv( )->has_active_component( ) is initial.
wd_this->wd_cpuse_alv( )->create_component( ).
endif.
* Through the interface controller of the ALV Component set the DATA node dynamically
wd_this->wd_cpifc_alv( )->set_data( r_node_data = dyn_node ). -
Dynamic ALV and cl_abap_structdescr Create method
Hi
In the process of creation of Dynamic ALV, as I have char_name and char_descr fields, I have to use char_descr as column header of ALV because char_name which has entries something like DVS_******(that do not make any sense to user). I am facing 2 problems here using the scenario above.
1. char_descr contains characters like '[', ']', ' /', '.', space which are invalid characters for method cl_abap_structdescr=>create(). How to handle scenario like this?
2. assign (lv_value) to <value>.
if sy-subrc = 0.
<value> = ls_bapi_char_value-charvalue.
if <value> is assigned.
move ls_bapi_char_value-charvalue to <value>.
where-> concatenate '<table_dyn_wa>-' ls_bapi_char-char_descr into lv_value
<value> type any
<table_dyn_wa>- is dynamic table with structure created with cl_abap_tabledescr=>create( p_line_type = stru_type )
with above code for few fields data is being assigned and for few sy-subrc = 4. The table from where I am reading the field contains char_name associated with it and not char_descr. For the fields whose char_name and char_descr matches exactly, ALV displays data for it.
How to resolve the issue so that I could get all the data?
Let me know if further details are needed.
Thanks, in advance
Trupti
Edited by: TRUPTI KALLURWAR on Jul 9, 2010 7:08 PMHello Srikanth,
CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE( ) uses the GENERATE SUBROUTINE POOL technique to create the dynamic internal tables.
And as per the SAP documentation,
In an internal mode, a maximum of 36 temporary subroutine pools may be created.
Source: [http://help.sap.com/abapdocu_702/en/abapgenerate_subroutine_pool.htm]
Btw why are you crating 36 dynamic internal table? That's way too far-fetched even for the RTTC classes
BR,
Suhas -
Hi all
i try to put color in the dynamic alv, but i become a dump message
Runtime Errors OBJECTS_MOVE_NOT_SUPPORTED
Date and Time 28.10.2010 08:46:49
Short text
Conversion of type "h" to type "g" not supported.
What happened?
Error in the ABAP Application Program
The current ABAP program "SAPLSLVC" had to be terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
You attempted to move one data object to another.
This is not possible here because the conversion of a data object
of type "h" to type "g" is not supported.
my code implementation looks like
method validate_order_deli.
data ls_scol type lvc_s_scol.
data ls_colo type lvc_s_colo.
data ls_aoc_percent type zsd_aoc_percent.
data lf_deliv type lifmg.
data lf_db_percent type f.
data lf_calc_perc type f.
refresh et_color.
select single *
from zsd_aoc_percent
into corresponding fields of ls_aoc_percent
where acin = 'X'.
if sy-subrc <> 0.
exit.
endif.
lf_db_percent = ls_aoc_percent-percent.
* ls_scol-fname = if_fieldname.
ls_scol-fname = 'MATNR'.
if if_deliv <> 0.
me->calc_amour_unit(
exporting
if_matnr = if_matnr
if_amount = if_deliv
if_input = if_deliv_unit
if_output = if_order_unit
importing
ef_amount = lf_deliv
lf_calc_perc = ( lf_deliv * 100 ) / if_order.
if lf_calc_perc < lf_db_percent.
ls_colo-col = cl_gui_resources=>list_col_positive.
else.
ls_colo-col = cl_gui_resources=>list_col_negative.
endif.
ls_scol-color = ls_colo.
append ls_scol to et_color.
else.
exit.
endif.
endmethod. "validate_order_deli
method add_color_field.
data ls_fcat type lvc_s_fcat.
ls_fcat-fieldname = 'COLOR'.
ls_fcat-ref_field = 'COLTAB'.
ls_fcat-ref_table = 'CALENDAR_TYPE'.
append ls_fcat to ct_fcat.
endmethod. "add_color_field
ls_lvc_s_layo-cwidth_opt = 'X'.
ls_lvc_s_layo-ctab_fname = 'COLOR'.
i don't no, what's wrong...
thx for help*& Form generate_alv
* text
form generate_alv.
field-symbols <lt_any_table> type any table.
if lrf_gui_custom_container is initial.
create object lrf_gui_custom_container
exporting
container_name = lf_container.
create object lrf_gui_alvgrid
exporting
i_parent = lrf_gui_custom_container.
ls_lvc_s_layo-cwidth_opt = 'X'.
ls_lvc_s_layo-ctab_fname = 'COLOR'.
check sy-subrc = 0.
call method lrf_gui_alvgrid->set_table_for_first_display
exporting
* i_buffer_active =
* i_bypassing_buffer =
* i_consistency_check =
* i_structure_name = 'ZAM_CELL_COLOR'
* is_variant = ls_disvariant
* i_save = 'A'
* i_default = 'X'
is_layout = ls_lvc_s_layo
* is_print =
* it_special_groups =
* it_toolbar_excluding =
* it_hyperlink =
* it_alv_graphics =
* it_except_qinfo =
* ir_salv_adapter =
changing
it_outtab = <gt_table>
it_fieldcatalog = gt_dyn_fcat
* it_filter =
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
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.
endif.
endform. "generate_alv
*& Module STATUS_0100 OUTPUT
* text
module status_0100 output.
set pf-status 'ZAM_CELL_STATUS'.
set titlebar 'ZAM_CELL_TIT'.
perform generate_alv.
endmodule. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
* text
module user_command_0100 input.
data lf_okcode type syucomm.
call method cl_gui_cfw=>dispatch.
lf_okcode = ok_code.
case lf_okcode.
when 'EXIT'.
set screen 0.
leave screen.
when 'CANCEL'.
leave program.
when 'BACK'.
set screen 0.
leave screen..
endcase.
endmodule. " USER_COMMAND_0100 INPUT -
I want to create dynamic ALV report
Hi great abapers,
I want to create dynamic ALV report.Please help me.
Regards,
BillaHi,
Please check the code below:
REPORT YMMR_PALLET_OVERVIEW MESSAGE-ID Y_MESSAGE_0001.
Short description:
To Display and sum up the Quantity of scanned materials on pallet for*
each Shipment number for the Packaging Materials. *
TYPE-POOLS : SLIS.
TABLES: YYLE0003. " Scanned SSCC No.
--Structure Declaration--
Structure for Shipment No. and Date.
TYPES : BEGIN OF T_VTTK_TAB ,
TKNUM LIKE VTTK-TKNUM, " Shipment number
ERDAT LIKE VTTK-ERDAT, " created Date
END OF T_VTTK_TAB .
Structure for Shipment No., Packaging Materials and Date.
TYPES: BEGIN OF T_ITAB2,
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
QUANTITY TYPE P,
ERDAT LIKE YYLE0003-ERDAT, " created Date
COUNT TYPE I,
END OF T_ITAB2.
Structure for Shipment No. and Packaging Materials.
TYPES: BEGIN OF T_ITAB3,
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
QUANTITY TYPE P, " Quantity
END OF T_ITAB3.
--Internal table Declaration--
*Internal tables for the above Declared structures
DATA: G_VTTK_TAB TYPE TABLE OF T_VTTK_TAB,
G_ITAB5_TAB TYPE TABLE OF T_ITAB2,
G_ITAB4_TAB TYPE TABLE OF T_ITAB3,
G_ITAB3_TAB TYPE TABLE OF T_ITAB2. "#EC NEEDED
*Internal table Holding Shipment No.and quantity
DATA: BEGIN OF G_TOTAL_TAB OCCURS 0 ,
TKNUM TYPE YYLE0003-TKNUM, " Shipment number
QUANTITY TYPE P,
COUNT TYPE I,
END OF G_TOTAL_TAB .
*Internal table for selection screen data
DATA: BEGIN OF G_SCANDATA_TAB OCCURS 0,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
EXIDV TYPE EXIDV, " External Handling Unit
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
END OF G_SCANDATA_TAB.
DATA: BEGIN OF ST_SCANDATA_TAB,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
EXIDV TYPE EXIDV, " External Handling Unit
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
END OF ST_SCANDATA_TAB.
DATA: BEGIN OF G_SCANDATA_COUNT_TAB OCCURS 0,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
TKNUM LIKE YYLE0003-TKNUM, " Shipment number
QUANTITY LIKE YYLE0003-QUANTITY, " Quantity
COUNT TYPE I,
END OF G_SCANDATA_COUNT_TAB.
DATA: L_COUNT TYPE I.
*Internal table for Packaging Materials and quantity
DATA: BEGIN OF G_ITAB6_TAB OCCURS 0,
VHILM LIKE YYLE0003-VHILM, " Packaging Materials
QUANTITY TYPE P, " Quantity
END OF G_ITAB6_TAB.
*- Field catalog
DATA: L_ALV_CAT1_TAB TYPE TABLE OF LVC_S_FCAT.
--Work area Declaration--
DATA: WA_VTTK TYPE T_VTTK_TAB,
WA_ITAB3 TYPE T_ITAB2,
WA_ITAB5 TYPE T_ITAB2,
WA_ITAB4 TYPE T_ITAB3,
WA_ITAB1 LIKE G_SCANDATA_TAB,
WA_ALV_CAT1 LIKE LINE OF L_ALV_CAT1_TAB.
----Variable Defnition -
DATA: G_CUSTOM_CONTAINER_0100 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_ALV_GRID_0100 TYPE REF TO CL_GUI_ALV_GRID,
G_CONTAINER_0100 TYPE SCRFNAME VALUE 'LIST',
G_MYLAYOUT TYPE LVC_S_LAYO, "#EC NEEDED
G_WA TYPE REF TO DATA.
DATA: G_VAR TYPE I, " No of records
G_VAR1 TYPE CHAR20. " Variable
--field symbols Declaration--
FIELD-SYMBOLS : <F_FS> TYPE TABLE,
<F_FS3> TYPE ANY,
<F_FS4> TYPE ANY,
<F_FS5> TYPE ANY,
<F_WA> TYPE ANY,
<F_FS15> TYPE ANY,
<F_FS16> TYPE SY-DATUM,
<F_FS2> TYPE T_ITAB2,
<F_FS6> TYPE ANY,
<F_FS7> TYPE ANY,
<F_FS12> TYPE ANY,
<F_FS13> TYPE ANY.
--Selection Parameters--
SELECTION-SCREEN: BEGIN OF BLOCK BLCK01 WITH FRAME TITLE TEXT-000.
"Select options
SELECT-OPTIONS :
S_TKNUM FOR YYLE0003-TKNUM , " Shipment number
S_YYREF FOR YYLE0003-YY_REFERENCE, " Packing reference
S_YYREFT FOR YYLE0003-YY_REFTP, " Reference type
S_EXIDV FOR YYLE0003-EXIDV, " External HU
S_MATNR FOR YYLE0003-MATNR, " Material number
S_VBELN FOR YYLE0003-VBELN, " SD number
S_POSNR FOR YYLE0003-POSNR, " Item number
S_LGTOR FOR YYLE0003-LGTOR, " Door for Wr Hs No
S_VHILM FOR YYLE0003-VHILM, " Packaging Mat
S_YYMEIN FOR YYLE0003-YY_MEINH, " Indicator for UOM
S_QUANTI FOR YYLE0003-QUANTITY, " Quantity
S_YCHECK FOR YYLE0003-YYCHECKED, " Destination_door
S_STATUS FOR YYLE0003-STATUS, " Packing status
S_STASHI FOR YYLE0003-STATUSSHIPTO, " Status on ship-to
S_LOADTR FOR YYLE0003-LOADTRUCK, " Load truck
S_ERDAT FOR YYLE0003-ERDAT , " Date
S_ERZET FOR YYLE0003-ERZET, " Entry time
S_AEDAT FOR YYLE0003-AEDAT, " Last changed on
S_ERNAM FOR YYLE0003-ERNAM, " Name of Person
S_AEZET FOR YYLE0003-AEZET, " Time last change
S_AENAM FOR YYLE0003-AENAM. " Name of person
SELECTION-SCREEN: END OF BLOCK BLCK01.
--INITIALIZATION--
INITIALIZATION.
Clear the variables and workarea
CLEAR :G_VAR,
G_VAR1,
WA_VTTK,
WA_ITAB3,
WA_ITAB5,
WA_ITAB4,
WA_ITAB1,
WA_VTTK,
WA_ITAB3,
WA_ITAB5,
WA_ITAB4,
WA_ITAB1.
--AT SELECTION-SCREEN--
AT SELECTION-SCREEN.
To validate the data entered in selection screen
PERFORM SUB_VALIDATE.
--START-OF-SELECTION--
START-OF-SELECTION.
*To fetch the data from table yyle0003
PERFORM GET_INPUT_DATA.
*To create the Dynamic Field Catalog
PERFORM GET_FIELDCAT.
To populate the data to final table
PERFORM GET_FINAL_DATA.
MODULE status_0100 OUTPUT *
MODULE STATUS_0100 OUTPUT.
*set title bar and PF status.
SET PF-STATUS 'ZVKS'.
SET TITLEBAR 'ZVKS'.
CHECK SY-UCOMM IS INITIAL.
SORT G_SCANDATA_TAB BY TKNUM VHILM.
*Create object for Custom container
CREATE OBJECT G_CUSTOM_CONTAINER_0100
EXPORTING
CONTAINER_NAME = G_CONTAINER_0100
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
*Create object for ALV grid
CREATE OBJECT G_ALV_GRID_0100
EXPORTING I_PARENT = G_CUSTOM_CONTAINER_0100.
G_MYLAYOUT-GRID_TITLE = 'Display Scanning data'.
*Call method for table Display
CALL METHOD G_ALV_GRID_0100->SET_TABLE_FOR_FIRST_DISPLAY
CHANGING
IT_OUTTAB = <F_FS>
IT_FIELDCATALOG = L_ALV_CAT1_TAB
EXCEPTIONS
INVALID_PARAMETER_COMBINATION = 1
PROGRAM_ERROR = 2
TOO_MANY_LINES = 3
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.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
User Interaction
MODULE USER_COMMAND_0100 INPUT.
CALL METHOD CL_GUI_CFW=>DISPATCH.
*To exit , back or cancel
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'CANCEL'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form get_input_data
This sub routine will get the data from yyle0003 table.
FORM GET_INPUT_DATA.
CONSTANTS: C_DOT TYPE C VALUE '.',
C_CHAR TYPE C VALUE 'D'.
CLEAR G_SCANDATA_TAB.
Get the data from yyle0003
SELECT VHILM " Packaging Materials
EXIDV " External Handling Unit
TKNUM " Shipment number
QUANTITY " Quantity
FROM YYLE0003
INTO TABLE G_SCANDATA_TAB
WHERE TKNUM IN S_TKNUM " Shipment number
AND YY_REFERENCE IN S_YYREF " Packing reference
AND YY_REFTP IN S_YYREFT " Reference type
AND EXIDV IN S_EXIDV " External Handling Unit
AND MATNR IN S_MATNR " Material number
AND VBELN IN S_VBELN " SD number
AND POSNR IN S_POSNR " Item number
AND LGTOR IN S_LGTOR " Door for warehouse No
AND VHILM IN S_VHILM " Packaging Materials
AND YY_MEINH IN S_YYMEIN " Indicator for UOM
AND QUANTITY IN S_QUANTI " Quantity
AND YYCHECKED IN S_YCHECK " Destination_door
AND STATUS IN S_STATUS " Packing status
AND STATUSSHIPTO IN S_STASHI " Status on ship-to
AND LOADTRUCK IN S_LOADTR " Load truck
AND ERDAT IN S_ERDAT " Date
AND ERZET IN S_ERZET " Entry time
AND AEDAT IN S_AEDAT " Last changed on
AND ERNAM IN S_ERNAM " Name of Person
AND AEZET IN S_AEZET " Time last change
AND AENAM IN S_AENAM. " Name of person
If VHILM contains any Decimal '.', replace it with D
LOOP AT G_SCANDATA_TAB.
REPLACE C_DOT WITH C_CHAR INTO G_SCANDATA_TAB-VHILM.
IF SY-SUBRC = 0.
MODIFY G_SCANDATA_TAB TRANSPORTING VHILM.
ENDIF.
CLEAR G_SCANDATA_TAB.
ENDLOOP.
*To get the Shipment No Creation date from VTTK.
SELECT TKNUM
ERDAT
FROM VTTK
INTO TABLE G_VTTK_TAB
WHERE TKNUM IN S_TKNUM.
SORT G_SCANDATA_TAB BY VHILM EXIDV. "TKNUM VHILM.
*To get the repeatition of Pacakaging material for each Shipment.
*--- to find the count of packaging materials under each shipment
LOOP AT G_SCANDATA_TAB.
READ TABLE G_SCANDATA_TAB INTO ST_SCANDATA_TAB INDEX SY-TABIX.
AT END OF EXIDV.
L_COUNT = L_COUNT + 1.
MOVE-CORRESPONDING ST_SCANDATA_TAB TO G_SCANDATA_COUNT_TAB.
G_SCANDATA_COUNT_TAB-COUNT = L_COUNT.
CLEAR: ST_SCANDATA_TAB, L_COUNT.
COLLECT G_SCANDATA_COUNT_TAB.
ENDAT.
CLEAR : G_SCANDATA_TAB.
ENDLOOP.
ENDFORM. " get_input_data
*& Form sub_validate
*This subroutine will validate the data eneterd in the selection screen
FORM SUB_VALIDATE.
*Varaiable declaration for Shipment number
DATA: L_TKNUM TYPE YYLE0003-TKNUM."#EC NEEDED " Shipment number
*- Condition will not qualify all primary key (IDENT)
SELECT TKNUM FROM YYLE0003 UP TO 1 ROWS
INTO L_TKNUM "wa_scandata
WHERE TKNUM IN S_TKNUM " Shipment number
AND YY_REFERENCE IN S_YYREF " Packing reference
AND YY_REFTP IN S_YYREFT " Reference type
AND EXIDV IN S_EXIDV " External Handling Unit
AND MATNR IN S_MATNR " Material number
AND VBELN IN S_VBELN " SD number
AND POSNR IN S_POSNR " Item number
AND LGTOR IN S_LGTOR " Door for warehouse No
AND VHILM IN S_VHILM " Packaging Materials
AND YY_MEINH IN S_YYMEIN " Indicator for UOM
AND QUANTITY IN S_QUANTI " Quantity
AND YYCHECKED IN S_YCHECK " Destination_door
AND STATUS IN S_STATUS " Packing status
AND STATUSSHIPTO IN S_STASHI " Status on ship-to
AND LOADTRUCK IN S_LOADTR " Load truck
AND ERDAT IN S_ERDAT " Date
AND ERZET IN S_ERZET " Entry time
AND AEDAT IN S_AEDAT " Last changed on
AND ERNAM IN S_ERNAM " Name of Person
AND AEZET IN S_AEZET " Time last change
AND AENAM IN S_AENAM. " Name of person
ENDSELECT.
IF SY-SUBRC <> 0.
MESSAGE E987 . " No data found for these selection criterias
ENDIF.
ENDFORM. " sub_validate
*& Form get_fieldcat
Preparing Field catalog
FORM GET_FIELDCAT.
DATA: L_REF TYPE REF TO DATA,
L_I TYPE I. " Variable
CONSTANTS: C_CENTER TYPE C VALUE 'C'. " Center Justified
LOOP AT G_SCANDATA_TAB INTO WA_ITAB1.
MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB3.
APPEND WA_ITAB3 TO G_ITAB3_TAB.
MOVE-CORRESPONDING WA_ITAB1 TO WA_ITAB4.
COLLECT WA_ITAB4 INTO G_ITAB4_TAB.
*To sum up the qunatity field for each TKNUM.
AT END OF TKNUM.
SUM.
MOVE WA_ITAB1-TKNUM TO G_TOTAL_TAB-TKNUM.
MOVE WA_ITAB1-QUANTITY TO G_TOTAL_TAB-QUANTITY .
APPEND G_TOTAL_TAB.
CLEAR G_TOTAL_TAB.
ENDAT.
CLEAR : WA_ITAB1,
WA_ITAB3,
WA_ITAB4.
ENDLOOP.
*--- Begin of change - SKR.EXT - EBDK986377
SORT G_ITAB4_TAB BY TKNUM.
*--- End of change - SKR.EXT - EBDK986377
LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
MOVE-CORRESPONDING WA_ITAB4 TO WA_ITAB5.
MOVE-CORRESPONDING WA_ITAB4 TO G_ITAB6_TAB.
*---- to get the count
READ TABLE G_SCANDATA_COUNT_TAB WITH KEY TKNUM = WA_ITAB5-TKNUM
VHILM = WA_ITAB5-VHILM.
IF SY-SUBRC EQ 0.
WA_ITAB5-COUNT = G_SCANDATA_COUNT_TAB-COUNT.
ENDIF.
APPEND WA_ITAB5 TO G_ITAB5_TAB.
COLLECT G_ITAB6_TAB.
ENDLOOP.
CLEAR : WA_ITAB3.
SORT G_ITAB4_TAB BY TKNUM VHILM.
DELETE ADJACENT DUPLICATES FROM G_ITAB4_TAB COMPARING VHILM.
*To get the Number of fields to be displayed
DESCRIBE TABLE G_ITAB4_TAB LINES G_VAR.
L_I = '3'.
*Field catalog
WA_ALV_CAT1-FIELDNAME = 'TKNUM'(002).
WA_ALV_CAT1-COL_POS = 1.
WA_ALV_CAT1-COLTEXT ='ShipmentNo.'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR : WA_ALV_CAT1.
WA_ALV_CAT1-FIELDNAME = 'ERDAT'(003).
WA_ALV_CAT1-COL_POS = 2.
WA_ALV_CAT1-COLTEXT ='Creation_Date.'(005).
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR : WA_ALV_CAT1.
Create field catalog for each of VHILM
LOOP AT G_ITAB4_TAB INTO WA_ITAB4.
IF G_VAR >= 1.
CONDENSE WA_ITAB4-VHILM NO-GAPS.
WA_ALV_CAT1-FIELDNAME = WA_ITAB4-VHILM. "l_fieldname.
WA_ALV_CAT1-COL_POS = L_I.
WA_ALV_CAT1-COLTEXT = WA_ITAB4-VHILM.
WA_ALV_CAT1-JUST = C_CENTER. "'C'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR WA_ALV_CAT1.
L_I = L_I + 1.
ENDIF.
*TOTAL-last column in the field catalog
AT LAST.
WA_ALV_CAT1-FIELDNAME = 'TOTAL'(004).
WA_ALV_CAT1-COL_POS = L_I.
WA_ALV_CAT1-COLTEXT = 'TOTAL'(004).
WA_ALV_CAT1-JUST = C_CENTER. " 'C'.
APPEND WA_ALV_CAT1 TO L_ALV_CAT1_TAB.
CLEAR WA_ALV_CAT1.
ENDAT.
SORT L_ALV_CAT1_TAB BY FIELDNAME.
*Non of the field name should not get repeated
DELETE ADJACENT DUPLICATES FROM L_ALV_CAT1_TAB.
ENDLOOP.
SORT L_ALV_CAT1_TAB BY COL_POS.
*Creating Dynamic Internal table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = L_ALV_CAT1_TAB
IMPORTING
EP_TABLE = L_REF.
Assigning the Dynamic field Catalog to field symbol.
ASSIGN L_REF->* TO <F_FS>.
CREATE DATA G_WA LIKE LINE OF <F_FS>.
ASSIGN G_WA->* TO <F_WA>.
DELETE ADJACENT DUPLICATES FROM <F_FS> COMPARING ALL FIELDS.
ENDFORM. " get_fieldcat
*& Form display_data
FORM GET_FINAL_DATA.
*variable declaration
DATA: L_TOTAL TYPE I, " Row wise total
L_FILL TYPE I, " Count
L_TOT TYPE I. " Grand total
*To get the TOTAL qunatity in the last line of out put.
LOOP AT G_ITAB6_TAB.
CLEAR WA_ITAB5.
WA_ITAB5-TKNUM = 'TOTAL'(004).
WA_ITAB5-ERDAT = SPACE.
MOVE-CORRESPONDING G_ITAB6_TAB TO WA_ITAB5 .
LOOP AT G_SCANDATA_COUNT_TAB WHERE VHILM = G_ITAB6_TAB-VHILM.
WA_ITAB5-COUNT = WA_ITAB5-COUNT + G_SCANDATA_COUNT_TAB-COUNT.
ENDLOOP.
APPEND WA_ITAB5 TO G_ITAB5_TAB.
CLEAR WA_ITAB5.
ENDLOOP.
DESCRIBE TABLE G_ITAB5_TAB LINES L_TOT.
*>>>>>>>>
****To get total qunatity of all TKNUM
LOOP AT G_TOTAL_TAB .
L_TOTAL = L_TOTAL + G_TOTAL_TAB-QUANTITY.
ENDLOOP.
*>>>>>>>>
*To assign ERDAT to g_itab5_tab
LOOP AT G_ITAB5_TAB INTO WA_ITAB5 .
READ TABLE G_VTTK_TAB INTO WA_VTTK WITH KEY TKNUM = WA_ITAB5-TKNUM.
IF SY-SUBRC = 0.
WA_ITAB5-ERDAT = WA_VTTK-ERDAT.
MODIFY G_ITAB5_TAB FROM WA_ITAB5 TRANSPORTING ERDAT.
ENDIF.
ENDLOOP.
*Assigning value in each field to respective Field symbols.
LOOP AT G_ITAB5_TAB ASSIGNING <F_FS2>.
CLEAR G_TOTAL_TAB-QUANTITY.
ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_FS2> TO <F_FS6>.
ASSIGN COMPONENT 'TKNUM' OF STRUCTURE <F_WA> TO <F_FS7>.
<F_FS7> = <F_FS6>.
CONDENSE <F_FS2>-VHILM NO-GAPS.
ASSIGN COMPONENT 'VHILM' OF STRUCTURE <F_FS2> TO <F_FS3>.
ASSIGN COMPONENT 5 OF STRUCTURE <F_FS2> TO <F_FS4>.
MOVE <F_FS3> TO G_VAR1.
ASSIGN COMPONENT G_VAR1 OF STRUCTURE <F_WA> TO <F_FS5>.
<F_FS5> = <F_FS4>.
ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_FS2> TO <F_FS16>.
ASSIGN COMPONENT 'ERDAT' OF STRUCTURE <F_WA> TO <F_FS15>.
WRITE <F_FS16> TO <F_FS15> .
Inorder not to display the date '00/00/000',
if there is no DATE .
IF ( <F_FS15> CP '00/*' )
OR ( <F_FS15> CP '00.*' )
OR ( <F_FS15> CP '00-*' ).
<F_FS15> = SPACE.
ELSEIF ( <F_FS15> CO ' / /' )
OR ( <F_FS15> CO ' . .' )
OR ( <F_FS15> CO ' - -' ) .
<F_FS15> = SPACE.
ENDIF.
READ TABLE G_TOTAL_TAB WITH KEY TKNUM = <F_FS6>.
IF SY-SUBRC = 0.
ASSIGN G_TOTAL_TAB-QUANTITY TO <F_FS12>.
ASSIGN COMPONENT 'COUNT' OF STRUCTURE <F_FS2> TO <F_FS12>.
ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
<F_FS13> = <F_FS13> + <F_FS12>.
L_TOTAL = L_TOTAL + <F_FS12>.
ENDIF.
L_FILL = L_FILL + 1.
IF L_FILL = L_TOT.
ASSIGN L_TOTAL TO <F_FS12>.
ASSIGN COMPONENT 'TOTAL' OF STRUCTURE <F_WA> TO <F_FS13>.
<F_FS13> = <F_FS12>.
ENDIF.
AT END OF <F_FS2>-TKNUM.
APPEND <F_WA> TO <F_FS>.
CLEAR <F_WA>.
ENDAT.
ENDLOOP.
CLEAR: <F_FS6>,
<F_FS7>,
<F_WA>.
*Call the screen where Custom container is defined
CALL SCREEN 0100.
ENDFORM. " display_data
Regards
Kannaiah -
Colors in Dynamic ALV table display
Hello All,
I have dynamic ALV table display in which i created the columns dynamically and finally binded that created node and diplayed the table ..
Now what i want to do is depending on some condition i need to change the colors in the table display..
I tried to set the color in this way inside the loop .
if lv_phase = '3'.
lr_column->set_cell_design( CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-badvalue_medium ).
else.
lr_column->set_cell_design( CL_WD_TABLE_COLUMN=>E_CELL_DESIGN-standard ).
endif.
This piece of code either changes all the coloumns into one color only why it is not changing the color based upon the condition . I am unable to understand..
Please help me in this...Do i need to some thing else..Solved by creating a new column called cell design ... and settign the set_cell_design_fieldname ...
This solved my Problem .. -
Dynamic ALV as per the periods on the selection screen
Hello Experts
I am new to dynamic ALV , Please help me to sought out my confusion.
I want to create a dynamic ALV , based on the period mentioned at selection screen.
for example I want to display the movement type ( sum of the quantity ) for materials for the full month.
I want the ALV output as below.
Material .........qty 01.04.2011..... qty 02.04.2011... qty 03.04.2011 ........ qty 30.04.2011
AB1........................... 30.................... 20............................. 50......................... 200
AB2.................................................... 50 ............................. 80 ..........................10
I create an internal table itab with there fields to selact the data
MATNR
date
qty
select MATNR
date
qty
into itab
from mseg
where based on the selection screen.
then collect the data to other table date wise , now i have summrise data of material quantity
now the results after collection data into table itab2 is as follows
Material ................... date ................................ qty
AB1 .................... 01.04.2011....................... 30
AB1 ................... 02.04.2011 ....................... 20
AB1 ................... 03.04.2011....................... 50
AB1 ................... .30.04.2011....................... 200
AB2 .................... 02.04.2011....................... 50
AB2 ....................... 03.04.2011....................... 80
AB2 ....................... 30.04.2011 ....................... 10
How can I display these fields horizontally instead of vertically ,
and to the exact column as per the field catalog column header belongs to date.
it would be so helpful if somebody explain with code by taking the above example.
Thanks in AdvanceHello Both Experts ,
I write the below code and it is working for the requirement.
Can you please check
REPORT z_test_dynamic .
TABLES : mkpf , mseg .
TYPES : BEGIN OF t_mseg ,
mblnr TYPE mblnr ,
bwart TYPE bwart ,
matnr TYPE matnr ,
werks TYPE werks_d ,
menge TYPE menge_d ,
budat TYPE budat ,
END OF t_mseg.
TYPES : BEGIN OF t_mseg_1 ,
matnr TYPE matnr ,
menge TYPE menge_d ,
budat TYPE budat ,
END OF t_mseg_1.
DATA : gt_mseg TYPE STANDARD TABLE OF t_mseg ,
gs_mseg TYPE t_mseg,
gt_mseg_1 TYPE STANDARD TABLE OF t_mseg_1 ,
gs_mseg_1 TYPE t_mseg_1,
gt_mseg_2 TYPE STANDARD TABLE OF t_mseg_1 ,
gs_mseg_2 TYPE t_mseg_1..
DATA : gt_date TYPE STANDARD TABLE OF sy-datum ,
gs_date TYPE sy-datum..
DATA: ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'CONTAINER_01',
grid1 TYPE REF TO cl_gui_alv_grid,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA: gt_fieldcat TYPE lvc_t_fcat.
DATA: gp_table TYPE REF TO data.
FIELD-SYMBOLS: <gt_table> TYPE table.
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_matnr FOR mseg-matnr ,
s_bwart FOR mseg-bwart NO INTERVALS,
s_werks FOR mseg-werks ,
s_budat FOR mkpf-budat .
PARAMETERS : p_mjahr TYPE mjahr OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
PERFORM field_catalog.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = gt_fieldcat
IMPORTING
ep_table = gp_table.
ASSIGN gp_table->* TO <gt_table>.
PERFORM select_main_data.
PERFORM move_data.
*& Form select_main_data
* text
* --> p1 text
* <-- p2 text
FORM select_main_data .
SELECT mseg~mblnr
mseg~bwart
mseg~matnr
mseg~werks
mseg~menge
mkpf~budat
INTO TABLE gt_mseg
FROM mseg AS mseg INNER JOIN mkpf AS mkpf
ON mseg~mblnr = mkpf~mblnr AND
mseg~mjahr = mkpf~mjahr
WHERE matnr IN s_matnr AND
budat IN s_budat AND
werks IN s_werks AND
bwart IN s_bwart AND
mseg~mjahr EQ p_mjahr .
IF gt_mseg IS NOT INITIAL.
LOOP AT gt_mseg INTO gs_mseg.
gs_mseg_1-matnr = gs_mseg-matnr.
gs_mseg_1-budat = gs_mseg-budat.
gs_mseg_1-menge = gs_mseg-menge.
COLLECT gs_mseg_1 INTO gt_mseg_1.
ENDLOOP.
ENDIF.
gt_mseg_2 = gt_mseg_1.
DELETE ADJACENT DUPLICATES FROM gt_mseg_2 COMPARING matnr.
ENDFORM. " select_main_data
*& Form field_catalog
* text
* --> p1 text
* <-- p2 text
FORM field_catalog .
DATA : lt_day_attributes TYPE STANDARD TABLE OF casdayattr ,
ls_day_attributes TYPE casdayattr .
DATA: ls_fieldcat TYPE lvc_s_fcat ,
lv_fieldname TYPE lvc_fname.
IF s_budat-high IS INITIAL.
s_budat-high = s_budat-low.
ENDIF.
CALL FUNCTION 'DAY_ATTRIBUTES_GET'
EXPORTING
* FACTORY_CALENDAR = ' '
* HOLIDAY_CALENDAR = ' '
date_from = s_budat-low
date_to = s_budat-high
language = sy-langu
* IMPORTING
* YEAR_OF_VALID_FROM =
* YEAR_OF_VALID_TO =
* RETURNCODE =
TABLES
day_attributes = lt_day_attributes
* EXCEPTIONS
* FACTORY_CALENDAR_NOT_FOUND = 1
* HOLIDAY_CALENDAR_NOT_FOUND = 2
* DATE_HAS_INVALID_FORMAT = 3
* DATE_INCONSISTENCY = 4
* 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.
LOOP AT lt_day_attributes INTO ls_day_attributes.
gs_date = ls_day_attributes-date.
APPEND gs_date TO gt_date.
ENDLOOP.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-inttype = 'CHAR18'.
ls_fieldcat-coltext = 'MATERIAL'.
* ls_fieldcat-decimals_o = '2'.
ls_fieldcat-outputlen = 18.
APPEND ls_fieldcat TO gt_fieldcat.
LOOP AT gt_date INTO gs_date.
CONCATENATE 'QTY_' gs_date INTO lv_fieldname.
ls_fieldcat-fieldname = lv_fieldname.
ls_fieldcat-inttype = 'QUAN'.
ls_fieldcat-coltext = gs_date.
ls_fieldcat-decimals_o = '2'.
* ls_fieldcat-outputlen = 18.
APPEND ls_fieldcat TO gt_fieldcat.
ENDLOOP.
ENDFORM. " field_catalog
*& Form move_data
* text
* --> p1 text
* <-- p2 text
FORM move_data .
DATA: l_row TYPE sy-index.
FIELD-SYMBOLS: <ls_table>.
FIELD-SYMBOLS: <l_field> ,
<l_mseg_1> TYPE t_mseg_1.
DATA: ls_fieldcat TYPE lvc_s_fcat .
ASSIGN LOCAL COPY OF INITIAL LINE OF <gt_table> TO <ls_table>.
SORT gt_mseg_1 BY matnr.
LOOP AT gt_mseg_1 ASSIGNING <l_mseg_1> .
IF <l_field> IS ASSIGNED.
UNASSIGN <l_field>.
ENDIF.
MOVE-CORRESPONDING <l_mseg_1> TO <ls_table>.
READ TABLE gt_fieldcat INTO ls_fieldcat WITH KEY coltext = <l_mseg_1>-budat.
IF sy-subrc EQ 0.
ASSIGN COMPONENT ls_fieldcat-fieldname OF STRUCTURE <ls_table> TO <l_field>.
<l_field> = <l_mseg_1>-menge.
ELSE.
<l_field> = 0.
ENDIF.
AT end of matnr.
APPEND <ls_table> TO <gt_table>.
clear <ls_table>.
ENDAT.
ENDLOOP.
ENDFORM. " move_data
your answers help me lot . I am awarding the points.
Very Very Thanks
Edited by: Dilraj Singh on Apr 13, 2011 3:58 PM
Edited by: Dilraj Singh on Apr 13, 2011 4:09 PM
Edited by: Dilraj Singh on Apr 13, 2011 4:23 PM -
Edit and save dynamic alv.
Hi Experts
I have created a dynamic table then filled this dynamic table with the help of field symbols and then passed this dynamic table to grid1->set_table_for_first_display and hence the dynamic alv is shown on the screen. Now, can I do something to make this alv editable and store these values in z table. I have tried the method get_changed_cell method, but no help.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = LT_LVC_CAT
IMPORTING
EP_TABLE = LP_TABLE.
ASSIGN LP_TABLE->* TO <LT_DATA>.
*Create structure = structure of the internal table
CREATE DATA LP_STRUCT LIKE LINE OF <LT_DATA>.
ASSIGN LP_STRUCT->* TO <HEADER>.
* SORT gt_data BY erdat.
*sort IT_VEWAO by MATNR.
LOOP AT IT_VEWZO INTO WA_VEWZO.
AT NEW VKBUR.
CLEAR <HEADER>.
ASSIGN COMPONENT 'VKBUR' OF STRUCTURE <HEADER> TO <FIELD>.
IF SY-SUBRC NE 0.
EXIT .
ENDIF.
<FIELD> = WA_VEWZO-VKBUR.
ENDAT.
MOVE WA_VEWZO-PD_HIER TO L_COL.
ASSIGN COMPONENT L_COL OF STRUCTURE <HEADER> TO <FIELD>.
IF SY-SUBRC NE 0.
EXIT .
ENDIF.
<FIELD> = WA_VEWZO-PLAN_QTY.
CONCATENATE WA_VEWZO-PD_HIER '_AP' INTO WA_VEWZO-PD_HIER .
MOVE WA_VEWZO-PD_HIER TO L_COL.
ASSIGN COMPONENT L_COL OF STRUCTURE <HEADER> TO <FIELD>.
IF SY-SUBRC NE 0.
EXIT .
ENDIF.
<FIELD> = WA_VEWZO-APROV_QTY.
AT END OF VKBUR.
APPEND <HEADER> TO <LT_DATA>.
ENDAT .
ENDLOOP.
CREATE OBJECT CUSTOM_CONTAINER1
EXPORTING
CONTAINER_NAME = 'CUST_CONT'.
CREATE OBJECT GRID1
EXPORTING
I_PARENT = CUSTOM_CONTAINER1.
CALL METHOD grid1->REGISTER_EDIT_EVENT
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
* I_STRUCTURE_NAME = lv_lp_struct
IS_LAYOUT = LS_LAYOUT
CHANGING
* IT_SORT = LT_SORT1
IT_FIELDCATALOG = LT_FIELDCAT
IT_OUTTAB = <LT_DATA>.Hi,
What help u need?
to activate the editable field u need to pass the field catalog parameter
EDIT = 'X'
Then Edit values in your alv
and press enter or define any icons in ur alv list useing user command
check the changed values using the method
CALL METHOD g_alvgrid1->check_changed_data( ).
It will help you i think.
Regards,
Nandha -
Create deep structure to disable some cells in Dynamic ALV GRID
Hi,
I want to disable some cells in a Dynamic ALV Grid before calling "SET_tABLE_Display" Method.
I check the BCALV_EDIT_02, where some cells are grayed out by assign the CL_GUI_ALV_GRID-MC_STYLE_DISABLED to the field name.
But I want the same using Field symbol.
I'm creating Dynamic table and dynamic structure based on the Dynamic field catalog.
Example: <FT_TAB> TYPE STANDARD TABLE,
<FS_TAB> TYPE ANY,
DATA: INT_TAB is my dynamic table values.
For the INT_TAB internal table, I created dynamic Structure and dynamic field symbol table.
LOOP AT INT_TAB.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <FS_TAB> TO <F_VALUE>
<F_VALUE> = INT_TAB-MATNR.
APPEND <FS_TAB> TO <FT_TAB>
"Here is the problem occurs, I want to grayed out the MATNR value based on some condition.
ENDLOOP.
I would like to set the 'MATNR' value to be grayed out by passing the CL_GUI_ALV_GRID-MC_STYLE_DISABLED.
and update into <FT_TAB>( <FT_TAB> structure will have 2 structures)
Finally the fieldsymbol should have two structure ( <F_TAB> = DYNAMIC STRUCTURE + LVC_S_STYLE )
Display alv grid by passing <FT_TAB> to set_table_display method.
Thanks in advance,
Kumar.Hi,
I am not sure whether I really understand your request. Let me try to help.
> Example: <FT_TAB> TYPE STANDARD TABLE,
> <FS_TAB> TYPE ANY,
>
> DATA: INT_TAB is my dynamic table values.
>
>
> LOOP AT INT_TAB.
> ASSIGN COMPONENT 'MATNR' OF STRUCTURE <FS_TAB> TO <F_VALUE>
> <F_VALUE> = INT_TAB-MATNR.
> APPEND <FS_TAB> TO <FT_TAB>
Here <FT_TAB> must already be assigned to some internal table with a given (dynamic) structure. Did this happen before this piece of code?
What I would do is to create a dynamic table (see documentation to CREATE DATA) with MATNR and the STYLE field (LVC_T_STYL). See the documentation for CREATE DATA - creation of internal tables. When collection the field descriptions for that internal table I would also build the field catalogue for the ALV.
Then assign <FT_TAB> to that newly created internal table, <FS_TAB> to a newly created structure (same as a table line).
Move the MATNR to component 1 (or component 'MATNR') of the table and fill the style table according to your needs. Then insert the <FS_TAB> into <FT_TAB>.
Finally call the ALV SET_TABLE... method with your dynamic table and your field catalogue.
Regards,
Gerd Rother -
Dynamic ALV using REUSE_ALV_HIERSEQ_LIST_DISPLAY
Hi All,
My requirement is to display a dynamic output table using REUSE_ALV_HIERSEQ_LIST_DISPLAY.
I was able to successfully display the dynamic output in grid display using REUSE_ALV_GRID_DISPLAY. But when I try to display the hierarchial list, then only the T_OUTTAB_HEADER data is getting displayed. The T_OUTTAB_ITEM is not getting displayed.
I am creating the dynamic table using
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = I_FIELDCAT_DYN
IMPORTING
EP_TABLE = I_DYNTABLE
ALV Display:
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = G_INTERFACE_CHECK
I_CALLBACK_PROGRAM = ALV_REPID
I_CALLBACK_PF_STATUS_SET = 'SET_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IS_LAYOUT = ALV_LAYOUT
IS_PRINT = ALV_PRINT
IT_FIELDCAT = FC_HIER[]
I_DEFAULT = 'X'
I_SAVE = 'A'
IS_VARIANT = ALV_VARIANT
IT_EVENTS = GT_EVENTS[]
I_TABNAME_HEADER = 'HEADER'
I_TABNAME_ITEM = 'LIST'
IS_KEYINFO = ALV_KEYINFO
TABLES
T_OUTTAB_HEADER = HEADER[]
T_OUTTAB_ITEM = <I_FS_DYNOUT>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
Any pointers in this regard will be helpful. Also any existing code for dynamic ALV for grid display, will be helpful.
Thanks & Regards,
Sonali.Hi All,
Thanks for your inputs.
All those demo programs are for displaying static output table. I need to display dynamic internal table.
Also the table name LIST / <I_FS_DYNOUT> does not make a difference.
Actually there is an existing tcode MB51. In this report first there is a list display, then when u click on detail button, then there is a grid display.
I had to modify this report to add some more columns.
So I made a copy and added few more columns to the output table dynamically.
now when I pass data for list display to REUSE_ALV_HIERSEQ_LIST_DISPLAY, then my list display shows only header data. And when I click on u201Cdetailsu201Dbutton, then the grid display that comes, shows all the data. So the grid display is displaying the dynamic output table contents correctly.
But the same output table isnt getting displayed in list display.
Any pointers?
Thanks & Regards,
Sonali Gupta. -
Hi experts,
I am having a dynamic ALV grid. How to create a new grid(second grid) in the same page with different values?
Thanks&Regards,
vinoAdd 2 view containers, create 2 different usages of AVL component and embed the view of these 2 alv components in 2 view containers..
Hope this helps
manas dua -
How to make cell coloring in dynamic ALV,I did it in normal internal tables.Any body can help me here?
Or can anybody tell me how to convert a field symbol to an internal table? as I have created a dynamic IT.
Thanks in advance.Thanks for u r quick replies,Now Iam not getting any error,the program getting executed without any error.But Iam not getting any colors,what might be the problem? Do I need to pass IS_layot to ALV_GRID FM ? I have not created any Layout though,here is my complete code :
TABLES : vbbe.
TYPE-POOLS : slis.
*& Data Declarations *
DATA : diff TYPE i VALUE 0,
maktx LIKE makt-maktx,
labst LIKE mard-labst.
DATA : BEGIN OF it_data OCCURS 0,
matnr LIKE vbbe-matnr,
mbdat LIKE vbbe-mbdat,
omeng LIKE vbbe-omeng,
END OF it_data,
wa_data LIKE LINE OF it_data.
DATA : g_tdref TYPE REF TO data,
g_wdref TYPE REF TO data.
DATA : dats LIKE vbbe-mbdat,
lvc_t_fieldcat TYPE lvc_t_fcat,
lvc_s_fieldcat TYPE lvc_s_fcat,
it_fldcat TYPE slis_t_fieldcat_alv,
wa_fldcat TYPE slis_fieldcat_alv.
FIELD-SYMBOLS : <it_dyn> TYPE STANDARD TABLE,
<wa_dyn>,
<dyn_field>.
*& Selection-Screen *
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_mbdat FOR vbbe-mbdat OBLIGATORY.
PARAMETER p_werks LIKE mard-werks OBLIGATORY.
SELECTION-SCREEN END OF BLOCK blk1.
*& INITIALIZATION *
INITIALIZATION.
p_werks = '1200'.
*& Start-Of-Selection *
START-OF-SELECTION.
PERFORM f_build_lvc_and_slis.
PERFORM f_build_dynamic_it.
PERFORM f_get_data.
PERFORM f_get_fata_into_it.
PERFORM f_display_alv.
*& Form f_build_lvc
FORM f_build_lvc_and_slis.
*.................Build LVC Fieldcatalog...............................*
lvc_s_fieldcat-tabname = 'MSKA'.
lvc_s_fieldcat-col_pos = 1.
lvc_s_fieldcat-fieldname = 'WERKS'.
lvc_s_fieldcat-datatype = 'CHAR'.
lvc_s_fieldcat-intlen = '10'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tabname = 'MSKA'.
lvc_s_fieldcat-col_pos = 2.
lvc_s_fieldcat-fieldname = 'MATNR'.
lvc_s_fieldcat-datatype = 'CHAR'.
lvc_s_fieldcat-intlen = '18'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tabname = 'MAKT'.
lvc_s_fieldcat-col_pos = 3.
lvc_s_fieldcat-fieldname = 'MAKTX'.
lvc_s_fieldcat-datatype = 'CHAR'.
lvc_s_fieldcat-intlen = '10'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tabname = 'MARD'.
lvc_s_fieldcat-col_pos = 4.
lvc_s_fieldcat-fieldname = 'LABST'.
lvc_s_fieldcat-datatype = 'QUAN'.
lvc_s_fieldcat-intlen = '13'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
lvc_s_fieldcat-tech = 'X'.
lvc_s_fieldcat-col_pos = 5.
lvc_s_fieldcat-fieldname = 'TCOLOR'.
lvc_s_fieldcat-ref_field = 'COLOR'.
lvc_s_fieldcat-ref_table = 'ZLVC_COL'.
lvc_s_fieldcat-scrtext_l = 'COLOR'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
*.................Build SLIS Fieldcatalog..............................*
wa_fldcat-tabname = 'MSKA'.
wa_fldcat-col_pos = 1.
wa_fldcat-fieldname = 'WERKS'.
wa_fldcat-datatype = 'CHAR'.
wa_fldcat-seltext_m = wa_fldcat-seltext_l = wa_fldcat-seltext_s =
'Plant'.
wa_fldcat-intlen = '6'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tabname = 'MSKA'.
wa_fldcat-outputlen = 15.
wa_fldcat-col_pos = 2.
wa_fldcat-fieldname = 'MATNR'.
wa_fldcat-datatype = 'CHAR'.
wa_fldcat-seltext_l = 'Material Number'.
wa_fldcat-intlen = '16'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tabname = 'MAKT'.
wa_fldcat-outputlen = 23.
wa_fldcat-col_pos = 3.
wa_fldcat-fieldname = 'MAKTX'.
wa_fldcat-datatype = 'CHAR'.
wa_fldcat-seltext_l = 'Material Description'.
wa_fldcat-intlen = '20'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tabname = 'MARD'.
wa_fldcat-col_pos = 4.
wa_fldcat-fieldname = 'LABST'.
wa_fldcat-datatype = 'QUAN'.
wa_fldcat-intlen = '13'.
wa_fldcat-seltext_m = wa_fldcat-seltext_l = wa_fldcat-seltext_s =
'x Stock'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
wa_fldcat-tech = 'X'.
wa_fldcat-col_pos = 5.
wa_fldcat-fieldname = 'TCOLOR'.
wa_fldcat-ref_fieldname = 'COLOR'.
wa_fldcat-ref_tabname = 'ZLVC_COL'.
wa_fldcat-seltext_l = 'COLOR'.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
*.................Build Dynamic Fields for LVC and SLIS................*
DATA : d TYPE i,
col(6) TYPE n VALUE '0',
date TYPE dats,
day(8) TYPE c,
number(2) TYPE n VALUE '0'.
d = s_mbdat-high - s_mbdat-low + 1.
date = s_mbdat-low - 1.
DO d TIMES.
number = number + 1.
date = date + 1.
col = col + 1.
CONCATENATE 'x Day' number INTO day.
lvc_s_fieldcat-tabname = 'VBBE'.
lvc_s_fieldcat-col_pos = col + 5.
lvc_s_fieldcat-fieldname = date.
lvc_s_fieldcat-datatype = 'QUAN'.
lvc_s_fieldcat-intlen = '15'.
APPEND lvc_s_fieldcat TO lvc_t_fieldcat.
CLEAR : lvc_s_fieldcat.
wa_fldcat-tabname = 'VBBE'.
wa_fldcat-col_pos = col + 5.
wa_fldcat-fieldname = date.
wa_fldcat-datatype = 'QUAN'.
wa_fldcat-intlen = '15'.
wa_fldcat-seltext_l = day.
APPEND wa_fldcat TO it_fldcat.
CLEAR : wa_fldcat.
ENDDO.
ENDFORM. " f_build_lvc
*& Form f_build_dynamic_it
FORM f_build_dynamic_it .
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lvc_t_fieldcat
IMPORTING
ep_table = g_tdref.
ASSIGN g_tdref->* TO <it_dyn>.
CREATE DATA g_wdref LIKE LINE OF <it_dyn>.
ASSIGN g_wdref->* TO <wa_dyn>.
ENDFORM. " f_build_dynamic_it
*& Form f_get_data
FORM f_get_data .
SELECT matnr mbdat omeng FROM vbbe INTO CORRESPONDING FIELDS OF TABLE
it_data WHERE mbdat IN s_mbdat AND
werks = p_werks.
DELETE it_data WHERE omeng = 0 .
SORT it_data BY matnr ASCENDING.
ENDFORM. " f_get_data
*& Form f_get_fata_into_it
FORM f_get_fata_into_it .
FIELD-SYMBOLS : <fs>,
<ta_color> TYPE table.
DATA : field(15) TYPE c,
col TYPE lvc_s_scol.
LOOP AT it_data INTO wa_data.
SELECT SINGLE maktx FROM makt INTO maktx WHERE matnr =
wa_data-matnr.
SELECT SINGLE labst FROM mard INTO labst WHERE matnr =
wa_data-matnr AND werks = p_werks.
diff = wa_data-mbdat - s_mbdat-low + 6.
ASSIGN COMPONENT 1 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = p_werks.
ASSIGN COMPONENT 2 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = wa_data-matnr.
ASSIGN COMPONENT 3 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = maktx.
ASSIGN COMPONENT 4 OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = labst.
ASSIGN COMPONENT diff OF STRUCTURE <wa_dyn> TO <fs>.
<fs> = wa_data-omeng.
IF labst < wa_data-omeng.
col-fname = wa_data-mbdat.
col-color-col = '5' .
col-color-int = '1'.
ELSE.
col-fname = wa_data-mbdat.
col-color-col = '5' .
col-color-int = '0' .
ENDIF.
ASSIGN COMPONENT 'TCOLOR' OF STRUCTURE <wa_dyn> TO <ta_color>.
APPEND col TO <ta_color> .
APPEND <wa_dyn> TO <it_dyn>.
CLEAR <wa_dyn>.
ENDLOOP.
ENDFORM. " f_get_fata_into_it
*& Form f_display_alv
FORM f_display_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = it_fldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE = ' '
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN = 0
* I_SCREEN_START_LINE = 0
* I_SCREEN_END_COLUMN = 0
* I_SCREEN_END_LINE = 0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* I_HTML_HEIGHT_TOP =
* I_HTML_HEIGHT_END =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = <it_dyn>
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. " f_display_alv -
Editing values within Dynamic ALV
Hello All,
I am currently working on dynamic ALV and want the columns to be editible.
I have gone through the tutorial
Link : [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/4c70444a-0801-0010-7688-9e4bd844b783]
and have created a dynamic Context and a corresponding ALV LIST display. Everything is fine except that i want to be able to edit values within the list and i want this to get populated back into the context.
I have gone through the tutorial.
Link : [https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/3133474a-0801-0010-d692-81827814a5a1]
But i couldn't relate that with the tutorial for dynamic ALV.
Please help.
Best Regards,
MzHello Lekha,
I am sorry to say that the code which you have provided is not working.
Maybe i am doing something wrong.
This is the entire code below.
data lo_interfacecontroller type ref to iwci_salv_wd_table .
data lo_cmp_usage type ref to if_wd_component_usage.
data : L_VIEW_CONTROLLER_API type ref to IF_WD_VIEW_CONTROLLER.
lo_cmp_usage = wd_this->wd_cpuse_alv( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
lo_interfacecontroller = wd_this->wd_cpifc_alv( ).
lo_interfacecontroller->set_data(
* only_if_new_descr = " wdy_boolean
"r_node_data =
dyn_node " ref to if_wd_context_node
DATA:
lo_value type ref to cl_salv_wd_config_table,
lr_column TYPE REF TO cl_salv_wd_column, " Table fo rcolumn ref
ls_columns TYPE salv_wd_s_column_ref, " Structure for column ref
lt_columns TYPE salv_wd_t_column_ref, " Structure for column ref
lr_input TYPE REF TO cl_salv_wd_uie_input_field.
lo_value = lo_interfacecontroller->get_model( ).
* Get the column ref
CALL METHOD lo_value->if_salv_wd_column_settings~get_columns
RECEIVING
value = lt_columns.
LOOP AT lt_columns INTO ls_columns.
lr_column = ls_columns-r_column.
case ls_columns-id.
when 'JAN2007'.
CREATE OBJECT lr_input
EXPORTING
value_fieldname = ls_columns-id.
CALL METHOD lr_column->set_cell_editor
EXPORTING
value = lr_input.
* Set the read only attribute
lr_input->set_read_only_fieldname( value = 'FALSE' ).
endcase.
endloop.
L_VIEW_CONTROLLER_API = WD_THIS->WD_GET_API( ).
L_VIEW_CONTROLLER_API->PREPARE_DYNAMIC_NAVIGATION(
source_window_name = 'WINDOW1'
source_vusage_name = 'MAIN_USAGE_0'
source_plug_name = 'TO_V1'
target_component_name = 'SALV_WD_TABLE'
target_component_usage = 'ALV'
target_view_name = 'TABLE'
target_plug_name = 'DEFAULT'
target_embedding_position = 'MAIN/VIEW_CONTAINER'
WD_THIS->FIRE_TO_V1_PLG( ).
The part which is entered as per your instructions are given between the asterisk lines.
Sorry if there are any silly mistakes on my part.
I have one small doubt regarding the value to be passed for the method lr_input->set_read_only_fieldname. This is a string value. I think that this could be the cause of the error. When i checked the class interface, CL_SALV_WD_UIE_INPUT_FIELD i found that the method set_read_only_fieldname is calling another attribute if_salv_wd_c_table_evt_editor=>set_read_only_fieldname.
Hope this was useful
Best Regards,
Mz -
Radio button in dynamic ALV grid
Hi guys!
I want to implement a dynamical ALV grid with a radiobutton in the first column.
when clicking a button, or processing the program i want to get the information of the selected row and perform other things....
Can someone help me with a code example for this, or just tell me where i can find the necessary information`?
regards
thomasHi,
I dont understand why you need Radio button, If you use REUSE_ALV_GRID_DISPLAY the output grid will by default allow you to select only one row.
see the program - BCALV_FULLSCREEN_DEMO for more information -
F4 help in ALV report output (FM REUSE_ALV_GRID_DISPLAY)
Hello,
I have developed ALV report using the FM REUSE_ALV_GRID_DISPLAY.
My requirement is to have a customized search help on the output of ALV on one field.
I tried to find it on SDN but all the methods are using OO ALV.
How we can attaché customized search help in ALV developed using the FM REUSE_ALV_GRID_DISPLAY.
Kindly Help
Regards
SachinHii..
If you use OO then it is very easy to create a F4 help on the ALV..
try this sample code
<removed by moderator>
Hope this will help u..
Regards,
Jhings
Moderator message: please post only relevant code parts, your post must be less than 5000 characters to preserve formatting.
Edited by: Thomas Zloch on Mar 28, 2011 12:51 PM
Maybe you are looking for
-
My iphone wont let me connect to my wifi it just keeps saying 'activation server is temporarily unavailable' what do i do?
-
I keep getting the following message The iTunes library cannot be found or created. The default location for this file is in the iTunes folder in the music folder. All of my playlists have disappeared and I am trying to recover them however I now can
-
HELP! Does Javascript need the explorer.exe process?
Here is a sample of javascript code in my web application: <script language="javascript"> function redirect() { eval("parent.ObjReview_Object.update();"); </script> Does someone know why this code runs perfectly when the Windows process "explorer.exe
-
i need to buy an ipod shuffle 4th generation for work using earphones but at home are there adapters to hook it up to my sony home stereo dock? the dock isnt compatible w/the shuffle but is w/the other ipods. Plz advise thank you
-
IPhone 5 preorder at ATT store on 9/16, am I screwed?
I was out of town and not able to preorder my iPhone 5 untill the 16th. I think I already know the answer, but am i completeley screwed? Meaning I probably wont get the phone untill late October if not November?