Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Update ZTable from editable ALV

StefanReitz
Explorer
0 Kudos

Hi All,

i'm calling a Function Module from within a Badi Class ( Workorder_Update) which uses an ALV to Add Comments in a Field of the ALV for Transportation to a ZTable. Therefore the ALV is set to editable.

The Problem is that if the User does not press 'enter' after she/he added the Comment, the value is not send back to the internal Table wich updates the ZTab. If the User presses 'enter' ONLY the Comment is transported but the remainder of the Fields are cleared.

This is part of the Coding:

Before Calling FM -->

...

...

+ IF wa_header_old-pronr NE wa_header-pronr.

CLEAR wa_zthlog.

wa_zthlog-uzeit = sy-uzeit.

wa_zthlog-aufnr = wa_header-aufnr.

wa_zthlog-objnr = wa_header-objnr.

wa_zthlog-vornr = wa_operation-vornr.

wa_zthlog-ktext = wa_header-ktext.

wa_zthlog-aenam = sy-uname.

wa_zthlog-aedat = sy-datum.

wa_zthlog-larnt = wa_operation-larnt.

wa_zthlog-pronr = wa_header-pronr.

wa_zthlog-arbei = wa_operation-arbei.

wa_zthlog-dauno = wa_operation-dauno.

wa_zthlog-dauno = wa_operation-dauno.

wa_zthlog-ltxa1 = wa_operation-ltxa1.

wa_zthlog-arbid = wa_operation-arbid.

wa_zthlog-fieldname = 'PRONR'.

wa_zthlog-matkl = wa_operation-matkl.

wa_zthlog-preis = wa_operation-preis.

wa_zthlog-waers = wa_header-waers.

wa_zthlog-old_value = wa_header_old-pronr.

wa_zthlog-new_value = wa_header-pronr.

  • Fill t_zthlog - Call FM

APPEND wa_zthlog TO t_zthlog.

ENDIF.

ENDLOOP.

  • Secure Values before change

MOVE t_zthlog TO y_zthlog.+

Calling FM -->

+function z_thlog.

t_zthlog[] = c_zthlog[].

call screen 0100 starting at 10 3.

c_zthlog[] = t_zthlog[].

endfunction.+

ALV Grid - Processing -->

+module output_0100 output.

  • Fill Fieldcatalog

call function 'LVC_FIELDCATALOG_MERGE'

exporting

i_structure_name = 'ZTHLOG'

changing

ct_fieldcat = gt_fieldcat[]

exceptions

inconsistent_interface = 1

program_error = 2

others = 3.

if g_custom_container is initial.

  • Prepare ALV

create object g_custom_container

exporting container_name = g_container.

create object grid1

exporting i_parent = g_custom_container.

g_repid = sy-repid.

gs_layout-grid_title = 'Änderungsprotokoll'.

gs_layout-zebra = 'X'.

gs_layout-cwidth_opt = 'X'.

gs_variant-report = g_repid.

gs_variant = '/default'.

gs_layout-edit = 'X'.

  • Call ALV

call method grid1->set_table_for_first_display

exporting

i_structure_name = 'ZTHLOG'

is_layout = gs_layout

i_save = 'A'

is_variant = gs_variant

changing

it_outtab = t_zthlog

it_fieldcatalog = gt_fieldcat[].

  • Ready for Input

call method grid1->set_ready_for_input

exporting

i_ready_for_input = 1.

  • Eventregistration

call method grid1->register_edit_event

exporting

i_event_id = cl_gui_alv_grid=>mc_evt_enter.

create object g_event_receiver.

set handler g_event_receiver->handle_data_changed for grid1.

else.

  • Refresh, if filled

call method grid1->refresh_table_display.

endif.

  • set Cursor

call method cl_gui_control=>set_focus

exporting

control = grid1.

endmodule. " output_0100 OUTPUT+

There are alot of fields so the manual creation of the fieldcatalog should be avoided if possible.

Any Help is appreciated!

Best Regards

Stefan

1 ACCEPTED SOLUTION

StefanReitz
Explorer
0 Kudos

Hi,

nice, two answers with the same solution - must be right then ^^

Could you explain, perhaps with a few lines of code, how to implement that method in my Code?

Thanks in Advance

Stefan

7 REPLIES 7

former_member194669
Active Contributor
0 Kudos

Hi,

Call the following in PAI


  call method g_grid->check_changed_data
    importing
      e_valid = v_valid.

aRs

Former Member
0 Kudos

Hi stefan,

In the starting of PAI use the method grid1->check_changed_data. This will inturn triggers the event data_changed.

Regards,

Kasinath Babu.

StefanReitz
Explorer
0 Kudos

Hi,

nice, two answers with the same solution - must be right then ^^

Could you explain, perhaps with a few lines of code, how to implement that method in my Code?

Thanks in Advance

Stefan

0 Kudos

Hi,

Check this


*----------------------------------------------------------------------*
* Module Pai INPUT                                                     *
*----------------------------------------------------------------------*
* PAI module                                                           *
*----------------------------------------------------------------------*
module pai input.
  save_ok = ok_code.
  clear ok_code.

  call method grid1->check_changed_data
    importing
      e_valid = v_valid.

" After this system will automatically update your changed data into 
" internal table t_zthlog


  case save_ok.
    when 'EXIT'.
      perform f_exit_program.
    when 'CANC'.
      perform f_exit_program.
    when 'BACK'.
      perform f_exit_program.
    when 'SAVE'.
      perform f_save_data.
  endcase.
endmodule.                               " Pai INPUT


aRs

0 Kudos

Hi,

And you have already coded for ENTER

call method grid1->register_edit_event

exporting

i_event_id = cl_gui_alv_grid=>mc_evt_enter.

create object g_event_receiver.

set handler g_event_receiver->handle_data_changed for grid1.

aRs

StefanReitz
Explorer
0 Kudos

...Perhaps i have to add that i'm using a 'modal dialogwindow' instead of a 'Full' Dynpro, regarding the implementation of the method in PAI...

StefanReitz
Explorer
0 Kudos

Hi a®s,

it does the trick - Thanks!