Application Development and Automation 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: 
Read only

ALV

Former Member
0 Likes
757

Hi,

In ALV i was displaying the records taking from the database in a grid dislay mode.

Now is it possible to change any data there itself and save it to the Database table.If so can u tell how it is possible..any sample code

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
715

Hi Mahesh if u are using REUSE_ then go through below code.

U have to give FORM user_command. & there u have to write code to save data. u have to first use w_fieldcat-edit = 'X'. for those fields which u want to edit.

Try this it's simple.

Give points if useful.

REPORT ZEDITALV .

type-pools: SLIS.

tables : zemp_y.

data: itab type standard table of zemp_y,wa type zemp_y.

DATA: it_events TYPE slis_t_event, wa_event TYPE slis_alv_event.

DATA: w_repid LIKE sy-repid .

DATA: w_title_first TYPE lvc_title.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,

w_fieldcat TYPE slis_fieldcat_alv.

select * from zemp_y into table itab.

perform build_fcat.

w_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = w_repid

i_callback_user_command = 'USER_COMMAND'

i_grid_title = w_title_first

it_fieldcat = it_fieldcat[]

i_save = 'A'

it_events = it_events

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.

&----


*& Form build_fcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_fcat .

w_fieldcat-fieldname = 'ENO'.

w_fieldcat-seltext_m = 'EMP NO'.

APPEND w_fieldcat TO it_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-fieldname = 'ENAME'.

w_fieldcat-seltext_m = 'EMP NAME'.

w_fieldcat-edit = 'X'.

APPEND w_fieldcat TO it_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-fieldname = 'DNO'.

w_fieldcat-seltext_m = 'DEP NO'.

w_fieldcat-edit = 'X'.

APPEND w_fieldcat TO it_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-fieldname = 'SAL'.

w_fieldcat-seltext_m = 'SALARY'.

w_fieldcat-edit = 'X'.

APPEND w_fieldcat TO it_fieldcat.

CLEAR w_fieldcat.

endform. " build_fcat

&----


  • Form user_command *

&----


  • This form will handle the user command from fm REUSE *

----


form user_command using p_ucomm type sy-ucomm

rs_selfield type slis_selfield.

data p_ref1 type ref to cl_gui_alv_grid.

call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'

importing

e_grid = p_ref1.

call method p_ref1->check_changed_data.

case p_ucomm.

when '&DATA_SAVE'.

update zemp_y from table itab. " to save data from itab to db

endcase.

rs_selfield-refresh = 'X'. " Grid refresh

endform.

5 REPLIES 5
Read only

Former Member
0 Likes
715

In Report it is not possible to update databse fields. For this requirement you have to go for modulepool programming.

Read only

former_member156446
Active Contributor
0 Likes
715
Read only

Former Member
0 Likes
715

Hi,

in field catalog ull have an option 'EDIT' if u set it 'X', that column will be editable........u can enter ur own values and save...........

try this standard demo program in se38

'BCALV_GRID_EDIT'

Cheers,

Will.

Read only

Former Member
0 Likes
715

yes it is possible but u have to write bdc in that case and editing is possible only in list display

here is a sample code

plz reward if useful

&----


*& Report Z11_VIVEK_PROGRAM_40 *

*& *

&----


*& *

*& *

&----


report z11_vivek_program_40 message-id z11va0816 .

type-pools : slis.

----


  • TABLES DECLARATION *

----


tables likp.

----


  • STRUCTURES *

----


types : begin of t_header,

vbeln type vbeln_vl,

ernam type ernam, "CONTACT PERSON.

vkorg type vkorg,

bldat type bldat,

wldat type wldat,

erdat type erdat,

kunnr type kunnr,

btgew type gsgew,

gewei type gewei,

anzpk type anzpk,

lfart type lfart,

vstel type vstel,

end of t_header.

types : begin of t_details,

vbeln type vbeln_vl,

posnr type posnr_vl,

arktx type arktx,

matnr type matnr,

lfimg type lfimg,

werks type werks_d,

lgort type lgort_d,

vrkme type vrkme,

brgew type brgew_15,

charg type charg_d,

end of t_details.

types : begin of t_final,

v_box(1) type c,

v_lights(4) type c,

vbeln type vbeln_vl,

ernam type ernam, "CONTACT PERSON.

vkorg type vkorg,

bldat type bldat,

wldat type wldat,

erdat type erdat,

kunnr type kunnr,

btgew type gsgew,

gewei type gewei,

anzpk type anzpk,

lfart type lfart,

vstel type vstel,

posnr type posnr_vl,

vgpos type vgpos,

arktx type arktx,

matnr type matnr,

lfimg type lfimg,

werks type werks,

lgort type lgort_d,

vrkme type vrkme,

brgew type brgew_15,

charg type charg_d,

end of t_final .

********************************************

  • WORK AREA

********************************************

*&---work area for internal tables

data:wa_header type t_header.

data:wa_details type t_details.

data:wa_final type t_final.

*&---work area for layout

data wa_layout type slis_layout_alv.

********************************************

  • INTERNAL TABLES

********************************************

data:i_header type standard table of t_header.

data:i_details type standard table of t_details.

data:i_final type standard table of t_final.

*****for BDC

data: it_tab like bdcdata occurs 0 with header line.

********************************************

  • VARIABLES

********************************************

data: wf_progname like sy-repid.

data: wf_gridtitle type lvc_title.

data: counter type i.

********************************************

  • DATA DECLARATION FOR THE CATALOGS

********************************************

data: i_fieldcat type slis_t_fieldcat_alv,

i_fieldcat1 type slis_t_fieldcat_alv,

*&---Internal table for the sorting sequence.

i_sortinfo type slis_t_sortinfo_alv,

*&---Internal table for the event catalog.

i_eventcat type slis_t_event,

*&---Internal table for the top of page event

i_listheader type slis_t_listheader.

********************************************

  • SELECTION SCREEN

********************************************

selection-screen begin of block v1 with frame.

select-options : s_lfart for likp-lfart.

select-options : s_vstel for likp-vstel.

select-options : s_vbeln for likp-vbeln.

select-options : s_erdat for likp-erdat.

selection-screen end of block v1.

selection-screen begin of block v2 with frame title text-101.

parameters: rb1 radiobutton group rad1, "Grid

rb2 radiobutton group rad1 . "List

selection-screen end of block v2.

********************************************

  • SELECTION-SCREEN VALIDATIONS

********************************************

at selection-screen.

select lfart into wa_header-lfart

from likp

where lfart in s_lfart.

exit.

endselect.

if sy-subrc <> 0.

message e001.

endif.

select vstel into wa_header-vstel

from likp

where vstel in s_vstel.

exit.

endselect.

if sy-subrc <> 0.

message e002.

endif.

select vbeln into wa_header-vbeln

from likp

where vbeln in s_vbeln.

exit.

endselect.

if sy-subrc <> 0.

message e003.

endif.

select erdat into wa_header-erdat

from likp

where erdat in s_erdat.

exit.

endselect.

if sy-subrc <> 0.

message e004.

endif.

********************************************

  • INITIALIZATION EVENT

********************************************

initialization.

wf_progname = sy-repid.

counter = 0.

********************************************

************************************************************************

  • START-OF-SELECTION EVENT *

************************************************************************

start-of-selection.

  • FUNCTION-POPULATING HEADER.

perform get_header tables i_header

s_lfart

s_vstel

s_vbeln

s_erdat.

if not i_header is initial.

  • FUNCTION - POPULATING DEATILS.

perform get_details tables i_details

i_header .

  • FUNCTION - MERGING TABLES.

perform get_merge tables i_details

i_header

i_final.

  • PREPARE FIELDCATALOG FOR THE MAIN REPORT.

perform zf_build_fieldcat using i_fieldcat.

  • FUNCTION FOR EVENT CALLING.

perform zf_eventcat using i_eventcat.

  • FUNCTION FOR TOP OF PAGE EVENT.

perform zf_build_listheader using i_listheader.

  • FUNCTION-TRAFFIC LIGHTS.

perform p_lights.

  • FUNCTION FOR BUILDING LAYOUT.

perform zf_layout.

  • FUNCTION FOR GRID TITLE.

perform zf_build_grid_title.

  • IF p_rb1 RADIO button (ALV GRID) IS selected .

if rb1 is not initial.

  • DISPLAY ALV GRID.

perform zf_display_alv_grid.

else.

  • DISPLAY ALV LIST.

perform zf_display_alv_list.

endif.

else.

*If Table is not Populated ie Records Does not exist

message 'Record Does Not Exist' type 'S'.

endif.

end-of-selection.

&----


*& Form get_header

&----


  • text

----


  • -->P_I_HEADER text

  • -->P_S_LFART text

  • -->P_S_VSTEL text

  • -->P_S_VBELN text

  • -->P_S_ERDAT text

----


form get_header tables p_i_header structure wa_header

p_s_lfart structure s_lfart

p_s_vstel structure s_vstel

p_s_vbeln structure s_vbeln

p_s_erdat structure s_erdat.

select vbeln

kunnr

ernam

bldat

wadat

btgew

gewei

anzpk

lfart

vstel

vkorg

into corresponding fields of table p_i_header

from likp

where lfart in s_lfart

and vstel in s_vstel

and vbeln in s_vbeln

and erdat in s_erdat .

sort i_header by vbeln.

endform. " get_header

&----


*& Form get_details

&----


  • text

----


  • -->P_I_DETAILS text

  • -->P_I_HEADER text

----


form get_details tables p_i_details structure wa_details

p_i_header structure wa_header.

select vbeln

posnr

matnr

vrkme

lfimg

arktx

werks

lgort

brgew

charg

into corresponding fields of table p_i_details

from lips for all entries in p_i_header where vbeln = p_i_header-vbeln.

append wa_details to i_details.

endform. " get_details

&----


*& Form get_merge

&----


  • text

----


  • -->P_I_DETAILS text

  • -->P_I_HEADER text

  • -->P_I_FINAL text

----


form get_merge tables p_i_details structure wa_details

p_i_header structure wa_header

p_i_final structure wa_final.

sort p_i_details by vbeln posnr .

loop at p_i_details into wa_details.

wa_final-posnr = wa_details-posnr.

wa_final-matnr = wa_details-matnr.

wa_final-lfimg = wa_details-lfimg.

wa_final-vrkme = wa_details-vrkme.

wa_final-arktx = wa_details-arktx.

wa_final-werks = wa_details-werks.

wa_final-lgort = wa_details-lgort.

wa_final-brgew = wa_details-brgew.

wa_final-charg = wa_details-charg.

read table p_i_header with key vbeln = wa_details-vbeln into wa_header.

move-corresponding wa_header to wa_final.

append wa_final to p_i_final.

clear wa_final.

endloop.

sort p_i_final by vbeln posnr.

endform. " get_merge

&----


*& Form zf_build_fieldcat

&----


  • text

----


  • -->P_I_FIELDCAT text

----


form zf_build_fieldcat using p_i_fieldcat type slis_t_fieldcat_alv.

data:l_fieldcat type slis_fieldcat_alv.

clear l_fieldcat.

l_fieldcat-col_pos = '1'. " POSITION OF THE COLUMN.

l_fieldcat-fieldname = 'V_LIGHTS'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.

  • L_FIELDCAT-EMPHASIZE = 'C311'. " COLOR OF THIS COLUMN.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION.

l_fieldcat-outputlen = 7.

" TO DEFINE OUTPUT LENGTH OF THE COLUMN.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '2'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'V_BOX'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

l_fieldcat-edit = 'X'.

l_fieldcat-input = 'X'.

l_fieldcat-checkbox = 'X'.

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Select'." long text for header.

l_fieldcat-seltext_m = 'Select'. " medium text for header.

l_fieldcat-seltext_s = 'Select'. " sort text for header.

l_fieldcat-outputlen = 1. " SET THE output length.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '3'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'POSNR'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

l_fieldcat-hotspot = 'x'.

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Delivery item'." long text for header.

l_fieldcat-seltext_m = 'Delivery item'. " medium text for header.

l_fieldcat-seltext_s = 'Delv. Item'. " sort text for header.

l_fieldcat-outputlen = 10. " SET THE output length.

l_fieldcat-ref_tabname = 'LIPS'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '4'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'MATNR'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

l_fieldcat-hotspot = 'x'.

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Material Number'." long text for header.

l_fieldcat-seltext_m = 'Material Number'. " medium text for header.

l_fieldcat-seltext_s = 'Material No.'. " sort text for header.

l_fieldcat-outputlen = 18. " SET THE output length.

l_fieldcat-ref_tabname = 'LIPS'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '5'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'ARKTX'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

l_fieldcat-edit = 'X'.

l_fieldcat-input = 'X'.

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Description'." long text for header.

l_fieldcat-seltext_m = 'Description'. " medium text for header.

l_fieldcat-seltext_s = 'Description'. " sort text for header.

l_fieldcat-outputlen = 40. " SET THE output length.

l_fieldcat-ref_tabname = 'LIPS'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '6'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'LFIMG'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Quantity'." long text for header.

l_fieldcat-seltext_m = 'Quantity'. " medium text for header.

l_fieldcat-seltext_s = 'Qty.'. " sort text for header.

l_fieldcat-outputlen = 13. " SET THE output length.

l_fieldcat-ref_tabname = 'LIPS'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '7'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'VRKME'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Sales Unit'." long text for header.

l_fieldcat-seltext_m = 'Sales Unit'. " medium text for header.

l_fieldcat-seltext_s = 'SU.'. " sort text for header.

l_fieldcat-outputlen = 3. " SET THE output length.

l_fieldcat-ref_tabname = 'LIPS'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '8'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'VRKME'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Sales Unit'." long text for header.

l_fieldcat-seltext_m = 'Sales Unit'. " medium text for header.

l_fieldcat-seltext_s = 'SU'. " sort text for header.

l_fieldcat-outputlen = 3. " SET THE output length.

l_fieldcat-ref_tabname = 'LIPS'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '9'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'BRGEW'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Gross weight'." long text for header.

l_fieldcat-seltext_m = 'Gross weight'. " medium text for header.

l_fieldcat-seltext_s = 'Gross weight'. " sort text for header.

l_fieldcat-outputlen = 15. " SET THE output length.

l_fieldcat-ref_tabname = 'LIPS'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '10'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'CHARG'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Batch Number'." long text for header.

l_fieldcat-seltext_m = 'Batch Number'. " medium text for header.

l_fieldcat-seltext_s = 'Batch'. " sort text for header.

l_fieldcat-outputlen = 10. " SET THE output length.

l_fieldcat-ref_tabname = 'LIPS'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '11'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'WERKS'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Plant'." long text for header.

l_fieldcat-seltext_m = 'Plant'. " medium text for header.

l_fieldcat-seltext_s = 'Plnt'. " sort text for header.

l_fieldcat-outputlen = 4. " SET THE output length.

l_fieldcat-ref_tabname = 'LIPS'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

l_fieldcat-col_pos = '12'. " POSITION OF THE COLUMN

l_fieldcat-fieldname = 'LGORT'.

" FIELD FOR WHICH CATALOG ID FILLED.

l_fieldcat-tabname = 'I_FINAL'.

" INTERNAL TABLE TO WHICH FIELD BELONGS TO

l_fieldcat-key = 'x'.

" SO THAT this field is not scrollable and hiddable.

l_fieldcat-just = 'L'. " FOR JUSTIFICATION

" MARK THIS field as hotsopt to cause the f2 events to trigger.

l_fieldcat-lzero = 'x'.

" OUTPUT WITH leading zeros.

l_fieldcat-seltext_l = 'Storage Location'." long text for header.

l_fieldcat-seltext_m = 'Storage Location'. " medium text for header.

l_fieldcat-seltext_s = 'St.Lo.'. " sort text for header.

l_fieldcat-outputlen = 4. " SET THE output length.

l_fieldcat-ref_tabname = 'LIPS'.

" FOR F1 & F4 help as refernced to the ddic table.

append l_fieldcat to p_i_fieldcat.

clear l_fieldcat.

endform. " zf_build_fieldcat

&----


*& Form zf_display_alv_grid

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form zf_display_alv_grid .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = wf_progname

  • 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 = wf_gridtitle

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = i_eventcat

  • 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 = 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. " zf_display_alv_grid

&----


*& Form zf_display_alv_list

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form zf_display_alv_list .

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = wf_progname

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

  • IS_LAYOUT =

it_fieldcat = i_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT =

  • I_SAVE =

  • IS_VARIANT =

it_events = i_eventcat

  • 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

  • IR_SALV_LIST_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

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. " zf_display_alv_list

&----


*& Form zf_eventcat

&----


  • text

----


  • -->P_I_EVENTCAT text

----


form zf_eventcat using p_i_eventcat type slis_t_event.

data l_eventcat type slis_alv_event.

clear l_eventcat.

*Get all the events.

call function 'REUSE_ALV_EVENTS_GET'

exporting

i_list_type = 0

importing

et_events = p_i_eventcat

exceptions

list_type_wrong = 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.

  • TOP-OF-PAGE FORM

clear l_eventcat.

read table p_i_eventcat into l_eventcat with key

name = slis_ev_top_of_page.

if sy-subrc = 0.

move 'ZF_TOP_OF_PAGE' to l_eventcat-form.

modify p_i_eventcat from l_eventcat index sy-tabix

transporting form.

endif.

  • PF_STATUS_SET FORM

clear l_eventcat.

read table p_i_eventcat into l_eventcat with key

name = slis_ev_pf_status_set.

if sy-subrc = 0.

move 'ZF_PF_STATUS_SET' to l_eventcat-form.

modify p_i_eventcat from l_eventcat index sy-tabix

transporting form.

.

endif.

  • USER_COMMAND FORM

clear l_eventcat.

read table p_i_eventcat into l_eventcat with key

name = slis_ev_user_command.

if sy-subrc = 0.

move 'ZF_USER_COMMAND' to l_eventcat-form.

modify p_i_eventcat from l_eventcat index sy-tabix

transporting form.

endif.

endform. " zf_eventcat

&----


*& Form zf_build_listheader

&----


  • text

----


  • -->P_I_LISTHEADER text

----


form zf_build_listheader using p_i_listheader type slis_t_listheader

.

data: l_listheader type slis_listheader.

refresh p_i_listheader.

clear l_listheader.

l_listheader-typ = 'H'. "Header

l_listheader-info = 'FUJITSU CONSULTING INDIA LIMITED'.

append l_listheader to p_i_listheader.

l_listheader-typ = 'S'.

l_listheader-key = 'DATE'.

l_listheader-info = sy-datum.

append l_listheader to p_i_listheader.

l_listheader-typ = 'S'.

l_listheader-key = 'PAGE NO.'.

l_listheader-info = sy-pagno.

append l_listheader to p_i_listheader.

endform. " zf_build_listheader

----


*FORM TOP-OF-PAGE.

----


form zf_top_of_page.

*This FM is responsible for formatting the header information

call function 'REUSE_ALV_COMMENTARY_WRITE'

exporting

it_list_commentary = i_listheader

i_logo = 'TYCO_LOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

endform. "TOP-OF-PAGE

----


*FORM PF_STATUS_SET.

----


form zf_pf_status_set using rt_extab type slis_t_extab.

set pf-status 'ALV_MENU1'.

endform. "SET_PF_STATUS

----


*FORM USER_COMMAND.

----


form zf_user_command using r_ucomm like sy-ucomm

rs_selfield type slis_selfield.

case r_ucomm.

when '&IC1'. "for hotspot with VBELN.

if rs_selfield-fieldname = 'MATNR'.

set parameter id 'AUN' field rs_selfield-value.

call transaction 'MM03' and skip first screen.

message i103 with rs_selfield-value .

endif.

when 'UPDATE'. "for editing decription.

loop at i_final into wa_final where v_box = 'X'.

counter = counter + 1.

endloop.

if counter = 1.

read table i_final into wa_final with key v_box = 'X'.

if sy-subrc = 0.

*FIRST SCREEN

perform bdc_dynpro using 'SAPMV50A'

'4004'.

perform bdc_field using 'BDC_CURSOR'

'LIKP-VBELN'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LIKP-VBELN'

wa_final-vbeln.

*SECOND SCREEN

perform bdc_dynpro using 'SAPMV50A'

'1000'.

perform bdc_field using 'BDC_OKCODE'

'=IDET_T'.

*THIRD SCREEN

perform bdc_dynpro using 'SAPMV50A'

'3000'.

perform bdc_field using 'BDC_OKCODE'

'=T\02'.

*FOURTH SCREEN

perform bdc_dynpro using 'SAPMV50A'

'3000'.

perform bdc_field using 'BDC_OKCODE'

'=BACK_T'.

perform bdc_field using 'BDC_CURSOR'

'LIPS-ARKTX'.

perform bdc_field using 'LIPS-ARKTX'

wa_final-arktx.

*FIFTH SCREEN

perform bdc_dynpro using 'SAPMV50A'

'1000'.

perform bdc_field using 'BDC_OKCODE'

'=SICH_T'.

call transaction 'VL02N' using it_tab mode 'E'.

message 'RECORD IS MODIFIED' type 'I'.

clear counter.

else.

clear counter.

message 'CLICK ONE CHECKBOX AT A TIME' type 'E'.

endif.

endif.

when 'DELIVERY'.

loop at i_final into wa_final where v_box = 'X'.

counter = counter + 1.

endloop.

if counter = 0.

message 'SELECT A RECORD TO SEE DELEIVERY' type 'E'.

elseif counter = 1.

read table i_final into wa_final with key v_box = 'X'.

if sy-subrc = 0.

set parameter id 'VL' field wa_final-vbeln.

call transaction 'VL03N' and skip first screen.

message 'DELIVERY NOTE ' type 'I' .

clear counter.

endif.

else.

clear counter.

message 'CLICK ONE CHECKBOX AT A TIME' type 'E'.

endif.

endcase.

endform. " USER_COMMAND

&----


*& Form zf_build_grid_title

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form zf_build_grid_title .

wf_gridtitle = 'Delivery details'.

endform. " zf_build_grid_title

&----


*& Form zf_layout

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form zf_layout .

clear wa_layout.

wa_layout-zebra = 'X'.

wa_layout-lights_fieldname = 'V_LIGHTS'.

wa_layout-lights_tabname = 'I_FINAL'.

" 1, 2 or 3 for red, yellow and green respectively.

wa_layout-box_fieldname = 'V_BOX'.

wa_layout-box_tabname = 'I_FINAL'.

endform. " zf_layout

----


  • Start new screen *

----


form bdc_dynpro using program dynpro.

clear it_tab.

it_tab-program = program.

it_tab-dynpro = dynpro.

it_tab-dynbegin = 'X'.

append it_tab.

endform.

----


  • Insert field *

----


form bdc_field using fnam fval.

clear it_tab.

it_tab-fnam = fnam.

it_tab-fval = fval.

append it_tab.

endform.

&----


*& Form P_LIGHTS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form p_lights .

loop at i_final into wa_final.

if wa_final-lfimg = '1'.

wa_final-v_lights = '3'.

modify i_final from wa_final.

elseif wa_final-lfimg = '2'.

wa_final-v_lights = '2'.

modify i_final from wa_final.

else.

wa_final-v_lights = '1'.

modify i_final from wa_final.

endif.

endloop.

endform. " P_LIGHTS

Read only

Former Member
0 Likes
716

Hi Mahesh if u are using REUSE_ then go through below code.

U have to give FORM user_command. & there u have to write code to save data. u have to first use w_fieldcat-edit = 'X'. for those fields which u want to edit.

Try this it's simple.

Give points if useful.

REPORT ZEDITALV .

type-pools: SLIS.

tables : zemp_y.

data: itab type standard table of zemp_y,wa type zemp_y.

DATA: it_events TYPE slis_t_event, wa_event TYPE slis_alv_event.

DATA: w_repid LIKE sy-repid .

DATA: w_title_first TYPE lvc_title.

DATA: it_fieldcat TYPE slis_t_fieldcat_alv,

w_fieldcat TYPE slis_fieldcat_alv.

select * from zemp_y into table itab.

perform build_fcat.

w_repid = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = w_repid

i_callback_user_command = 'USER_COMMAND'

i_grid_title = w_title_first

it_fieldcat = it_fieldcat[]

i_save = 'A'

it_events = it_events

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.

&----


*& Form build_fcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form build_fcat .

w_fieldcat-fieldname = 'ENO'.

w_fieldcat-seltext_m = 'EMP NO'.

APPEND w_fieldcat TO it_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-fieldname = 'ENAME'.

w_fieldcat-seltext_m = 'EMP NAME'.

w_fieldcat-edit = 'X'.

APPEND w_fieldcat TO it_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-fieldname = 'DNO'.

w_fieldcat-seltext_m = 'DEP NO'.

w_fieldcat-edit = 'X'.

APPEND w_fieldcat TO it_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-fieldname = 'SAL'.

w_fieldcat-seltext_m = 'SALARY'.

w_fieldcat-edit = 'X'.

APPEND w_fieldcat TO it_fieldcat.

CLEAR w_fieldcat.

endform. " build_fcat

&----


  • Form user_command *

&----


  • This form will handle the user command from fm REUSE *

----


form user_command using p_ucomm type sy-ucomm

rs_selfield type slis_selfield.

data p_ref1 type ref to cl_gui_alv_grid.

call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'

importing

e_grid = p_ref1.

call method p_ref1->check_changed_data.

case p_ucomm.

when '&DATA_SAVE'.

update zemp_y from table itab. " to save data from itab to db

endcase.

rs_selfield-refresh = 'X'. " Grid refresh

endform.