cancel
Showing results for 
Search instead for 
Did you mean: 

Editable Option in Webdynpro Abap

Former Member
0 Kudos

Hello Guys,

There is a scenerio i was working with and facing the issue.

Lemme go thru the issue .

I have a Webdynpro table in which i have 3 Fields 1st Quarter 2nd Quarter 3rd Quarter.

Depend on the present month Either 1 field will be editable.

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'FIRST QUARTER' ).

LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).

LR_TABLE_SETTINGS ?= LO_VALUE.

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_FALSE ).

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = 'FIRST QUARTER'.

LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

This is the code which iam using for all the 3 fields.

The problem which iam getting is Either all the fields getting Editable or All the fields are not getting non editable.

Can any one help me to resolve this issue .

Regards

DKM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

hI dkm,

hope this code works

LR_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'FIRST QUARTER' ).

CREATE OBJECT LR_INPUT

EXPORTING

VALUE_FIELDNAME = 'W_FCST_OWN'.

CALL METHOD LR_COLUMN->SET_CELL_EDITOR

EXPORTING

VALUE = LR_INPUT.

LR_INPUT->SET_READ_ONLY_FIELDNAME( VALUE = 'W_DIS_ENABLE' ).

LO_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( VALUE = ABAP_FALSE ).

LR_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'SECOND QUARTER' ).

CREATE OBJECT LR_INPUT

EXPORTING

VALUE_FIELDNAME = 'W_FCST_OWN'.

CALL METHOD LR_COLUMN->SET_CELL_EDITOR

EXPORTING

VALUE = LR_INPUT.

LR_INPUT->SET_READ_ONLY_FIELDNAME( VALUE = 'W_DIS_DISABLE' ).

LO_VALUE->IF_SALV_WD_TABLE_SETTINGS~SET_READ_ONLY( VALUE = ABAP_FALSE ).

Thanks

dhinesh

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi saravana,

the option which u said is working fine, Thanks for that.

but on enhancement part i have a doubt.

my project deals with entering the po amount. it has two buttons basically Edit and Save.

under the edit button i have these codes to be written (Editable fields.). once the user enters amount and click save button all the editable fields must change into non-editable.

as per the above code i can get my fields getting editable but when i click save the fields stil remains editable. if i refresh my screen then only it is non-editable.

Can u help me in the logic which i need to write under save button so that once i click save button everything becomes non editable .

Thanks

DKM

saravanan_narayanan
Active Contributor
0 Kudos

Hello Dhinesh,

this can be controlled via another boolean context attribute in the context node that is being passed to the ALV. do the following

1. Create an context attribute READ_ONLY of type boolean in the context node that is being passed to the ALV component

2. while initialising the ALV component delete the column that is being created for the READ_ONLY attribute

3. bind this attribute as READ_ONLY property to all the inputfields

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = ''first quarter'.

LR_INPUT_FIELD->SET_READ_ONLY_FIELDNAME( 'READ_ONLY')

4. during save set the value of the READ_ONLY attribtue to ABAP_TRUE and during EDIT set the READ_ONLY value to abap_false

BR, Saravanan

Former Member
0 Kudos

Hello ,

this is the code .

As per this code either eveything becomes editable or everything becomes not editable.

Recall: i have 3 fields in my ALV table First quarter second quarter and third quarter , on base of current month i have to make one of the 3 fields to editable and remaining other 2 fields should be not editable.

if month is jan to april

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'first quarter' ).

LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).

LR_TABLE_SETTINGS ?= LO_VALUE.

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_FALSE ).

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = ''first quarter'.

LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'second quarter' ).

LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).

LR_TABLE_SETTINGS ?= LO_VALUE.

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_true ).

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = ''second quarter'.

LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'third quarter' ).

LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).

LR_TABLE_SETTINGS ?= LO_VALUE.

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_true ).

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = ''third quarter'.

LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

else if month is may to sep

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'first quarter' ).

LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).

LR_TABLE_SETTINGS ?= LO_VALUE.

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_true ).

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = ''first quarter'.

LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'second quarter' ).

LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).

LR_TABLE_SETTINGS ?= LO_VALUE.

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_false).

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = ''second quarter'.

LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'third quarter' ).

LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).

LR_TABLE_SETTINGS ?= LO_VALUE.

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_true ).

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = ''third quarter'.

LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

else if month is oct to dec

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'first quarter' ).

LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).

LR_TABLE_SETTINGS ?= LO_VALUE.

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_true ).

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = ''first quarter'.

LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'second quarter' ).

LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).

LR_TABLE_SETTINGS ?= LO_VALUE.

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_true).

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = ''second quarter'.

LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'third quarter' ).

LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).

LR_TABLE_SETTINGS ?= LO_VALUE.

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_false ).

CREATE OBJECT LR_INPUT_FIELD

EXPORTING

VALUE_FIELDNAME = ''third quarter'.

LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

saravanan_narayanan
Active Contributor
0 Kudos

Hello Dhinesh,

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_true ) is used to control the entire table edit mode and its not for individual columns/fileds. since one of the field has to be editable, you have to always set this to ABAP_FALSE

LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_FALSE ).

And regarding the fields - based on the current month you need to convert the field type to INPUT_Field only for that quarter. other fields should be TEXT_VIEW

For example if the current month is March, then only for the First_Quarter column you need to set the cell editor as inputfield for other quaters you dont need to change the cell editor. by default it will be text view.

adapted code for your requirement



LR_TABLE_SETTINGS ?= LO_VALUE.
LR_TABLE_SETTINGS->SET_READ_ONLY( ABAP_FALSE ). 

if month is jan to april
LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'first quarter' ).
LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).
CREATE OBJECT LR_INPUT_FIELD
EXPORTING
VALUE_FIELDNAME = ''first quarter'.
LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).

else if month is may to sep

LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'second quarter' ).
LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).
CREATE OBJECT LR_INPUT_FIELD
EXPORTING
VALUE_FIELDNAME = ''second quarter'.
LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).


else if month is oct to dec



LR_ALV_COLUMN = LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'third quarter' ).
LR_ALV_HEADER = LR_ALV_COLUMN->GET_HEADER( ).
CREATE OBJECT LR_INPUT_FIELD
EXPORTING
VALUE_FIELDNAME = ''third quarter'.
LR_ALV_COLUMN->SET_CELL_EDITOR( LR_INPUT_FIELD ).


 
 

BR, Saravanan

Former Member
0 Kudos

Dear DKM,

since you're only posting part of your code, I'm not sure if the remaining code is correct.

It seems you're getting the reference to your column, but you're using the same ID "FIRST QUARTER" for every column

LO_VALUE->IF_SALV_WD_COLUMN_SETTINGS~GET_COLUMN( 'FIRST QUARTER' ).

Am I correct ? (I'm asking you this because I'm assuming that is the case, according to your description).

If that is the case you need to use the corresponding ID of each UI column, and deal with it inside your method with IF-ENDIF or CASE for example.

Please let me know if this has helped you.

Otherwise please paste the complete code for this same method, for me to provide you better help.

Kind Regards

/Ricardo Quintas