ALV : Catch after editing ALV ?
Hi all,
I've done an ALV report ( using 'REUSE_ALV_GRID_DISPLAY' ). I've also add a GUI Status to add a button.
I've some checkbox and some editable field.
The display is ok, I can edit and click checkbox but when I press my own button, the table isn't updated ( In debug Mode, in the 'IATB_USER_COMMAND' routine, the table is like the first display )
How can I update my table after ALV screen update ?
Thx a lot
Regards,
Erwan
follow this code,
regards
srikanth
FORM f_user_command_modify USING
r_ucomm LIKE sy-ucomm "#EC *
rs_selfield TYPE slis_selfield.
IF r_ucomm = c_fc_save.
*--User Selected SAVE button.
READ TABLE it_zbcar50_modify WITH KEY rec_sel = c_x.
*--Check user selected atleast 1 line.
IF sy-subrc <> 0.
MESSAGE i000 WITH 'No record(s) Selected to
Modify'(016).
EXIT.
ENDIF.
LOOP AT it_zbcar50_modify WHERE rec_sel = c_x.
*--Move All records into ZBCAR50 structure table
MOVE-CORRESPONDING it_zbcar50_modify TO
it_zbcar50_temp.
it_zbcar50_temp-mandt = sy-mandt.
APPEND it_zbcar50_temp.
CLEAR : it_zbcar50_temp.
ENDLOOP.
*--it_zbcar50_temp is the same structure as the database table.
*--Modify ZBCAR50 Table with the changed values.
MODIFY zbcar50 FROM TABLE it_zbcar50_temp.
IF sy-subrc = 0 .
COMMIT WORK AND WAIT.
*--Display message with Success in Updating database
MESSAGE i000 WITH sy-dbcnt
' Record(s) has been Updated'(020).
endif.
ENDFORM.
Similar Messages
-
ALV Grid after EDIT has to UPDATE DB........
Hi,
I am using FM 'REUSE_ALV_GRID_DISPLAY' and in FIELD CATALOG I set EDIT option for some coloumns.
Now every thing is working fine and values are changing in output when I press ENTER after value is changed.
Now I want to know how to catch that changed values in Internal table and I want to Update DATABASE Table.
So let me know what are the events I have to process.
If any one has example code plzzzz post it.
Thanks in advance.Hi,
Here is the sample code.If you executed the program and edited something,then after pressing back you will get the changed value in output.For that,I have used loop..Endloop. after FM.SInce your requirement is to update DB,you use
modify db from table itab.
That will insert/update the entries in db.
Kindly reward points by clicking the star on the left of reply,if it helps.
TYPE-POOLS: slis.
DATA: report_id LIKE sy-repid.
DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
DATA: i_layout TYPE slis_layout_alv.
DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
types : begin of ty,
pernr type pa0001-pernr,
SEQNR type pa0001-seqnr,
end of ty.
data itab type standard table of ty.
data wa type ty.
select pernr seqnr from pa0001 into table itab.
report_id = sy-repid.
PERFORM f1000_layout_init CHANGING i_layout.
PERFORM f2000_fieldcat_init CHANGING i_fieldcat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = report_id
i_grid_title = ws_title
is_layout = i_layout
it_fieldcat = i_fieldcat
i_save = 'A'
TABLES
t_outtab = itab
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.
*Use modify statement here instead of loop
<b>loop at itab into wa.
write : / wa-pernr, wa-seqnr.
endloop.</b>
FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.
CLEAR i_layout.
i_layout-colwidth_optimize = 'X'.
i_layout-edit = 'X'.
ENDFORM.
FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
DATA: line_fieldcat TYPE slis_fieldcat_alv.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'PERNR'. " The field name and the table
line_fieldcat-tabname = 'ITAB'. " name are the two minimum req.
line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)
line_fieldcat-seltext_m = 'Personal No.'. " Column Header
APPEND line_fieldcat TO i_fieldcat.
CLEAR line_fieldcat.
line_fieldcat-fieldname = 'SEQNR'.
line_fieldcat-tabname = 'ITAB'.
line_fieldcat-seltext_l = 'No. of records with same key'.
line_fieldcat-edit = 'X'. APPEND line_fieldcat TO i_fieldcat.
ENDFORM. " f2000_fieldcat_init -
Event Handling in Editable ALV
Hi all,
I am having 4 to 5 fields in my module pool screen and at the same time i am having a custom container wherein, there is editable ALV [using OOPS Editable ALV inside a custom container].
Here in editable ALV, i am having an editable field called dealer code.When i enter dealer code in editable ALV and press enter
my dealer name and dealer address in editable ALV inside Custom Container should get populated.
But when the cursor is inside the custom container in that editable field none of my screen eventsModule pool events
are getting triggered [Hence my values are not getting populated.When the cursor is outside the custom container all my module pool events are working fine, hence values are getting populated....
*I am handling the event in my program.But i don't know where exactly i should create object and handle this as
nothing is getting triggered[pai or pbo] when my cursor is inside the custom container.
Could you suggest me anything...*
Waiting for your repiles...Hi
First of all you need to creat object in PBO.
You must be calling method SET_TABLE_FOR_FIRST_DISPLAY.After this call method REGISTER_EDIT_EVENT.And then REFRESH_TABLE_DISPLAY.
In OK code create an OK code with name "OK".This is for ENTER key.
And in that call method CHECK_CHANGED_DATA.
Sample code for REGISTER_EDIT_EVENT is given below:
*--event to detect if data gets edited
CALL METHOD OBJ_ALV2->REGISTER_EDIT_EVENT
EXPORTING
I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED
EXCEPTIONS
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.
Sample code for CHECK_CHANGED_DATA
*--when alv is edited and ENTER button is clicked then data
*will be saved in internal table and edited data will
*be displayed on alv
IF V_OK_CODE = 'OK'.
*--metohd to detect if data was changed in oops alv
CALL METHOD OBJ_ALV2->CHECK_CHANGED_DATA
IMPORTING
E_VALID =
CHANGING
C_REFRESH = 'X'
ENDIF.
Hope this solves your problem.
Thanks
Khushboo -
Update the Billing orders after display/ modifiy in the Editable ALV
Hi Experts,
I have created one Editable ALV to display theBilling order with BP details,
Once user get the ALV output he can modify the content and same will be updated once he hits UPDATE button.
my requirement is after user hits the UPDATE button a background should be created and update of BO should happen also user user should able to see the status by checking the SPOOL.
currently i am using the FM crm_order_maintain to update, kindly guide me how to process this step in background for all the entries which are selected in ALV by user.
i think i can use SUBMIT with JOB_OPEN and JOB_CLOSE, but i need some same code & guidance.
Thanks in Advance.
Regards,
Pradeepproblem solved
-
How to save data in ztable after editing in alv report
how to save data in ztable after editing in alv report?
Hi,
Please find the attachment below.This may be usefull to you.
[http://wiki.sdn.sap.com/wiki/display/Snippets/ALV-Editingandsavingtheeditedvaluesin+Database%28OOPS%29]
Regards,
Ramakrishna Yella. -
Edit a selected row in an alv report after pressing a push button ?
hi all ,
I want to edit a selected row in an alv report but that too after i press a push button . After pressing the push button , a pop up shud *** showing all the entries of the selected row which shud be editable and after editing it shud be saved into the database table.
How can i do this please help asap ???May this prog. of mine can solve your requirement.
REPORT z_demo_alv_jg.
TYPE-POOLS *
TYPE-POOLS: slis.
INTERNAL TABLES/WORK AREAS/VARIABLES *
DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
w_field TYPE slis_fieldcat_alv,
p_table LIKE dd02l-tabname,
dy_table TYPE REF TO data,
dy_tab TYPE REF TO data,
dy_line TYPE REF TO data.
FIELD-SYMBOLS *
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa> TYPE ANY,
<dyn_field> TYPE ANY,
<dyn_tab_temp> TYPE STANDARD TABLE.
SELECTION SCREEN *
PARAMETERS: tabname(30) TYPE c,
lines(5) TYPE n.
START-OF-SELECTION *
START-OF-SELECTION.
Storing table name
p_table = tabname.
Create internal table dynamically with the stucture of table name
entered in the selection screen
CREATE DATA dy_table TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_table->* TO <dyn_table>.
IF sy-subrc <> 0.
MESSAGE i000(z_zzz_ca_messages) WITH ' No table found'.
LEAVE TO LIST-PROCESSING.
ENDIF.
Create workarea for the table
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
Create another temp. table
CREATE DATA dy_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN dy_tab->* TO <dyn_tab_temp>.
SORT i_fieldcat BY col_pos.
Select data from table
SELECT * FROM (p_table)
INTO TABLE <dyn_table>
UP TO lines ROWS.
REFRESH <dyn_tab_temp>.
Display report
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
TABLES
t_outtab = <dyn_table>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
*& Form SET_PF_STATUS
Setting custom PF-Status
-->RT_EXTAB Excluding table
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'Z_STANDARD'.
ENDFORM. "SET_PF_STATUS
*& Form user_command
Handling custom function codes
-->R_UCOMM Function code value
-->RS_SELFIELD Info. of cursor position in ALV
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Local data declaration
DATA: li_tab TYPE REF TO data,
l_line TYPE REF TO data.
Local field-symbols
FIELD-SYMBOLS:<l_tab> TYPE table,
<l_wa> TYPE ANY.
Create table
CREATE DATA li_tab TYPE STANDARD TABLE OF (p_table).
ASSIGN li_tab->* TO <l_tab>.
Create workarea
CREATE DATA l_line LIKE LINE OF <l_tab>.
ASSIGN l_line->* TO <l_wa>.
CASE r_ucomm.
When a record is selected
WHEN '&IC1'.
Read the selected record
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX
rs_selfield-tabindex.
IF sy-subrc = 0.
Store the record in an internal table
APPEND <dyn_wa> TO <l_tab>.
Fetch the field catalog info
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = 'Z_DEMO_PDF_JG'
i_structure_name = p_table
CHANGING
ct_fieldcat = i_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc = 0.
Make all the fields input enabled except key fields
w_field-input = 'X'.
MODIFY i_fieldcat FROM w_field TRANSPORTING input
WHERE key IS INITIAL.
ENDIF.
Display the record for editing purpose
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = p_table
it_fieldcat = i_fieldcat
i_screen_start_column = 10
i_screen_start_line = 15
i_screen_end_column = 200
i_screen_end_line = 20
TABLES
t_outtab = <l_tab>
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc = 0.
Read the modified data
READ TABLE <l_tab> INDEX 1 INTO <l_wa>.
If the record is changed then track its index no.
and populate it in an internal table for future
action
IF sy-subrc = 0 AND <dyn_wa> <> <l_wa>.
<dyn_wa> = <l_wa>.
i_index = rs_selfield-tabindex.
APPEND i_index.
ENDIF.
ENDIF.
ENDIF.
When save button is pressed
WHEN 'SAVE'.
Sort the index table
SORT i_index.
Delete all duplicate records
DELETE ADJACENT DUPLICATES FROM i_index.
LOOP AT i_index.
Find out the changes in the internal table
and populate these changes in another internal table
READ TABLE <dyn_table> ASSIGNING <dyn_wa> INDEX i_index.
IF sy-subrc = 0.
APPEND <dyn_wa> TO <dyn_tab_temp>.
ENDIF.
ENDLOOP.
Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table
EXCEPTIONS
foreign_lock = 1
system_failure = 2
OTHERS = 3.
IF sy-subrc = 0.
Modify the database table with these changes
MODIFY (p_table) FROM TABLE <dyn_tab_temp>.
REFRESH <dyn_tab_temp>.
Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
mode_rstable = 'E'
tabname = p_table.
ENDIF.
ENDCASE.
rs_selfield-refresh = 'X'.
ENDFORM. "user_command
Regards,
Joy. -
Editable ALV - editable fields after copying row
Hi all!
I've got a (simple?) problem. I created an editable ALV (by using class CL_GUI_ALV_GRID). There it is possible to add, delte or change entries. That's work!
The problem is, when the user copies an entry, the fields are not ready for input. It's the default function of the ALV. My questions is, how can I make the new line editable (including the key fields). I tried to replace the "copy line" function of the ALV with my own function code (on event TOOLBAR) and process it on event BEFORE_USER_COMMAND.
In my own copy routine I read the selected line to create a new one with the same values, set the attributes (field table type LVC_T_STYL) for the new line and append it to my internal table. After that, I make a refresh of the ALV. Unfortunately the DATA_CHANGED event does not work anymore. So it is not possible for me to check for double entries and validitiy. It doesn't help to call method CHECK_CHANGED_DATA on the grid instance.
Does anybody has an idea or an example??
Thank you a lot!
Best regards,
Florian
PS: I used the report BCALV_EDIT_04 as example, but unfortunatley there is no copy functionality implemented!Hi,
Please check this [thread|Re: ALV Function module to Copy the row;.
Hope this helps.
Regards,
Chandravadan -
Enter Key Event in Editable ALV Grid
Hi all,
I am trying to create and editable ALV grid using the REUSE ALV FM.
On the grid after changing a value, if I press enter key the pai is not triggered. I have tried the various example programs (BCALV*) but could not find anything relevant.
Basically I need similar functionality to normal module pool programming as in validations on screen done when enter key is pressed after screen entry.
Is it possible to capture the Enter keypress on the ALV grid?Hello Preet
I can only tell you how I would solve this using the ALV grid control (CL_GUI_ALV_GRID) because I have abandoned using ALV function modules.
The problem with running through PAI is whether the focus (i.e. the cursor) is still on the control or already on the (surrounding) main program. If the control has the focus, you do not run through PAI.
I would add a "Refresh" button to the toolbar of the ALV list. Normally, this button is already there or you only have to make it visible.
When the user pushes this button you catch the corresponding user-command and call the CHECK_DATA_CHANGED method to see if values have been changed on the editable grid. If so, the previous method will fire event DATA_CHANGED.
Now, in the event handler method (e.g. HANDLE_DATA_CHANGED) you receive as input a data change object (CL_ALV_CHANGED_DATA_PROTOCOL). This object contains all changed values. These values you will need to make your checks.
I assume that the logic will be similar using ALV function modules.
Regards
Uwe -
I_grid_settings-edt_cll_cb = 'X' in editable ALV
Hi,
I displayed output in editable ALV in ABAP. In output I have edited the cell but in debugging the value is not getting reflected. Using
i_grid_settings-edt_cll_cb = 'X' we can catch the value but I am not able to catch.
Kindly provide the suggestion to catch the the edited value using above settings.
Thanks in advance,
Regards,
Arindam Samanta.Hi,
I assume Your requirement like this .
Hope you activate >
I_GRID_SETTINGS = I_GRID_SETTINGS.
and then check this full code will help you as example.
transferring alv grid data to other program
Otherwise if you only want few editable field,then you can follow this code,which I am using,it is also easy.
a snippet,
CONSTANTS :
gc_refresh TYPE syucomm VALUE '&REFRESH'.
CONSTANTS :
c_x VALUE 'X'.
data: lt_event_exit TYPE slis_t_event_exit,
ls_event_exit TYPE slis_event_exit.
wa_fieldcat-fieldname = 'REMARKS'.
wa_fieldcat-seltext_l = 'Remarks'.
wa_fieldcat-edit = 'X'.
wa_fieldcat-col_pos = 1.
wa_fieldcat-outputlen = 50.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR ls_event_exit.
ls_event_exit-ucomm = gc_refresh. " Refresh
ls_event_exit-after = c_x.
APPEND ls_event_exit TO lt_event_exit.
Depend upon your user command like save,refresh it ill work also,like example,
FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE sy-ucomm.
WHEN gc_refresh.
refresh it_new_s.
LOOP AT it_new into wa_new where flag eq 'X'.
append wa_new to it_new_s.
ENDLOOP.
it_fieldcat_s[] = it_fieldcat[].
delete it_fieldcat_s where fieldname = 'FLAG'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_user_command = 'USER_COMMAND_S'
i_callback_pf_status_set = 'PF_STATUS_SET'
it_fieldcat = it_fieldcat_s
is_layout = wa_layout
it_sort = it_sort
it_event_exit = lt_event_exit
TABLES
t_outtab = it_new_s[].
and
FORM pf_status_set USING ut_extab TYPE slis_t_extab. "#EC CALLED
DELETE ut_extab WHERE fcode = gc_refresh.
SET PF-STATUS 'STANDARD_FULLSCREEN' OF PROGRAM 'SAPLKKBL'
EXCLUDING ut_extab.
ENDFORM.
There are lots of thread on editable alv,check also.
Thanks
Gourav. -
Hi guys,
I use the following method (register_edit_event) in the PBO soon after first display of an editable ALV grid to register enter as an event to do validations on fields like qty. If user enters some character like 'abc' for qty and hits enter on keyboard, ALV grid pop's up a standard message ( I haven't coded for this.Since I use DDIC structure in field catalog, the Std. ALV program takes care of it. ). THis takes care of the validation before I click on save.
call method alv_grid->register_edit_event
exporting
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
This works fine. But I want this validation to run when I also click the SAVE button of the screen. Is it possible to run this standard validation in my PAI event eg. SAVE ? I thought I will be, by calling the method check_changed_data in my PAI event. But this is doing nothing. Does this method conflict with register_edit_event or something ? So , basically what I am looking for is to trigger the event or call the method which does the same work as the "check" button on ALV grid.
Any advice or tips or sample code is greatly appreciated.
Thanks,
ShareenHi Shareen,
Handle the data_changed event in the grid.
Whenever you make changes in the data in ALV Grid this event would be triggered. Here you can perform additional validations that you may need to perform.
METHODS handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed.
Implementation:
METHOD handle_data_changed.
PERFORM validations USING er_data_changed.
ENDMETHOD.
FORM validations USING er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
DATA: ls_good TYPE lvc_s_modi.
DATA wa LIKE LINE OF lt_good_cells.
CALL METHOD g_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
LOOP AT er_data_changed->mt_good_cells INTO ls_good.
CASE ls_good-fieldname.
WHEN 'FIELDNAME'. "Your fieldname
CALL METHOD er_data_changed->get_cell_value "Get the changed value
EXPORTING
i_row_id = ls_good-row_id
i_fieldname = ls_good-fieldname
IMPORTING
e_value = temp. "Your temp variable
"Make your validations here.
ENDCASE.
Ps: Reward points if helpful.
Regards,
Wenceslaus. -
Urgent : Problem with Editable ALV Grid for Quantity and Currency Fields
Hi All,
I am using Editable ALV Grid display and have quantity and value as editable fields in the display.
When user changes these values these values are not changing properly .
For the quantity field the domain is MENG13 with 3 deciamal places and here if we enter 500 it takes it as 0.500 .
The same problem is for the currency field. Here the Domain is WERT7 with 3 decimal places.
Here also it takes last 2 digits after decimal places by default.
Please advice how to get proper values in this case from ALV editable fields.
Thanks and Regards
Harshad
Edited by: Harshad Rahirkar on Dec 25, 2007 7:39 AMfor all the currency field , it will display like that only.
u have to manipulate uin program before displaying.
if they are giving 500, in program multiply with 100 and move it to table.
when u are getting from table, divinde and display.
this is what I am doing.
Reward if helpfull. -
Hi all,
Frnds i am working in editable alv using function modules not object oriented abap.
i m trying to edit a Field(MATNR ) in my output list and finally update it with changed values in the DB table.
But i m getting syntax error like
"the work area i_final is not alligned properly
below i m providing my code.
<code>
*& Report ZEDITABLE_ALV1
REPORT ZEDITABLE_ALV1.
TABLES: vbak,vbap.
TYPE-POOLS: slis. "ALV Declarations
data: BEGIN OF i_final occurs 0,
vbeln like vbap-vbeln,
posnr like vbap-posnr,
matnr like vbap-matnr,
erdat like vbap-erdat,
END OF i_final.
DATA : C_X(1) TYPE C VALUE 'X',
C_FC_MODIFY(6) TYPE C VALUE 'MODIFY'.
*DATA: i_final TYPE STANDARD TABLE OF T_FINAL with header line.
i_temp type standard table of T_FINAL with header line.
*wa_final like line of i_final.
*DATA:i_final LIKE vbap OCCURS 0.
*DATA:wa_final LIKE vbap.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
* Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
fieldcatalog-fieldname = 'VBELN'.
fieldcatalog-seltext_m = 'sales order'.
fieldcatalog-col_pos = 0.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'ERDAT'.
fieldcatalog-seltext_m = 'date'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'material no.'.
fieldcatalog-col_pos = 2.
fieldcatalog-edit = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'POSNR'.
fieldcatalog-seltext_m = 'line item no.'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-FIELDNAME = 'REC_SEL'.
fieldcatalog-NO_OUT = C_X.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
* Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
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_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'GUI_STAT'
*i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
*it_special_groups = gd_tabgroup
*it_events = it_events
i_save = 'X'
*is_variant = z_template
TABLES
t_outtab = i_final
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_REPORT
**& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
*SELECT avbeln aerdat bmatnr bposnr FROM vbak AS a
*INNER JOIN vbap AS b ON avbeln = bvbeln
*INTO TABLE i_final WHERE a~vbeln = b~vbeln.
select VBELN ERDAT MATNR POSNR up to 10 rows from vbap into corresponding fields of table i_final.
ENDFORM. " DATA_RETRIEVAL
* FORM GUI_STAT *
* --> RT_EXTAB *
FORM gui_stat USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'MODIFY' EXCLUDING rt_extab.
ENDFORM.
* FORM USER_COMMAND *
* --> U_COMM *
* --> RS_SELFIELD *
FORM user_command USING u_comm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA:selfield TYPE slis_selfield.
*RS_SELFIELD-REFRESH = C_X.
CASE u_comm.
*IF U_COMM = C_FC_MODIFY.
WHEN 'UPDATE'.
LOOP AT i_final. " into wa_final."into wa_final.
*READ TABLE I_TEMP WITH KEY VBELN = I_FINAL-VBELN.
*IF SY-SUBRC = 0.
i_final-matnr = vbap-matnr.
*MODIFY I_final INDEX SY-TABIX.
*ENDIF.
ENDLOOP.
*ENDIF.
MODIFY VBAP FROM TABLE i_final.
IF SY-SUBRC = 0.
COMMIT WORK AND WAIT.
*MESSAGE I000 WITH SY-DBCNT
*' Record(s) has been Updated'(020).
ENDIF.
*append i_final.
*it_temp = i_final.
*append it_temp.
**UPDATE sflight FROM TABLE sflight_tab.
*ENDLOOP.
*update vbap from table i_final.
*IF sy-subrc = 0.
*MESSAGE s000(0) WITH 'records updated successfully'.
*ENDIF.
ENDCASE.
ENDFORM.
</code>
Frnds plz help me in this regard.
Thanks,
satyaTry something like this...ur code was not clear..i have done something u can understand.
First check that u r not trying to update the primary key field.
first before updating.
Before updating select the record u r going to update from the main table.
select single * from VBAP where <pass the key values>.
if sy-subrc = 0.
move the rest of the values to the table header except the key values.
vbap-<field1> = value1.
vbap-<field2> = value2.
after moving the values.
update <table>.
if sy-subrc = 0.
commit work.
endif.
data:st_vbap type vbap.
WHEN 'UPDATE'.
LOOP AT i_final. " into wa_final."into wa_final.
select single * from vbap where vbeln = I_FINAL-VBELN.
move-corresponding i_final to vbap.
update vbap.
if sy-subrc = 0.
commit work.
wk_cnt = wk_cnt + 1.
endif.
at last.
*MESSAGE I000 WITH SY-DBCNT
*' Record(s) has been Updated'(020).
endat.
endloop -
Unable to display Refreshed editable alv
hi
I have developed editable alv which contains 7 colums. the final column is the addition of 4th n 5th cplumn. when i refresh after changing the values, the final column is not changing. but while debugging the changed values are reflected in internal table but its reflected in alv.
help me outin the user_comand form you have to put rs_selfield-refresh = 'X'.
like this:
*& Form user_comand
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
rs_selfield-refresh = 'X'. -
Retrieve front end values of editable alv in same format
I have a problem to retrieve the front end values in editable alv filled by user.
I am able to get it from MODIFIED CELL method but it gives the values after
alv automatically conversion. For example if user filled 1 in cell of type numc
then i want to keep it as 1 not as 00..001 format of numc.
Same for when user fill alphbets in small letter the alv convert it in CAPS.
I want to retain it as it as filled by user.
Example: User filled aAbBcFG in a cell
then it should update in database in same format not like AABBCFG as alv did
<offer removed by moderator>
Edited by: Rocky_S on Jan 20, 2011 7:50 AM
Edited by: Rocky_S on Jan 20, 2011 7:51 AM
Edited by: Thomas Zloch on Jan 20, 2011 11:24 PMHi Srinivas I have used CONVERSION_EXIT_ALPHA_OUTPUT for number input. My problem is that
when user fill 0 in the alv cell then alv automatically convert it into 00000000. My field is of type numc
that why it converts in 00000000. I want to retrieve it as the user fill in alv cell. Through this function
module the import parameter parameter is of numc format not as filled by user. In my case if it is 0
then then i should retrieve it as it is.
My actual scenario is i have a numc type field in alv and i want to keep it as mandatory. For which i am
writing a logic. Because in my table there is a valid entry of 0. If user do not fill 0 then it takes automatically
0 as input because of initial value of numc field. I want to restict it. I can not convert this field as char.
Give me some logic to make numeric field mandatory. -
Problem While Saving the editable ALV GRID
Dear Experts,
I have a scenario in which i am display the ALV(using class) with some data in the custom container of module pool screen in the non-editable mode.Also i have save and edit buttons.If i click the edit button i have written the code to edit the some columns in the ALV grid, it is working fine.After editing it,when i click the save button then ALV has to refreshed with edited data and then it should go to non editable mode but it is not working.I have written the code for changing the editable ALv to non editable mode as follows :
call method c_alvgd->set_ready_for_input
exporting
i_ready_for_input = 0.
*****Row and column of the alv are refreshed after changing values
stable-row = 'X'.
stable-col = 'X'.
*REfreshed ALV display with the changed values
*This ALV is non editable and contains new values
call method c_alvgd->refresh_table_display
exporting
is_stable = stable
exceptions
finished = 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.
Could you Suggest me solution for this issue ?
Thanks & Regards,
R.Dhineshraj.Dhinesh,
I suppose that you are able to get your changes values on screen but not able to get your field in DISPLAY mode from editable mode, let me know if this is not your problem.
When you press SAVE, after the PAI, again PBO will run and hence the editable code for that field will overwrite which will keep it editable.
So, do something like this.
data: gv_edit value 'X'..... "global variable in TOP include
PBO....
loop at ...
if gv_edit = 'X'.
CALL METHOD lo_alv->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
else.
CALL METHOD lo_alv->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
endif.
endloop.
PAI.
when 'SAVE'.
gv_edit = space.
When 'EDIT'.
gv_edit = 'X'.
Regards,
Diwakar
Maybe you are looking for
-
What date will the Ipod Touch 5 come out?
I know it will be out in october but what date? I sold my Ipod Touch 4 the other day and I would like to know how long I have to wait.
-
How do I stop Quicktime from stopping recording when it believes the signal is lost?
I'm trying to digitize old VHS home videos through Quicktime (latest version). But when the tracking goes a bit awry, Quicktime stops recording telling me "RECORDING STOPPED, TRY RECORDING AGAIN." This is not true. It's just an instance of a bad part
-
How to enlarge the memory in Microblaze for software applications?
Dear, I wrote a C program, which after compiled generates a ELF binary with around 85KB. However, it is known that the Microblaze by default uses only 64KB. So my question is how can I enlarge the memory in Microblaze for software applications? The a
-
ODI Error while loading data to Classic HFM Application
Hello All, I am performing a integration from source(Flat file) to HFM application I have created a Integration to it and while loading the data i get the following error:- org.apache.bsf.BSFException: exception from Jython: Traceback (most recent ca
-
mes photos prisent avec mon iphone 4 ne se transfèrent plus sur mon pc depuis la dernière mise à jour , quelqu'un sait pourquoi.