Saturday, 25 April 2015

How to Create Number Range Object [Tx- SNRO]

--------------------------------------------------------------------------------------------------------------------------------
Step1. Go to Tx- SNRO











Step2. Provide an object name and click on create button.



Step3. Provide the details and Save.


Step4. Choose Yes.


Step5. Go Back.



Step6. Click on Number Ranges button.



Step7. Click on Change Intervals button.


Step8. The below screen appears, click on + Interval button.


Step9.  The below screen appears.


Step10. Provide the interval number and the limits and hit enter key.


Step11. Click on Save. So number range object with interval is created.


Step12. Continue.


Step13. Create a program and call the below FM and pass the number range object and range number. Execute the program.


Step14. The program output. Each time the program executed a new next number is generated.


---------------------------------------------------------------------------------------------------------------------------------

Friday, 24 April 2015

Editable ALV with save functionality uisng OOABAP


-----------------------------------------------------------------------------------------------------------------------------
Step1.  The code :
----------------------------------------------
CLASS lcl_event_handle DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS : hndl_data_changed
                                FOR EVENT data_changed
                                OF cl_gui_alv_grid
                                IMPORTING er_data_changed.
ENDCLASS.
CLASS lcl_event_handle IMPLEMENTATION.
  METHOD hndl_data_changed.
    DATA : lt_scarr TYPE TABLE OF scarr.
    FIELD-SYMBOLS : <fs> TYPE any .
    ASSIGN er_data_changed->mp_mod_rows->* TO <fs>.
    lt_scarr = <fs>.
    IF lt_scarr IS NOT INITIAL.
      MODIFY scarr FROM TABLE lt_scarr.
      IF sy-subrc = 0.
        COMMIT WORK.
        MESSAGE 'Database update successful' TYPE 'S'.
      ENDIF.
    ENDIF.

  ENDMETHOD.
ENDCLASS.


CLASS lcl_main DEFINITION.
  PUBLIC SECTION.

    CLASS-DATA : lo_grid   TYPE REF TO cl_gui_alv_grid,
                          lo_cust   TYPE REF TO cl_gui_custom_container,
                          lo_handle TYPE REF TO lcl_event_handle,
                          lt_scarr  TYPE TABLE OF scarr,
                          ls_layout TYPE lvc_s_layo.

    CLASS-METHODS: run,
                               get_data,
                               prepare_layout,
                               display_alv,
                              user_command.

ENDCLASS.


CLASS lcl_main IMPLEMENTATION.
  METHOD run.
    CALL METHOD lcl_main=>get_data.
    CALL METHOD lcl_main=>prepare_layout.
    CALL METHOD lcl_main=>display_alv.
  ENDMETHOD.

  METHOD get_data.
    SELECT * FROM scarr INTO TABLE lt_scarr.
  ENDMETHOD.

  METHOD prepare_layout.
    ls_layout-edit = abap_true.
  ENDMETHOD.

  METHOD display_alv.
    IF lo_cust IS NOT BOUND.
      CREATE OBJECT lo_cust
        EXPORTING
          container_name = 'CONT'.

    ENDIF.

    IF lo_grid IS NOT BOUND.
      CREATE OBJECT lo_grid
        EXPORTING
          i_parent = lo_cust.

    ENDIF.

    IF lo_handle IS NOT BOUND.
      CREATE OBJECT lo_handle.
    ENDIF.

    IF lo_handle IS BOUND.
      SET HANDLER lo_handle->hndl_data_changed FOR lo_grid.
    ENDIF.

    CALL METHOD lo_grid->set_table_for_first_display
      EXPORTING
        i_structure_name = 'SCARR'
        is_layout        = ls_layout
      CHANGING
        it_outtab        = lt_scarr.

  ENDMETHOD.

  METHOD user_command.
    CASE sy-ucomm.
      WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
        LEAVE TO SCREEN 0.
      WHEN 'SAVE'.
        DATA lv_valid.
        DATA lv_refresh.
        CALL METHOD lo_grid->check_changed_data
          IMPORTING
            e_valid = lv_valid.  " Entries are Consistent
      WHEN OTHERS.
    ENDCASE.
  ENDMETHOD.

ENDCLASS.


START-OF-SELECTION.
  CALL SCREEN 0001.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0001  OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0001 OUTPUT.
  SET PF-STATUS 'STATUS'.
  SET TITLEBAR 'TITLE'.
  CALL METHOD lcl_main=>run.
ENDMODULE.
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0001  INPUT
*&---------------------------------------------------------------------*

MODULE user_command_0001 INPUT.
  CALL METHOD lcl_main=>user_command.
ENDMODULE.

--------------------------------------------------------------------------------------------
Step2. Program code with screen shots.






Step2. Double click on the SET PF-STATUS 'STATUS' , and provide below function keys and activate it.


Step3. Double click on the line SET TITLEBAR 'TITLE' and define it.


Step4. The flow logic of the Screen.


Step5. Screen design with custom container.


Step6. Execute the program.


Step7.  The ALV displayed in editable mode.


Step8. The back end table records.


Step9.  Change some text and save it. line no-4,5, 6 & 9.


Step10. The DB table is updated after save.






-----------------------------------------------------------------------------------------------------------------------------

Creating a dynamic variant for a report

---------------------------------------------------------------------------------------------------------------------------------

Step1. Go to Tx- STVARV

Step2. Click Selection Options tab.

Step3. Choose the Change button.

Step4. To create a new one, select the Create button.

Step5. The below screen appears.

Step6. Provide a selection options name and then click on the arrow button.

Step7. The below screen appears, to maintain the range select second tab.

Step8. Provide the lower limit value and upper limit value and then F8 button.

Step9. Save it.

Step10. The below screen appears.

Step11. Create a report and create a select-option parameter. Execute it.

Step12. If we don't provide any value and execute it. It displays all the records.

Step13. Here the report output. Go back.

Step14. Now click on the Save button to create a variant.

Step15. The below screen appears, Provide the variant name, description and press F4 button of the selection variable.

Step16. Select type of variable as T.

Step17. Click F4 against the name of the variable field.

Step18. Select the pre created variable name.

Step19. Save it.

Step20. Click on the variant button.

Step21. Select the newly created variant name.

Step22. The values are mapped to the select-option field. To see the values click on Right Arrow.

Step23. Choose select ranges tab.

Step24. So here we have the values. Click on F8 button.

Step25. Execute the report.

Step26. So here we have the report output.


 

-----------------------------------------------------------------------------------------------------------------------
Without going to the Tx- STVARV we can create variants.

Step27. Execute the report.

Step28. Click on save to create a variant.

Step29. Go to Environment and select Maint. Sel.Variables


Step30. This will open the Tx- STVARV screen. here we can maintain the names and values and can create a report variant using that STVARV value.



----------------------------------------------------------------------------------------------------------------------------------

Comments system

Disqus Shortname