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: 

Create a Procedural ALV Report with editable fields and save the changes

Former Member
0 Kudos

Hi,

I am new to ABAP. I have created a Procedural ALV Report with 3 fields. I want to make 2 fields editable. When executed, if the fields are modified, I want to save the changes. All this I want to do without using OO concepts. Please help . Also, I checked out the forum and also the examples

BCALV_TEST_GRID_EDIT_01

BCALV_TEST_GRID_EDIT_02

BCALV_TEST_GRID_EDIT_04_FORMS

BCALV_TEST_GRID_EDITABLE

BCALV_EDIT_01

BCALV_EDIT_02

BCALV_EDIT_03

BCALV_EDIT_04

BCALV_EDIT_05

BCALV_EDIT_06

BCALV_EDIT_07

BCALV_EDIT_08

BCALV_FULLSCREEN_GRID_EDIT

But all these are using OO Concepts.

Please help.

Regards,

Smruthi

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

Try using the EDIT property of filedcatalog for the particular field u wish to edit.

wa-fieldname = 'field name'.

wa-edit = 'X'.

Thanks

Ravi Aswani

6 REPLIES 6

Former Member
0 Kudos

TABLES: ekko.

TYPE-POOLS: slis. "ALV Declarations

*Data Declaration

*----


TYPES: BEGIN OF t_ekko,

ebeln TYPE ekpo-ebeln,

ebelp TYPE ekpo-ebelp,

statu TYPE ekpo-statu,

aedat TYPE ekpo-aedat,

matnr TYPE ekpo-matnr,

menge TYPE ekpo-menge,

meins TYPE ekpo-meins,

netpr TYPE ekpo-netpr,

peinh TYPE ekpo-peinh,

line_color(4) TYPE c, "Used to store row color attributes

END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,

wa_ekko TYPE t_ekko.

*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.

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 = 'EBELN'.

fieldcatalog-seltext_m = 'Purchase Order'.

fieldcatalog-col_pos = 0.

fieldcatalog-outputlen = 10.

fieldcatalog-emphasize = 'X'.

fieldcatalog-key = 'X'.

  • fieldcatalog-do_sum = 'X'.

  • fieldcatalog-no_zero = 'X'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'EBELP'.

fieldcatalog-seltext_m = 'PO Item'.

fieldcatalog-col_pos = 1.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'STATU'.

fieldcatalog-seltext_m = 'Status'.

fieldcatalog-col_pos = 2.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'AEDAT'.

fieldcatalog-seltext_m = 'Item change date'.

fieldcatalog-col_pos = 3.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'MATNR'.

fieldcatalog-seltext_m = 'Material Number'.

fieldcatalog-col_pos = 4.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'MENGE'.

fieldcatalog-seltext_m = 'PO quantity'.

fieldcatalog-edit = 'X'

fieldcatalog-col_pos = 5.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'MEINS'.

fieldcatalog-seltext_m = 'Order Unit'.

fieldcatalog-col_pos = 6.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'NETPR'.

fieldcatalog-seltext_m = 'Net Price'.

fieldcatalog-col_pos = 7.

fieldcatalog-outputlen = 15.

fieldcatalog-datatype = 'CURR'.

APPEND fieldcatalog TO fieldcatalog.

CLEAR fieldcatalog.

fieldcatalog-fieldname = 'PEINH'.

fieldcatalog-seltext_m = 'Price Unit'.

fieldcatalog-col_pos = 8.

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-info_fieldname = 'LINE_COLOR'.

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_pf_status_set = 'STATUS'

i_callback_top_of_page = 'TOP-OF-PAGE'

  • i_callback_user_command = 'USER_COMMAND'

  • i_grid_title = outtext

is_layout = gd_layout

it_fieldcat = fieldcatalog[]

  • it_special_groups = gd_tabgroup

  • IT_EVENTS = GT_XEVENTS

i_save = 'X'

  • is_variant = z_template

TABLES

t_outtab = it_ekko

EXCEPTIONS

program_error = 1

OTHERS = 2.

ENDFORM. " DISPLAY_ALV_REPORT

&----


*& Form DATA_RETRIEVAL

&----


  • Retrieve data form EKPO table and populate itab it_ekko

----


FORM data_retrieval.

DATA: ld_color(1) TYPE c.

SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh

UP TO 10 ROWS

FROM ekpo

INTO TABLE it_ekko.

LOOP AT it_ekko INTO wa_ekko.

ld_color = ld_color + 1.

IF ld_color = 8.

ld_color = 1.

ENDIF.

CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.

MODIFY it_ekko FROM wa_ekko.

ENDLOOP.

ENDFORM. " DATA_RETRIEVAL

----


  • FORM top-of-page *

----


  • ........ *

----


FORM top-of-page.

WRITE:/ 'This is First Line of the Page'.

ENDFORM.

----


  • FORM status *

----


  • ........ *

----


FORM status USING rt_extab TYPE slis_t_extab. .

SET PF-STATUS 'ALV'.

ENDFORM.

----


  • FORM USER_COMMAND *

----


  • ........ *

----


  • --> RF_UCOMM *

  • --> RS *

----


FORM user_command USING rf_ucomm LIKE sy-ucomm

rs TYPE slis_selfield.

DATA ref1 TYPE REF TO cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref1.

CALL METHOD ref1->check_changed_data.

CASE rf_ucomm.

when 'SAVE'.

get all the modified entries and store them in an internal table and udpate them in to the required transaction or your custom table.

endcase.

endform.

ENDFORM.

here u need to 2 performs for PF status and USER_COMMAND in the ALV parameters.

create a custom PF status and create push buttons and assign your ok codes in your PF status.

if the field has to be edited in the ALV then pass EDIT = 'X' for that field in the fieldcatlog preparation.

Hope this will help you.

Regards,

phani.

Former Member
0 Kudos

Hi Smruthi,

You can do this by below mentioned way

1. Suppose you wanted to edit two field FIELD1 & FIELD2 as editable. You need to use the "EDIT" parameter in your fieldcatalog.

i.e.

wa-fieldname = 'FIELD1'.

wa-edit = 'X'.

append wa to itab.

wa-fieldname = 'FIELD2'.

wa-edit = 'X'.

append wa to itab.

2. Now you wanted to update the edited records in particular transaction. So, for this you need to write code under USER_COMMAND.

WHEN 'SAVE'.

  • modify your internal table with updated entries & pass it for particular transaction

Regards,

Amit

Former Member
0 Kudos

Hi,

Try using the EDIT property of filedcatalog for the particular field u wish to edit.

wa-fieldname = 'field name'.

wa-edit = 'X'.

Thanks

Ravi Aswani

0 Kudos

Thanks Ravi,

But how to save the changes is my question.

Former Member
0 Kudos

Thanks to all. I have been able to edit. But save is still causing a problem. I therefore wrote a separate program. I have posted another question " Save Data in ALV Report".

Former Member
0 Kudos

Resolved