ALV Grid Calling Transaction Code

Hello Everybody
Can anyone help me about my problem in using ALV Grid calling a transaction code...?Here is the sample code below..
       IF rs_selfield-fieldname = 'BELNR'.
        SET PARAMETER ID 'BLN' FIELD  rs_selfield-value.
        CALL TRANSACTION 'FB03'  AND SKIP FIRST SCREEN.
      ENDIF.
the main problem is how can I set my parameter id for company since
my rs_field-value is for the column BELNR ( document # field only)
it returns error when i set this code since i have no value to pass for rs_selfield for company code
        SET PARAMETER ID 'BUK' FIELD 
Help
thanks in advance
aVaDuDz

Hi,
*"Table declarations...................................................
TABLES:
  rbkp,                                " Document Header Invoice receipt
  rseg,                                " Document Item: Incoming Invoice
  eban,                                " Purchase Requisition
  t001w.                               " Plants/Branches
*"Selection screen elements............................................
PARAMETERS:
  p_gjahr LIKE rbkp-gjahr.             " Fiscal Year
SELECT-OPTIONS:
  s_belnr FOR rbkp-belnr,              " Document number of an invoice
  s_bldat FOR rbkp-bldat,              " Document Date in Document
  s_budat FOR rbkp-budat,              " Posting Date in the Document
  s_werks FOR rseg-werks.              " Plant
*" Data declarations...................................................
Work variables                                                      *
DATA:
  w_flag1  TYPE c VALUE '0',           " Flag variable 1
  w_flag2  TYPE c VALUE '0',           " Flag variable 2
  w_index1 TYPE sy-tabix.              " Index variable
Field String to hold Document Header Invoice receipt                *
DATA:
  BEGIN OF fs_rbkp,
    belnr TYPE rbkp-belnr,             " Document number of an invoice
    gjahr TYPE rbkp-gjahr,             " Fiscal Year
    bldat TYPE rbkp-bldat,             " Posting Date in the Document
    budat TYPE rbkp-budat,             " Posting Date in the Document
    lifnr TYPE rbkp-lifnr,             " Different invoicing party
  END OF fs_rbkp,
Internal table to hold Document Header Invoice receipt              *
  t_rbkp LIKE STANDARD TABLE OF fs_rbkp.
Field String to hold Document Item: Incoming Invoice                *
DATA:
  BEGIN OF fs_rseg,
    belnr TYPE rseg-belnr,             " Document number of an invoice
    ebeln TYPE rseg-ebeln,             " Purchasing Document Number
    wrbtr TYPE rseg-wrbtr,             " Amount in document currency
  END OF fs_rseg,
Internal table to hold Document Item: Incoming Invoice              *
t_rseg LIKE STANDARD TABLE OF fs_rseg.
Field String to hold Purchase Requisition                           *
DATA:
  BEGIN OF fs_eban,
    banfn TYPE eban-banfn,             " Purchase requisition number
    ernam TYPE eban-ernam,             " Person who Created the Object
    afnam TYPE eban-afnam,             " Name of requisitioner/requester
    badat TYPE eban-badat,             " Requisition (request) date
    ebeln TYPE eban-ebeln,             " Purchase order number
  END OF fs_eban,
Internal table to hold Purchase Requisition                         *
  t_eban LIKE STANDARD TABLE OF fs_eban.
Field String to hold Desired Data                                   *
DATA:
  BEGIN OF fs_final,
    ebeln TYPE rseg-ebeln,             " Purchasing Document Number
    banfn TYPE eban-banfn,             " Purchase requisition number
    badat TYPE eban-badat,             " Requisition (request) date
    bldat TYPE rbkp-bldat,             " Posting Date in the Document
    lifnr TYPE rbkp-lifnr,             " Different invoicing party
    wrbtr TYPE rseg-wrbtr,             " Amount in document currency
    afnam TYPE eban-afnam,             " Name of requisitioner/requester
    ernam TYPE eban-ernam,             " Name of Person who Created the
                                       " Object
  END OF fs_final,
Internal table to hold Desired Data                                 *
  t_final LIKE STANDARD TABLE OF fs_final.
                      INITIALIZATION                                *
INITIALIZATION.
  p_gjahr = sy-datum+0(4).
                      AT SELECTION-SCREEN EVENT                     *
AT SELECTION-SCREEN.
  IF s_belnr IS INITIAL OR s_bldat IS INITIAL OR s_budat IS INITIAL.
    MESSAGE ' (Invoice) Add Creation Date .' TYPE 'E'.
  ENDIF.                               " IF S_BELNR...
                      AT SELECTION-SCREEN ON FIELD EVENT            *
AT SELECTION-SCREEN ON s_werks.
  SELECT SINGLE werks                  " Plant
    FROM t001w
    INTO t001w
   WHERE werks IN s_werks.
  IF sy-subrc NE 0.
    MESSAGE 'Invalid plant' TYPE 'E'.
  ENDIF.                               " IF SY-SUBRC NE 0.
                      START-OF-SELECTION EVENT                      *
START-OF-SELECTION.
  PERFORM get_purchaserequistion.
  LOOP AT t_rseg INTO fs_rseg.
    READ TABLE t_rbkp INTO fs_rbkp WITH KEY belnr = fs_rseg-belnr
                                                    BINARY SEARCH.
    IF sy-subrc EQ 0.
      READ TABLE t_eban INTO fs_eban WITH KEY ebeln = fs_rseg-ebeln
                                                    BINARY SEARCH.
      IF sy-subrc EQ 0.
        IF fs_rbkp-bldat LE fs_eban-badat.
          DELETE t_rseg INDEX sy-tabix.
        ENDIF.                         " IF FS_RBKP-BLDAT...
      ENDIF.                           " IF SY-SUBRC EQ 0
    ENDIF.                             " IF SY-SUBRC EQ 0
  ENDLOOP.                             " LOOP AT T_RSEG...
  LOOP AT t_rbkp INTO fs_rbkp.
    WHILE w_flag1 EQ '0'.
      READ TABLE t_rseg INTO fs_rseg WITH KEY belnr = fs_rbkp-belnr
                                                      BINARY SEARCH.
      w_index1 = sy-tabix.
      IF sy-subrc EQ 0.
        WHILE w_flag2 EQ '0'.
          READ TABLE t_eban INTO fs_eban WITH KEY ebeln = fs_rseg-ebeln
                                                          BINARY SEARCH.
          IF sy-subrc EQ 0.
            fs_final-bldat = fs_rbkp-bldat.
            fs_final-lifnr = fs_rbkp-lifnr.
            fs_final-ebeln = fs_rseg-ebeln.
            fs_final-wrbtr = fs_rseg-wrbtr.
            fs_final-banfn = fs_eban-banfn.
            fs_final-badat = fs_eban-badat.
            fs_final-afnam = fs_eban-afnam.
            fs_final-ernam = fs_eban-ernam.
            APPEND fs_final  TO t_final.
            CLEAR fs_final.
            DELETE t_eban INDEX sy-tabix .
          ELSE.
            w_flag2 = '1'.
            DELETE t_rseg INDEX w_index1.
          ENDIF.                       " IF SY-SUBRC EQ 0
        ENDWHILE.                      " WHILE W_FLAG2...
        w_flag2 = '0'.
      ELSE.
        w_flag1 = '1'.
      ENDIF.                           " IF SY-SUBRC EQ 0
    ENDWHILE.                          " WHILE W_FLAG1...
    w_flag1 = '0'.
  ENDLOOP.                             " LOOP AT T_RBKP...
  CLASS lcl_event_receiver DEFINITION DEFERRED.
Declare reference variables to the ALV grid and the container
  DATA :
    cust_con TYPE scrfname VALUE 'BCALVC_TOOLBAR_D100_C1',
    cont_on_dialog TYPE scrfname VALUE 'BCALVC_TOOLBAR_D101_C1',
    ref1 TYPE REF TO cl_gui_custom_container,
    ref2 TYPE REF TO cl_gui_alv_grid,
    event_receiver TYPE REF TO lcl_event_receiver,
    fcat    TYPE lvc_t_fcat,
    wa      TYPE lvc_s_fcat,
    wa_layo TYPE lvc_s_layo.
  CALL SCREEN 200.
class lcl_event_receiver: local class to define and handle own
*functions......................................................
Definition:
CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:
    handle_toolbar
        FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING e_object e_interactive,
    handle_user_command
        FOR EVENT user_command OF cl_gui_alv_grid
            IMPORTING e_ucomm.
  PRIVATE SECTION.
ENDCLASS.                    "lcl_event_receiver DEFINITION
class lcl_event_receiver (Implementation)
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_toolbar.
In event handler method for event TOOLBAR: Append own functions
  by using event parameter E_OBJECT.
    DATA: ls_toolbar  TYPE stb_button.
E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
append a separator to normal toolbar
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.
    APPEND ls_toolbar TO e_object->mt_toolbar.
append an icon to show booking table
    CLEAR ls_toolbar.
    MOVE 'PORDER' TO ls_toolbar-function.
    MOVE icon_employee TO ls_toolbar-icon.
    MOVE 'Show Bookings' TO ls_toolbar-quickinfo.
    MOVE 'PONUMBER' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
append a separator to normal toolbar
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.
    APPEND ls_toolbar TO e_object->mt_toolbar.
append an icon to show booking table
    CLEAR ls_toolbar.
    MOVE 'PREQUISITION' TO ls_toolbar-function.
    MOVE icon_employee TO ls_toolbar-icon.
    MOVE 'Show Bookings' TO ls_toolbar-quickinfo.
    MOVE 'PRNUMBER' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
  ENDMETHOD.                           " handle_toolbar
  METHOD handle_user_command.
*Event handler method for event USER_COMMAND:
    CASE e_ucomm.
      WHEN 'PORDER'.
        CALL TRANSACTION 'ME23N'.
      WHEN 'PREQUISITION'.
        CALL TRANSACTION 'ME53N'.
    ENDCASE.
  ENDMETHOD.                           " handle_user_command
ENDCLASS.                              " lcl_event_receiver
*& Module STATUS_0200 OUTPUT
text
MODULE status_0200 OUTPUT.
  SET PF-STATUS 'GUI'.
  SET TITLEBAR 'TITLE'.
  IF sy-ucomm = 'BACK'.
    LEAVE PROGRAM.
  ENDIF.
  PERFORM form_fcat.
  PERFORM form_layo.
  IF ref1 IS INITIAL.
    CREATE OBJECT ref1
    EXPORTING
PARENT = ref1
    container_name = 'CUST_CON'
STYLE =
LIFETIME = lifetime_default
REPID =
DYNNR =
NO_AUTODEF_PROGID_DYNNR =
    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.
  IF ref2 IS INITIAL.
    CREATE OBJECT ref2
    EXPORTING
I_SHELLSTYLE = 0
I_LIFETIME =
    i_parent = ref1
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.
    CALL METHOD ref2->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 = wa_layo
IS_PRINT =
IT_SPECIAL_GROUPS =
IT_TOOLBAR_EXCLUDING =
IT_HYPERLINK =
IT_ALV_GRAPHICS =
IT_EXCEPT_QINFO =
    CHANGING
    it_outtab = t_final
    it_fieldcatalog = fcat
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.
    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_user_command FOR ref2.
    SET HANDLER event_receiver->handle_toolbar FOR ref2.
*Call method 'set_toolbar_interactive' to raise event TOOLBAR.
    CALL METHOD ref2->set_toolbar_interactive.
  ENDIF.
ENDMODULE.                             " STATUS_0200 OUTPUT
Form FORM_FCAT                                                     *
text                                                               *
FORM form_fcat.
  CLEAR fcat.
  CLEAR wa.
  wa-fieldname = 'EBELN'.
  wa-col_pos = 1.
  wa-scrtext_l = ' PURCHASE ORDER NUMBER'.
  APPEND wa TO fcat.
  CLEAR wa.
  wa-fieldname = 'BANFN'.
  wa-col_pos = 2.
  wa-scrtext_l = 'PURCHASE REQUISITION NUMBER'.
  APPEND wa TO fcat.
  CLEAR wa.
  wa-fieldname = 'BADAT'.
  wa-col_pos = 3.
  wa-scrtext_l = 'PR CREATION DATE'.
  APPEND wa TO fcat.
  CLEAR wa.
  wa-fieldname = 'BLDAT'.
  wa-col_pos = 4.
  wa-scrtext_l = 'INVOICE DATE'.
  APPEND wa TO fcat.
  CLEAR wa.
  wa-fieldname = 'LIFNR'.
  wa-col_pos = 5.
  wa-scrtext_l = 'VENDOR NUMBER'.
  APPEND wa TO fcat.
  wa-fieldname = 'WRBTR'.
  wa-col_pos = 6.
  wa-do_sum  = 'X'.
  wa-scrtext_l = ' PO AMOUNT'.
  APPEND wa TO fcat.
  wa-fieldname = 'AFNAM'.
  wa-col_pos = 7.
  wa-scrtext_l = 'REQUISITIONER'.
  APPEND wa TO fcat.
  wa-fieldname = 'ERNAM'.
  wa-col_pos = 8.
  wa-scrtext_l = 'PR CREATOR'.
  APPEND wa TO fcat.
ENDFORM.                               " FORM_FCAT
Module USER_COMMAND_0200 INPUT                                      *
text                                                                *
MODULE user_command_0200 INPUT.
  CASE sy-ucomm.
    WHEN 'BACK' OR 'CANCEL' OR 'EXIT'.
      LEAVE PROGRAM.
  ENDCASE.
ENDMODULE.                             " USER_COMMAND_0200 INPUT
     FORM FORM_LAYO                                                *
There are no interface parameters to be passed to this subroutine.*
FORM form_layo.
  CLEAR wa_layo.
  wa_layo-zebra = 'X'.
  wa_layo-grid_title = 'GRID TITLE'.
  wa_layo-no_toolbar = 'X'.
ENDFORM.                               " FORM_LAYO
     FORM GET_PURCHASEREQUISITION                                   *
This subroutine selects all the Purchase requisitions from table   *
EBAN for all the selected Invoices based on the Purchase orders.   *
There are no interface parameters to be passed to this subroutine. *
FORM get_purchaserequistion.
  SELECT belnr                         " Document number of an invoice
         gjahr                         " Fiscal Year
         bldat                         " Posting Date in the Document
         budat                         " Posting Date in the Document
         lifnr                         " Different invoicing party
    FROM rbkp
    INTO TABLE t_rbkp
   WHERE belnr IN s_belnr
     AND gjahr EQ p_gjahr
     AND bldat IN s_bldat
     AND budat IN s_budat.
  IF NOT t_rbkp[] IS INITIAL.
    SELECT belnr                       " Document number of an invoice
           ebeln                       " Purchasing Document Number
           wrbtr                       " Amount in document currency
      FROM rseg
      INTO TABLE t_rseg
       FOR ALL ENTRIES IN t_rbkp
     WHERE belnr EQ t_rbkp-belnr
       AND werks IN s_werks.
  ENDIF.                               " IF NOT t_rbkp[] IS INITIAL...
  IF NOT t_rseg[] IS INITIAL.
    SELECT banfn
           ernam
           afnam
           badat
           ebeln
      FROM eban
      INTO CORRESPONDING FIELDS OF TABLE t_eban
       FOR ALL ENTRIES IN t_rseg
     WHERE ebeln EQ t_rseg-ebeln.
  ENDIF.                               " IF NOT t_rseg[] IS INITIAL...
ENDFORM.                               " GET_PURCHASEREQUISITION
reward points if helpful.
regards,
kiran kumar k.

Similar Messages

  • Alv grid - call transaction 'ME22N' and reflect the change made in alv grid

    Hi,
    <u>Scenario</u>
    I have an alv list which has fields Purchase document no. (EBELN) and Item delivery date (EINDT). EBELN field is hot spot enabled. when i click on that transaction 'ME22' is called. I have done this using USER_COMMAND subroutine.the code is given.
          FORM USER_COMMAND                                             *
    Call transaction ME22N on clicking Document number                 *
    FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM
                    I_SELFIELD TYPE SLIS_SELFIELD.
      DATA: F_SUBRC LIKE SY-SUBRC,
            s_arseg like G_T_PORD. "the internal table used is G_T_PORD
      CASE F_UCOMM.
        WHEN '&IC1'.
          IF i_selfield-fieldname = 'EBELN'.
            READ TABLE G_T_PORD INDEX i_selfield-tabindex INTO s_arseg.
            SET PARAMETER ID 'BES' FIELD s_arseg-ebeln.
            CALL TRANSACTION 'ME22N' AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
    endform.
    <u>Requirement</u>
    After calling the transaction, If the user changes the Item delivery date (EINDT) at the ME22 transaction screen, the new date needs to be reflected in the ALV grid.
    Plz help it is very urgent.

    The first method (using selfield-refresh = 'X'.) didn't work as the internal table doesnt get modified when the user make changes in Item delivery date(EINDT) at ME22 transaction screen. The 2nd method is OO,which can't be used in my case.
    I tried calling the subroutine for populating the itab (G_T_PORD) and the subroutine for displaying the alv grid immediately after calling ME22N transaction. Still it is not reflecting the new date in the output alv. The code is given below.
          FORM USER_COMMAND                                             *
    Call transaction ME22N on clicking Document number                 *
    FORM USER_COMMAND USING F_UCOMM LIKE SY-UCOMM
                    I_SELFIELD TYPE SLIS_SELFIELD.
      DATA: F_SUBRC LIKE SY-SUBRC,
            s_arseg like G_T_PORD.
      CASE F_UCOMM.
        WHEN '&IC1'.
          IF i_selfield-fieldname = 'EBELN'.
            READ TABLE G_T_PORD INDEX i_selfield-tabindex INTO s_arseg.
            SET PARAMETER ID 'BES' FIELD s_arseg-ebeln.
            CALL TRANSACTION 'ME22N' AND SKIP FIRST SCREEN.
          ENDIF.
      ENDCASE.
            refresh G_T_PORD.
            perform F1000_POPULATE_PO.
            perform F2000_DISPLAY_PO .
    endform.

  • Reg calling Transaction code in Webdynpro ABAP

    Hi All,
    Can I call Transaction code in Webdynpro ABAP Portal Application. If so, how can this be possible? Can anybody give me a lead?
    Thanks.
    Kumar Saurav.

    Hi,
    The most easy Way is here:
    1) Test any Webdynpro Application from SE80 when the webdynpro Browser opens to display output
    Copy its HTTP link, Suppose we get the below link
    http://r3d01web1.Siemens.dk:8001/sap/bc/webdynpro/sap/z_dynamic_view?sap-client=002&sap-language=EN
    2) Now replace some part of the above link ( webdynpro/sap/z_dynamic_view?sap-client=002&sap-language=EN )  with the new link part ( gui/sap/its/webgui?~transaction=PA30 )
    So that the newly generated link is such that the below one:
    http://r3d01web1.Siemens.dk:8001/sap/bc/gui/sap/its/webgui?~transaction=PA30
    Note in place of PA30 you can put any of your desired tcode.
    3) Now Just Make a webdynpro component and in its View layout put a LINK TO URL ui element
    and in its property REFERENCE just past the http link ( http://r3d01web1.Siemens.dk:8001/sap/bc/gui/sap/its/webgui?~transaction=PA30 )
    4) Activate and test your webdynpro Application.

  • CALL TRANSACTION code in RFC

    Hi Experts,
    I've created RFC function module that make use of CALL TRANSACTION code. This function module is being called in CRM system. However I encountered a short dump CALL_FUNCTION_RECEIVE_ERROR. Kindly help to determine if CALL TRANSACTION code is possible in RFC function module?
    Thanks in advance!

    Hello,
    Here's the detailed error analysis found in ST22:
    Error analysis
        An error occurred when executing a Remote Function Call.
        "Exception condition "CNTL_ERROR" raised. "
        Status of connection.... " "
        Internal error code.... "RFC_GET3"
        Log error: No end marker in data container.
    Thanks!

  • Calling Transaction code & returning back to calling program

    Hi,
    I have requirement as below
    Write the report to call the transaction code say for example different tcode (1000 in number) need to be executed and after every tcode execution it should return back to calling report. I tried using "CALL TRANSACTION 'ABC' AND SKIP FIRST SCREEN"  it does execute the tcode but need the user interaction to return back to report, where here i want do this programatically.
    can someone please help me & what is possible ways this can be do able.
    Thanks,
    John.

    There are two method of BDC
    1- Call transaction method
    2- BDC Session method
    In this case you can use call tansaction method.
    Syntax- call tansaction abc using gt_bdcdata.
    Do the recording with t-code SHDB for that particular transaction and after the necessary modification use it in your program.
    Please check f1 help of call transaction for details.

  • Calling transaction codes.

    Hi Everyone,
    I have around 5 different programs, and have transaction codes for them. Now if I navigate from one screen to another say for until the 4 screen and then again if I press the back button, it has to come back to the previous screen until the last one.
    Can this be implemented through callstack if so, how can it be done, any suggestions.
    It would be of great help if anyone can help me.
    Thanks,
    Prabs.

    Hi
    If you use call transaction then you can go back only one step with leave program . There is no way to determine previuos steps. You can still achieve this -
    In Program for ( TRANSACTION Z1 )
         CALL TRANSACTION Z2 .
    In Program for ( TRANSACTION Z2 )
         CALL TRANSACTION Z3 .
         LEAVE PROGRAM.
    In Program for ( TRANSACTION Z3 )
         CALL TRANSACTION Z4 .
         LEAVE PROGRAM.
    If now you branch to Z4 and click a back button here it will goto ( internally ->Z3 -> Z2 ) to Z1 .  You have to place the "LEAVE PROGRAM" just after the call transaction.
    If you are using call screen ( within same program ) you can use SET SCREEN 0 . LEAVE SCREEN to branch to first screen in call sequence.
    You can also try function module SYSTEM_CALLSTACK in your code  . With every call transaction a new call stack is created.
    ( You can even check in debugging the call stack ).
    Cheers

  • Personas: how to call Transaction code using a Script Button?

    Hi,
    I want to use a script button to run to certain UI based on the given transaction code. I am thinking there might be some ways to do so:
    Option 1:
        Somehow one can let the script button call the T-code in script, say, IW21, but how to write such script?
    Option 2:
        In the script of the script button, use "Push" or "Click" to cause an action on the launch button which contains the T-code, say /nIW21.
    But on my PC, this does not work. Why?
    pls help asap!
    Thx a lot!
    Br,
    Dong

    Knowledge sharing:
    Hi,
    I have found exact answer to this question: in the script of a script button, one can first set the T-code to the /okdc component, then call "press Enter" action. By this way, any script button can be used to triggle an action for a T-code. One can set teh /okdc as "hidden". Hope this will help other newers.
    Br,
    Dong

  • Deactivate buttons in ALV GRID being called in subscreen

    Hi,
    In a screen, when a specific tab is selected (tab strip), the subscreen area is filled with ALV GRID. I need to deactivate few buttons on the ALV GRID. How can that be done??
    Advance Thanks

    Hi Aadarsh,
    Check out the following program.
    Global data definitions for ALV
    To allow the declaration of gr_event_handler before the
    lcl_event_receiver class is defined, decale it as deferred in the
    start of the program
    CLASS lcl_event_handler DEFINITION DEFERRED.
    Object reference
    ALV Grid instance reference
    DATA: gr_alvgrid    TYPE REF TO cl_gui_alv_grid,
    Custom container instance reference
          gr_ccontainer TYPE REF TO cl_gui_custom_container,
    Event class reference
          gr_event_handler TYPE REF TO lcl_event_handler.       "IC210507+
    Internal Table
    Field catalog table
    DATA: gt_fieldcat TYPE lvc_t_fcat,
    Internal table holding list data
          gt_list     TYPE STANDARD TABLE OF sflight,
    Table to be filled up for excluding some of the standard function
    buttons
          gt_exclude  TYPE ui_functions.                        "IC210507+
    Work area
    Layout structure
    DATA: gs_layout   TYPE lvc_s_layo,
    Field catalog structure
          gs_fcat     TYPE lvc_s_fcat,
    Exclude button structure
          gs_exclude  TYPE ui_func,                             "IC210507+
    Structure to add button in the ALV toolbar
          gs_toolbar  TYPE stb_button.                          "IC210507+
    Variables
    DATA: ok_code                TYPE sy-ucomm,
          save_ok                TYPE sy-ucomm,
    Name of the custom control added on the screen
          gv_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
    Begin of IC210507
    Local classes
    CLASS lcl_event_handler DEFINITION .
      PUBLIC SECTION.
        METHODS:
    To add new functional buttons to the ALV toolbar
        handle_toolbar      FOR EVENT toolbar OF cl_gui_alv_grid
                            IMPORTING e_object e_interactive,
    To implement user commands
        handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
                            IMPORTING e_ucomm.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    End of IC210507
    Calling the screen where ALV output is displayed
    CALL SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
          PBO
    MODULE status_0100 OUTPUT.
    ALV display
      PERFORM display_alv.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          PAI
    MODULE user_command_0100 INPUT.
      save_ok = ok_code.
      CLEAR ok_code.
      IF save_ok EQ 'EXIT'.
        LEAVE PROGRAM.
      ENDIF.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  display_alv
          ALV display
    FORM display_alv.
      PERFORM get_data.
      PERFORM create_alv.
    ENDFORM.                    " display_alv
    *&      Form  get_data
          Fetch data to be displayed in the list
    FORM get_data.
      SELECT * FROM sflight
               INTO TABLE gt_list.
    ENDFORM.                    " get_data
    *&      Form  create_alv
          Create and set or Refresh ALV
    FORM create_alv.
    Checking whether an instance of the container (or ALV Grid) exists.
      IF gr_alvgrid IS INITIAL.
    If not, creating and setting ALV for the first display.
    Creating custom container instance
        CREATE OBJECT gr_ccontainer
          EXPORTING
            container_name              = gv_custom_control_name
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            OTHERS                      = 6.
    Creating ALV Grid instance
        CREATE OBJECT gr_alvgrid
          EXPORTING
            i_parent          = gr_ccontainer
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
    Begin of IC210507
    Creating an instance for the event handler
        CREATE OBJECT gr_event_handler.
    Registering handler methods to handle ALV Grid events
        SET HANDLER gr_event_handler->handle_user_command FOR gr_alvgrid.
        SET HANDLER gr_event_handler->handle_toolbar FOR gr_alvgrid.
    End of IC210507
    Preparing field catalog.
        PERFORM prepare_field_catalog CHANGING gt_fieldcat.
    Preparing layout structure
        PERFORM prepare_layout CHANGING gs_layout.
    Excluding Unwanted Standard Function Buttons
        PERFORM exclude_tb_functions CHANGING gt_exclude.       "IC210507+
    Method to display ALV grid
        CALL METHOD gr_alvgrid->set_table_for_first_display
          EXPORTING
            is_layout                     = gs_layout
    To exclude buttons the exclusion table must be passed to the following
    field
            it_toolbar_excluding          = gt_exclude          "IC210507+
          CHANGING
            it_outtab                     = gt_list
            it_fieldcatalog               = gt_fieldcat
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
    To make ALV show our additional buttons, we must call the method
    “set_toolbar_interactive” for the ALV Grid instance after the instance
    is created.
        CALL METHOD gr_alvgrid->set_toolbar_interactive.       "IC210507+
      ELSE.
    If an instance of the container (or ALV Grid) exists, refreshing it.
        CALL METHOD gr_alvgrid->refresh_table_display
          EXCEPTIONS
            finished = 1
            OTHERS   = 2.
      ENDIF.
    ENDFORM.                    " create_alv
    *&      Form  prepare_field_catalog
          Subroutine to populate field catalog
         <--P_GT_FIELDCAT  Table to describe the field catalog
    FORM prepare_field_catalog  CHANGING p_gt_fieldcat TYPE lvc_t_fcat.
    Generating the field catalog semi automatically
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'SFLIGHT'
        CHANGING
          ct_fieldcat            = p_gt_fieldcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      LOOP AT p_gt_fieldcat INTO gs_fcat.
        CASE gs_fcat-fieldname.
          WHEN 'CARRID'.
            gs_fcat-outputlen = '10'.
            gs_fcat-coltext = 'Airline Carrier ID'.
            MODIFY p_gt_fieldcat FROM gs_fcat.
          WHEN 'FLDATE'.
            gs_fcat-just = 'C'.
            gs_fcat-hotspot = 'X'.
            MODIFY p_gt_fieldcat FROM gs_fcat.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    " prepare_field_catalog
    *&      Form  prepare_layout
          Preparing layout structure
         <--P_GS_LAYOUT  Layout structure
    FORM prepare_layout  CHANGING p_gs_layout TYPE lvc_s_layo.
      p_gs_layout-zebra = 'X' .
      p_gs_layout-grid_title = 'Flight Info System'.
      p_gs_layout-smalltitle = 'X'.
    ENDFORM.                    " prepare_layout
    Begin of IC210507
    *&      Form  exclude_tb_functions
          Excluding Unwanted Standard Function Buttons
         <--P_GT_EXCLUDE  Table to be filled up to exclude buttons
    FORM exclude_tb_functions  CHANGING p_gt_exclude TYPE ui_functions.
    “MC_FC_” are names for functions directly and the names beginning with
    “MC_MB_” are for the function menus including some subfunctions as menu
    entries.
    In this case 'Maximum' and 'Minimum' options under 'Sum' button & 'Print'
    button are excluded
      gs_exclude = cl_gui_alv_grid=>mc_fc_maximum.
      APPEND gs_exclude TO p_gt_exclude.
      gs_exclude = cl_gui_alv_grid=>mc_fc_minimum.
      APPEND gs_exclude TO p_gt_exclude.
      gs_exclude = cl_gui_alv_grid=>mc_fc_print.
      APPEND gs_exclude TO p_gt_exclude.
    ENDFORM.                    " exclude_tb_functions
    *&       Class (Implementation)  lcl_event_handler
           Event handler for the ALV Grid instance.
    CLASS lcl_event_handler IMPLEMENTATION.
    Handle Toolbar
      METHOD handle_toolbar.
        PERFORM handle_toolbar USING e_object e_interactive .
      ENDMETHOD .                    "handle_toolbar
    Handle User Command
      METHOD handle_user_command .
        PERFORM handle_user_command USING e_ucomm .
      ENDMETHOD.                    "handle_user_command
    ENDCLASS.               "lcl_event_handler
    *&      Form  handle_toolbar
          Subroutine called from event handler method for event toolbar.
          This is to add a new button in the ALV application toolbar
         -->P_E_OBJECT
         -->P_E_INTERACTIVE
    FORM handle_toolbar  USING    p_e_object TYPE REF TO cl_alv_event_toolbar_set
                                  p_e_interactive.
    Begin of 'Adding a new Button'
      CLEAR gs_toolbar.
    Function code
      MOVE 'EXIT' TO gs_toolbar-function.
    Button type that will be added to the toolbar
      gs_toolbar-butn_type = 0.
    Icon for the button
    From the type group ICON in SE11, we can get the value to be passed
    for icon
      gs_toolbar-icon = '@2N@'.
    Quick info for the button
      MOVE 'Exit' TO gs_toolbar-quickinfo.
    Text for the button
      MOVE 'Exit' TO gs_toolbar-text.
    Adds the button as disabled if set to X
      MOVE ' ' TO gs_toolbar-disabled.
    Appending the structure to the table attribute “mt_toolbar” of the object
      APPEND gs_toolbar TO p_e_object->mt_toolbar.
    End of 'Adding a new Button'
    Begin of 'Disabling an existing standard Button'
      LOOP AT p_e_object->mt_toolbar
              INTO gs_toolbar
    Identify which button to disable from the function code
    In this case disabling the 'Filter' button
              WHERE function = '&MB_FILTER'.
    Set the 'DISABLED' field to disable a button
        gs_toolbar-disabled = 'X'.
        MODIFY p_e_object->mt_toolbar FROM gs_toolbar.
      ENDLOOP.
    End of 'Disabling an existing standard Button'
    ENDFORM.                    " handle_toolbar
    *&      Form  handle_user_command
          Implement any new function
         -->P_E_UCOMM  text
    FORM handle_user_command  USING    p_e_ucomm TYPE syucomm.
      IF p_e_ucomm EQ 'EXIT'.
        LEAVE PROGRAM.
      ENDIF.
    ENDFORM.                    " handle_user_command
    End of IC210507
    Award points if found useful.
    Regards
    Indrajit.

  • Hi guys please give me sample code for call transaction that handles error

    hi guys, please give me sample code for call transaction that handles error,
    please send me the sample code in which there should be all decleration part and everything, based on the sample code i will develop my code.
    please do help me as it is urgent.
    thanks and regards.
    prasadnn.

    Hi Prasad,
    Check this code.
    Source Code for BDC using Call Transaction
    *Code used to create BDC
    *& Report  ZBDC_EXAMPLE                                                *
    *& Example BDC program, which updates net price of item 00010 of a     *
    *& particular Purchase order(EBELN).                                   *
    REPORT  ZBDC_EXAMPLE  NO STANDARD PAGE HEADING
                          LINE-SIZE 132.
    Data declaration
    TABLES: ekko, ekpo.
    TYPES: BEGIN OF t_ekko,
        ebeln TYPE ekko-ebeln,
        waers TYPE ekko-waers,
        netpr TYPE ekpo-netpr,
        err_msg(73) TYPE c,
    END OF t_ekko.
    DATA: it_ekko  TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko  TYPE t_ekko,
          it_error TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_error TYPE t_ekko,
          it_success TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_success TYPE t_ekko.
    DATA: w_textout            LIKE t100-text.
    DATA: gd_update TYPE i,
          gd_lines TYPE i.
    *Used to store BDC data
    DATA: BEGIN OF bdc_tab OCCURS 0.
            INCLUDE STRUCTURE bdcdata.
    DATA: END OF bdc_tab.
    *Used to stores error information from CALL TRANSACTION Function Module
    DATA: BEGIN OF messtab OCCURS 0.
            INCLUDE STRUCTURE bdcmsgcoll.
    DATA: END OF messtab.
    *Screen declaration
    SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME
                                        TITLE text-001. "Purchase order Num
    SELECT-OPTIONS: so_ebeln FOR ekko-ebeln OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK block1.
    SELECTION-SCREEN BEGIN OF BLOCK block2 WITH FRAME
                                        TITLE text-002. "New NETPR value
    PARAMETERS:  p_newpr(14)   TYPE c obligatory.  "LIKE ekpo-netpr.
    SELECTION-SCREEN END OF BLOCK block2.
    *START-OF-SELECTION
    START-OF-SELECTION.
    Retrieve data from Purchase order table(EKKO)
      SELECT ekkoebeln ekkowaers ekpo~netpr
        INTO TABLE it_ekko
        FROM ekko AS ekko INNER JOIN ekpo AS ekpo
          ON ekpoebeln EQ ekkoebeln
       WHERE ekko~ebeln IN so_ebeln AND
             ekpo~ebelp EQ '10'.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Check data has been retrieved ready for processing
      DESCRIBE TABLE it_ekko LINES gd_lines.
      IF gd_lines LE 0.
      Display message if no data has been retrieved
        MESSAGE i003(zp) WITH 'No Records Found'(001).
        LEAVE TO SCREEN 0.
      ELSE.
      Update Customer master data (instalment text)
        LOOP AT it_ekko INTO wa_ekko.
          PERFORM bdc_update.
        ENDLOOP.
      Display message confirming number of records updated
        IF gd_update GT 1.
          MESSAGE i003(zp) WITH gd_update 'Records updated'(002).
        ELSE.
          MESSAGE i003(zp) WITH gd_update 'Record updated'(003).
        ENDIF.
    Display Success Report
      Check Success table
        DESCRIBE TABLE it_success LINES gd_lines.
        IF gd_lines GT 0.
        Display result report column headings
          PERFORM display_column_headings.
        Display result report
          PERFORM display_report.
        ENDIF.
    Display Error Report
      Check errors table
        DESCRIBE TABLE it_error LINES gd_lines.
      If errors exist then display errors report
        IF gd_lines GT 0.
        Display errors report
          PERFORM display_error_headings.
          PERFORM display_error_report.
        ENDIF.
      ENDIF.
    *&      Form  DISPLAY_COLUMN_HEADINGS
          Display column headings
    FORM display_column_headings.
      WRITE:2 ' Success Report '(014) COLOR COL_POSITIVE.
      SKIP.
      WRITE:2 'The following records updated successfully:'(013).
      WRITE:/ sy-uline(42).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
              (10) 'Purchase Order'(004), sy-vline,
              (11) 'Old Netpr'(005), sy-vline,
              (11) 'New Netpr'(006), sy-vline.
      WRITE:/ sy-uline(42).
    ENDFORM.                    " DISPLAY_COLUMN_HEADINGS
    *&      Form  BDC_UPDATE
          Populate BDC table and call transaction ME22
    FORM bdc_update.
      PERFORM dynpro USING:
          'X'   'SAPMM06E'        '0105',
          ' '   'BDC_CURSOR'      'RM06E-BSTNR',
          ' '   'RM06E-BSTNR'     wa_ekko-ebeln,
          ' '   'BDC_OKCODE'      '/00',                      "OK code
          'X'   'SAPMM06E'        '0120',
          ' '   'BDC_CURSOR'      'EKPO-NETPR(01)',
          ' '   'EKPO-NETPR(01)'  p_newpr,
          ' '   'BDC_OKCODE'      '=BU'.                      "OK code
    Call transaction to update customer instalment text
      CALL TRANSACTION 'ME22' USING bdc_tab MODE 'N' UPDATE 'S'
             MESSAGES INTO messtab.
    Check if update was succesful
      IF sy-subrc EQ 0.
        ADD 1 TO gd_update.
        APPEND wa_ekko TO it_success.
      ELSE.
      Retrieve error messages displayed during BDC update
        LOOP AT messtab WHERE msgtyp = 'E'.
        Builds actual message based on info returned from Call transaction
          CALL FUNCTION 'MESSAGE_TEXT_BUILD'
               EXPORTING
                    msgid               = messtab-msgid
                    msgnr               = messtab-msgnr
                    msgv1               = messtab-msgv1
                    msgv2               = messtab-msgv2
                    msgv3               = messtab-msgv3
                    msgv4               = messtab-msgv4
               IMPORTING
                    message_text_output = w_textout.
        ENDLOOP.
      Build error table ready for output
        wa_error = wa_ekko.
        wa_error-err_msg = w_textout.
        APPEND wa_error TO it_error.
        CLEAR: wa_error.
      ENDIF.
    Clear bdc date table
      CLEAR: bdc_tab.
      REFRESH: bdc_tab.
    ENDFORM.                    " BDC_UPDATE
          FORM DYNPRO                                                   *
          stores values to bdc table                                    *
    -->  DYNBEGIN                                                      *
    -->  NAME                                                          *
    -->  VALUE                                                         *
    FORM dynpro USING    dynbegin name value.
      IF dynbegin = 'X'.
        CLEAR bdc_tab.
        MOVE:  name TO bdc_tab-program,
               value TO bdc_tab-dynpro,
               'X'  TO bdc_tab-dynbegin.
        APPEND bdc_tab.
      ELSE.
        CLEAR bdc_tab.
        MOVE:  name TO bdc_tab-fnam,
               value TO bdc_tab-fval.
        APPEND bdc_tab.
      ENDIF.
    ENDFORM.                               " DYNPRO
    *&      Form  DISPLAY_REPORT
          Display Report
    FORM display_report.
      FORMAT COLOR COL_NORMAL.
    Loop at data table
      LOOP AT it_success INTO wa_success.
        WRITE:/      sy-vline,
                (10) wa_success-ebeln, sy-vline,
                (11) wa_success-netpr CURRENCY wa_success-waers, sy-vline,
                (11) p_newpr, sy-vline.
        CLEAR: wa_success.
      ENDLOOP.
      WRITE:/ sy-uline(42).
      REFRESH: it_success.
      FORMAT COLOR COL_BACKGROUND.
    ENDFORM.                    " DISPLAY_REPORT
    *&      Form  DISPLAY_ERROR_REPORT
          Display error report data
    FORM display_error_report.
      LOOP AT it_error INTO wa_error.
        WRITE:/      sy-vline,
                (10) wa_error-ebeln, sy-vline,
                (11) wa_error-netpr CURRENCY wa_error-waers, sy-vline,
                (73) wa_error-err_msg, sy-vline.
      ENDLOOP.
      WRITE:/ sy-uline(104).
      REFRESH: it_error.
    ENDFORM.                    " DISPLAY_ERROR_REPORT
    *&      Form  DISPLAY_ERROR_HEADINGS
          Display error report headings
    FORM display_error_headings.
      SKIP.
      WRITE:2 ' Error Report '(007) COLOR COL_NEGATIVE.
      SKIP.
      WRITE:2 'The following records failed during update:'(008).
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_HEADING.
      WRITE:/      sy-vline,
              (10) 'Purchase Order'(009), sy-vline,
              (11) 'Netpr'(010), sy-vline,
              (73) 'Error Message'(012), sy-vline.
      WRITE:/ sy-uline(104).
      FORMAT COLOR COL_NORMAL.
    ENDFORM.                    " DISPLAY_ERROR_HEADINGS
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards

  • Need BDC code for Call Transaction of VL31N, which creates Inbound del.s,

    Hi Experts,
    Is any body does have the BDC (CALL TRANSACTION) code for VL31N transaction, where we can crete INBOUND deliveries from Purc Orders.
    Actually, currently am doing by using FM - GN_DELIVERY_CREATE, but, its not given me a chance to incorporate BATCH SPLIT functionality. So, decided to go with BDC
    1 - Is this VL31N is Okay for BDC, bcoz, some where I red that, since its a ENJOY tx, its NOT recommended?
    2 - Is there any other FM, BAPI to create INBOUND deliveries from POs, which can take care of BATCH SPLIT functionality?
    3 - BDC code for VL31N  tx.
    thanq
    Edited by: Srinivas on Jul 29, 2008 1:47 PM

    1 - Is this VL31N is Okay for BDC, bcoz, some where I red that, since its a ENJOY tx, its NOT recommended?
    yes you can do that .
    2 - Is there any other FM, BAPI to create INBOUND deliveries from POs, which can take care of BATCH SPLIT functionality?
    using BDC we can achieve the  Barch split functionality.
    3 - BDC code for VL31N tx.
    Record using SHDB it will give you.

  • Not triggering PBO in OOABAP ALV grid

    Hi all.
    I want to create drop down for Document type BSART.for that iam using OOABAP but my program is not triggering PBO module itself.I have seen so many examples but iam unable to fetch data.what are the changes i have to do here.i have reduced some code here.i have written my final internal table select query before this stataement.
    loop at it_git_final into wa_git_final.
    APPEND wa_git_final TO it_git_final.
    ENDLOOP.
    *Call to ALV
      CALL SCREEN 600.
    MODULE status_0600 OUTPUT.
    SET PF-STATUS 'DISP'.
    SET TITLEBAR 'ALVF4'.
    ENDMODULE.                 " STATUS_0600  OUTPUT
    calling the PBO module ALV_GRID.
    MODULE pbo OUTPUT.
    *Creating objects of the container
      *  SET field for ALV
      if g_custom_container is initial.
      perform create_and_init_alv changing it_git_final
                                             gt_fieldcat.
    PERFORM alv_build_fieldcat.
      endif.
      * Set ALV attributes FOR LAYOUT
    PERFORM alv_report_layout.
       CHECK NOT c_alvgd IS INITIAL.
    Call ALV GRID
       CALL METHOD c_alvgd->set_table_for_first_display
        EXPORTING
          is_layout                     = it_layout
          i_save                        = 'A'
        CHANGING
          it_outtab                     = it_git_final
          it_fieldcatalog               = it_fcat
        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.
       ENDMODULE.                 " PBO  OUTPUT
          MODULE PAI INPUT                                              *
    MODULE pai INPUT.
       ENDMODULE.                    "pai INPUT
    *subroutine to build fieldcat
    FORM alv_build_fieldcat changing pt_fieldcat type lvc_t_fcat..
       DATA lx_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'IT_GIT_FINAL'
        CHANGING
          ct_fieldcat      = gt_fieldcat.
    * To assign dropdown in the fieldcataogue
    LOOP AT gt_fieldcat INTO lx_fcat.
       DATA : lx_fcat TYPE lvc_s_fcat.
      lx_fcat-row_pos   = '1'.
      lx_fcat-col_pos   = '1'.
    lx_fcat-fieldname = 'CHECK1'.
    lx_fcat-ref_field = 'CHECK1'
      lx_fcat-EDIT = 'X'.
      lx_fcat-coltext = 'Check Box'.
    lx_fcat-seltext = text-c01.
    APPEND lx_fcat TO Gt_fieldcat.
    CLEAR lx_fcat.
    lx_fcat-row_pos   = '1'.
      lx_fcat-col_pos   = '15'.
      lx_fcat-fieldname = 'BSART'.
      lx_fcat-ref_field = 'BSART'.
      lx_fcat-ref_table = 'T161P'.
      lx_fcat-coltext = 'Document Type'.
    lx_fcat-drdn_hndl = '1'.
      lx_fcat-outputlen = 15.
      lx_fcat-edit = 'X'.
      append  lx_fcat to gt_fieldcat.
      CLEAR lx_fcat.
       DATA: lt_dropdown TYPE lvc_t_drop,
            ls_dropdown TYPE lvc_s_drop.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '01 ZFC Vesselchart Contract'.
      APPEND ls_dropdown TO lt_dropdown.
      ls_dropdown-handle = '1'.
      ls_dropdown-value = '02 ZQTY QTY Contract(SESA)'.
      APPEND ls_dropdown TO lt_dropdown.   ls_dropdown-handle = '1'.
    *method to display the dropdown in ALV
      CALL METHOD g_grid->set_drop_down_table
        EXPORTING
          it_drop_down = lt_dropdown.
    LOOP AT it_fcat INTO lx_fcat.
        CASE lx_fcat-fieldname.
    To assign dropdown in the fieldcataogue
          WHEN 'BSART'.
            lx_fcat-drdn_hndl = '1'.
            lx_fcat-outputlen = 15.
            MODIFY it_fcat FROM lx_fcat.
        ENDCASE.
      ENDLOOP.
          endform.
    form ALV_OUTPUT .
    *Create object for container
    CREATE OBJECT g_custom_container
            EXPORTING container_name = 'CCONT'.
    *create object for grid
    CREATE OBJECT g_grid
            EXPORTING i_parent = g_custom_container.
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          is_layout       = it_layout
        CHANGING
          it_fieldcatalog = gt_fieldcat
          it_outtab       = it_git_final.
    endform.                    " ALV_OUTPUT
    form ALV_REPORT_LAYOUT .
      it_layout-cwidth_opt = 'X'.
      it_layout-col_opt = 'X'.
      it_layout-zebra = 'X'.
    endform.                    " ALV_REPORT_LAYOUT
    form CREATE_AND_INIT_ALV  changing p_it_git_final
                                       p_gt_fieldcat.
      create object g_custom_container
             exporting container_name = g_container.
      create object g_grid
             exporting i_parent = g_custom_container.
    endform.

    Hello Raj
      Actually all the code is described in PBO module, so you need to invoke this module in PBO when defining the screen.
    For example, access transaction SE51, start in Change mode and inser line
        MODULE PBO.
    Then activate the object
    Best regards
    Carlos Machad o

  • ALV Grid - Display/change Problem

    Hi Guys,
    I have a peculiar problem. I have developed a Module pool application containing two screens. In the first screen I have a input field and 2 buttons for display and change. When I enter the value and press Displaythe second screen is called which shows an ALV grid in the respective display mode. But If I come back and press change I could not get the change mode for the ALV grid still it remains in the Display mode. Again if rerun the transaction and press change it shows the ALV grid in change mode but if we press back and choose display then it is not getting changed still remains as such. In all at the first run what ever the mode is chosen it remains stationery. I am using OOALV and i have tried flushing the container, grid and also refreshing the ALV. But could not trace the problem. If you guys have worked or can put some inputs please reply back.
    Jagath.

    Please find the attached code...
    from the first screen 100 i am assigning the flag w_display or w_change based on the okcode. in the second screen 200 PBO i have the following code:
    MODULE status_0200 OUTPUT.
      SET PF-STATUS 'STAT200'.
      SET TITLEBAR 'TIT200'.
      if w_display eq 'X'.
      perform grid_display.
      else.
      perform grid_change.
      endif.
    ENDMODULE.                 " STATUS_0200  OUTPUT
    Now in perform display I have the following code:
    form grid_display .
    Set the Fieldcatalog.
      REFRESH t_fieldcat.
      PERFORM get_field_catalog.
    set the Layout.
      CLEAR wa_layout.
      wa_layout-cwidth_opt = 'X'.
    wa_layout-stylefname = 'CELLTAB'.
    set the Variant
      w_variant-report = sy-repid.
    Create the Instance for container
      IF lcl_custom_disp IS INITIAL.
        CREATE OBJECT lcl_custom_disp
          EXPORTING
           PARENT                      =
            container_name              = 'CONTAINER1'
          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.
    create the object for ALV grid
        CREATE OBJECT lcl_grid_disp
          EXPORTING
            i_parent          = lcl_custom_disp
          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.
    Create the object for events
        CREATE OBJECT lcl_events.
        SET HANDLER lcl_events->handle_top_of_list FOR lcl_grid_disp.
    Display the  ALV.
        CALL METHOD lcl_grid_disp->set_table_for_first_display
          EXPORTING
            is_variant                    = w_variant
            i_save                        = ' '
            is_layout                     = wa_layout
          CHANGING
            it_outtab                     = t_final[]
            it_fieldcatalog               = t_fieldcat
          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.
      ELSE.
    Refresh the ALV grid
        CALL METHOD lcl_grid_disp->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.
      ENDIF.
    endform.                    " grid_display
    In the perform change the same code is followed for different object with the fieldcatalog  is changed to edit based on flag.
    Set the Fieldcatalog.
      REFRESH t_fieldcat.
      PERFORM get_field_catalog.
    set the Layout.
      CLEAR wa_layout.
      wa_layout-cwidth_opt = 'X'.
    wa_layout-stylefname = 'CELLTAB'.
    set the Variant
      w_variant-report = sy-repid.
    Create the Instance for container
      IF lcl_custom_chng IS INITIAL.
        CREATE OBJECT lcl_custom_chng
          EXPORTING
           PARENT                      =
            container_name              = 'CONTAINER1'
          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.
    create the object for ALV grid
        CREATE OBJECT lcl_grid_chng
          EXPORTING
            i_parent          = lcl_custom_chng
          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.
    Create the object for events
        CREATE OBJECT lcl_events.
        SET HANDLER lcl_events->handle_top_of_list FOR lcl_grid_chng.
        SET HANDLER lcl_events->handle_data_changed FOR lcl_grid_chng.
        SET HANDLER lcl_events->handle_data_changed_finished FOR lcl_grid_chng.
    Display the  ALV.
        CALL METHOD lcl_grid_chng->set_table_for_first_display
          EXPORTING
            is_variant                    = w_variant
            i_save                        = ' '
            is_layout                     = wa_layout
          CHANGING
            it_outtab                     = t_final[]
            it_fieldcatalog               = t_fieldcat
          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.
      ELSE.
    Refresh the ALV grid
        CALL METHOD lcl_grid_chng->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.
      ENDIF.
    Please let me know if you require some more inputs?
    Jagath

  • 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

  • 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 display in a particular format

    Hi,
    Could you please tell me how do i display the alv grid in this particular format :
    col1           |         col2               |           col3          |       col4             |
    abc1          |         def1               | -
    |----
    |           
    abc1           |         def2              | -
    |----

    abc1          |-----|            ghi1           |-----|
    abc1          |-----|            ghi2           |-----|
    abc2          |         def3               | -
    |----
    |           
    abc2           |         def4              | -
    |----

    abc2          |-----|            ghi3           |-----|
    abc2          |-----|            ghi4           |-----|
    1. For a single site (col1), there are multiple values in col2 and col3.
    2. col2 and col3 are not related.
    3. col2 and col3 individually is rlated to col1.
    Any help would be highly appreciated.

    Hi,
    All you need to do is to sort the records while displaying in ALV Grid.
    Refer the below code snippet:-
    *SORTING
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *          SORT INFO
      wa_sort-spos = 1. "<--sort preference
      wa_sort-fieldname = 'COL1'. "<--column which needs to be sorted
      wa_sort-tabname = 'IT_FINAL'. "<--internal table
      wa_sort-up = 'X'. "<--ascending order
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
      wa_sort-spos = 2. "<--sort preference
      wa_sort-fieldname = 'COL3'. "<--column which needs to be sorted
      wa_sort-tabname = 'IT_FINAL'. "<--internal table
      wa_sort-up = 'X'. "<--ascending order
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
      wa_sort-spos = 3. "<--sort preference
      wa_sort-fieldname = 'COL2'. "<--column which needs to be sorted
      wa_sort-tabname = 'IT_FINAL'. "<--internal table
      wa_sort-up = 'X'. "<--ascending order
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    *          DISPLAY RECORDS IN ALV GRID
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program                = sy-repid
          it_fieldcat                       = it_field
          it_sort                           = it_sort  "<--sort info
        TABLES
          t_outtab                          = it_final
    Hope this helps you.
    Regards,
    Tarun

Maybe you are looking for

  • Creating a restricted key figure in BI7 reporting

    Hi I am creating a restricted key figure globally in BI7 query designer, whenever I try to restrict Calender Year /Month, an error message pops up showing: Runtime error '457' (This key is already associated with an element of this collection), when

  • Did System Restore w/o backing up files, will songs be recognized from iPod

    I am a user of Windows Vista, and I recently did a system restore on my PC. The problem is that I did not back up the files from my iPod before doing so. If I re-install iTunes and hook up my iPod to my PC, will the songs automatically be recognized

  • Map on ios6 is suck !! how can i get google maps back !????

    Every thing eles is fine , only MAP is very suck ! i need google map back ! how ?

  • Applescript can't find files

    Applescript cannot find any files. Whether using Finder's exists command or any other way of trying to access a file, alias or not, it says the file cannot be found. I just had iCal also not be able to find a script that ran just fine yesterday. Noth

  • Nokia c2-00 software update

    I updated my c2-00 from version  03.45 to 03.99 yesterday via nokia suite. Now I can manually do the configuration settings of internet. It also has Personal Configuration option. I added a Streaming Point but when I clicked on a youtube video it did