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 grid

Former Member
0 Likes
1,435

Hi,

In ALV grid output screen has two fields are there one is edit mode.if i chage value in edit mode

and i enter enter-buttonit will do sum calculation and the output will be displayed on the next field.

for example:

closing stock quantity diffenence

20 15(10) 5(10)

30 10 20

this is the alv grid output screen.the quantity in edit mode. if i change the quantity 15(10) and i enterenter-button it will show output in difference field 10.

can you help me.

Regards,

K.Karthikeyan.

Moderator message=>

use meaningful subject for your future questions

Edited by: Vijay Babu Dudla on Mar 18, 2009 12:32 AM

1 ACCEPTED SOLUTION
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,395

Hi,

Take a field for difference in internal table and calculate the difference as per the entries.

Now you must have used this internal table to display data in alv grid.

So use this code to reflect the data as per changes in alv:-


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     i_callback_program                = v_rep_id       " report id
     i_callback_pf_status_set          = 'PF'           " for PF-STATUS
     i_callback_user_command           = 'USER_COMMAND' " for User-Command
     is_layout                         = wa_layout      " for layout
     it_fieldcat                       = it_field       " field catalog
     it_sort                           = it_sort        " sort info
    TABLES
      t_outtab                          = it_final      " internal table
   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  pf
*&---------------------------------------------------------------------*
*       SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
*       ON WHICH THE ALV GRID IS DISPLAYED
*----------------------------------------------------------------------*
*       -->RT_EXTAB
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZTG_STAT'.
ENDFORM.                    "pf

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
*       AND EXECUTE THE APPROPIATE CODE
*----------------------------------------------------------------------*
*      -->LV_OKCODE   used to capture the function code
*                     of the user-defined push-buttons
*      -->L_SELFIELD   text
*----------------------------------------------------------------------*
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.

* assign the function code to variable v_okcode
  lv_okcode = sy-ucomm.

* handle the code execution based on the function code encountered
  CASE lv_okcode.

* when the function code is 'SAVE' then reflect the changes as per user
    WHEN 'SAVE'.

* to reflect the data changed into internal table
      DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new

      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.

      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data.
      ENDIF.

"now at this time you have modified internal table
      loop at it_final.
        it_final-diff = it_final-field4 - it_final-field5. "calculate difference
        modify it_final index sy-index.
      endloop.

* refresh the ALV Grid output from internal table
      l_selfield-refresh = c_check.

"alv output is refreshed as per changes in internal table

  ENDCASE.

ENDFORM.                    "USER_COMMAND

In pf-status take the function code for standard SAVE button as SAVE and when user clicks SAVE button then calculate the new difference and modify internal table.

Hope this helps you.

Regards,

Tarun

Hi,

In ALV grid output screen has two fields are there one is edit mode.if i chage value in edit mode

and i enter enter-buttonit will do sum calculation and the output will be displayed on the next field.

for example:

closing stock quantity diffenence

20 15(10) 5(10)

30 10 20

this is the alv grid output screen.the quantity in edit mode. if i change the quantity 15(10) and i enterenter-button it will show output in difference field 10.

can you help me.

Regards,

K.Karthikeyan.

Moderator message=>

use meaningful subject for your future questions

Edited by: Vijay Babu Dudla on Mar 18, 2009 12:32 AM

11 REPLIES 11
Read only

Former Member
0 Likes
1,395

Hi KK,

formula is closing = stock quantity + diffenence

20 = 15 + 5

IF u make 15 -


> 10 then

20 = 10 + 10

therfore, difference is 10.

Reg,

Sachin

Read only

0 Likes
1,395

Hi,

there are three feilds like

closing stock

quantity

difference

but logic is correct.

Regards,

K.Karthikeyan

Edited by: Karthikeyan Krishnan on Mar 16, 2009 3:29 PM

Read only

0 Likes
1,395

hi after enter means after user interface run same fm for alv grid by editing the internal table.

we have fm for getting the changed data from editable alv

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,396

Hi,

Take a field for difference in internal table and calculate the difference as per the entries.

Now you must have used this internal table to display data in alv grid.

So use this code to reflect the data as per changes in alv:-


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     i_callback_program                = v_rep_id       " report id
     i_callback_pf_status_set          = 'PF'           " for PF-STATUS
     i_callback_user_command           = 'USER_COMMAND' " for User-Command
     is_layout                         = wa_layout      " for layout
     it_fieldcat                       = it_field       " field catalog
     it_sort                           = it_sort        " sort info
    TABLES
      t_outtab                          = it_final      " internal table
   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  pf
*&---------------------------------------------------------------------*
*       SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
*       ON WHICH THE ALV GRID IS DISPLAYED
*----------------------------------------------------------------------*
*       -->RT_EXTAB
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZTG_STAT'.
ENDFORM.                    "pf

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
*       AND EXECUTE THE APPROPIATE CODE
*----------------------------------------------------------------------*
*      -->LV_OKCODE   used to capture the function code
*                     of the user-defined push-buttons
*      -->L_SELFIELD   text
*----------------------------------------------------------------------*
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.

* assign the function code to variable v_okcode
  lv_okcode = sy-ucomm.

* handle the code execution based on the function code encountered
  CASE lv_okcode.

* when the function code is 'SAVE' then reflect the changes as per user
    WHEN 'SAVE'.

* to reflect the data changed into internal table
      DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new

      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.

      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data.
      ENDIF.

"now at this time you have modified internal table
      loop at it_final.
        it_final-diff = it_final-field4 - it_final-field5. "calculate difference
        modify it_final index sy-index.
      endloop.

* refresh the ALV Grid output from internal table
      l_selfield-refresh = c_check.

"alv output is refreshed as per changes in internal table

  ENDCASE.

ENDFORM.                    "USER_COMMAND

In pf-status take the function code for standard SAVE button as SAVE and when user clicks SAVE button then calculate the new difference and modify internal table.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
1,395

Hi Tarun,

your answer is exactly correct.but i need one more modification.when user clicks SAVE button then calculate the new difference and modify internal table.but i need that new difference and modify in the alv output screen itself.

as per your logic it modify iternal table only.but i need both internal table and alv output screen.

Regards,

K.Karthikeyan.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,395

Hi,

>

> Hi Tarun,

> your answer is exactly correct.but i need one more modification.when user clicks SAVE button then calculate the new difference and modify internal table.but i need that new difference and modify in the alv output screen itself.

>

> as per your logic it modify iternal table only.but i need both internal table and alv output screen.

>

> Regards,

> K.Karthikeyan.

Use:-


FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
 
* assign the function code to variable v_okcode
  lv_okcode = sy-ucomm.
 
* handle the code execution based on the function code encountered
  CASE lv_okcode.
 
* when the function code is 'SAVE' then reflect the changes as per user
    WHEN 'SAVE'.
 
* to reflect the data changed into internal table
      DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
 
      IF ref_grid IS INITIAL.
        CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
          IMPORTING
            e_grid = ref_grid.
      ENDIF.
 
      IF NOT ref_grid IS INITIAL.
        CALL METHOD ref_grid->check_changed_data.
      ENDIF.
 
"now at this time you have modified internal table
      loop at it_final.
        it_final-diff = it_final-field4 - it_final-field5. "calculate difference
        modify it_final index sy-index.
      endloop.
 
* refresh the ALV Grid output from internal table "<--
      l_selfield-refresh = 'X'.  "<-- to refresh alv from internal table

"if internal table is modified then the alv output is refreshed as per changes in internal table
 
  ENDCASE.
 
ENDFORM.                    "USER_COMMAND

Read only

Former Member
0 Likes
1,395

Hi Tarun,

Problem sloved.thank you so much.

Regards,

K.Karthikeyan.

Read only

Former Member
0 Likes
1,395

Hi,

I want to add purchase order field in standard T.code s_alr_87012105.

Regards,

Karthikeyan.K

Read only

Former Member
0 Likes
1,395

Hello hw r

Can u HElp me in ALV Grid Reports.

i am making a sales exp reports in ALV grid. i am completed but it is cant give actual value of OPEN QTY, DEL QTY, AND ORDER QTY.

also hw to paste my code here to disp all. a am trying it help of code toll but i cant.

Thnks

Please Reply

Bhavesh Panchal.

Read only

Former Member
0 Likes
1,395

Hi,

To Register Edit Events use this code as:

data w_grid TYPE REF TO cl_gui_alv_grid,

CALL METHOD w_grid->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_enter

Thanks & Regards,

Anagha Deshmukh

Read only

Former Member
0 Likes
1,395

Hello hw r

Can u HElp me in ALV Grid Reports.

i am making a sales exp reports in ALV grid. i am completed but it is cant give actual value of OPEN QTY, DEL QTY, AND ORDER QTY.

also hw to paste my code here to disp all. a am trying it help of code toll but i cant.

Thnks

Please Reply

Bhavesh Panchal.