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

Save Data in ALV Report .

Former Member
0 Likes
7,691

Hello,

Given below is my code

*&---------------------------------------------------------------------*
*& Report  ZALV_TEST_SA                                                *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  ZALV_TEST_SA NO STANDARD PAGE HEADING.

*----------------------TYPE POOL OF ALV--------------------------------*
*                                                                      *
TYPE-POOLS: SLIS.

*----------------------DATABASE TABLES---------------------------------*
*                                                                      *
TABLES: ZFLIGHTM_SA, ZFLIGHT_AVAIL_SA.

*-------------DATA DECLARATION-----------------------------------------*
*                                                                      *
DATA: BEGIN OF ITAB OCCURS 0,
         ZFLIGHT_ID TYPE ZFLIGHT_ID,
         ZCITY_FROM TYPE ZCITY_FROM,
         ZCITY_TO TYPE ZCITY_TO,
         ZDEP_DATE TYPE DATS,
         ZTIME TYPE TIMS,
         ZPRICE TYPE ZPRICE,
         ZNUM_OF_PSNGRS(3) TYPE N,
         ZAVAIL_SEATS(3) TYPE N,
      END OF ITAB.

DATA: BEGIN OF ITABM OCCURS 0,
         MANDT TYPE MANDT,
         ZFLIGHT_ID TYPE ZFLIGHT_ID,
         ZCITY_FROM TYPE ZCITY_FROM,
         ZCITY_TO TYPE ZCITY_TO,
         ZTIME TYPE TIMS,
         ZPRICE TYPE ZPRICE,
      END OF ITABM.

DATA: BEGIN OF ITAB_AVAIL OCCURS 0,
         MANDT TYPE MANDT,
         ZFLIGHT_ID TYPE ZFLIGHT_ID,
         ZDEP_DATE TYPE DATS,
         ZNUM_OF_PSNGRS(3) TYPE N,
         ZAVAIL_SEATS(3) TYPE N,
      END OF ITAB_AVAIL.

DATA: WA_ITAB LIKE LINE OF ITAB,
      WA_ITABM LIKE LINE OF ITABM,
      WA_ITAB_AVAIL LIKE LINE OF ITAB_AVAIL.

DATA: L_REPID LIKE SY-REPID,
      L_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
      L_LAYOUT TYPE SLIS_LAYOUT_ALV,
      L_EVENTS TYPE SLIS_T_EVENT.

DATA: WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

*----------------SELECTION SCREEN SELECT-OPTIONS-----------------------*
*                                                                      *
SELECT-OPTIONS S_CITY FOR ZFLIGHTM_SA-ZCITY_FROM NO INTERVALS.
SELECT-OPTIONS D_CITY FOR ZFLIGHTM_SA-ZCITY_TO NO INTERVALS.
SELECT-OPTIONS D_DATE FOR ZFLIGHT_AVAIL_SA-ZDEP_DATE NO INTERVALS.

*----------------------SELECTION OF DATA-------------------------------*
*                                                                      *
PERFORM SELECT_DATA.

*----------------SETTING DATA IN TABLE FOR FIELD CATALOG---------------*
*                                                                      *
PERFORM CALL_FIELDCAT_MERGE.

*----------CALLING FUNCTION FOR DISPLAYING REPORT----------------------*
*                                                                      *
PERFORM DISPLAY_TABLE.

*----------------------AT SELECTION SCREEN EVENT-----------------------*
*                                                                      *
AT USER-COMMAND.
  CASE sy-ucomm.
    WHEN 'STORE'.
       PERFORM SAVE_DATA.
    WHEN 'PREVIOUS'.
       LEAVE TO SCREEN 0.
    WHEN OTHERS.
  ENDCASE.

*------------------------------FORMS-----------------------------------*
*                                                                      *
*&---------------------------------------------------------------------*
*&      Form  SELECT_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SELECT_DATA .
  SELECT A~ZFLIGHT_ID    ZCITY_FROM
         ZCITY_TO        ZDEP_DATE
         ZTIME           ZPRICE
         ZNUM_OF_PSNGRS  ZAVAIL_SEATS
     FROM ZFLIGHTM_SA AS A INNER JOIN ZFLIGHT_AVAIL_SA AS B
        ON A~ZFLIGHT_ID = B~ZFLIGHT_ID
         INTO CORRESPONDING FIELDS OF TABLE ITAB
            WHERE A~ZCITY_FROM IN S_CITY
              AND A~ZCITY_TO IN D_CITY
              AND B~ZDEP_DATE IN D_DATE.

  L_REPID = SY-REPID.

ENDFORM.                    " SELECT_DATA

*&---------------------------------------------------------------------*
*&      Form  CALL_FIELDCAT_MERGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM CALL_FIELDCAT_MERGE .
*  CLEAR WA_FIELDCAT.
*  WA_FIELDCAT-TABNAME       = ITAB.
*  WA_FIELDCAT-FIELDNAME     = 'ZFLIGHT_ID'.
*  WA_FIELDCAT-KEY           = 'X'.     "sets key field
*  APPEND WA_FIELDCAT TO  L_FIELDCAT.
*
*
*  WA_FIELDCAT-TABNAME       = ITAB.
*  WA_FIELDCAT-FIELDNAME     = 'ZPRICE'.
* WA_FIELDCAT-KEY           = 'X'.     "sets key field
*  APPEND WA_FIELDCAT TO  L_FIELDCAT.
*
*  WA_FIELDCAT-TABNAME       = ITAB.
*  WA_FIELDCAT-FIELDNAME     = 'ZAVAIL_SEATS'.
*  WA_FIELDCAT-KEY           = 'X'.     "sets key field
*  APPEND WA_FIELDCAT TO  L_FIELDCAT.


*--------------CALLING FUNCTION FOR FIELD CATALOG----------------------*
*                                                                      *
  CLEAR L_FIELDCAT.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
  EXPORTING
     I_PROGRAM_NAME               = L_REPID
     I_INTERNAL_TABNAME           = 'ITAB'
*       I_STRUCTURE_NAME             = 'WA_ITAB'
*       I_CLIENT_NEVER_DISPLAY       = 'X'
     I_INCLNAME                   = 'ZALV_TEST_SA'
     I_BYPASSING_BUFFER           = 'X'
*       I_BUFFER_ACTIVE              =
    CHANGING
      CT_FIELDCAT                  = L_FIELDCAT
*     EXCEPTIONS
*       INCONSISTENT_INTERFACE       = 1
*       PROGRAM_ERROR                = 2
*       OTHERS                       = 3
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

*--------------EDITING FIELDS IN FIELD CATALOG ------------------------*
*                                                                      *
  LOOP AT L_FIELDCAT INTO WA_FIELDCAT.

    CASE WA_FIELDCAT-FIELDNAME.
         WHEN 'ZFLIGHT_ID'.
           WA_FIELDCAT-COL_POS = '1'.
*          WA_FIELDCAT-text_fieldname = 'Flight ID'.
           WA_FIELDCAT-KEY = '3'.
           WA_FIELDCAT-JUST = 'L'.
           WA_FIELDCAT-NO_ZERO = 'X'.
           WA_FIELDCAT-EMPHASIZE = 'X'.
           WA_FIELDCAT-SELTEXT_L = 'Flight ID'. "40 char long field name
           WA_FIELDCAT-SELTEXT_M = 'Flight ID'. "20 char long field name
           WA_FIELDCAT-SELTEXT_S = 'Flight ID'. "10 char long field name
         WHEN 'ZCITY_FROM' .
           WA_FIELDCAT-NO_OUT = 'X'.
         WHEN 'ZCITY_TO' .
           WA_FIELDCAT-NO_OUT = 'X'.
         WHEN 'ZDEP_DATE' .
           WA_FIELDCAT-NO_OUT = 'X'.
         WHEN 'ZTIME' .
           WA_FIELDCAT-NO_OUT = 'X'.
         WHEN 'ZPRICE' .
           WA_FIELDCAT-COL_POS = '2'.
*          WA_FIELDCAT-text_fieldname = 'Flight ID'.
           WA_FIELDCAT-KEY = '4'.
           WA_FIELDCAT-JUST = 'L'.
           WA_FIELDCAT-NO_ZERO = 'X'.
*          WA_FIELDCAT-EMPHASIze = 'X'.
           WA_FIELDCAT-SELTEXT_L = 'Price'. "40 char long field name
           WA_FIELDCAT-SELTEXT_M = 'Price'. "20 char long field name
           WA_FIELDCAT-SELTEXT_S = 'Price'. "10 char long field name
           WA_FIELDCAT-EDIT = 'X'.
         WHEN 'ZNUM_OF_PSNGRS' .
           WA_FIELDCAT-NO_OUT = 'X'.
         WHEN 'ZAVAIL_SEATS' .
           WA_FIELDCAT-COL_POS = '3'.
*          WA_FIELDCAT-text_fieldname = 'Flight ID'.
           WA_FIELDCAT-KEY = '4'.
           WA_FIELDCAT-JUST = 'L'.
           WA_FIELDCAT-NO_ZERO = 'X'.
*          WA_FIELDCAT-EMPHASIze = 'X'.
           WA_FIELDCAT-SELTEXT_L = 'Available Seats'.
           "40 char long field
           WA_FIELDCAT-SELTEXT_M = 'Available Seats'.
           "20 char long field
           WA_FIELDCAT-SELTEXT_S = 'Seats'. "10 char long field name
           WA_FIELDCAT-EDIT = 'X'.
         WHEN OTHERS.
           WA_FIELDCAT-NO_OUT = 'X'.
    ENDCASE.
MODIFY L_FIELDCAT FROM WA_FIELDCAT.

  ENDLOOP.
ENDFORM.                    " CALL_FIELDCAT_MERGE

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND_ALV_SA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM USER_COMMAND_ALV_SA USING I_UCOMM LIKE SY-UCOMM
                        IS_SELFIELD TYPE SLIS_SELFIELD.

*****form frm_usercommand using r_ucomm like sy-ucomm
*****rs_selfield type slis_selfield.

****CASE I_UCOMM.
CASE sy-ucomm.
    WHEN 'STORE'.
       PERFORM SAVE_DATA ON COMMIT.
    WHEN 'PREVIOUS'.
       LEAVE TO SCREEN 0.
    WHEN OTHERS.
ENDCASE.
ENDFORM.                    "USER_COMMAND_ALV_SA

*&---------------------------------------------------------------------*
*&      Form  DISPLAY_TABLE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM DISPLAY_TABLE .
*  L_FIELDCAT-input = 'X'.
*  L_FIELDCAT-edit = 'X'.
*  L_LAYOUT-Edit = 'X'.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '

I_CALLBACK_PROGRAM                = L_REPID " report id
I_CALLBACK_PF_STATUS_SET          = 'ZALV_TEST_SA' " to set pf-status
I_CALLBACK_USER_COMMAND           = 'USER_COMMAND_ALV_SA' " to handle
                                                          " user command

*   I_CALLBACK_TOP_OF_PAGE            = ' '
*   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*   I_CALLBACK_HTML_END_OF_LIST       = ' '
*   I_STRUCTURE_NAME                  = ''
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
*   IS_LAYOUT                         = L_LAYOUT

IT_FIELDCAT                       = L_FIELDCAT " for field catalog

*   IT_EXCLUDING                      =
*   IT_SPECIAL_GROUPS                 =
*   IT_SORT                           =
*   IT_FILTER                         =
*   IS_SEL_HIDE                       =
*   I_DEFAULT                         = 'X'
*   I_SAVE                            = ' '
*   IS_VARIANT                        =

 IT_EVENTS                         = L_EVENTS "internal table with
                                                           " user events

*   IT_EVENT_EXIT                     =
*   IS_PRINT                          =
*   IS_REPREP_ID                      =
*   I_SCREEN_START_COLUMN             = 0
*   I_SCREEN_START_LINE               = 0
*   I_SCREEN_END_COLUMN               = 0
*   I_SCREEN_END_LINE                 = 0
*   IT_ALV_GRAPHICS                   =
*   IT_HYPERLINK                      =
*   IT_ADD_FIELDCAT                   =
*   IT_EXCEPT_QINFO                   =
*   I_HTML_HEIGHT_TOP                 =
*   I_HTML_HEIGHT_END                 =
*  IMPORTING
*   E_EXIT_CAUSED_BY_CALLER           =
*   ES_EXIT_CAUSED_BY_USER            =
   TABLES
    T_OUTTAB                          = ITAB "internal table with
                                                               " records
   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_TABLE

*-------------------------SET PF-STATUS--------------------------------*
*                                                                      *
*&---------------------------------------------------------------------*
*&      Form  ZALV_TEST_SA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM  ZALV_TEST_SA USING RT_EXTAB TYPE SLIS_T_EXTAB.
  SET PF-STATUS 'ZALV_TEST_SA' .
ENDFORM.                    "ZALV_TEST_SA

*&---------------------------------------------------------------------*
*&      Form  SAVE_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM SAVE_DATA.
  LOOP AT ITAB INTO WA_ITAB.

****HIDE:WA_ITAB-ZFLIGHT_ID,      WA_ITAB-ZCITY_FROM,
****WA_ITAB-ZCITY_TO,        WA_ITAB-ZTIME,
****WA_ITAB-ZDEP_DATE,       WA_ITAB-ZNUM_OF_PSNGRS,
****WA_ITAB-ZAVAIL_SEATS.

    CLEAR: WA_ITABM,WA_ITAB_AVAIL.

    WA_ITABM-ZFLIGHT_ID          = WA_ITAB-ZFLIGHT_ID.
    WA_ITABM-ZCITY_FROM          = WA_ITAB-ZCITY_FROM.
    WA_ITABM-ZCITY_TO            = WA_ITAB-ZCITY_TO.
    WA_ITABM-ZTIME               = WA_ITAB-ZTIME.
    WA_ITABM-ZPRICE              = WA_ITAB-ZPRICE.
    WA_ITAB_AVAIL-ZDEP_DATE      = WA_ITAB-ZDEP_DATE.
    WA_ITAB_AVAIL-ZNUM_OF_PSNGRS = WA_ITAB-ZNUM_OF_PSNGRS.
    WA_ITAB_AVAIL-ZAVAIL_SEATS   = WA_ITAB-ZAVAIL_SEATS.

    APPEND WA_ITABM TO ITABM.
    APPEND WA_ITAB_AVAIL TO ITAB_AVAIL.
  ENDLOOP.

  MODIFY ZFLIGHTM_SA FROM TABLE ITABM.
  MODIFY ZFLIGHT_AVAIL_SA FROM TABLE ITAB_AVAIL.

  COMMIT WORK.

ENDFORM.                    " SAVE_DATA

I want to edit a field--the price and save the changes. I have assigned a button STORE for this. But my data is not getting saved.

I searched the forum and wrote the code accordingly. I even referred the stored programs. Still I am not getting the output. Please help.

Regards,

Smruthi.

Edited by: Smruthi Acharya on Feb 10, 2009 3:31 PM

Edited by: Julius Bussche on Feb 10, 2009 12:16 PM

Please use code tags

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
5,157

Firstly, enclose your code in tags to make it more readable.

Secondly, during your search, did you chance upon the term &DATA_SAVE ?

pk

34 REPLIES 34
Read only

tarangini_katta
Active Contributor
0 Likes
5,157

Hi smruthi,

In SAP technical we have scenarion ALV with EDIT and SAVE functionality (More details) .

Please check that once.You can see that and write u r code according to that it exactly suits u r req.

I am sure that solves u r problem.

Thanks,

Read only

0 Likes
5,157

Hi Tarangini,

I am new to ABAP.

Where do I look for SAP technical we have scenarion ALV with EDIT and SAVE functionality?

Read only

0 Likes
5,157

Hi Tarangini,

I am new to ABAP.

Where do I look for SAP technical we have scenarion ALV with EDIT and SAVE functionality?

Regards,

Smruthi.

Read only

Former Member
0 Likes
5,158

Firstly, enclose your code in tags to make it more readable.

Secondly, during your search, did you chance upon the term &DATA_SAVE ?

pk

Read only

0 Likes
5,157

Hi pk,

I am new to ABAP.

Please tell me how and where should I enclose my code in tags to make it more readable.

Also I have not come across &DATA_SAVE in this program. The first case for sy-ucomm is STORE itself.

Regards,

Smruthi.

Edited by: Smruthi Acharya on Feb 10, 2009 3:49 PM

Read only

0 Likes
5,157

{cod.e} paste your code here{co.de}

remove the dots.

do a search on the search term i mentioned. it will solve your problem, as it did for me just 2 days ago.

pk

Read only

0 Likes
5,157

This message was moderated.

Read only

0 Likes
5,157

This message was moderated.

Read only

0 Likes
5,157

Hi pk,

Formatting the code does not seem to work.

&DATA_SAVE worked for me too for another program. But in this case it is not that. As I have mention in the menu painter , the button as STORE.

regards,

smruthi

Read only

0 Likes
5,157

Hi Smruthi ,

Please keep a breakpoint in the subroutine Save_Data and check the values passed to it and please check the value of sy-subrc and sy-dbcnt after the modify command .

I am unable to execute your program and see as i dont have the tables used by your program in my system.

Regards

Arun

Read only

0 Likes
5,157

Hi,

In SAVE_DATA,

Try to modify your ztable using workarea.

Hope that works.

thanks.

Read only

0 Likes
5,157

Hi Rajkumar,

modify ztable from wa does not work.

i tried it.

Regards,

Smruthi.

Read only

0 Likes
5,157

Hi,

Did you try it inside the loop.

Thanks.

Read only

0 Likes
5,157

Hi Arun,

I kept a breakpoint at the subroutine SAVE DATA and noticed that throught the subroutine the

values were as follows:

SY-SUBRC 0 SY-DBCNT 1

Regards,

Smruthi

Read only

0 Likes
5,157

Please donu2019t try and R&D here unless you feel comfortable yourself with the uses of Code tags.Because it leads duplicate post in same thread hence unnecessary the length of thread increases.

For your reference =>

Also, Please feel free for R&D and testing the Code tags in forum .

Thanks for understanding.

Cheers,

Amit.

Read only

0 Likes
5,157

Hi Smruthi ,

SY-DBCNT indicates the number if records that have been modified , so your code seem to be working correctly , now still if you find that the table is not getting updated , please check the content of the internal table used to updated the database table , is the value you changed in the alv actaiully being used to modify the table,

Regards

Arun

Read only

0 Likes
5,157

Hey Amit,

Thanks a ton for helping me to understand and try out how to post a code!

And sorry for the length of this thread. I thought we could delete posts on the thread

Regards,

Smruthi.

Edited by: Smruthi Acharya on Feb 10, 2009 4:46 PM

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
5,157

Hi,

Refer these links:-

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/learn%252bto%252bdisplay%252bdata%252bin...

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/alv%252bgrid%252bdisplay%252bwith%252bch...

To reflect changed data in internal table from the alv grid, use code:-


*&---------------------------------------------------------------------*
*&      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 EXECUTE then process the selected records
    WHEN 'EXECUTE'.

* 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.

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

ENDFORM.                    "USER_COMMAND

Hope this helps you.

Thanks & Regards,

Tarun Gambhir

Read only

0 Likes
5,157

Hi Arun,

SY-DBCNT = 1 irrespective of any record modification in my case.

I checked the content of the internal table. The modified value does not get updated into it.

Regards,

Smruthi.

Read only

Former Member
0 Likes
5,157

hi,

use this FM

DATA ref1 TYPE REF TO cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref1.

CALL METHOD ref1->check_changed_data.

...

Then the changes made are updated into internal table.. the above function module has to be used

once after clicking the button..

hope this helps..

if u need more info.. search in SCN for check box interactive alv..

Rgds.,

subash

Read only

0 Likes
5,157

Hi subash. i tried using the function module. It is giving me a dump. It mentions something about object ref... I used the FM exactly as you have given under the form DISPLAY TABLE. Is that proper? I am new to ABAP.

Regards,

Smruthi

Read only

Former Member
0 Likes
5,157

Hi,

Please refer to SAP standard demo program BCALV_TEST_FULLSCREEN_EDIT and select Editable option in the selection screen.

Thanks,

Sriram Ponna.

Read only

0 Likes
5,157

Hi Sriram,

The program BCALV_TEST_FULLSCREEN_EDIT does not exist.

Moreover, I have clearly mentioned that I checked most of the standard programs, still could not get the output.

Regards,

Smruthi.

Read only

0 Likes
5,157

Hi Smruthi,

----


  • FORM user_command *

----


  • ........ *

----


  • --> RF_UCOMM *

  • --> RS *

----


FORM user_command USING rf_ucomm LIKE sy-ucomm

rs TYPE slis_selfield.

DATA ref1 TYPE REF TO cl_gui_alv_grid.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

e_grid = ref1.

CALL METHOD ref1->check_changed_data.

CASE rf_ucomm.

when 'SAVE'.

clear : rf_ucomm, sy-ucomm.

perform : your calculations

rs-refresh = 'X'.

Hope this will work.

Regards,

Phani.

Read only

tarangini_katta
Active Contributor
0 Likes
5,157

This message was moderated.

Read only

Former Member
0 Likes
5,157
Read only

0 Likes
5,157

Hi Arun,

Can you please explain how is http://help.sap.com/saphelp_nw04/helpdata/en/e3/e3eb40c4f8712ae10000000a155106/frameset.htm

helpful?

I dont think it is of any help to my question.

Regards,

Smruthi

Read only

0 Likes
5,157

Hi Smruthi ,

Please try executing this code in your system and see if in user command the data in the internal table is changed .

No need to add a menu , after modifying the quantity field in the alv , press the save button , the program will enter the user command and there check if the value in the internal table has changed or not .

type-pools : slis.
types : begin of g_ty_matnr ,
         matnr type matnr ,
         werks type werks_d,
         lgort type lgort_d ,
         labst type labst ,
       end of g_ty_matnr.

data : g_t_matnr type table of g_ty_matnr ,
      g_t_catalog type SLIS_T_FIELDCAT_ALV,
      g_r_catalog type slis_fieldcat_alv,
      g_t_events  type SLIS_T_EVENT,
      g_r_events type slis_alv_event,
      g_f_prog type sy-repid .

start-of-SELECTION.

select matnr werks lgort labst
  into table g_t_matnr
  up to 10 rows
  from mard.

  clear g_r_catalog.
   g_r_catalog-fieldname = 'MATNR'.
  append g_r_catalog to g_t_catalog.

    clear g_r_catalog.
   g_r_catalog-fieldname = 'WERKS'.
  append g_r_catalog to g_t_catalog.

    clear g_r_catalog.
   g_r_catalog-fieldname = 'LGORT'.
  append g_r_catalog to g_t_catalog.

    clear g_r_catalog.
   g_r_catalog-fieldname = 'LABST'.
   g_r_catalog-edit = 'X'.
  append g_r_catalog to g_t_catalog.

g_f_prog = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
  EXPORTING
     I_CALLBACK_PROGRAM                = g_f_prog
     I_CALLBACK_USER_COMMAND           = 'TEST'
     IT_FIELDCAT                       = g_t_catalog
    TABLES
      t_outtab                          = g_t_matnr
*   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   TEST using u_ucomm like sy-ucomm
                                 u_selfield type slis_selfield..
  BREAK-POINT.
  ENDFORM.

A better option to create an ALV from next time onwards would be to use ABAP objects , ie.e use the classes like CL_GUI_ALV_GRID or cl_salv_table.

Regards

Arun

Read only

Former Member
0 Likes
5,157

This message was moderated.

Read only

0 Likes
5,157

Thanks Ravi,

But this was already mentioned in the replies above.

Read only

Former Member
0 Likes
5,157

Hi all,

I checked again and found out that the modified data is not getting stored in the internal table, when I click on STORE button. But if I press ENTER after modifying the data and then click on STORE it works.

I am not able to understand why it is so. Please can anyone help. Also please suggest me a solution to save the data just on clicking STORE button.(without pressing ENTER)

Thanks and Regards,

Smruthi.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
5,157

Hi,

You must have taken some function code for that STORE button (say you have taken it as MODIFY )

Use this code, it will modify the code in internal table from alv.

I have tried it, n its working:-


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*     I_INTERFACE_CHECK                 = ' '
*     I_BYPASSING_BUFFER                = ' '
*     I_BUFFER_ACTIVE                   = ' '
     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
*     I_CALLBACK_TOP_OF_PAGE            = ' '
*     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*     I_CALLBACK_HTML_END_OF_LIST       = ' '
*     I_STRUCTURE_NAME                  =
*     I_BACKGROUND_ID                   = ' '
*     I_GRID_TITLE                      =
*     I_GRID_SETTINGS                   =
     is_layout                         = wa_layout      " for layout
     it_fieldcat                       = it_field       " field catalog
*     IT_EXCLUDING                      =
*     IT_SPECIAL_GROUPS                 =
     it_sort                           = it_sort        " sort info
*     IT_FILTER                         =
*     IS_SEL_HIDE                       =
*     I_DEFAULT                         = 'X'
*     i_save                            = 'A'
*     is_variant                        = wa_variant     " variant name
*     IT_EVENTS                         =
*     IT_EVENT_EXIT                     =
*     IS_PRINT                          =
*     IS_REPREP_ID                      =
*     I_SCREEN_START_COLUMN             = 0
*     I_SCREEN_START_LINE               = 0
*     I_SCREEN_END_COLUMN               = 0
*     I_SCREEN_END_LINE                 = 0
*     I_HTML_HEIGHT_TOP                 = 0
*     I_HTML_HEIGHT_END                 = 0
*     IT_ALV_GRAPHICS                   =
*     IT_HYPERLINK                      =
*     IT_ADD_FIELDCAT                   =
*     IT_EXCEPT_QINFO                   =
*     IR_SALV_FULLSCREEN_ADAPTER        =
*   IMPORTING
*     E_EXIT_CAUSED_BY_CALLER           =
*     ES_EXIT_CAUSED_BY_USER            =
    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  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 MODIFY (STORE button) then save data
    WHEN 'MODIFY'.
 
* 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.

" at this point your data in internal table is changed

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

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
5,157

Thanks to all,

My problem has been solved.

Regards,

Smruthi.

Read only

Former Member
0 Likes
5,157

Thanks to all

Edited by: Smruthi Acharya on Feb 11, 2009 7:59 PM