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

DOUBT REGARDING ALV

Former Member
0 Likes
1,736

<u><b>how to catch contents of field on list displayed in alv</b></u>

Hi i have created a field in alv which is editable when the list is displayed .

on that list i will enter some value say reject the item with so and so reason( have a field called reject in the list). So once data entered how to catch the contents once entered could anybody plz tell me how to do that. I'm doing it without oop's concept..

<u><b>how to catch contents of field on list displayed in alv</b></u>

Hi i have created a field in alv which is editable when the list is displayed .

on that list i will enter some value say reject the item with so and so reason( have a field called reject in the list). So once data entered how to catch the contents once entered could anybody plz tell me how to do that. I'm doing it without oop's concept..

14 REPLIES 14
Read only

Former Member
0 Likes
1,691

data : iselfield type slis_t_selfield ,

wselfield type slis_selfield.

this thing contain the data.

you can track it in user command form

Form user_command using pucomm like sy-ucomm selfield type slis_t_selfield.

case pucomm.

when 'Your fcode'.

loop at selfield into wselfield.

endloop.

endform.

regards

shiba dutta

Read only

0 Likes
1,691

Wht should be there inside the loop. which is field whihhas the field contents

Read only

0 Likes
1,691
fp_selfield-value

contails the value of the field which u have clicked..

Message was edited by:

Naresh Reddy

Read only

Former Member
0 Likes
1,691

if u doulbe click on the field... u will get the complete datiails into one variable.

if ua can handle the USER_COMMAND in the ALV u will get..it.

Read only

0 Likes
1,691

Hi ,

Thanx a lot 4 ur reply but 'm not using classes . so could u plz tell me without oop's concept.. plz reply as soon as possible coz it's very urgent..

Thanx

Read only

Former Member
0 Likes
1,691

hi

The ALV Grid has events “data_changed” and “data_changed_finished”. The former method is triggered just after the change at an editable field is perceived. Here you can make checks for the input. And the second event is triggered after the change is committed.

You can select the way how the control perceives data changes by using the method “register_edit_event”. You have two choices:

i. After return key is pressed: To select this way, to the parameter “i_event_id” pass “cl_gui_alv_grid=>mc_evt_enter”.

ii. After the field is modified and the cursor is moved to another field:

For this, pass “cl_gui_alv_grid=>mc_evt_modifies” to the same parameter.

To make events controlling data changes be triggered, you must select either way by calling this method. Otherwise, these events will not be triggered.

To control field data changes, ALV Grid uses an instance of the class “CL_ALV_CHANGED_DATA_PROTOCOL” and passes this via the event “data_changed”. Using methods of this class, you can get and modify cell values and produce error messages. Here are some of those methods:

get_cell_value

Gets the cell value. You pass the address of the cell to the interface.

modify_cell

Modifies the cell value addressed via parameters.

add_protocol_entry

Add a log entry. You make use of standard message interface with message type, message id, etc…

protocol_is_visible

Make the error table visible or not.

refresh_protocol

Refreshing log entries.

With the reference of the instance, you can reach information about modifications. These useful attribute tables are:

MT_MOD_CELLS

Contains addresses of modified cells with “row_id”s and “fieldname”s.

MP_MOD_ROWS

Contains modified rows. Its type is generic.

MT_GOOD_CELLS

Contains cells having proper values

MT_DELETED_ROWS

Contains rows deleted from the list

MT_INSERTED_ROWS

Contains rows inserted to the list

Utilizing these methods and attributes you can check and give proper message and also modify the cell content.

here is a sample code.

FORM handle_data_changed USING ir_data_changed

TYPE REF TO cl_alv_changed_data_protocol.

DATA : ls_mod_cell TYPE lvc_s_modi ,

lv_value TYPE lvc_value .

SORT ir_data_changed->mt_mod_cells BY row_id .

LOOP AT ir_data_changed->mt_mod_cells

INTO ls_mod_cell

WHERE fieldname = 'SEATSMAX' .

CALL METHOD ir_data_changed->get_cell_value

EXPORTING i_row_id = ls_mod_cell-row_id

i_fieldname = 'CARRID'

IMPORTING e_value = lv_value .

IF lv_value = 'THY' AND ls_mod_cell-value > '500' .

CALL METHOD ir_data_changed->add_protocol_entry

EXPORTING

i_msgid = 'SU'

i_msgno = '000'

i_msgty = 'E'

i_msgv1 = 'This number can not exceed 500 for '

i_msgv2 = lv_value

i_msgv3 = 'The value is et to ''500'''

i_fieldname = ls_mod_cell-fieldname

i_row_id = ls_mod_cell-row_id .

CALL METHOD ir_data_changed->modify_cell

EXPORTING i_row_id = ls_mod_cell-row_id

i_fieldname = ls_mod_cell-fieldname

i_value = '500' .

ENDIF .

ENDLOOP .

ENDFORM. " handle_data_changed

The event “data_changed” makes you aware about F4 functions. It sets the appropriate parameter from the group with respect to where it was triggered. These parameters are { E_ONF4, E_ONF4_BEFORE, E_ONF4_AFTER }.

hope this helps

PLz reward if helpful

Read only

0 Likes
1,691

Hi,

i want to learn oop's concept and programming in alv using opp's could u plz send the material which will help me learning oop's concept my id is

[email protected]

Read only

0 Likes
1,691

Hi,

Refer these links for OOPS Concepts for ALV.

<b>www.abap4.it/download/ALV.pdf</b> -This pdf is very good for beginners in OOPS ALV.

Some more for your reference:

http://www.sapdevelopment.co.uk/reporting/alvhome.htm

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf

http://help.sap.com/saphelp_46c/helpdata/en/c5/3bd1369f2d280ee10000009b38f889/frameset.htm

<b>Sample Programs for ALV in OOPS:</b>

http://www.geocities.com/victorav15/sapr3/abap_ood.html#d_grid

<b>For oops concepts:</b>

http://www.erpgenie.com/abap/OO/

Regards,

Beejal

    • Reward if these links help

Read only

Former Member
0 Likes
1,691

Hi ,

In the REUSE_ALV_LIST display have a parameter called i_callusercommand .When you entered you will have a event USERCOMMAND on click any of the buttons in the toolbar or your own button .

In the That form user_command .

You can get the input values in the output table which you are displaying using RE_ALV_LIST_DISPLAY.

Use bcalv_test*

Please reward if useful.

Read only

anversha_s
Active Contributor
0 Likes
1,691
Read only

0 Likes
1,691

REPORT ZSALEHA1 .

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,

field_style TYPE lvc_t_styl, "FOR DISABLE

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.

DATA: it_fieldcat TYPE lvc_t_fcat, "slis_t_fieldcat_alv WITH HEADER LINE,

wa_fieldcat TYPE lvc_s_fcat,

gd_tab_group TYPE slis_t_sp_group_alv,

gd_layout TYPE lvc_s_layo, "slis_layout_alv,

gd_repid LIKE sy-repid.

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

*Start-of-selection.

START-OF-SELECTION.

PERFORM data_retrieval.

PERFORM set_specific_field_attributes.

PERFORM build_fieldcatalog.

PERFORM build_layout.

PERFORM display_alv_report.

&----


*& Form BUILD_FIELDCATALOG

&----


  • Build Fieldcatalog for ALV Report

----


FORM build_fieldcatalog.

wa_fieldcat-fieldname = 'EBELN'.

wa_fieldcat-scrtext_m = 'Purchase Order'.

wa_fieldcat-col_pos = 0.

wa_fieldcat-outputlen = 10.

wa_fieldcat-emphasize = 'X'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'EBELP'.

wa_fieldcat-scrtext_m = 'PO Item'.

wa_fieldcat-col_pos = 1.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'STATU'.

wa_fieldcat-scrtext_m = 'Status'.

wa_fieldcat-col_pos = 2.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'AEDAT'.

wa_fieldcat-scrtext_m = 'Item change date'.

wa_fieldcat-col_pos = 3.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-scrtext_m = 'Material Number'.

wa_fieldcat-col_pos = 4.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MENGE'.

wa_fieldcat-scrtext_m = 'PO quantity'.

wa_fieldcat-col_pos = 5.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MEINS'.

wa_fieldcat-scrtext_m = 'Order Unit'.

wa_fieldcat-col_pos = 6.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'NETPR'.

wa_fieldcat-scrtext_m = 'Net Price'.

wa_fieldcat-edit = 'X'. "sets whole column to be editable

wa_fieldcat-col_pos = 7.

wa_fieldcat-outputlen = 15.

wa_fieldcat-datatype = 'CURR'.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PEINH'.

wa_fieldcat-scrtext_m = 'Price Unit'.

wa_fieldcat-col_pos = 8.

APPEND wa_fieldcat TO it_fieldcat.

CLEAR wa_fieldcat.

ENDFORM. " BUILD_FIELDCATALOG

&----


*& Form BUILD_LAYOUT

&----


  • Build layout for ALV grid report

----


FORM build_layout.

  • Set layout field for field attributes(i.e. input/output)

gd_layout-stylefname = 'FIELD_STYLE'.

gd_layout-zebra = 'X'.

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'

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

i_callback_program = gd_repid

  • i_callback_user_command = 'USER_COMMAND'

is_layout_lvc = gd_layout

it_fieldcat_lvc = it_fieldcat

i_save = 'X'

TABLES

t_outtab = it_ekko

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 ebeln ebelp statu aedat matnr menge meins netpr peinh

UP TO 10 ROWS

FROM ekpo

INTO CORRESPONDING FIELDS OF TABLE it_ekko.

ENDFORM. " DATA_RETRIEVAL

&----


*& Form set_specific_field_attributes

&----


  • populate FIELD_STYLE table with specific field attributes

----


form set_specific_field_attributes .

DATA ls_stylerow TYPE lvc_s_styl .

DATA lt_styletab TYPE lvc_t_styl .

  • Populate style variable (FIELD_STYLE) with style properties

*

  • The NETPR field/column has been set to editable in the fieldcatalog...

  • The following code sets it to be disabled(display only) if 'NETPR'

  • is gt than 10.

LOOP AT it_ekko INTO wa_ekko.

IF wa_ekko-netpr GT 10.

ls_stylerow-fieldname = 'NETPR' .

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.

"set field to disabled

APPEND ls_stylerow TO wa_ekko-field_style.

MODIFY it_ekko FROM wa_ekko.

ENDIF.

ENDLOOP.

endform. " set_specific_field_attributes

Read only

0 Likes
1,691

The source code is giving error

Read only

Former Member
0 Likes
1,691

   CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
       i_callback_program = l_repid
       is_layout          = fp_wa_layout
       I_CALLBACK_USER_COMMAND  = 'user_command'
       it_fieldcat        = fp_it_fldcat
       i_save             = c_a
       is_variant         = fp_variant
       it_events          = fp_it_event
     TABLES
       t_outtab           = fp_it_data
     EXCEPTIONS
       program_error      = 1
       OTHERS             = 2.
   IF sy-subrc <> 0.
     MESSAGE i001.                     "ALV report can't be generated
     LEAVE LIST-PROCESSING.
   ENDIF.


 FORM user_command USING  fp_ucomm    TYPE syucomm
                                              fp_selfield TYPE slis_selfield . 

    IF   fp_ucomm = 'PICK'
     * ur code
   "fp_selfield  contains all the values..related to the field which u click on.

     ENDIF.
 ENDFORM.                    "user_command
Read only

0 Likes
1,691

In fp_name there are around 17 field so which particular field will have the contents that i will edit and enter say if i have field called reject in that column i will write r2 so in fp_name which field will have r2 . i want this b'coz the data what user enters i should save in the database table...