cancel
Showing results for 
Search instead for 
Did you mean: 

Cell Editors for Input Field and LinkToAction in Table

former_member219737
Participant
0 Kudos

Hi Experts,

I have a requirement like ...I want to display the fields of a table in LinkToAction and On particular action I want the field

to be as Input Field as mentioned below ...

.

Process :

1. When I click on Insert Row button , I want the field of a table as "Input Field" and in other case it should be in LinkToAction field ....

Request to guide me for the same ...

Regards,

Karthik S

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Karthik,

Please refer to the below document

Table with cell variant | Team ABAP

Your requirement can be achieved as below

  • Create an attribute VARIANT in the context node which is bound to TABLE
  • As suggested in the column, create cell variant with link to action and input field for all columns
  • For all variants, give the same variantKey VAR_KEY
  • Now while populating data to time sheet, by default fill VARIANT = 'VAR_KEY'
  • On initial line, you just pass VARIANT = space

    

          clear ls_timesheet.

         

          append ls_timesheet to lt_timesheet.

Now, new line should have input fields as cell editors in your table.

Hope this helps you.

Regards,

Rama

former_member219737
Participant
0 Kudos

Hi Rama,

Thanks for your reply...

I am not able to add an attribute to the Context Node as its Binded to the Structure....in turn they use some Supply Function.

Can u suggest me how to overcome this ...

Regards,

Karthik S

ramakrishnappa
Active Contributor
0 Kudos

Hi Karthik,

To add new attribute to context node, you need to add a field VARIANT in structure and then update your context node and add attribute from structure fields.

Hope this helps.

Regards,

Rama

former_member219737
Participant
0 Kudos

Hi rama,

Thanks a lot for yr' reply ...

I have added the field VARIANT in the strcture....just have a doubt that...same structure used in other

applications....will there be any type compatible issue in it ??

I have tried ...I need to perform it in on Click of "INSERT ROW" button....so i can write the rest of code in the method of INSERT_ROW ...right ??

Can u suggest idea for the same ...

Regards,

KArthik S

ramakrishnappa
Active Contributor
0 Kudos

Hi Karthik,

as long as fields of structure are not altered it wont be any issue.  Adding new field would not be any issue.

In supply function you pass variant key to get link to action as cell editor.

On insert button, if variant key is empty it will pick input field as cell editor.

Regards,

Rama

former_member219737
Participant
0 Kudos

Hi Rama,

Thanks for yr' reply ....

Is the above mentioned steps of mine is ok to proceed ??

Can i know the snippet of code to be given in Insert button to achieve it....

I am not using any Supply Function ....

Regards,

Karthik s

former_member219737
Participant
0 Kudos

Hi Rama,

I have kept the VariantKey as "VAR_KEY" for both the Cell Variants of Input field and LinkToAction ...

Is the above mentioned screen is ok to proceed ...

Regards,

Karthik S

ramakrishnappa
Active Contributor
0 Kudos

Hi Karthik,

The variant key cannot be same for both input field and link to action. It should be different.

So, you no need to have two variants, you can just have one variant either for link to action or input field.

By default, an element without any variant would be set as cell editor in table. if you pass VARIANT key exclusively, then system sets the element inside variant as cell editor.

In your case, create a variant for LINK TO ACTION and pass while populating value into context node. For initial line, no need to pass any variant key as system by default picks the INPUT field as cell editor.

Hope this helps you.

Regards,

Rama

Former Member
0 Kudos

Rama, where did you learn your Patience

It's great that you're trying to help so much, but often i miss self-initiative of People. Hopefully you will earn some Points in this thread

former_member219737
Participant
0 Kudos

Hi Rama,

Thanks a lot for your Valuable replies ...

I have tried the same and I have applied the Variant key for LinkToAction and No Variant key for Input Field.

On Click of Insert Row Button, I have passed the below code ...


   ls_timesheet-variant = space .

* append a line to the node
  lo_el_timesheet = lo_nd_timesheet->bind_structure( new_item = ls_timesheet set_initial_elements = abap_false ).

Still, I could able to see the layout as disable one for the field of a table ...

I have applied the logic only on DAY3...Mon Column....

Can u sugeest an idea for it .

Regards,

Karthik S

ramakrishnappa
Active Contributor
0 Kudos

Hi Karthik,

You need to check if read only property  of input field is bound properly.

Regards,

Rama

former_member219737
Participant
0 Kudos

Hi Rama,

Thanks for your reply ...

I have given the value of Enabled as Check one ...

When I Click on "Insert Row" Button, .....field of a table is editable one....But , the value which is

available for LinkToAction Field is not populating into the screen .

I have attached the screen for reference ...

On Click of Insert Row : which Its fine now

Can u guide for the same ...

Regards,

Karthik S

ramakrishnappa
Active Contributor
0 Kudos

Hi Karthik,

You have placed input field inside variant VARIANT_INPUT, actually, input field should not be kept inside the variant, remove variant_input and place the input field directly.

After removing, variant_input try again.

Regards,

Rama

former_member219737
Participant
0 Kudos

Hi Rama,

Thanks a lot for yr' valuable reply ...

I made the cell Variant only for Input field....not for LinkToAction ...

If I am changing the value in the LinkToAction field via Pop-up Window...like below

Step 1 : If i am changing the value ...from 3.00 to 4.00 of Row (5) Column (Tue) ...its getting changed

in the above row too of respective Column....

Before


After

Can u suggest an idea ....for not reflecting in other cells of the respective column ...

ramakrishnappa
Active Contributor
0 Kudos

Hi Karthik,

I suspect, some where the value is getting set for other cell while updating changed value to the cell from popup window.

I suggest you to debug and check if your update logic is changing other cell's value as well.

If you are not able to find, could you share the code, where you update the changed value back to context node.

Regards,

Rama

former_member219737
Participant
0 Kudos

Hi Rama,

Thanks for your reply ...

I have given the below list of code in "Sumbit of Pop-up screen" ...

      lo_nd_timesheet->get_static_attributes_table( importing table = lt_timesheet ).
clear ls_timesheet .
loop at lt_timesheet into ls_timesheet.
  if sy-tabix ge 2 . "lv_chang_index . "concatenate 'day' lo_componentcontroller->change_column

*      ls_timesheet-day3 = lv_changed_value .
*      modify lt_timesheet from ls_timesheet transporting day3.
*      clear ls_timesheet.
     if lv_chang_column = 1.

      ls_timesheet-day1 = lv_changed_value .
      modify lt_timesheet from ls_timesheet transporting day1 . "lv_chang_column.
      clear ls_timesheet.

     elseif  lv_chang_column = 2.

      ls_timesheet-day2 = lv_changed_value .
      modify lt_timesheet from ls_timesheet transporting day2 . "lv_chang_column.
      clear ls_timesheet.

     elseif  lv_chang_column = 3.

      ls_timesheet-day3 = lv_changed_value .
      modify lt_timesheet from ls_timesheet transporting day3 . "lv_chang_column.
      clear ls_timesheet.

      elseif  lv_chang_column = 4.

      ls_timesheet-day4 = lv_changed_value .
      modify lt_timesheet from ls_timesheet transporting day4 . "lv_chang_column.
      clear ls_timesheet.

      elseif  lv_chang_column = 5.

      ls_timesheet-day5 = lv_changed_value .
      modify lt_timesheet from ls_timesheet transporting day5 . "lv_chang_column.
      clear ls_timesheet.

      elseif  lv_chang_column = 6.

      ls_timesheet-day6 = lv_changed_value .
      modify lt_timesheet from ls_timesheet transporting day6 . "lv_chang_column.
      clear ls_timesheet.

      elseif  lv_chang_column = 7.

      ls_timesheet-day7 = lv_changed_value .
      modify lt_timesheet from ls_timesheet transporting day7 . "lv_chang_column.
      clear ls_timesheet.

  endif .

  endif.

endloop.

Can u suggest me an idea on it ...

Regards,

Karthik S

Former Member
0 Kudos

You are changing always all rows (see your screenshot in detail)!! Why are doing the LOOP?

By the way: Please use

a) Switch Statement instead of if OR Even better

b) field symbols

Answers (3)

Answers (3)

ramakrishnappa
Active Contributor
0 Kudos

Hi Karthik,

Your code updates changed value to all cells of respective column. So, if you change a value in any cell, it changes all cells in the same column of every row.

You have to update only the row which got changed. not all the rows

Sample code:


        data lv_colname type string.

        

     field-symbols: <fv_value> type any.

          lo_nd_timesheet->get_static_attributes_table( importingtable = lt_timesheet ).

     " Collect changed row index into variable lv_changed_row

     " Collect changed column value into variable lv_changed_column

     " Collect changed value into lv_changed_value.

     read lt_timesheet into ls_timesheet index lv_changed_row

     if sy-subrc is initial.

          lv_colname = lv_changed_row.

          concatenate 'DAY' lv_colname into lv_colname.

          unassign <fv_value>

          assign component lv_colname of structure ls_timesheet into <fv_value>.

          if <fv_value> is assigned.

               <fv_value> = lv_changed_value.

          endif.    

          modify lt_timesheet from ls_timesheet index lv_changed_row.

     endif.

You can also directly read only one line from context node and modify that instead of reading whole table and setting it back

Hope this helps you.       

Regards,

Rama

former_member219737
Participant
0 Kudos

Hi Rama,

Thanks a lot for your Valuable reply ...

I have changed my condition as below ...

Old code :

if sy-tabix ge 2 . "lv_chang_index

New Code:

if sy-tabix  = lv_chang_index . (Row Changed Value )

Its working fine now ...

Regards,

Karthik S

ramakrishnappa
Active Contributor
0 Kudos

Hi Karthik,

Its good to hear.

Please close all your discussions related to this by marking replies as correct / helpful answers whichever helped you.

Regards,

Rama

former_member219737
Participant
0 Kudos

Thanks a lot for your patient replies ...

Regards,

Karthik S

former_member184578
Active Contributor
0 Kudos

Hi,

Use CellVariants to achieve this. Search for Cell Variants in Table.

Regards,

kiran

Former Member
0 Kudos

Check the following link it might help you to develop your logic..

WebDynpro for ABAP Cell Variants - Web Dynpro ABAP - SCN Wiki