2007 Jul 24 5:46 AM
<b>I have created editable ALV using OOPs. </b>
But my requirement is while creating new rows in ALV, one column value should be filled with some default value automatically(as soon as I press create row icon on toolbar)
Thanks.
2007 Jul 24 5:49 AM
Hi,
use
DATA:LAYOUT TYPE LVC_S_LAYO.
LAYOUT-EDIT = 'X'.
CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = LAYOUT
CHANGING
IT_FIELDCATALOG = FCAT[]
IT_OUTTAB = MARA.
RGDS,
2007 Jul 24 5:49 AM
generate own entries if database table is empty
perform generate_entries changing pt_outtab.
endif.
call method g_grid->set_table_for_first_display
exporting it_toolbar_excluding = lt_exclude
changing it_fieldcatalog = pt_fieldcat
it_outtab = pt_outtab.
Set editable cells to ready for input initially
CALL METHOD g_grid->set_ready_for_input
EXPORTING
I_READY_FOR_INPUT = 1.
clear lt_f4.
lt_f4-fieldname = 'WUNIT'.
lt_f4-register = 'X'.
append lt_f4.
<b>reward points if it is usefull ....</b>
2007 Jul 24 5:58 AM
Hi Abhay,
both of your answer are not sufficient enough to solve my requirement.
I am using ALV toolbar button to create new rows. So when I press button on toolbar to create new row, a blank row gets created. In that newly created row I am suppose to fill with some values and process further.
So whenever new row gets created, I want to have some cell value to be filled automatically.
I hope I have cleared my requirement.
2007 Jul 24 6:02 AM
HI HaReSh
<b>refer to this code below.hope it might help u.</b>
*&---------------------------------------------------------------------*
*& Report ZTESTDEMO_INTERACTIVE_LIST_2
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZTESTDEMO_INTERACTIVE_LIST_2.
TABLES: MARA,MARC,MARD.
* internal table itab_mara 3 fields matnr, ernam,mtart
DATA: BEGIN OF ITAB_MARA OCCURS 0,
MATNR LIKE MARA-MATNR, " material number
ERNAM LIKE MARA-ERNAM, " name of person who create
MTART LIKE MARA-MTART, " Material Type
END OF ITAB_MARA.
* internal table itab_marc 3 fields matnr, werks,lvorm
DATA: BEGIN OF ITAB_MARC OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS, " Plant
LVORM LIKE MARC-LVORM, " Flag Material for Deletion at Plant Level
END OF ITAB_MARC.
* internal table itab_mard 2 fields
DATA: BEGIN OF ITAB_MARD OCCURS 0,
MATNR LIKE MARD-MATNR,
LGORT LIKE MARD-LGORT, " Storage Location
END OF ITAB_MARD.
SELECT-OPTIONS: S_MTART FOR MARA-MTART.
INITIALIZATION.
S_MTART-LOW = 'HALB'.
S_MTART-HIGH = 'HAWA'.
S_MTART-OPTION = 'BT'.
APPEND S_MTART.
START-OF-SELECTION.
SELECT MATNR ERNAM MTART FROM MARA INTO TABLE ITAB_MARA WHERE MTART IN
S_MTART.
PERFORM DISPLAY.
TOP-OF-PAGE.
WRITE:/2(15) 'MATERIAL NO',20(20) 'CREATED BY',45(15) 'MATERIAL TYPE'.
FORM DISPLAY.
LOOP AT ITAB_MARA.
WRITE:/ ITAB_MARA-MATNR UNDER 'MATERIAL NO' HOTSPOT ON,ITAB_MARA-ERNAM
UNDER 'CREATED BY',ITAB_MARA-MTART UNDER 'MATERIAL TYPE'.
HIDE: ITAB_MARA-MATNR.
ENDLOOP.
ENDFORM.
AT LINE-SELECTION.
CASE SY-LSIND.
WHEN 1.
SELECT MATNR WERKS LVORM FROM MARC INTO TABLE ITAB_MARC WHERE MATNR =
ITAB_MARA-MATNR.
PERFORM DISPLAY1.
WHEN 2.
SELECT MATNR LGORT FROM MARD INTO TABLE ITAB_MARD WHERE MATNR =
ITAB_MARC-MATNR.
PERFORM DISPLAY2.
when 3.
sy-lsind = 0.
ENDCASE.
FORM DISPLAY1.
LOOP AT ITAB_MARC.
WRITE:/ ITAB_MARC-MATNR HOTSPOT ON, ITAB_MARC-WERKS,ITAB_MARC-LVORM.
HIDE: ITAB_MARC-MATNR.
ENDLOOP.
WRITE:/ SY-LSIND.
ENDFORM.
FORM DISPLAY2.
LOOP AT ITAB_MARD.
WRITE:/ ITAB_MARD-MATNR, ITAB_MARD-LGORT.
ENDLOOP.
WRITE:/ SY-LSIND.
ENDFORM.
regards
ravish
<b>plz reward for useful ans</b>
2007 Jul 24 6:05 AM
Hi,
You will have to insert that value in the internal table you are displying , you can either add it when you are appending the records to the internal table or , once the internal table is populated with the data , just use modify command to add value to that field.
aRs
2007 Jul 24 6:15 AM
Hi aRs,
I don't know how to control standard toolbar action in ALV. And that's why I cannot add or modify value at the time when new row gets created.
So i'll be thankful if you can help to me have proper example for the same.
Thanks,