Application Development 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: 

ALV GRid

Former Member
0 Kudos

Hello..

i have case in which i have one ALV grid display, then i select a row in it and click on a button.

Now a new ALV Grid appears with the related details with 1 column as editable.

I enter a new value in that editable column...and click on a Save button.

i require that after clicking on the Save button, the previous ALV Grid shuld be dispalyed with the changed value.

How to read the edited value and store it in the internal table.?

Note that im not using OO ALV.....

Kindly help.

its urgent.

thank u in advance.

Regards,

Pranali

5 REPLIES 5

Former Member
0 Kudos

Hi,

If you are using the OOPS approach to create the ALV grids, then you can use the method "check_changed_data" to read the changes made into the underlying internal table of ALV.

Regards,

Himanshu

former_member404244
Active Contributor
0 Kudos

Hi,

check the below links

How do I create and use input-enabled fields in ALV?

http://www.sapfans.com/forums/viewtopic.php?t=84933

http://www.sapfans.com/forums/viewtopic.php?t=69878

rewrad if helpful.

Regards,

Nagaraj

former_member194152
Contributor
0 Kudos

Hi,

You are so lucky i have recently develop this logic for my company requirement hope this will helpful to you.

You have to create 2 PF status and activate SAVE button in first Grid display then next screen will come ALV List on which another PF status will triiger in which CLICK function code assign for further list processing.

here is code

REPORT ZPPR0019 NO STANDARD PAGE HEADING
LINE-SIZE 80.
TABLES : VBRK.

TYPE-POOLS: SLIS.
DATA: GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
      ALV_LAYOUT TYPE SLIS_LAYOUT_ALV,

      AFCAT TYPE SLIS_FIELDCAT_ALV,
      ALV_FCAT  TYPE SLIS_T_FIELDCAT_ALV.
DATA : BEGIN OF GT_VBRK OCCURS 0,
         VBELN LIKE VBRK-VBELN,
         WAERK LIKE VBRK-WAERK,
         NETWR LIKE VBRK-NETWR,
         CHEK1,
        END OF GT_VBRK.

DATA : DFLAG,SFLAG.
DATA WA TYPE ZTEMP.
DATA ITAB1 TYPE TABLE OF ZTEMP .

SELECT-OPTIONS : VBELN FOR VBRK-VBELN.

SELECT * FROM  VBRK  INTO CORRESPONDING FIELDS OF TABLE GT_VBRK WHERE VBELN IN VBELN.

AFCAT-FIELDNAME = 'VBELN'.
AFCAT-SELTEXT_S = 'Bill Number'.
AFCAT-SELTEXT_L = 'Bill Number'.

AFCAT-REF_FIELDNAME = 'VBELN'.
AFCAT-EDIT = 'X'.
APPEND AFCAT TO ALV_FCAT.
CLEAR AFCAT.

AFCAT-FIELDNAME = 'NETWR'.
AFCAT-SELTEXT_S = 'Price'.
AFCAT-SELTEXT_L = 'PRICE'.

AFCAT-REF_FIELDNAME = 'NETWR'.
*afcat-edit = 'X'.
APPEND AFCAT TO ALV_FCAT.
CLEAR AFCAT.

AFCAT-FIELDNAME = 'WAERK'.
AFCAT-SELTEXT_S = 'Curr'.
AFCAT-SELTEXT_L = 'Curr'.

AFCAT-REF_FIELDNAME = 'WAERK'.
*afcat-edit = 'X'.
APPEND AFCAT TO ALV_FCAT.
CLEAR AFCAT.

*gs_layout-edit = 'X'.
ALV_LAYOUT-F2CODE = ' '.
ALV_LAYOUT-ZEBRA             = 'X'.
ALV_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
ALV_LAYOUT-BOX_FIELDNAME = 'CHEK1'.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
     EXPORTING
          I_CALLBACK_PROGRAM      = 'ZT1'
          I_CALLBACK_USER_COMMAND = 'USER_COMMAND'

*          is_layout               = gs_layout
          IT_FIELDCAT              = ALV_FCAT
     TABLES
          T_OUTTAB                = GT_VBRK.

*&---------------------------------------------------------------------*
*&      Form  user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM TYPE SY-UCOMM
                        RS_SELFIELD TYPE SLIS_SELFIELD.
  IF SFLAG = 'X'.
    LEAVE PROGRAM.
  ENDIF.
  IF R_UCOMM = '&DATA_SAVE'  .

    MESSAGE I000(0K) WITH 'Data Saved'.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM       = 'ZT1'
        IT_FIELDCAT              = ALV_FCAT
        I_CALLBACK_PF_STATUS_SET = 'PFSTAT'
        I_CALLBACK_USER_COMMAND  = 'USER_COMMAND1'
        IS_LAYOUT                = ALV_LAYOUT
      TABLES
        T_OUTTAB                 = GT_VBRK.

  ENDIF.
ENDFORM.                    "user_command

*&---------------------------------------------------------------------*
*&      Form  PFSTAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------*
FORM PFSTAT USING RT_EXTAB TYPE SLIS_T_EXTAB.
  SET PF-STATUS 'PFSTAT' EXCLUDING RT_EXTAB.
*set pf-status 'STANDARD_FULLSCREEN' EXCLUDING RT_EXTAB.

ENDFORM.                    "PFSTAT


*&---------------------------------------------------------------------*
*&      Form  user_command1
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM1     text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM USER_COMMAND1 USING R_UCOMM1 TYPE SYUCOMM
RS_SELFIELD TYPE SLIS_SELFIELD  .
  DATA : FLAG,FLAG1.

  READ TABLE GT_VBRK INTO WA WITH KEY CHEK1 = 'X'.
  CLEAR FLAG1.
  IF SY-SUBRC = 0.
*flag1 = 'X'.

*if r_ucomm = '&IC1'.
*clear r_ucomm.
*r_ucomm = 'CLICK'.
*endif.

    CASE R_UCOMM1.
      WHEN 'CLICK'.
        SFLAG = 'X'.
        DFLAG = 'X'.
        SET PF-STATUS 'PFSTAT1'  .

        APPEND LINES OF GT_VBRK TO ITAB1.
        DELETE ITAB1 WHERE CHEK1 <> 'X'.

        LOOP AT GT_VBRK INTO WA WHERE CHEK1 = 'X'.
          WA-CHEK1 = ' '.
          MODIFY GT_VBRK FROM WA.
        ENDLOOP.
    ENDCASE.

  ENDIF.
  PERFORM DISPLAY.

ENDFORM.                    "user_command1

*&---------------------------------------------------------------------*
*&      Form  display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM DISPLAY.
  LOOP AT ITAB1 INTO WA.
    WRITE : / WA-VBELN.
  ENDLOOP.

ENDFORM.                    "display

Reward if helpful.

Regards

Gagan

0 Kudos

Hi Gagan,

Could you elaborate your code in detail please. i didn't get code clearly.

Former Member
0 Kudos

Hello,

When calling the second alv grid ,

in the export parameter 'i_grid_settings'

mark the filed 'edt_cll_cb' = 'X'.

When the value is changed its automatically updated in the internal table.

Drawback : After changing the values it is mandatory to press the enter key else the change is not reflected in the internal table.

on button click call the Alv with the new updated values.

Regards,

Pranali.