ALV with an Editable Row

ALV with an Editable Row

Introduction to ALV with an Editable Row

Practically we all are very mindful of ALVs with an editable section. Assuming got some information about an editable line, we could see bewildered faces. Albeit the idea has been talked about in various discussions often previously, no whole code was found to carry out that in a hurry. The accompanying conversation will make sense of all through making an ALV with an Editable Row. Additionally, find the whole working code toward the end which can be downloaded and yet again utilized.

Requirement of ALV with an Editable Row

We should expect the necessity is to show buy orders given as a contribution to the choice screen. Buy requests will be shown with all thing numbers and material numbers. In our result screen, we need Buy Request Number, Plant, Stockpiling, Organization Code, Archive Type, Thing No and Material. Moreover, we ought to have an area of interest empower field on Buy request number after tapping on which framework ought to explore to the ME21N screen. At the point when tapped on back from ‘ME21N’ exchange every one of the lines of that specific buy request ought to become editable.

Program Construct

  1. Types and Structure Declarations
  2. Work Areas and Internal Tables
  3. Declare Local Class For Event Handling
  4. Class Implementation
  5. Selection Screen Design
  6. Start Of Selection
  7. Call Screen
  8. PBO
  9. Module DISPLAY_ALV
  10. PAI

 

1. Types and Structure Declarations

OOPS ALV Reports in ABAP

Note – Aside from the expected sorts, in our last kinds structure we utilized ‘fstyl’ of type lvc_t_styl to control the editable settings. This assumes the real part to make the last ALV yield table lines editable or show as it were.

OOPs Report

2. Workspaces and Interior Tables Note-LS_STYLEROW and LT_STYLEROW are utilized for holding the style data we will make later in this article.

3. Declare Local Class for Event Handling

Hot Spot in ALV

For area of interest occasion, we have made this class-technique.

4. Class Implementation

ALV Report to make Row Editable

This part will deal with the significant errands expected in our program. Above all else, we want to have the area of interest route usefulness. This has been accomplished with ‘Consider Exchange’ explanation in the wake of perusing the row_id and comparing PO number for that. Additionally note, for that specific PO number, we have gathered all the details into the GT_FINAL table which we will make editable.

Presently we ought to deal with the column altering rationale.

SAP ALV report

Make note of the utilization of this segment (cl_gui_alv_grid=>mc_style_enabled). This really makes a specific field of your ALV editable. For this necessity, I utilized every one of the fields. On the other hand, in the event that you have a necessity to create 2 fields of a specific column editable you can basically pass just those two field names and you will see those as editable.

You need to make fields editable as well as need to deal with making those handicapped on the off chance that the altering condition isn’t met.

Editable Field in ALV

Presently you ought to be great with the editable line usefulness. We should continue on toward the fundamental body of our program.

5. Selection Screen Design

*&-------------------------------------------------------------------*
*&     S E L E C T I O N    S C R E E N
*&-------------------------------------------------------------------*
selection-screen: begin of block B1 with frame title text-001.
select-options: s_ebeln for ekko-ebeln.
selection-screen: end of block B1.

6. Start Of Selection

*&-------------------------------------------------------------------*
*&     S T A R T   O F   S E L E C T I O N
*&-------------------------------------------------------------------*
start-of-selection.
perform fetch_data.
call screen 0100.

Make a subroutine for bringing the fundamental information for framework show. The stream rationale for the custom screen made will look like underneath.

custom screen in SAP

6.a. Refer the full code.

6.b. Refer the full code.

6.c. Module Display_ALV

This part contains rationale to recognize whether the program has been executed in closer view/foundation. Contingent upon that, it utilizes a specific class reference. Keep in mind, on the off chance that you have made an object of a custom compartment (for example assuming you have utilized CL_GUI_CUSTOM_CONTAINER), foundation execution of the report will come up short and occupation status will be dropped. Continuously use docking holder reference in such cases. We use CL_GUI_ALV_GRID_OFFLINE to distinguish whether the program is executed on frontal area/foundation.

Docking Container

6.d. Refer the full code.

We should perceive how accurately it was planned.

Selection Screen
SAP OOPs Report
List Screen

Click on any Buying Record no in list screen and explore back to the report. You ought to have the option to see all related lines of the buying report editable.

Attempted with other PO number and it worked consistently!

Why ALV Report is dumping in Background

Execute the program in foundation

Foundation Occupation Status ought to be “Done”

Further Reading

For comparative usefulness and better comprehension allude BCALV_EDIT_02 program.

Extra Perusing

The client will clearly need some altering activity with change-save usefulness. When the lines are in the editable mode, the client will change a few information and hit save button. This will ultimately set off the PAI part of the custom screen and to deal with the save we want to utilize ‘SPOS’ capability code. Changes can be saved to particular standard tables/custom tables(depending on the prerequisite). To simplify our article I presented no such save activity except for showed the changed information in another ALV design utilizing the manufacturing plant technique.

Code for the PAI section is attached below.

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       Process After Input and Back,Exit and Cancel logic
*----------------------------------------------------------------------*

MODULE USER_COMMAND_0100 INPUT.

  if sy-ucomm = 'E'.

    leave to screen 0.

  elseif sy-ucomm = 'ENDE'.

    leave to screen 0.

  elseif sy-ucomm = 'ECAN'.

    leave to screen 0.

  elseif sy-ucomm = 'SPOS'.

* When save trigger this section
  ref_ag->check_changed_data(

  importing e_valid = c_valid ).

  if c_valid eq abap_true.

*Check the data change

    if lt_final_old[] NE lt_final[].

      LOOP AT lt_final into ls_final.

        read table lt_final_old into ls_final_old index sy-tabix.

         if ls_final_old ne ls_final.

           append ls_final to t_final.

         endif.

      ENDLOOP.

*Any table update should be handled here

*Create the ALV to show the final data updated

    TRY.

     CALL METHOD CL_SALV_TABLE=>FACTORY
        IMPORTING
          R_SALV_TABLE   = ref_salv
        CHANGING
          T_TABLE        = t_final.

    CATCH CX_SALV_MSG .
    ENDTRY.

*Display the final updated table
    ref_salv->display( ).

    leave to screen 0.

    endif.

  endif.

  endif.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

The last result in the wake of consolidating this activity will look something like beneath.

The client will alter something in the ALV yield (I have changed the ‘Material’ as WL-test and DG-test).

After change hit the ‘SAVE’ button and see the changed tuples in last ALV.

So… What Is Your Take?

Presently we need to hear from you.

What is your take of this technique? Do you have a superior methodology?

 

YOU MAY BE INTERESTED IN

Introduction to SAP ABAP for HANA

Future of ABAP on Cloud

ABAP Evolution: From Monolithic Masterpieces to Agile Architects

Create and Consume Business Add-in(BAdI) in ABAP

 

 

WhatsApp WhatsApp us