Skip to Content
author's profile photo
Former Member

ABAP - Editable report using Excel view

hi friends

In my report i am using REUSE_ALV_GRID_DISPLAY

Function module to display the data in alv format. I am using the view in

Excel format.

My requirement is,

If i change the data in the

excel sheet that should reflect in the internal table.

I am able to do changes, but the data is not getting change in the internal

table.

The purpose of this is, the output of this report will be the

input of another program after changing the output in excel(only, bcoz in

excel they will change using some formulas).

Note:

I am

getting the changes to internal table if i use grid display not in excel

format.

Can anyone suggest me how to solve this problem?

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Best Answer
    author's profile photo
    Former Member
    Posted on Aug 23, 2007 at 05:51 AM

    Hi u can esily do this using Object oriented ALVs. Heres the code :

    &----


    *&

    *& ALV using objects : ADD, MODIFY RECORDS

    &----


    ----


    • Data Declaration

    ----


    DATA : ITAB1 TYPE TABLE OF SFLIGHT,

    G_CUST1 TYPE REF TO CL_GUI_CUSTOM_CONTAINER,

    G_GRID1 TYPE REF TO CL_GUI_ALV_GRID,

    LT_FCAT1 TYPE LVC_T_FCAT,

    LS_FCAT TYPE LVC_S_FCAT.

    ----


    • Start of selection

    ----


    START-OF-SELECTION.

    PERFORM POPULATE_TABLE.

    END-OF-SELECTION.

    CALL SCREEN 100.

    &----


    *& Module STATUS_0100 OUTPUT

    &----


    • PBO module

    ----


    MODULE STATUS_0100 OUTPUT.

    SET PF-STATUS 'ZSAB1'.

    • SET TITLEBAR 'xxx'.

    IF G_CUST1 IS INITIAL.

    CREATE OBJECT G_CUST1

    EXPORTING

    CONTAINER_NAME = 'CC1'.

    CREATE OBJECT G_GRID1

    EXPORTING

    I_PARENT = G_CUST1.

    ENDIF.

    PERFORM FCAT_SFLIGHT.

    • to display the ALV Grid

    CALL METHOD G_GRID1->SET_TABLE_FOR_FIRST_DISPLAY

    CHANGING

    IT_OUTTAB = ITAB1

    IT_FIELDCATALOG = LT_FCAT1.

    • transfering the grid from display mode to editable mode

    CALL METHOD G_GRID1->SET_READY_FOR_INPUT

    EXPORTING

    I_READY_FOR_INPUT = 1.

    ENDMODULE. " STATUS_0100 OUTPUT

    &----


    *& Form fcat_sflight

    &----


    • Filling Field Catalog

    ----


    FORM FCAT_SFLIGHT.

    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

    EXPORTING

    I_STRUCTURE_NAME = 'SFLIGHT'

    I_CLIENT_NEVER_DISPLAY = 'X'

    I_BYPASSING_BUFFER = 'X'

    CHANGING

    CT_FIELDCAT = LT_FCAT1.

    LOOP AT LT_FCAT1 INTO LS_FCAT.

    IF LS_FCAT-FIELDNAME EQ 'PRICE'

    OR LS_FCAT-FIELDNAME EQ 'PLANETYPE'

    OR LS_FCAT-FIELDNAME EQ 'FLDATE'.

    LS_FCAT-EDIT = 'X'.

    LS_FCAT-CHECKTABLE = '!'. "do not check foreign key relations

    MODIFY LT_FCAT1 FROM LS_FCAT.

    ENDIF.

    ENDLOOP.

    ENDFORM. " fcat_sflight

    &----


    *& Module USER_COMMAND_0100 INPUT

    &----


    • PAI module

    ----


    MODULE USER_COMMAND_0100 INPUT.

    CASE SY-UCOMM.

    WHEN 'SAVE'.

    PERFORM SAVE_DATA.

    WHEN 'LEAV' OR 'CANC' OR 'BACK'.

    LEAVE PROGRAM.

    ENDCASE.

    ENDMODULE. "USER_COMMAND_0100 INPUT

    &----


    *& Form save_data

    &----


    • checking the changed or added data is consistent

    ----


    FORM SAVE_DATA.

    DATA: L_VALID TYPE C.

    CALL METHOD G_GRID1->CHECK_CHANGED_DATA

    IMPORTING

    E_VALID = L_VALID.

    IF L_VALID IS NOT INITIAL.

    PERFORM UPDATE_DATABASE.

    MESSAGE S000(0K) WITH TEXT-S01.

    ENDIF.

    ENDFORM. "save_data

    &----


    *& Form update_database

    &----


    • Update records to DB table

    ----


    FORM UPDATE_DATABASE.

    DATA: LS_SFLIGHT TYPE SFLIGHT,

    LS_OUTTAB LIKE LINE OF ITAB1,

    LT_INSTAB TYPE TABLE OF SFLIGHT.

    LOOP AT ITAB1 INTO LS_OUTTAB.

    MOVE-CORRESPONDING LS_OUTTAB TO LS_SFLIGHT.

    APPEND LS_SFLIGHT TO LT_INSTAB.

    ENDLOOP.

    MODIFY SFLIGHT FROM TABLE LT_INSTAB.

    ENDFORM. "update_database

    &----


    *& Form POPULATE_TABLE

    &----


    • POPULATE TABLE I_KNA1

    ----


    FORM POPULATE_TABLE .

    SELECT * FROM SFLIGHT INTO TABLE ITAB1.

    ENDFORM. " POPULATE_TABLE

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      HI MRUNAL..

      thanks for ur replay..

      ya its working fine in abap grid layout..but my requirement is in microsoft excel layout i will edit data. from excel screen to internal table i want to save data