ALV Grid and wrong number

Hi,
in SE16, browsing MSEG table, when I display a number field such as MENGE I see a strange case:
with classic SE16 output I see a value as "10,000"
with ALV Grid output I see a value as "100,00"
This in a ECC 6.04 box with last Kernel patch 171, last BASIS SP and last ABAP SP.
Have you got any suggest?
Regards.

Check if note 1571782 & 1394178 helps.

Similar Messages

  • ALV Grid and return to selection screen

    Hello
    I have an ALV Grid and when I push a buttom that I program appears another ALV Grid. In this second ALV I try to program different buttoms. When I program the BACK buttom I want to go to selection screen.
    I try with CALL SELECTION SCREEN but when I stay in selection screen and push the execute buttom the ALV that I see is the second, not the first. It seems that we don't catch the news selections.
    I put rs_selfied-refresh = 'X' after the CALL SELECTION SCREEN but is wrong again.
    What can I do????

    Hello Silvia
    There is a simple trick to return from the second ALV list directly back to the selection screen:
    *& Report  ZUS_SDN_REUSE_ALV_GRID_DISPLAY
    REPORT  zus_sdn_reuse_alv_grid_display.
    TYPE-POOLS: slis.
    DATA:
      gt_t001        TYPE STANDARD TABLE OF t001,
      gt_knb1        TYPE STANDARD TABLE OF knb1.
    DATA:
      gs_fcat        TYPE slis_fieldcat_alv,
      gt_fcat_t001   TYPE slis_t_fieldcat_alv,
      gt_fcat_knb1   TYPE slis_t_fieldcat_alv.
    PARAMETERS:
      p_bukrs        TYPE bukrs  DEFAULT '1000'.
    START-OF-SELECTION.
      SELECT * FROM  t001 INTO TABLE gt_t001.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_PROGRAM_NAME               =
    *     I_INTERNAL_TABNAME           =
          i_structure_name             = 'T001'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_INCLNAME                   =
    *     I_BYPASSING_BUFFER           =
    *     I_BUFFER_ACTIVE              =
        CHANGING
          ct_fieldcat                  = gt_fcat_t001
        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.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
    *     I_INTERFACE_CHECK                 = ' '
    *     I_BYPASSING_BUFFER                = ' '
    *     I_BUFFER_ACTIVE                   = ' '
          i_callback_program                = syst-cprog
          i_callback_pf_status_set          = 'ALV_SET_PF_STATUS'
          i_callback_user_command           = 'ALV_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                         =
          it_fieldcat                       = gt_fcat_t001
    *   IMPORTING
    *     E_EXIT_CAUSED_BY_CALLER           =
    *     ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = gt_t001
    *   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.
    END-OF-SELECTION.
    *&      Form  set_pf_status
    *       text
    *      -->RT_EXTAB   text
    FORM alv_set_pf_status USING rt_extab TYPE slis_t_extab.
    * NOTE: identical to STANDARD_FULLSCREEN with additional button
    *       for detail list ('DETAILLIST')
      SET PF-STATUS 'STANDARD_FULLSCREEN'.
    ENDFORM.                    "set_pf_status
    *&      Form  alv_user_command
    *       text
    *      -->R_UCOMM    text
    *      -->RS_SELFIELDtext
    FORM alv_user_command  USING r_ucomm LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
    *   Display detail list: all customers for selected company code
        WHEN 'DETAILLIST'.
          IF ( rs_selfield-fieldname = 'BUKRS' ).
            SELECT        * FROM  knb1 INTO TABLE gt_knb1
                   WHERE  bukrs  = rs_selfield-value.
            CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
              EXPORTING
    *         I_INTERFACE_CHECK                 = ' '
    *         I_BYPASSING_BUFFER                = ' '
    *         I_BUFFER_ACTIVE                   = ' '
                i_callback_program                = syst-cprog
                i_callback_pf_status_set          = 'ALV_SET_PF_STATUS'
                i_callback_user_command           = 'ALV_USER_COMMAND'
    *         I_CALLBACK_TOP_OF_PAGE            = ' '
    *         I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *         I_CALLBACK_HTML_END_OF_LIST       = ' '
                i_structure_name                  = 'KNB1'
    *       IMPORTING
    *         E_EXIT_CAUSED_BY_CALLER           =
    *         ES_EXIT_CAUSED_BY_USER            =
              TABLES
                t_outtab                          = gt_knb1
              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.
    <b>*       NOTE: when the program logic returns from the 2nd ALV list
    *             and exit = 'X' then the program leaves the
    *       1st ALV list, too, and returns to the selection screen.</b>
            rs_selfield-exit = 'X'.
          ENDIF.
        WHEN OTHERS.
      ENDCASE.
    ENDFORM.                    "alv_user_command
    Regards
      Uwe

  • ALV GRID  and Integrated ITS 7 (SAP GUI for HTML) - dissapears on reload

    Hi All,
    We have a custom report that uses an ALV grid to display information to the user. Within this grid, there are fields that are display only and fields that are editable. Also, the grid is wider than the screen's width. It works fine in ECC. It also worked fine when we were using ITS 6.4.
    We have recently upgraded to ITS 7. Now when we run the report using a Transaction iView (in EP 7) or the Webgui service (SAP GUI for HTML), if a field that is editable has focus when an event is triggered that reloads the grid, the screen becomes blank. So, you can click the Save button and the screen goes blank, also, there are date fields in the grid and if you choose a new date, the grid reloads and the screen becomes blank.
    We have found that when the screen is blank, you can use the "Page Up" button on your keyboard and the last few columns of the grid will appear. As if the entire grid has moved off-screen to the left.
    If you click onto a non-editable field and refresh or save, the grid returns to its normal state.
    We are on Basis Patch level 15.
    Does anyone have any ideas on how to fix this?
    Also, does anyone know of a standard SAP transaction we can call from the Webgui that would have a similar setup...with an ALV grid containing editable and non-editable fields? We would like to rule out any errors in the report itself. Since it worked before we upgraded and it works fine in ECC. This would be a really big help too.
    Thank you so much!
    -Kevin

    Hi,
    Thanks Raymond, I have seen Note 314568. I could not get the second link to work but I have looked at just about every Note in reference to Integrated ITS 7 and Tables or ALV Grids and there are very many, so it would appear that SAP has had a hard time with implementing this control, but I have not seen any instance that matches the problem we are having.
    Unfortunately, SAP will not investigate this unless we can provide a standard Transaction that exhibits the same behavior.
    If anyone knows of a standard SAP Transaction that displays an ALV Grid that is wider than the screen (requiring a horizontal scroll bar) and with editable and non-editable fields, that would be fantastic. If we can test against that, then we would know for sure if this is a problem with ITS / SAP GUI for HTML, or if there is an issue with this specific report.
    Thanks!
    -Kevin

  • Help me in alv grid and form printing

    hi experts,
    my requirement is
    i have a check box in the selection screen for  batch processing.
    if i  tick the check box,  the  data  which is in the  t_output  table  should be displayed in alv grid  and
    in turn if i select  one row  in alv o/p  and double click on it  the entire data shold be displayed in the form.
    if 2 rows are selected in alv  and double clicked on it then data in the two rows is dispalyed in the form.
    points  are rewarded .
    thanks in advance.

    Hi,
    Check the following link:
    http://sapdev.co.uk/reporting/alv/alvgrid_rowsel.htm
    Regards,
    bhaskar

  • ALV REPORT: read selected checkbox in alv grid and process the pushbutton

    my requirement is to check some rows from alv grid and the press the pushbutton. Thereby following things should process:
    select all checked rows into an itab and call the transaction code CJ01 for all
    entries......
    I am finding the problem that when I select the checkbox....the internal table doesnt recognize the boxes as checked ones......
    thanks in advance...
    Kartikey Singh,

    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.
          loop at t_output where Flag = 'X'.
            if t_output-VKUEGRU is initial.
              message e000 with text-110.
            endif.
    endloop.

  • Report with two ALV grids and a header

    Hi experts,
    I have a report with two ALV grids in the same screen, each one in a separated container. The information displays it correctly. The report has been implemented by using OO Programming.
    My real trouble is in the header. It must have a logo, a title with a specific font and other information.
    I'll attach a capture of my need:
    [Report with two ALV grids and a header|http://picasaweb.google.com/lh/photo/AcQD49QPmm-0L_jL2iMedA?feat=directlink]
    Then, I want to set up the header you can see, with logo, a font with specific features. Obviously, the header you see has taken from another report. But is the same idea.
    I've tried with a third container, using the CL_GUI_CONTAINER and CL_GUI_CONTAINER classes, but it doesn't work.
    Any idea? Would welcome any help you can provide.
    Thanks in advance,
    Jorge Rojas

    Hi, Jorge.
    Should the header be a"attached" to any of the ALV? Or it should be carried alone?
    If first applies, you've given the solution yourself: put the info & logo in first ALV's header and invoke it from the proper method.
    You could use CL_GUI_DOCKING_CONTAINER CLASS to divide screen in several containers and then, in the upper one, I would create another one docking container to divide the screen into two: the written info could be performed with an HTML viewer class and the logo with a CL_GUI_PICTURE element.
    Cheers.

  • ALV-Grid and update dynpro fields

    Hi!
    I've created a dynpro with an ALV-Grid for Data-Overview and fields on the dynpro to change additional data.
    My ALV has one editable column, when this value change I calculate other value for  a field dynrpo, but I canu2019t see this change in my field dynpro.
    How can I update my data filed dynpro when changing the selected row at the ALV.
    I use the method handle_data_changed to obtain changes in ALV-Grid and it works fine, but I canu2019t update my fileds on the dynpro, when changing value in ALV.
    Thanks for any hints!
    Lili.

    This error occurs becuase when you change anything on the ALV, control is not triggering the PAI and PBO of your dynpro. Hence your values are not getting updated in the dynpro field.
    You should call the CL_GUI_CFW=>DISPATCH in PAI module to trigger the PAI also after the event has been triggered in the ALV.
      CALL METHOD CL_GUI_CFW=>DISPATCH
        importing return_code = return_code.
    * a control event occured => exit PAI
      if return_code <> cl_gui_cfw=>rc_noevent.
        clear g_ok_code.
        exit.
      endif.
    Regards,
    Naimesh Patel

  • ALV Grid and ALV List difference?

    Hello,
    Can you help me differentiate ALV List and ALV grid and the low-level definition or context of each?
    Also, can you give me a transaction code that outputs an ALV list as well as a tcode for ALV grid?
    Thanks,
    Jennah

    Hi Kirtish,
    Thanks but I  havent done any function module stuff as I am not an ABAPer but anyway can you guide me through thios?
    "I hope this might slove your query. For more please refer to documentation on ALV and also implement the ALV LIST and GRID reports. By using class Class CL_GUI_ALV_GRID, Function module REUSE_ALV_LIST_DISPLAY , REUSE_ALV_GRID_DISPLAY and some more functions like that only."
    I will give you some tcode can you please try tcode FBL1n? then execute the report. What is the output is it an ALV list?
    I wish to see an ALV list also an ALV grid to see difference.
    Tjhakns,
    Jennah

  • ALV Grid and Icon : Printing Problem

    Hi, i develop some reports using ALV Grid and Icon and i'm facing printing problem, all report that using ALV grid with the option icon = 'X' cannot print properly, all the character field showing improper icon instead of the text. While all the ALV grid report with the option icon = ' ' can print normally.
    Thanks.

    Hi,
    Check the Demo Program <b>BCALV_DEMO_TOOLTIP</b>, Here i am able to see the Output Properly, and also able to Print them.
    Regards
    vijay

  • Alv Grid and Table Control

    What is the difference between Alv Grid and Table Control?Explain in detail..

    Table control is a screen table to display table data in a screen. You can add table control to a screen in the Screen Painter. The typical flow-logic to process table control is:
    LOOP AT <internal table> CURSOR <scroll-var>
    [WITH CONTROL <table-control> ]
    [FROM <line1> ] [TO <line2> ].
    ...<actions>...
    ENDLOOP.
    ALV Grid is a SAP Technology to display a set of data on the output screen. For example if you have selected some SAP tables and processed these data in a way you want to display, then you can pass the internal table to the ALV Grid and it will be displayed on the result screen as ALV Grid. See example in SE16 result.

  • ALV Grid and LIST?

    HI all,
    Diff between ALV GRID and ALV LIST?
    sachin.

    Hi,
    ckeck these differences.
    first one is for list display and second one is for grid display.
    For all practical purposes, they are the same.
    2. Some differences:
    a) from abap coding point of view,
    alv list is done with Function modules,
    alv gris can also be done with FM,
    but can also be done using OO concepts.
    b) Alv grid (using oo concept) requires
    designing the screen layout .
    Hence, in one screen, we can show more
    then one alv grid
    (we cannot show more than
    one alv list on one screen)
    c) ALV grid uses ActiveX controls
    present on the Presentation Server.
    Hence, it consumes More Memory
    on the presentation server.
    d) ALV LIST is Display Only.
    Whereas
    ALV Grid Can Be made EDITABLE for entry purpose.
    e) In alv grid, these options are possible,
    but not in alv list.
    without horizontal lines
    without vertical lines
    without cell merging during sorts
    display total lines above the entries
    ALV LIST Can be coded using only FMs
    ALV GRID Can be coded using FMs and object oriented concepts
    ALV LIST Can be displayed hieraicharlly
    ALV GRID cannot be displayed hierarichally.
    reward points if hlpful.

  • Display totals on the first line in ALV grid and ALV LIST

    Generally we wll display totals at the end..
    bu the requirement is to display it in the first line of the column.
    how to display the totals in the first line?
    I have used ALV GRID and ALV LIST (choice) using function modules.
    Plz help me
    .for example : Po qty : Should display total po qty on the first line of the Po line item.

    IN LAYOUT
    ILAYOUT-totals_before_items = 'X'.
    REGARDS
    SHIBA DUTTA

  • First try with ALV Grid and Abap Objects

    Hi,
    this is my first try to write a simple report which just reads a textfile and display it in an ALV Grid. As a basis, I used some examples from SDN, but it did not work as expected
    I would like just to use a docking container. I do not need a separate area for the ALV Grid. The report gives no syntax errors, but it just display the report title, nothing else. SAP R/3 Release is 4.7. Below is the source code of the report. Any idea what is missing?
    *& Report  Z_PLAN_TEXT_UPLOAD                                          *
    REPORT z_plan_text_upload.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_dynnr TYPE sy-dynnr,
      gf_repid TYPE sy-repid.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)           TYPE c,
        kostenstelle(20)    TYPE c,
        datenart1(10)       TYPE c,
        planjahr(10)        TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)      TYPE c,
        datenart2(10)       TYPE c,
        planungposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)       TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)      TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Local Class Definition
    * Local Class Implementation
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    SKIP.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SKIP.
    PARAMETERS:
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn.
    SELECTION-SCREEN END OF BLOCK b1.
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
      gf_dynnr = sy-dynnr.
      gf_repid = sy-repid.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog
        CHANGING gt_fieldcat.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
    *      PARENT                      =
            repid                       = gf_repid
            dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *      EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
    *      RATIO                       =
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_docking_container IS INITIAL
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid IS INITIAL.
        CREATE OBJECT go_alv_grid
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid is initial
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      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  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Kostenstelle' .
      ls_fcat-seltext = 'Kostenstelle' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog

    I have added some more functionality to my report. The good thing is, the report works as it should.
    BUT, I'm not really sure, whether this is a good (correct) design. The report works the following way:
    1. Read planning data form text file into internal table
    2. Display the internal table
    3. Convert the data and display the converted result
    4. Post the converted data to the system
    5. Display log with messages
    The main thing is, I would like to know, do i really need two dynros, to display the two different internal tables or is it possible just to use one ALV-Grid? I was not able to find another solution. Any comment or help to the report is appreciated.
    *& Report  Z_PLAN_TEXT_UPLOAD_TEST                                     *
    REPORT z_plan_text_upload_test.
    INCLUDE <icon>.
    * Data Declaration
    DATA:
      gf_okcode TYPE ui_func,
      gf_balloghndl TYPE balloghndl.
    DATA:
      go_docking_container TYPE REF TO cl_gui_docking_container,
      go_alv_grid_0100 TYPE REF TO cl_gui_alv_grid,
      go_alv_grid_0200 TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_fieldcat TYPE lvc_t_fcat,
      gs_fieldcat LIKE LINE OF gt_fieldcat.
    TYPES:
      BEGIN OF gy_text_input,
        firma(20)            TYPE c,
        kostenstelle(20)     TYPE c,
        datenart1(10)        TYPE c,
        planjahr(10)         TYPE c,
    *    planperiode         TYPE co_perio,
        planperiode(5)       TYPE c,
        datenart2(10)        TYPE c,
        planungsposition(10) TYPE c,
    *    kostenart           TYPE koart,
        kostenart(10)        TYPE c,
    *    planbetrag          TYPE bapicurr_d,
        planbetrag(20)       TYPE c,
      END OF gy_text_input.
    DATA:
      gt_text_input TYPE TABLE OF gy_text_input,
      gs_text_input LIKE LINE OF gt_text_input.
    * Bapi Strukturen
    DATA:
      gs_headerinfo TYPE bapiplnhdr,
      gt_indexstructure TYPE TABLE OF bapiacpstru,
      gs_indexstructure LIKE LINE OF gt_indexstructure,
      gt_coobject TYPE TABLE OF bapipcpobj,
      gs_coobject LIKE LINE OF gt_coobject,
      gt_pervalue TYPE TABLE OF bapipcpval,
      gs_pervalue LIKE LINE OF gt_pervalue,
      gt_return TYPE TABLE OF bapiret2,
      gs_return LIKE LINE OF gt_return,
      gt_control TYPE TABLE OF bapipcpctrl,
      gt_totvalue TYPE TABLE OF bapipcptot.
    TYPES:
      BEGIN OF gy_bapi_input,
        version      TYPE versn,
    *    perio       TYPE co_perio,
        fisc_year    TYPE gjahr,
        coobject(10) TYPE c,
        cost_elem    TYPE kstar,
        wkgbtr01     TYPE wkgxxx,
        wkgbtr02     TYPE wkgxxx,
        wkgbtr03     TYPE wkgxxx,
        wkgbtr04     TYPE wkgxxx,
        wkgbtr05     TYPE wkgxxx,
        wkgbtr06     TYPE wkgxxx,
        wkgbtr07     TYPE wkgxxx,
        wkgbtr08     TYPE wkgxxx,
        wkgbtr09     TYPE wkgxxx,
        wkgbtr10     TYPE wkgxxx,
        wkgbtr11     TYPE wkgxxx,
        wkgbtr12     TYPE wkgxxx,
      END OF gy_bapi_input.
    DATA:
      gt_bapi_input TYPE TABLE OF gy_bapi_input,
      gs_bapi_input LIKE LINE OF gt_bapi_input.
    * Anwendungs-Log
    DATA: gs_balsmsg TYPE bal_s_msg.
    * Selection-Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1
      WITH FRAME TITLE text-001.
    PARAMETERS:
      gp_file TYPE localfile,
      gp_head TYPE checkbox DEFAULT 'X'.
    SELECTION-SCREEN SKIP.
    PARAMETERS:
      gp_kokrs  LIKE coep-kokrs,
      gp_gjahr LIKE coep-gjahr,
      gp_versn LIKE coep-versn,
      gp_test AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK b1.
    * Local Class Definition
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar_0100 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0100 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm,
        handle_toolbar_0200 FOR EVENT toolbar OF cl_gui_alv_grid
          IMPORTING
            e_object
            e_interactive,
        handle_user_command_0200 FOR EVENT user_command OF cl_gui_alv_grid
          IMPORTING
            e_ucomm.
      PRIVATE SECTION.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    * Local Class Implementation
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD handle_toolbar_0100.
        PERFORM handle_toolbar_0100
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0100.
        PERFORM handle_user_command_0100
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
      METHOD handle_toolbar_0200.
        PERFORM handle_toolbar_0200
          USING
            e_object.
    *        e_interactive.
      ENDMETHOD.                    "handle_toolbar_0100
      METHOD handle_user_command_0200.
        PERFORM handle_user_command_0200
          USING
            e_ucomm.
      ENDMETHOD.                    "handle_user_command_0100
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    * Initialization
    INITIALIZATION.
      DATA:
        lf_sapworkdir TYPE string.
      CALL METHOD cl_gui_frontend_services=>get_sapgui_workdir
        CHANGING
          sapworkdir            = lf_sapworkdir
        EXCEPTIONS
          get_sapworkdir_failed = 1
          cntl_error            = 2
          error_no_gui          = 3
          not_supported_by_gui  = 4
          OTHERS                = 5.
      IF sy-subrc <> 0 OR lf_sapworkdir = ''.
        CALL METHOD cl_gui_frontend_services=>directory_get_current
          CHANGING
            current_directory            = lf_sapworkdir
          EXCEPTIONS
            directory_get_current_failed = 1
            cntl_error                   = 2
            error_no_gui                 = 3
            not_supported_by_gui         = 4
            OTHERS                       = 5.
        CALL METHOD cl_gui_cfw=>flush.
      ENDIF."sy-subrc <> 0 OR sapworkdir = ''
      gp_file = lf_sapworkdir.
    * At Selection-Screen
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR gp_file.
      DATA:
        lt_filetable TYPE filetable,
        ls_filetable LIKE LINE OF lt_filetable,
        lt_rc TYPE i.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
    *  EXPORTING
    *    WINDOW_TITLE            =
    *    DEFAULT_EXTENSION       =
    *    DEFAULT_FILENAME        =
    *    FILE_FILTER             =
    *    INITIAL_DIRECTORY       =
    *    MULTISELECTION          =
    *    WITH_ENCODING           =
        CHANGING
          file_table              = lt_filetable
          rc                      = lt_rc
    *    USER_ACTION             =
    *    FILE_ENCODING           =
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      READ TABLE lt_filetable INDEX 1
        INTO
          ls_filetable.
      gp_file = ls_filetable-filename.
      CALL METHOD cl_gui_cfw=>flush.
    * Start-Of-Selection
    START-OF-SELECTION.
      DATA:
        lf_filename LIKE filename-fileintern.
      PERFORM create_log.
      gs_return-type = 'I'.
      IF gp_test = 'X'.
        gs_return-message = text-010.
      ELSE.
        gs_return-message = text-020.
      ENDIF.
      PERFORM add_log_message_free_text
        USING
           gs_return-type
           gs_return-message.
      lf_filename = gp_file.
      CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
        EXPORTING
          i_filename                 = lf_filename
          i_servertyp                = 'PRS '
          i_fileformat               = 'TXT'
    *     I_FIELD_SEPERATOR          =
          i_line_header              = gp_head
    *   IMPORTING
    *     E_BIN_FILELENGTH           =
       TABLES
         i_tab_receiver             = gt_text_input
       EXCEPTIONS
         file_not_found             = 1
         close_failed               = 2
         authorization_failed       = 3
         open_failed                = 4
         conversion_failed          = 5
         OTHERS                     = 6.
      IF sy-subrc <> 0.
        gs_balsmsg-msgty = sy-msgty.
        gs_balsmsg-msgid = sy-msgid.
        gs_balsmsg-msgno = sy-msgno.
        gs_balsmsg-msgv1 = sy-msgv1.
        gs_balsmsg-msgv2 = sy-msgv2.
        gs_balsmsg-msgv3 = sy-msgv3.
        gs_balsmsg-msgv4 = sy-msgv4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDIF.
      CALL SCREEN '0100'.
    *&      Module  status_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999  "full-screen size !!!
          EXCEPTIONS
            cntl_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.
      ENDIF."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog ---------------------------------------*
      PERFORM build_fieldcatalog_input
        CHANGING gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0100 IS INITIAL.
        CREATE OBJECT go_alv_grid_0100
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
            i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid_0100 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0100 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0100.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0100->handle_toolbar_0100
        FOR go_alv_grid_0100.
      SET HANDLER go_event_handler_0100->handle_user_command_0100
        FOR go_alv_grid_0100.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0100->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_text_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0100->set_toolbar_interactive.
    ENDMODULE.                 " status_0100  OUTPUT
    *&      Module  status_0200  OUTPUT
    *       text
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *------ Create the docking container ----------------------------------*
      IF go_docking_container IS INITIAL.
        CREATE OBJECT go_docking_container
          EXPORTING
            parent                      = cl_gui_container=>screen0
    *        repid                       = gf_repid
    *        dynnr                       = gf_dynnr
    *     SIDE                        = go_docking_container->DOCK_AT_bottom
    *       EXTENSION                   = 200
    *      STYLE                       =
    *      LIFETIME                    = lifetime_default
    *      CAPTION                     =
    *      METRIC                      = 0
            ratio                       = 95
    *      NO_AUTODEF_PROGID_DYNNR     =
    *      NAME                        =
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    *------ Expand  docking container to full screen    -------------------*
        CALL METHOD go_docking_container->set_extension
          EXPORTING
            extension  = 99999
          EXCEPTIONS
            cntl_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.
      ENDIF."go_docking_container IS INITIAL
    *------ Link docking container to screen ------------------------------*
      CALL METHOD go_docking_container->link
        EXPORTING
          repid                       = sy-repid
          dynnr                       = '0200'
    *      CONTAINER                   =
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          lifetime_dynpro_dynpro_link = 3
          OTHERS                      = 4
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *------ Build the Field Catalog---------------------------------------*
      PERFORM build_fieldcatalog_bapi_input
        CHANGING
          gt_fieldcat.
    *------ Create the ALV Grid -------------------------------------------*
      IF go_alv_grid_0200 IS INITIAL.
        CREATE OBJECT go_alv_grid_0200
          EXPORTING
    *      I_SHELLSTYLE      = 0
    *      I_LIFETIME        =
           i_parent          = go_docking_container
    *      I_APPL_EVENTS     = space
    *      I_PARENTDBG       =
    *      I_APPLOGPARENT    =
    *      I_GRAPHICSPARENT  =
    *      I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDIF."go_alv_grid_0200 is initial
    *------ Create instance for event handler -----------------------------*
      DATA: go_event_handler_0200 TYPE REF TO lcl_event_handler.
      CREATE OBJECT go_event_handler_0200.
    *------ Register event handler ----------------------------------------*
      SET HANDLER go_event_handler_0200->handle_toolbar_0200
        FOR go_alv_grid_0200.
      SET HANDLER go_event_handler_0200->handle_user_command_0200
        FOR go_alv_grid_0200.
    *------ Call ALV Grid -------------------------------------------------*
      CALL METHOD go_alv_grid_0200->set_table_for_first_display
    *     EXPORTING
    *      I_BUFFER_ACTIVE               =
    *      I_BYPASSING_BUFFER            =
    *      I_CONSISTENCY_CHECK           =
    *      I_STRUCTURE_NAME              =
    *      IS_VARIANT                    =
    *      I_SAVE                        =
    *      I_DEFAULT                     = 'X'
    *      IS_LAYOUT                     =
    *      IS_PRINT                      =
    *      IT_SPECIAL_GROUPS             =
    *      IT_TOOLBAR_EXCLUDING          =
    *      IT_HYPERLINK                  =
    *      IT_ALV_GRAPHICS               =
    *      IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_bapi_input
          it_fieldcatalog               = gt_fieldcat
    *      IT_SORT                       =
    *      IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *---- Call method 'set_toolbar_interactive' to raise event TOOLBAR.
      CALL METHOD go_alv_grid_0200->set_toolbar_interactive.
      CALL METHOD go_alv_grid_0200->refresh_table_display
    *  EXPORTING
    *    IS_STABLE      =
    *    I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 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.
      CALL METHOD cl_gui_control=>set_focus
        EXPORTING
          control = go_alv_grid_0200.
    ENDMODULE.                 " status_0200  OUTPUT
    *&      Module  user_command_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0100  INPUT
    *&      Module  user_command_0200  INPUT
    *       text
    MODULE user_command_0200 INPUT.
      CASE gf_okcode.
        WHEN 'BACK' OR 'END' OR 'CANC'.
          PERFORM exit_program.
        WHEN OTHERS.
      ENDCASE.
      CLEAR gf_okcode.
    ENDMODULE.                 " user_command_0200  INPUT
    *&      Form  build_fieldcatalog
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      ls_fcat-fieldname = 'FIRMA' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Firma' .
      ls_fcat-seltext = 'Firma' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENSTELLE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART1' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart1' .
      ls_fcat-seltext = 'Datenart1' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANJAHR' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planjahr' .
      ls_fcat-seltext = 'Planjahr' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANPERIODE' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '5' .
      ls_fcat-coltext = 'Planperiode' .
      ls_fcat-seltext = 'Planperiode' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'DATENART2' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Datenart2' .
      ls_fcat-seltext = 'Datenart2' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANUNGSPOSITION' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Planungsposition' .
      ls_fcat-seltext = 'Planungsposition' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'KOSTENART' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '10' .
      ls_fcat-coltext = 'Kostenart' .
      ls_fcat-seltext = 'Kostenart' .
      APPEND ls_fcat TO pt_fieldcat .
      ls_fcat-fieldname = 'PLANBETRAG' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'Planbetrag' .
      ls_fcat-seltext = 'Planbetrag' .
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    "build_fieldcatalog
    *&      Form  handle_toolbar_0100
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0100
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'KONV'.
      ls_toolbar-quickinfo  = 'Konvertieren'.
      ls_toolbar-text       = 'Konvertieren'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0100
    *&      Form  handle_user_command_0100
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0100
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'KONV'.
          PERFORM convert_data.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0100
    *&      Form  exit_program
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM exit_program.
      CALL METHOD go_alv_grid_0100->free.
      IF NOT go_alv_grid_0200 IS INITIAL.
        CALL METHOD go_alv_grid_0200->free.
      ENDIF.
      CALL METHOD go_docking_container->free.
      CALL METHOD cl_gui_cfw=>flush.
      IF sy-subrc NE 0.
    * add your handling, for example
        CALL FUNCTION 'POPUP_TO_INFORM'
          EXPORTING
            titel = sy-repid
            txt2  = sy-subrc
            txt1  = 'Error in Flush'(500).
      ENDIF.
      LEAVE PROGRAM.
    ENDFORM.                    " exit_program
    *&      Form  handle_toolbar_0200
    *       text
    *      -->P_E_OBJECT  text
    *      -->P_E_INTERACTIVE  text
    FORM handle_toolbar_0200
      USING
        po_object TYPE REF TO cl_alv_event_toolbar_set.
      DATA: ls_toolbar TYPE stb_button.
      CLEAR ls_toolbar.
      ls_toolbar-butn_type  = 0.
      ls_toolbar-function   = 'POST'.
      ls_toolbar-quickinfo  = 'Buchen'.
      ls_toolbar-text       = 'Buchen'.
      ls_toolbar-disabled   = ' '.
      APPEND ls_toolbar TO po_object->mt_toolbar.
    ENDFORM.                    " handle_toolbar_0200
    *&      Form  handle_user_command_0200
    *       text
    *      -->P_E_UCOMM  text
    FORM handle_user_command_0200
      USING
        pf_ucomm TYPE syucomm.
      CASE pf_ucomm.
        WHEN 'POST'.
          PERFORM post.
      ENDCASE.
    ENDFORM.                    " handle_user_command_0200
    *&      Form  convert_data
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM convert_data.
      DATA: lf_perio(3) TYPE n.
      LOOP AT gt_text_input INTO gs_text_input.
        TRANSLATE gs_text_input-planbetrag USING '. '.
        TRANSLATE gs_text_input-planbetrag USING ',.'.
        CONDENSE gs_text_input-planbetrag.
        gs_bapi_input-version   = gp_versn.
        gs_bapi_input-fisc_year = gp_gjahr.
        gs_bapi_input-coobject  = gs_text_input-kostenstelle.
        gs_bapi_input-cost_elem = gs_text_input-kostenart.
        lf_perio = gs_text_input-planperiode.
        CASE lf_perio.
          WHEN '001'.
            gs_bapi_input-wkgbtr01 = gs_text_input-planbetrag.
          WHEN '002'.
            gs_bapi_input-wkgbtr02 = gs_text_input-planbetrag.
          WHEN '003'.
            gs_bapi_input-wkgbtr03 = gs_text_input-planbetrag.
          WHEN '004'.
            gs_bapi_input-wkgbtr04 = gs_text_input-planbetrag.
          WHEN '005'.
            gs_bapi_input-wkgbtr05 = gs_text_input-planbetrag.
          WHEN '006'.
            gs_bapi_input-wkgbtr06 = gs_text_input-planbetrag.
          WHEN '007'.
            gs_bapi_input-wkgbtr07 = gs_text_input-planbetrag.
          WHEN '008'.
            gs_bapi_input-wkgbtr08 = gs_text_input-planbetrag.
          WHEN '009'.
            gs_bapi_input-wkgbtr09 = gs_text_input-planbetrag.
          WHEN '010'.
            gs_bapi_input-wkgbtr10 = gs_text_input-planbetrag.
          WHEN '011'.
            gs_bapi_input-wkgbtr11 = gs_text_input-planbetrag.
          WHEN '012'.
            gs_bapi_input-wkgbtr12 = gs_text_input-planbetrag.
        ENDCASE.
        COLLECT gs_bapi_input INTO gt_bapi_input.
        CLEAR gs_bapi_input.
      ENDLOOP. "at gt_text_input
      CALL SCREEN 0200.
    ENDFORM.                    " convert_data
    *&      Form  build_fieldcatalog_bapi_input
    *       text
    *      <--P_GT_FIELDCAT  text
    FORM build_fieldcatalog_bapi_input
      CHANGING
        pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      CLEAR pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'VERSION' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'FISC_YEAR' .
      ls_fcat-ref_table = 'BAPIPLNHDR' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COOBJECT' .
      ls_fcat-inttype = 'C' .
      ls_fcat-outputlen = '20' .
      ls_fcat-coltext = 'CO-Objekt' .
      ls_fcat-seltext = 'CO-Objekt' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'COST_ELEM' .
      ls_fcat-ref_table = 'BAPIPCPVAL' .
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR01'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR02'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR03'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR04'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR05'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR06'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR07'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR08'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR09'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR10'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR11'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'WKGBTR12'.
      ls_fcat-ref_table = 'COEP' .
      ls_fcat-ref_field = 'WKGBTR'.
      APPEND ls_fcat TO pt_fieldcat .
    ENDFORM.                    " build_fieldcatalog_bapi_input
    *&      Form  post
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM post.
      DATA:
        lf_index(6) TYPE n,
        lf_kostl    LIKE csks-kostl,
        lf_aufnr    LIKE aufk-aufnr,
        lf_kstar    LIKE cska-kstar.
      DATA:
        lt_csks TYPE TABLE OF csks.
      break c5085345.
    * Header
      gs_headerinfo-co_area       = gp_kokrs.
      gs_headerinfo-fisc_year     = gp_gjahr.
      gs_headerinfo-period_from   = '001'.
      gs_headerinfo-period_to     = '012'.
      gs_headerinfo-version       = gp_versn.
      gs_headerinfo-plan_currtype = 'C'.
      LOOP AT gt_bapi_input INTO gs_bapi_input.
    *   Fill index structure
        CLEAR gs_indexstructure.
        lf_index = sy-tabix.
        gs_indexstructure-object_index = lf_index.
        gs_indexstructure-value_index  = lf_index.
        gs_indexstructure-attrib_index = '000000'.
        INSERT gs_indexstructure INTO TABLE gt_indexstructure.
    *   Fill coobject
        CLEAR gs_coobject.
        gs_coobject-object_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-coobject
          IMPORTING
            output = lf_kostl.
        SELECT * FROM csks INTO TABLE lt_csks
          WHERE
            kokrs = gp_kokrs AND
            kostl = lf_kostl.
        IF sy-subrc = 0.
          gs_coobject-costcenter = lf_kostl.
        ELSE.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = gs_bapi_input-coobject
            IMPORTING
              output = lf_aufnr.
          CALL FUNCTION 'K_ORDER_READ'
            EXPORTING
              aufnr     = lf_aufnr
            EXCEPTIONS
              not_found = 1.
          IF NOT sy-subrc = 0.
            gs_return-type = 'E'.
            gs_return-message+0(10)  = 'CO-Objekt '.
            gs_return-message+10(10) = gs_bapi_input-coobject.
            gs_return-message+20(20)  = ' existiert nicht.'.
            CONDENSE gs_return-message.
            PERFORM add_log_message_free_text
              USING
                gs_return-type
                gs_return-message.
            EXIT.
          ENDIF. "IF NOT sy-subrc = 0
          gs_coobject-orderid = lf_aufnr.
        ENDIF. "sy-subrc = 0
        INSERT gs_coobject INTO TABLE gt_coobject.
    *   Period value
        gs_pervalue-value_index = lf_index.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
          EXPORTING
            input  = gs_bapi_input-cost_elem
          IMPORTING
            output = lf_kstar.
        gs_pervalue-cost_elem = lf_kstar.
        gs_pervalue-fix_val_per01 = gs_bapi_input-wkgbtr01.
        gs_pervalue-fix_val_per02 = gs_bapi_input-wkgbtr02.
        gs_pervalue-fix_val_per03 = gs_bapi_input-wkgbtr03.
        gs_pervalue-fix_val_per04 = gs_bapi_input-wkgbtr04.
        gs_pervalue-fix_val_per05 = gs_bapi_input-wkgbtr05.
        gs_pervalue-fix_val_per06 = gs_bapi_input-wkgbtr06.
        gs_pervalue-fix_val_per07 = gs_bapi_input-wkgbtr07.
        gs_pervalue-fix_val_per08 = gs_bapi_input-wkgbtr08.
        gs_pervalue-fix_val_per09 = gs_bapi_input-wkgbtr09.
        gs_pervalue-fix_val_per10 = gs_bapi_input-wkgbtr10.
        gs_pervalue-fix_val_per11 = gs_bapi_input-wkgbtr11.
        gs_pervalue-fix_val_per12 = gs_bapi_input-wkgbtr12.
        INSERT gs_pervalue INTO TABLE gt_pervalue.
      ENDLOOP. "at gt_bapi_input
    * Buchungsbaustein
      CALL FUNCTION 'BAPI_PRIM_COST_CHECK_AND_POST'
        EXPORTING
          header_info         = gs_headerinfo
          testrun             = gp_test
    *   DELTA               = ' '
        TABLES
          idx_structure       = gt_indexstructure
          object              = gt_coobject
          per_value           = gt_pervalue
          tot_value           = gt_totvalue
          contrl              = gt_control
          return              = gt_return.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    *   EXPORTING
    *     WAIT          =
    *   IMPORTING
    *     RETURN        =
      LOOP AT gt_return INTO gs_return.
        gs_balsmsg-msgty = gs_return-type.
        gs_balsmsg-msgid = gs_return-id.
        gs_balsmsg-msgno = gs_return-number.
        gs_balsmsg-msgv1 = gs_return-message_v1.
        gs_balsmsg-msgv2 = gs_return-message_v2.
        gs_balsmsg-msgv3 = gs_return-message_v3.
        gs_balsmsg-msgv4 = gs_return-message_v4.
        PERFORM add_log_message
          USING
            gs_balsmsg.
      ENDLOOP. "AT gt_return
      PERFORM show_log.
    ENDFORM.                    " post
    *&      Form  create_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM create_log .
      DATA: ls_balslog TYPE bal_s_log.
    * Einige Verwaltungsdaten
      ls_balslog-extnumber = 'ZPLAN010'.
      ls_balslog-aluser    = sy-uname.
      ls_balslog-alprog    = sy-repid.
    * Create
      CALL FUNCTION 'BAL_LOG_CREATE'
        EXPORTING
          i_s_log                 = ls_balslog
    *    IMPORTING
    *      e_log_handle            = gf_balloghndl
        EXCEPTIONS
          log_header_inconsistent = 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.                    " create_log
    *&      Form  add_log_message
    *       text
    *      -->P_GS_BALSMSG  text
    FORM add_log_message
      USING
        ps_balsmsg TYPE bal_s_msg.
      break c5085345.
      CALL FUNCTION 'BAL_LOG_MSG_ADD'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_s_msg                   = ps_balsmsg
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 3
         OTHERS                    = 4.
      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.                    " add_log_messa
    *&      Form  add_log_message_free_text
    *       text
    *      -->P_GS_RETURN_TYPE  text
    *      -->P_GS_RETURN_MESSAGE  text
    FORM add_log_message_free_text
      USING
        ps_type
        ps_message.
      CALL FUNCTION 'BAL_LOG_MSG_ADD_FREE_TEXT'
        EXPORTING
    *       I_LOG_HANDLE              =
          i_msgty                   = ps_type
    *       I_PROBCLASS               = '4'
          i_text                    = ps_message
    *       I_S_CONTEXT               =
    *       I_S_PARAMS                =
    *     IMPORTING
    *       E_S_MSG_HANDLE            =
    *       E_MSG_WAS_LOGGED          =
    *       E_MSG_WAS_DISPLAYED       =
       EXCEPTIONS
         log_not_found             = 1
         msg_inconsistent          = 2
         log_is_full               = 3
         OTHERS                    = 4.
      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.                    " add_log_message_free_text
    *&      Form  show_log
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM show_log .
      DATA:
        l_s_display_profile TYPE bal_s_prof.
    * get display profile
      CALL FUNCTION 'BAL_DSP_PROFILE_NO_TREE_GET'
        IMPORTING
          e_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    * use grid for display if wanted
      l_s_display_profile-use_grid = 'X'.
    * set report to allow saving of variants
      l_s_display_profile-disvariant-report = sy-repid.
    * when you use also other ALV lists in your report,
    * please specify a handle to distinguish between the display
    * variants of these different lists, e.g:
      l_s_display_profile-disvariant-handle = 'LOG'.
    * call display function module
    * We do not specify any filter (like I_S_LOG_FILTER, ...,
    * I_T_MSG_HANDLE) since we want to display all logs available
      CALL FUNCTION 'BAL_DSP_LOG_DISPLAY'
        EXPORTING
          i_s_display_profile = l_s_display_profile
        EXCEPTIONS
          OTHERS              = 1.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • Alv grid and pop up

    This program is an example with a Grid list and a Popup list   
    The Sales Orders are displayed in the first list  .
    When a line is selected, the items of the order are displayed in  a popup list

    For the given selection parameters.select all the sales order fields(listed in report fields section) from VBAP      by performing an inner join on VBAK where the sales order date and number match and the material group is equal to IM01 or IM02  or IM03 or IM04  or IM05  into an internal table A.
    For the above slected sales order get the purchase requisition (BANFN)  and purchase order type (BSART) from table VBEP into another internal table B loop through  the sales order internal table A.
    Read internal  table B.  If sy-subrc = 0 ,then select EBELN (purchase order number) from EBAN using purchase order requisition line item,item number of purchase  requisition  and purchase order  number is not initial.If there is a purchase order number,then delete the sales order line from the internal table else move  the purchase requisition number for each of the sales  order number into internal table A.
    Provide an ALV sort by sales order number and line item.
    Display the output in ALV grid by using  the FM REUSE_ALV_GRID_DISPLAY.
    Provide menu lists for display ,sorting,select/deselect functionalities.
    Note:     check the standard report VA05 as an example for creating the output for this custom  report.
    For       ALV variant use the FM_REUSE_ALV_VARIANT_F4 and REUSE_ALV_VARIANT_DEFAULT_GET to allow the user to save the variant and select it for displaying output.If   any of the data (Z fields in VBAP) is blank,the cell in the column must be highlighted in red.
    NAME      Table/check box/radio button     Selection option/parameter      comments     Default value
    S_DATE     VBAK-ERDAT     S     Sales order creation date     Current date
    S_VBELN     VABAK-VBELN     S     Saled order/orders     
    P_ALVVAR     DISVARIANT-VARAIANT     P          
    Report field label     Sap table     Sap field name     Field calculation     comments
    Sales order number     VBAP     VBELN          
    Line item     VBAP     POSNR          
    Created by     VBAP     ERNAM          
    Material master     VBAP     MATNR          
    description     VBAP     ARKTX          
    Material group     VBAP     MATKL

  • Query related to alv grid and sap script

    Hi All,
    I have a requirement where i should read the values which are selected on the alv grid list output and those values i need to display on the script(layout).
    Help me out guru's its an urgency...
    thanks in advance .
    regards
    ravi ganji

    Hi Ravi,
    I have done it exactly like your requirement. This program contains ALV and Smartform.
    But whatever may be, both are layouts and having driver program. So just finish your driver program and Script layout and then use this program.
    I have written this code to print contact letters from VA42. So, modify this code to insert your transaction code.
    Let me know if you have any questions.
    Here is the code.
    REPORT ILETTER MESSAGE-ID CM.
    TYPE POOLS (ALV)
      TYPE-POOLS:
                slis.
    Customized Types
      TYPES:
            BEGIN OF ty_cntrt,
              box(1)   TYPE c,
              kunnr    TYPE kunag,
              vbeln    TYPE vbeln_va,
              vbeln1   TYPE vbeln_va,
              vposn    TYPE posnr,
              vuntdat  TYPE vudat_veda,
              vbegdat  TYPE vbdat_veda,
              vdemdat  TYPE vddat_veda,
              venddat  TYPE vndat_veda,
            END   OF ty_cntrt,
          single line TYPES
            BEGIN OF ty_vkorg,
             vkorg    TYPE vkorg,
            END   OF ty_vkorg.
    Constants
      CONSTANTS:
         c_sform  TYPE char10             VALUE 'SMARTFORMS',
         c_tcode  TYPE sy-tcode           VALUE 'VA42',
         c_mode   TYPE c                  VALUE 'N',
         c_updat  TYPE c                  VALUE 'A',
         c_batch  TYPE sy-callr           VALUE 'BATCH',
         c_dclick TYPE char10             VALUE '&IC1'.
    Internal tables
      DATA: it_cntrt TYPE TABLE OF ty_cntrt,
            it_bdc   TYPE TABLE OF bdcdata,
            it_mesg  TYPE TABLE OF bdcmsgcoll,
            it_const TYPE TABLE OF /SIE/SSG_XCM_CUC,
            it_vkorg TYPE TABLE OF ty_vkorg.
    Work areas
      DATA: wa_cntrt TYPE ty_cntrt,
            wa_bdc   TYPE bdcdata,
            wa_const TYPE /SIE/SSG_XCM_CUC,
            w_vbak   TYPE vbak,
            w_veda   TYPE veda,
            w_xcm_pr TYPE /sie/ssg_xcm_pr,
            w_vkorg  TYPE ty_vkorg.
    Variables
      DATA: l_repid    TYPE sy-repid,
            l_vakey    TYPE vakey,
            l_variant  TYPE varid-variant,
            l_vbeln    TYPE i,
            l_vkorg    TYPE i,
            l_vkbur    TYPE i,
            l_vkgrp    TYPE i,
            l_ckappl(40)   TYPE c,
            l_ckschl(40)   TYPE c,
            l_cauart(40)   TYPE c.
    Program Constants
      DATA: c_kappl    TYPE kappl,
            c_kschl    TYPE kschl,
            c_auart    TYPE auart,
            c_repco    TYPE /sie/ssg_xcm_const,
            c_value    TYPE /sie/ssg_xcm_value.
    ALV data declarations
      DATA:
          gt_fieldcat  TYPE slis_t_fieldcat_alv,
          gt_tab_group TYPE slis_t_sp_group_alv,
          gs_layout    TYPE slis_layout_alv,
          gs_repid     TYPE sy-repid,
          gs_sort      TYPE TABLE OF slis_sortinfo_alv.
    Selection screen
      SELECTION-SCREEN BEGIN OF BLOCK indletter WITH FRAME TITLE text-001.
      skip one line
        SELECTION-SCREEN SKIP.
        SELECT-OPTIONS:
                     contract
                       so_vbeln FOR w_vbak-vbeln,
                     category
                       so_auart FOR w_vbak-auart NO-DISPLAY,
                     Sales Org
                       so_vkorg FOR w_vbak-vkorg OBLIGATORY,
                     Dis Channel
                       so_vtweg FOR w_vbak-vtweg,
                     Division
                       so_spart FOR w_vbak-spart,
                     Sales Group
                       so_vkgrp FOR w_vbak-vkgrp,
                     Sales Office
                       so_vkbur FOR w_vbak-vkbur OBLIGATORY,
                     Cancellation Procedure
                       so_vkues FOR w_veda-vkuesch OBLIGATORY,
                     Contract Signed Date
                       so_vuntd FOR w_veda-vuntdat,
                     created by
                       so_ernam FOR w_vbak-ernam,
                     Fixed Indexation formula
                       so_fnum  FOR w_xcm_pr-fnum OBLIGATORY.
      skip one line
        SELECTION-SCREEN SKIP.
      Indexation letter
        PARAMETERS: rb_index  RADIOBUTTON GROUP radi USER-COMMAND usr.
      Follow up report
        PARAMETERS: rb_follo  RADIOBUTTON GROUP radi.
      skip one line
        SELECTION-SCREEN SKIP.
      Manual processing checkbox
        PARAMETERS:    p_manpr AS CHECKBOX.
      SELECTION-SCREEN END   OF BLOCK indletter.
    Printer block
      SELECTION-SCREEN BEGIN OF BLOCK blk_par WITH FRAME TITLE text-002.
      Printer
        PARAMETERS:     p_print  LIKE nast-ldest DEFAULT 'LOCL' OBLIGATORY.
      SELECTION-SCREEN END OF BLOCK blk_par.
    User selection data validation
      AT SELECTION-SCREEN ON so_vkorg.
    Ragne for sales org
      RANGES: r_vkorg FOR vbak-vkorg.
      REFRESH: it_const, r_vkorg.
      CLEAR   wa_const.
    Proceed for execution only for Sales Orgs in /SIE/SSG_XCM_CUC
      LOOP AT so_vkorg.
       r_vkorg-sign = 'I'.
       r_vkorg-option = 'EQ'.
       r_vkorg-low    = so_vkorg-low.
       APPEND r_vkorg.
    Check Sales Org intervals entered in the selection screen
       IF NOT so_vkorg-high IS INITIAL.
    Get all Sales Org for interval
         SELECT vkorg FROM tvko INTO TABLE it_vkorg
           WHERE vkorg BETWEEN so_vkorg-low AND so_vkorg-high.
         IF sy-subrc = 0.
         Add all Sales org into one internal table
           LOOP AT it_vkorg INTO w_vkorg.
             r_vkorg-low = w_vkorg-vkorg.
             APPEND r_vkorg.
             CLEAR: w_vkorg.
           ENDLOOP.
         delete repeated records
           DELETE ADJACENT DUPLICATES FROM r_vkorg COMPARING low.
         ENDIF.
       ENDIF.
       CLEAR r_vkorg.
      ENDLOOP.
    Get Sales Org entries maintained in /SIE/SSG_XCM_CUC
      l_repid = sy-repid.
    Check Sales Org is maintained for Renewal Letter?
      LOOP AT r_vkorg.
      concatenate constant with Sales Org
        CONCATENATE 'INX_LETTER_CREATE_' r_vkorg-low INTO c_repco.
      Get constant
        SELECT SINGLE value
          FROM /sie/ssg_xcm_cuc
          INTO c_value
         WHERE repid = l_repid
           AND const = c_repco
           AND vkorg EQ so_vkorg-low.
      Check alerady maintained?
        IF sy-subrc <> 0 OR
          ( sy-subrc = 0 AND c_value <> 'X' ).
        Issue massage 'Sales Org no permitted for renewal Letter'.
          MESSAGE E012.
          CLEAR: c_repco, r_vkorg.
          EXIT.
        ENDIF.
        CLEAR: c_repco, r_vkorg.
      ENDLOOP.
      AT SELECTION-SCREEN.
    Read single Sales Org
       READ TABLE so_vkorg INDEX 1.
       IF sy-subrc = 0.
         CLEAR: l_ckappl, l_ckschl, l_cauart, c_kappl, c_kschl, c_auart.
       for application
         CONCATENATE 'INX_LETTER_V1_' so_vkorg-low INTO l_ckappl.
       for output type
         CONCATENATE 'INX_LETTER_Y6C4_' so_vkorg-low INTO l_ckschl.
       document type
         CONCATENATE 'INX_LETTER_AUART_' so_vkorg-low INTO l_cauart.
       Get application
         SELECT SINGLE value FROM /sie/ssg_xcm_cuc
           INTO c_kappl WHERE repid = sy-repid AND const LIKE l_ckappl.
       Get output type
         SELECT SINGLE value FROM /sie/ssg_xcm_cuc
           INTO c_kschl WHERE repid = sy-repid AND const LIKE l_ckschl.
       Get document type
         SELECT SINGLE value FROM /sie/ssg_xcm_cuc
           INTO c_auart WHERE repid = sy-repid AND const LIKE l_cauart.
       ENDIF.
    find no of Sales org entries entered in the selection screen
       DESCRIBE TABLE so_vkorg LINES l_vkorg.
    find no of Sales office entries entered in the selection screen
       DESCRIBE TABLE so_vkbur LINES l_vkbur.
    find no of Sales Group entries entered in the selection screen
       DESCRIBE TABLE so_vkgrp LINES l_vkgrp.
    Check if enterred more than one entry
       IF l_vkorg = 1 AND l_vkbur = 1.
         add Sales Org, Sales office, Sales group for key
         IF NOT so_vkgrp[] IS INITIAL.
           CONCATENATE so_vkorg-low so_vkbur-low so_vkgrp-low INTO l_vakey.
         ELSE.
           CONCATENATE so_vkorg-low so_vkbur-low '%' INTO l_vakey.
         ENDIF.
         CONDENSE l_vakey.
       Get printer name for selection.
         SELECT SINGLE ldest FROM nach INTO p_print
          WHERE kappl = c_kappl AND kschl = c_kschl AND vakey LIKE l_vakey.
       ENDIF.
    Manual processing is possible for Renewal Letter in advance only
      IF p_manpr = 'X' AND rb_follo = 'X'.
        MESSAGE E017.
      ENDIF.
    Main Processing
    START-OF-SELECTION.
      Check for the Follow up report
        IF rb_follo = 'X'.
        Call Follow up report with Selection criteria
          SUBMIT /SIE/SWE_XCM_INDEX_FOLLOWUP
           USING SELECTION-SET l_variant
            WITH so_vbeln IN so_vbeln
            WITH so_vkorg IN so_vkorg
            WITH so_vtweg IN so_vtweg
            WITH so_spart IN so_spart
            WITH so_vkgrp IN so_vkgrp
            WITH so_vkbur IN so_vkbur
            WITH so_vkues IN so_vkues
            WITH so_vuntd IN so_vuntd
            WITH so_ernam IN so_ernam
            WITH so_fnum  IN so_fnum
            WITH p_kappl  EQ c_kappl
            WITH p_kschl  EQ c_kschl
            WITH p_auart  EQ c_auart
          AND RETURN.
        ELSE.
        Process for Indexation Report
          gs_repid = sy-repid.
        Get data.
          PERFORM get_data.
        Filter data based on Siemens France rules
          PERFORM process_data.
        Check contract data is available for selection criteria
          IF NOT it_cntrt[] IS INITIAL.
          create ALV output header
            PERFORM alv_fieldcat USING gt_fieldcat[].
          create ALV layout
            PERFORM alv_layout CHANGING gs_layout.
          Sort ALV output
            PERFORM alv_sort.
          display filtered contract data
            PERFORM output_data.
          ELSE.
          Display a message 'No records found'.
            MESSAGE I011.
            EXIT.
          ENDIF.
        ENDIF.
    *&      Form  get_data
          Retrieve contracts data from tables
    -->  p1        text
    <--  p2        text
    FORM get_data.
    Get contract data from VBAK and VEDA.
      SELECT avbeln   aaudat   a~kunnr
             bvuntdat bvbegdat
             bvdemdat bvenddat
        INTO CORRESPONDING FIELDS OF TABLE it_cntrt
        FROM vbak AS a INNER JOIN veda AS b
          ON avbeln = bvbeln
       WHERE a~vbeln   IN so_vbeln
         AND a~auart   EQ c_auart
         AND a~vkorg   IN so_vkorg
         AND a~vtweg   IN so_vtweg
         AND a~spart   IN so_spart
         AND a~vkgrp   IN so_vkgrp
         AND a~vkbur   IN so_vkbur
         AND a~ernam   IN so_ernam
         AND b~vposn   = '000000'
         AND b~vkuesch IN so_vkues
         AND b~vuntdat IN so_vuntd.
    ENDFORM.                    " get_data
    *&      Form  process_data
          text
    -->  p1        text
    <--  p2        text
    FORM process_data.
    Internal tables
      DATA: l_nast   TYPE TABLE OF nast,
            it_pr    TYPE TABLE OF /sie/ssg_xcm_pr.
    Work areas
      DATA: w_nast   TYPE nast,
            wa_pr    TYPE /sie/ssg_xcm_pr.
    local Variables
      DATA: l_datum1 TYPE sy-datum,
            l_datum2 TYPE sy-datum,
            l_d3last TYPE sy-datum,
            l_d3next TYPE sy-datum.
    current date.
      l_datum1 = sy-datum.
    Calcuate date after 3 months.
      CALL FUNCTION 'DATE_CREATE'
        EXPORTING
          ANZAHL_MONATE        = 3
          DATUM_EIN            = l_datum1
        IMPORTING
          DATUM_AUS            = l_datum2.
      l_datum2 = l_datum2 - 1.
      SORT it_cntrt BY KUNNR VBELN.
    Get corresponding records from /SIE/SSG_XCM_PR.
      SELECT vbeln posnr fnum
          FROM /SIE/SSG_XCM_PR
          INTO CORRESPONDING FIELDS OF TABLE it_pr
           FOR ALL ENTRIES IN it_cntrt
         WHERE vbeln = it_cntrt-vbeln
          AND posnr = it_cntrt-vposn
           AND fnum IN so_fnum.
    clear workarea
      CLEAR wa_cntrt.
    filter contracts agaist the table /SIE/SSG_XCM_PR records.
      LOOP AT it_cntrt INTO wa_cntrt.
        CLEAR wa_pr.
      check contracts available in table /SIE/SSG_XCM_PR
        READ TABLE it_pr INTO wa_pr WITH KEY vbeln = wa_cntrt-vbeln.
        IF sy-subrc <> 0.
            DELETE it_cntrt.
            CLEAR wa_pr.
            CONTINUE.
        ELSEIF sy-subrc = 0 AND NOT wa_pr-fnum IN so_fnum.
      if not available, do not consider this contract
            DELETE it_cntrt.
            CLEAR wa_pr.
            CONTINUE.
        ENDIF.
         Dont consider contracts expires before today and after 3 months.
        IF wa_cntrt-vdemdat > l_datum1.   "current date
               IF wa_cntrt-vdemdat(6) > l_datum2(6). "AND   "after 3 months
               delete contract
                 DELETE it_cntrt.
                 CLEAR wa_cntrt.
                 CONTINUE.
               ENDIF.
        ELSE.
            DELETE it_cntrt.
            CLEAR wa_cntrt.
            CONTINUE.
        ENDIF.
      Is contract renewal letter has been sent already?
      Get all records from NAST to find letter sent?
        SELECT kappl objky kschl nacha datvr
          FROM NAST
          INTO CORRESPONDING FIELDS OF TABLE l_nast
         WHERE kappl = c_kappl
           AND objky = wa_cntrt-vbeln
           AND kschl = c_kschl
           AND nacha = '1'.
        IF sy-subrc = 0.
           sort renewal letter sent dates by latest is first
             SORT l_nast BY datvr DESCENDING.
           Get latest nast record
             READ TABLE l_nast INTO w_nast INDEX 1.
             IF sy-subrc = 0.
                IF p_manpr <> 'X'.  " ignore 3 month logic
                    l_d3next = wa_cntrt-vdemdat(06).
                    l_d3next+6(2) = '01'.
                  Calcuate date after 3 months.
                    CALL FUNCTION 'DATE_CREATE'
                      EXPORTING
                        ANZAHL_MONATE        = -3
                        DATUM_EIN            = l_d3next
                      IMPORTING
                        DATUM_AUS            = l_d3last.
                    l_d3last = l_d3last + 1.
                  Check letter already sent year equals current year
                    IF w_nast-datvr BETWEEN l_d3last AND wa_cntrt-vdemdat.
                     do not consider it
                       DELETE it_cntrt.
                       CLEAR: l_d3last, wa_cntrt, w_nast, l_d3next.
                       CONTINUE.
                    ENDIF.
                ENDIF.
             ENDIF.
        ENDIF.
      no leading zeros to contract
        WRITE wa_cntrt-vbeln TO wa_cntrt-vbeln1 NO-ZERO.
      modify internal table
        MODIFY it_cntrt FROM wa_cntrt.
        CLEAR: l_nast, w_nast.
      ENDLOOP.
    ENDFORM.                    " process_data
    *&      Form  output_data
          text
    -->  p1        text
    <--  p2        text
    FORM output_data.
    Display output in a ALV Grid
       CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
           I_CALLBACK_PROGRAM                = gs_repid
           I_CALLBACK_PF_STATUS_SET          = 'ALV_STATUS'
           I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
           IS_LAYOUT                         = gs_layout
           IT_FIELDCAT                       = gt_fieldcat
           IT_SORT                           = gs_sort
           I_SAVE                            = 'A'
         TABLES
           T_OUTTAB                          = it_cntrt
         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.                    " output_data
    *&      Form  alv_header
          text
    -->  p1        text
    <--  p2        text
    FORM alv_fieldcat USING gs_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: ls_fieldcat TYPE slis_fieldcat_alv.
    Sold-to Party header
      ls_fieldcat-col_pos = 1.
      ls_fieldcat-fieldname = 'KUNNR'.
      ls_fieldcat-seltext_m = 'Sold-to Party'.
      ls_fieldcat-outputlen = 14.
      ls_fieldcat-datatype  = 'CHAR'.
      ls_fieldcat-key       = 'X'.
      APPEND ls_fieldcat TO gs_fieldcat.
      CLEAR ls_fieldcat.
    Contract number
      ls_fieldcat-col_pos = 2.
      ls_fieldcat-fieldname = 'VBELN'.
      ls_fieldcat-seltext_m = 'Contract Number'.
      ls_fieldcat-outputlen = 20.
      ls_fieldcat-datatype  = 'CHAR'.
      APPEND ls_fieldcat TO gs_fieldcat.
      CLEAR ls_fieldcat.
    Contract Signed Date
      ls_fieldcat-col_pos = 3.
      ls_fieldcat-fieldname = 'VUNTDAT'.
      ls_fieldcat-seltext_m = 'Contract signed date'.
      ls_fieldcat-outputlen = 20.
      ls_fieldcat-datatype  = 'DATS'.
      APPEND ls_fieldcat TO gs_fieldcat.
      CLEAR ls_fieldcat.
    Contract Start Date
      ls_fieldcat-col_pos = 4.
      ls_fieldcat-fieldname = 'VBEGDAT'.
      ls_fieldcat-seltext_m = 'Contract start date'.
      ls_fieldcat-outputlen = '20'.
      ls_fieldcat-datatype  = 'DATS'.
      APPEND ls_fieldcat TO gs_fieldcat.
      CLEAR ls_fieldcat.
    Dismantling date
      ls_fieldcat-col_pos = 5.
      ls_fieldcat-fieldname = 'VDEMDAT'.
      ls_fieldcat-seltext_m = 'Dismantling date'.
      ls_fieldcat-outputlen = 14.
      ls_fieldcat-datatype  = 'DATS'.
      APPEND ls_fieldcat TO gs_fieldcat.
      CLEAR ls_fieldcat.
    ENDFORM.                    " alv_header
    *&      Form  alv_layout
          text
    -->  p1        text
    <--  p2        text
    FORM alv_layout USING ls_layout TYPE slis_layout_alv.
    No input
      ls_layout-no_input          = 'X'.
    Column width is flexible
    ls_layout-colwidth_optimize = 'X'.
      ls_layout-box_fieldname = 'BOX'.
      ls_layout-info_fieldname = 'LINE_COLOR'.
      ls_layout-zebra = 'X'.
      ls_layout-get_selinfos = 'X'.
      ls_layout-reprep = 'X'.
    ENDFORM.                    " alv_layout
    *&      Form  alv_status
          text
    -->  p1        text
    <--  p2        text
    FORM alv_status USING rt_extab TYPE slis_t_extab.
    GUI Status and Application Toolbar
      SET PF-STATUS '/SIE/SWE_XCM_INDEXLE'.
    ENDFORM.
    *&      Form  user_command
          text
    -->  p1        text
    <--  p2        text
    FORM user_command USING l_ucomm      LIKE sy-ucomm
                            l_selfield   TYPE slis_selfield.
      RANGES: r_kappl FOR nast-kappl,
              r_objky FOR nast-objky,
              r_kschl FOR nast-kschl,
              r_nacha FOR nast-nacha.
      DATA: l_jobname  TYPE TBTCJOB-JOBNAME,
            l_jobcount TYPE TBTCJOB-JOBCOUNT,
            l_repid    TYPE sy-repid,
            l_print_params TYPE PRI_PARAMS,
            l_arc_params   TYPE ARC_PARAMS,
            l_valid        TYPE c,
            l_retcode      TYPE sy-subrc,
            l_blines       TYPE i.
      CASE l_ucomm.
      Process button seleted
        WHEN c_sform.
        process selected records.
          LOOP AT it_cntrt INTO wa_cntrt.
             IF wa_cntrt-box = 'X'.
              place output type in the contract
                PERFORM bdc_output USING wa_cntrt
                                   CHANGING l_retcode.
                IF l_retcode = 0.
                add record for jobground job
                  r_objky-sign   = 'I'.
                  r_objky-option = 'EQ'.
                  r_objky-low    = wa_cntrt-vbeln.
                  APPEND r_objky.
                ENDIF.
                CLEAR: wa_cntrt, l_retcode, r_objky.
             ENDIF.
          ENDLOOP.
        WHEN c_dclick.
        set contract number id with the selected contract
          SET PARAMETER ID 'AUN' FIELD l_selfield-value.
          SET PARAMETER ID 'KTN' FIELD l_selfield-value.
        call va42 tcode when double click on contract
          CALL TRANSACTION c_tcode AND SKIP FIRST SCREEN.
      ENDCASE.
      DESCRIBE TABLE r_objky LINES l_blines.
    IF NOT r_objky[] IS INITIAL.
      IF l_blines > 0.
        Background job name.
          CONCATENATE 'XCM_INDEXATION' sy-uname '_' sy-uzeit
                 INTO l_jobname.
        Application
          r_kappl-sign   = 'I'.
          r_kappl-option = 'EQ'.
          r_kappl-low    = 'V1'.
          APPEND r_kappl.
        Message Type
          r_kschl-sign   = 'I'.
          r_kschl-option = 'EQ'.
          r_kschl-low    = c_kschl.
          APPEND r_kschl.
        Message transmission medium
          r_nacha-sign   = 'I'.
          r_nacha-option = 'EQ'.
          r_nacha-low    = '1'.
          APPEND r_nacha.
          l_repid = sy-repid.
        Print Parameters
          CALL FUNCTION 'GET_PRINT_PARAMETERS'
            EXPORTING
              DESTINATION                  = p_print
              MODE                         = c_batch
              NO_DIALOG                    = 'X'
              REPORT                       = l_repid
              EXPIRATION                   = 2
              IMMEDIATELY                  = 'X'
              NEW_LIST_ID                  = 'X'
            IMPORTING
              OUT_ARCHIVE_PARAMETERS       = l_arc_params
              OUT_PARAMETERS               = l_print_params
              VALID                        = l_valid
            EXCEPTIONS
              ARCHIVE_INFO_NOT_FOUND       = 1
              INVALID_PRINT_PARAMS         = 2
              INVALID_ARCHIVE_PARAMS       = 3
              OTHERS                       = 4.
          IF SY-SUBRC <> 0.
             MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                      WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        opening the job
          CALL FUNCTION 'JOB_OPEN'
            EXPORTING
              JOBNAME                = l_jobname
            IMPORTING
              JOBCOUNT               = l_jobcount
           EXCEPTIONS
             CANT_CREATE_JOB        = 1
             INVALID_JOB_DATA       = 2
             JOBNAME_MISSING        = 3
             OTHERS                 = 4.
          IF SY-SUBRC <> 0.
           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                   WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        Job submit
          SUBMIT /sie/swe_xcm_index_rsnast00 TO SAP-SPOOL
                          USER sy-uname
                          WITH s_kappl IN r_kappl
                          WITH s_objky IN r_objky
                          WITH s_kschl IN r_kschl
                          WITH s_nacha IN r_nacha
                          WITH p_print  EQ p_print
             VIA JOB l_jobname NUMBER l_jobcount
             SPOOL PARAMETERS l_print_params
             WITHOUT SPOOL DYNPRO
             AND RETURN.
          IF sy-subrc <> 0.
          display message when error in scheduling background job
            MESSAGE E016 WITH 'Error scheduling Job'.
          ENDIF.
        Job close
          CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              JOBCOUNT                          = l_jobcount
              JOBNAME                           = l_jobname
              STRTIMMED                         = 'X'
           EXCEPTIONS
             CANT_START_IMMEDIATE              = 1
             INVALID_STARTDATE                 = 2
             JOBNAME_MISSING                   = 3
             JOB_CLOSE_FAILED                  = 4
             JOB_NOSTEPS                       = 5
             JOB_NOTEX                         = 6
             LOCK_FAILED                       = 7
             OTHERS                            = 8.
          IF SY-SUBRC <> 0.
             MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                     WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
      ENDIF.
    ENDFORM.
    *&      Form  bdc_output
          text
    -->  p1        text
    <--  p2        text
    FORM bdc_output USING    wa_cntrt  TYPE ty_cntrt
                    CHANGING l_retcode TYPE sy-subrc.
    DATA: l_nast TYPE TABLE OF nast,
           it_nast TYPE TABLE OF nast,
           w_nast TYPE nast,
           l_cellno(2) TYPE n,
           l_vbelv TYPE vbfa-vbelv,
           l_vbpa  TYPE vbpa,
           l_yes(1),
           l_temp(40) TYPE c,
           l_lines    TYPE i,
           l_lesscnt  TYPE i,
           l_less(1),
           l_lines1(2) TYPE n.
        REFRESH: it_nast, l_nast, it_bdc.
        CLEAR: l_nast, w_nast, l_yes, l_cellno,
               it_nast, l_nast, it_bdc.
        PERFORM dyn_scr USING 'SAPMV45A' '0102' 'X'.
          PERFORM dyn_fld USING 'VBAK-VBELN' wa_cntrt-vbeln.
          PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
        PERFORM dyn_scr USING 'SAPMV45A' '4001' 'X'.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=HEAD'.
        PERFORM dyn_scr USING 'SAPMV45A' '4002' 'X'.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=KDOK'.
        SELECT *
          FROM nast
          INTO CORRESPONDING FIELDS OF TABLE l_nast
         WHERE kappl = c_kappl
           AND objky = wa_cntrt-vbeln.
        IF sy-subrc = 0.
            SORT l_nast BY kschl vstat.
            DESCRIBE TABLE l_nast LINES l_lines.
            LOOP AT l_nast INTO w_nast.
                l_cellno = sy-tabix.
                IF w_nast-kschl = c_kschl AND w_nast-vstat = 0.
                  EXIT.
                ENDIF.
                IF w_nast-kschl > c_kschl OR
                   ( w_nast-kschl = c_kschl AND w_nast-vstat <> 0 ).
                   IF l_less = space.
                     l_cellno = l_cellno - 1.
                   ENDIF.
                   CLEAR l_less.
                  IF l_cellno = 0.
                     l_cellno = 1.
                  ENDIF.
                  l_lines = l_lines + 1.
                  l_lines1 = l_lines.
                  PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
                    CONCATENATE 'DNAST-KSCHL(' l_lines1 ')' INTO l_temp.
                    CONDENSE l_temp.
                    PERFORM dyn_fld USING l_temp 'Y6C4'.
                    CLEAR: l_temp, l_lines, l_lines1.
                    PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
                  EXIT.
                ELSEIF w_nast-kschl < c_kschl.
                  l_less = 'X'.
                  l_lesscnt = l_lesscnt + 1.
                ENDIF.
            ENDLOOP.
        ELSE.
            l_cellno = '01'.
            PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
              CONCATENATE 'DNAST-KSCHL(' l_cellno ')' INTO l_temp.
              CONDENSE l_temp.
              PERFORM dyn_fld USING l_temp 'Y6C4'.
              CLEAR l_temp.
              PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
        ENDIF.
        IF l_less = 'X'.
            l_lesscnt = l_lesscnt + 1.
                  l_cellno = l_lesscnt.
                  l_lines = l_lines + 1.
                  l_lines1 = l_lines.
                  PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
                    CONCATENATE 'DNAST-KSCHL(' l_lines1 ')' INTO l_temp.
                    CONDENSE l_temp.
                    PERFORM dyn_fld USING l_temp 'Y6C4'.
                    CLEAR: l_temp, l_lines, l_lines1.
                    PERFORM dyn_fld USING 'BDC_OKCODE' '/00'.
        ENDIF.
        PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
          CONCATENATE 'DV70A-SELKZ(' l_cellno ')' INTO l_temp.
          CONDENSE l_temp.
          PERFORM dyn_fld USING l_temp 'X'.
          CLEAR l_temp.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=V70P'.
        PERFORM dyn_scr USING 'SAPDV70A' '0101' 'X'.
          PERFORM dyn_fld USING 'NAST-LDEST' p_print.
          PERFORM dyn_fld USING 'NAST-DIMME' 'X'.
          PERFORM dyn_fld USING 'NAST-TDARMOD' '1'.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=V70B'.
        PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
          CONCATENATE 'DV70A-SELKZ(' l_cellno ')' INTO l_temp.
          CONDENSE l_temp.
          PERFORM dyn_fld USING l_temp 'X'.
          CLEAR l_temp.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=V70I'.
        PERFORM dyn_scr USING 'SAPDV70A' '0102' 'X'.
          PERFORM dyn_fld USING 'NAST-VSZTP' '1'.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=V70B'.
        PERFORM dyn_scr USING 'SAPDV70A' '0100' 'X'.
          PERFORM dyn_fld USING 'BDC_OKCODE' '=V70S'.
        CALL TRANSACTION c_tcode USING it_bdc
                                 MODE c_mode     "'N'
                                 UPDATE c_updat  "'A'
                                 MESSAGES INTO it_mesg.
        IF sy-subrc = 0.
          l_retcode = 0.
        ENDIF.
    ENDFORM.                    " bdc_output
    *&      Form  dyn_scr
          text
         -->P_0642   text
         -->P_0643   text
         -->P_0644   text
    FORM dyn_scr USING    P_0642
                          P_0643
                          P_0644.
        MOVE:  p_0642 TO wa_bdc-program,
               p_0643 TO wa_bdc-dynpro,
               p_0644 TO wa_bdc-dynbegin.
        APPEND wa_bdc TO it_bdc.
        CLEAR wa_bdc.
    ENDFORM.                    " dyn_scr
    *&      Form  dyn_fld
          text
         -->P_0654   text
         -->P_0655  text
    FORM dyn_fld USING    P_0654
                          P_0655.
       MOVE: p_0654 TO wa_bdc-fnam,
             p_0655 TO wa_bdc-fval.
       APPEND wa_bdc TO it_bdc.
       CLEAR wa_bdc.
    ENDFORM.                    " dyn_fld
    *&      Form  alv_sort
          text
    FORM alv_sort.
      DATA: wa_sortcat  TYPE slis_sortinfo_alv.
      WA_SORTCAT-SPOS      = 1.
      WA_SORTCAT-FIELDNAME = 'KUNNR'.
      WA_SORTCAT-UP        = 'X'.
      WA_SORTCAT-EXPA      = 'X'.
    Appending gd_sortcat-tabname
      APPEND WA_SORTCAT TO gs_sort.
      CLEAR wa_sortcat.
      WA_SORTCAT-SPOS      = 2.
      WA_SORTCAT-FIELDNAME = 'VBELN'.
      WA_SORTCAT-UP        = 'X'.
      WA_SORTCAT-EXPA      = 'X'.
    Appending gd_sortcat-tabname
      APPEND WA_SORTCAT TO gs_sort.
      WA_SORTCAT-SPOS      = 3.
      WA_SORTCAT-FIELDNAME = 'VUNTDAT'.
      WA_SORTCAT-UP        = 'X'.
      WA_SORTCAT-EXPA      = 'X'.
    Appending gd_sortcat-tabname
      APPEND WA_SORTCAT TO gs_sort.
    ENDFORM.                    " alv_sort

Maybe you are looking for