Cl_gui_custom_container

I have placed a HTML viewer inside a custom container.
Can I add vertical and horizontal scrollbars to
the container or to the control?  And how would
I do it?

Hi,
Please check the demo program
SAPHTML_EVENTS_DEMO
aRs

Similar Messages

  • Problem with Custom container - cl_gui_custom_container/cl_gui_alv_grid

    Hi,
    I want to reuse the same custom container screen for a different data.
    First screen there will be button 1 and button 2
    if I click button 1 then calculate and display data  in custom container, if button 2 is clicked then calculate and display data with  in the same custom container.
    For this
    1. Created Custom container - CONTAINER
    2. In program defined and created custom container and custom alv grid
    g_custom_container TYPE REF TO cl_gui_custom_container,
            alv_grid                     TYPE REF TO cl_gui_alv_grid.
           IF g_custom_container IS INITIAL.
                CREATE OBJECT g_custom_container
                    EXPORTING
                  container_name = 'CONTAINER'.
                CREATE OBJECT alv_grid
                   EXPORTING
                    i_parent = g_custom_container.
          ENDIF.
    3. Display data using CALL METHOD alv_grid->set_table_for_first_display
       every thing works great for button 1
    4. when button 2 is clicked then calculate and display different set of data in same custom container which is used earlier.
    5. here I used
    call method alv_grid->free.
        call method g_custom_container->free.
    6. create above objects once again and tried to use
    call method alv_grid->set_table_for_first_display
    , to reuse the same custom container 'CONTAINER' again for a different set of data and getting ABAP dump.
    In debug mode, when I used the above method FREE for both ALV_GRID and G_CUSTOM_CONTAINER objects are not clearing.
    Please let me know how can I reuse the same container for a different set of data when button2 is pressed.
    Thanks in advance,
    Krishna
    Please use code tags to format your code and post in the correct forum
    Edited by: Rob Burbank on Oct 1, 2010 2:37 PM

    Hello Krishna
    I would recommend to use a different approach instead of trying to initialize your container instances:
    DATA:
      go_container_1 TYPE REF TO cl_gui_custom_container,
      go_container_2 TYPE REF TO cl_gui_custom_container,
      go_grid_1          TYPE REF TO cl_gui_alv_grid,
      go_grid_2          TYPE REF TO cl_gui_alv_grid.
    " NOTE: Do this coding BEFORE calling the screen
    * (1) Create 2 containers
    CREATE OBJECT g_container_1
                    EXPORTING
                  container_name = 'CONTAINER'.
    CREATE OBJECT g_container_2
                    EXPORTING
                  container_name = 'CONTAINER'.
    " NOTE: If it is not possible to use the same container name then either create an additional
    "            dummy screen having a second CUSTOM_CONTROL element or replace
    " the customer containers with docking containers -> here you do not need to give a container name
    * (2) Create 2 grid instances using a different container
    * (3) Link the first container to the screen using its LINK method:
      CALL METHOD go_container_1
        EXPORTING
           repid = <...>
          dynnr = <...>.
    * (4) Perhaps you need to define a second dummy screen to which you link the second container
    * (5) Display first grid instance (as default)
    Now when the user pushes button 2 (to display the second grid) link container_1 to the dummy screen
    and link container_2 to your main screen.
    Regards
      Uwe

  • Help needed in using cl_gui_alv_grid  and cl_gui_custom_container.

    Hi experts,
       I have created a screen with custom control( cl_gui_custom_container ) and displayed a alv using cl_gui_alv_grid in the screen. I have to enter tha values into the alv displayed on screen.The problem here is i have to make 2 fields as mandatory on the alv displayed on  the screen.
    Is it possible to get screen name of these fields so that i can process it in the PBO or is their some way??
    Thanks in advance
    regards,
    Ashwin

    Anyway the fields that are getting displayed is from the structure u have created right?
    So in PBO,  u can use the field names like 'MATNR'.
    If u want to process after selecting u have to right in PAI like
    CASE sy-ucomm.
      WHEN 'MATNR'.
    In oops for selected row processing
       CASE e_ucomm.
          WHEN 'FCODE'.
            CALL METHOD o_alvgrid->get_selected_rows
              IMPORTING
                et_index_rows = i_selected_rows
    *            ET_ROW_NO     =
            IF i_selected_rows[] IS INITIAL.
              MESSAGE i153 WITH text-009.
              LEAVE LIST-PROCESSING.
            ENDIF.
            CLEAR: w_reviewed_mat.
    *        w_reviewed_mat-reviewed = c_x.
    *        w_reviewed_mat-reviewedby = sy-uname.
    *        w_reviewed_mat-reviewedon = sy-datum.
            LOOP AT i_selected_rows INTO w_selected_rows.
              READ TABLE i_output INTO w_output INDEX w_selected_rows-index.
              IF sy-subrc EQ 0.
                w_reviewed_mat-matnr = w_output-matnr.
              ENDIF.
              APPEND w_reviewed_mat TO i_reviewed_mat.
              CLEAR: w_reviewed_mat-matnr.
            ENDLOOP.
    *        MODIFY zzcs_mat FROM TABLE i_reviewed_mat.
          WHEN OTHERS.
        ENDCASE.

  • Modify width property in CL_GUI_CUSTOM_CONTAINER

    Hello,
    I have created a HTML custom container (class CL_GUI_CUSTOM_CONTAINER) and then, as a child of this object, a html control (class cl_crm_cic_html_viewer). which calls a URL. I'm trying to modify the size of this container using the SET_WIDTH method, but the size does not change. The code i am using is basically the following:
      CREATE OBJECT my_container
            EXPORTING
                container_name = 'HTML'
            EXCEPTIONS
                OTHERS = 1.
    CALL METHOD my_container->SET_WIDTH
        EXPORTING
          WIDTH = 500.
    CREATE OBJECT html_control
           EXPORTING
                parent    = my_container
                SHELLSTYLE = i_style.
    CALL METHOD html_control->show_url
        EXPORTING
          url = doc_url.
    Does anybody know how to change the size properties of the gui containers?
    Thank you and best regards,
    Mario

    Hello Björn,
    The problem is that i'm not drowing anything with the screren painter. I have a BSP view inside the html_control. The BSP has the 100% of the size, but the html_control only shows a part of it, because the resolution of my screen (1280x1024) is bigger than the standard .
    I don't know how to resize the html_control to obtain all the posibilities of this resolution.
    Best regards,
    Mario

  • Cl_gui_custom_container Problem

    HI Gurus,
    I have defined a variable g_custom_container as below,
    g_custom_container type ref to cl_gui_custom_container,
    and I am cheking in the program for its initial value as
    if g_custom_container is initial.
        perform create_and_init_ct1_alv changing gt_outtab[]
                                             gt_fieldcat.
      endif.
    Now,
    when I am executing the program, its not going inside the if condition becouse the value of the  g_custom_container is not initial ,
    Please tell the way to set g_custom_container to its initial value.

    My code for calling the module is
    *&      Module  ct1_PBO  OUTPUT
          text
    module ct1_PBO output.
    *call method g_custom_container->free.
    if g_custom_container is initial.
        perform create_and_init_ct1_alv changing gt_outtab[]
                                             gt_fieldcat.
      endif.
    endmodule.                 " ct1_PBO  OUTPUT
    and the definition of perform create_and_init_ct1_alv changing gt_outtab[]
                                             gt_fieldcat.
    is
    FORM create_and_init_ct1_alv CHANGING pt_outtab LIKE gt_outtab[]
                                      pt_fieldcat TYPE lvc_t_fcat.
      DATA: lt_exclude TYPE ui_functions.
            g_container = 'ZEXC_REC_CT1'.
      CREATE OBJECT g_custom_container
             EXPORTING container_name = g_container.
      CREATE OBJECT g_grid
             EXPORTING i_parent = g_custom_container.
    Create Objekt to verify input values.
    (This object is already needed in form SELECT_DATA).
      CREATE OBJECT g_verifier.
      SET HANDLER g_verifier->handle_data_changed FOR g_grid.
      PERFORM select_data CHANGING pt_outtab[].
    Build fieldcat and set columns LFIMG VRKME
    NETPR WAERS edit enabled.
      PERFORM build_fieldcat CHANGING pt_fieldcat.
      PERFORM exclude_tb_functions CHANGING lt_exclude.
      gs_layout-stylefname = 'CELLTAB'.
      CALL METHOD g_grid->set_table_for_first_display
        EXPORTING
          it_toolbar_excluding = lt_exclude
          is_layout            = gs_layout
        CHANGING
          it_fieldcatalog      = pt_fieldcat
          it_outtab            = pt_outtab[].
    Set editable cells to ready for input initially
      CALL METHOD g_grid->set_ready_for_input
        EXPORTING
          i_ready_for_input = 1.
    ENDFORM.  "CREATE_AND_INIT_ALV
    when I am executing the program it is showing me the previous values because it is not going inside the if condition .
    I also used the statement
    call method g_custom_container->free.
    but its giving runtime error.
    Please suggest the solution.
    Please suggest.

  • Methods used in cl_gui_custom_container for ALV and for what purpose

    Methods used in cl_gui_custom_container for ALV and for what purpose and i want the exact senario for the usage of those method?
    2. What events are used in ALV?
    I anyone help me please,
    Points will be awarded.
    Thank you & Regards,
    Jagrut BharatKumar Shukla

    hey,
    look at this sample code....
    TABLES: SFLIGHT.
    G L O B A L   I N T E R N  A L   T A B L E S
    DATA: GI_SFLIGHT TYPE STANDARD TABLE OF SFLIGHT.
    G L O B A L   D A T A
    DATA: OKCODE LIKE SY-UCOMM,
          G_WA_SFLIGHT LIKE SFLIGHT.
    Declare reference variables to the ALV grid and the container
    DATA:
      GO_GRID             TYPE REF TO CL_GUI_ALV_GRID,
      GO_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    S T A R T - O F - S E L E C T I O N.
    START-OF-SELECTION.
      SET SCREEN '0100'.
    *&      Module  USER_COMMAND_0100  INPUT
    MODULE USER_COMMAND_0100 INPUT.
      CASE OKCODE.
        WHEN 'EXIT'.
          LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  STATUS_0100  OUTPUT
    MODULE STATUS_0100 OUTPUT.
    Create objects
      IF GO_CUSTOM_CONTAINER IS INITIAL.
        CREATE OBJECT GO_CUSTOM_CONTAINER
          EXPORTING CONTAINER_NAME = 'ALV_CONTAINER'.
        CREATE OBJECT GO_GRID
          EXPORTING
            I_PARENT = GO_CUSTOM_CONTAINER.
        PERFORM LOAD_DATA_INTO_GRID.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Form  load_data_into_grid
    FORM LOAD_DATA_INTO_GRID.
    Read data from table SFLIGHT
      SELECT *
        FROM SFLIGHT
        INTO TABLE GI_SFLIGHT.
    Load data into the grid and display them
      CALL METHOD GO_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          I_STRUCTURE_NAME = 'SFLIGHT'
        CHANGING
          IT_OUTTAB        = GI_SFLIGHT.
    ENDFORM.                    " load_data_into_grid
    <b>* the Events are</b>
    ITEM_DATA_EXPAND, REPREP_SEL_MODIFY, CALLER_EXIT, USER_COMMAND, TOP_OF_PAGE, DATA_CHANGED, TOP_OF_COVERPAGE, END_OF_COVERPAGE, FOREIGN_TOP_OF_PAGE, FOREIGN_END_OF_PAGE, PF_STATUS_SET, LIST_MODIFY, TOP_OF_LIST, END_OF_PAGE, END_OF_LIST,AFTER_LINE_OUTPUT, BEFORE_LINE_OUTPUT, SUBTOTAL_TEXT, CONTEXT_MENU.
    <b>the methods used with the class CL_GUI_CUSTOM_CONTAINER are as follows......</b>
    IF_CACHED_PROPGET_NEXT_PROP, IF_CACHED_PROPSEEK_FIRST_PROP, IF_CACHED_PROP~SET_PROP, IS_VALID, FREE, GET_PROPERTY, SET_PROPERTY, CALL_METHOD, ASSIGN_PROPERTY, CALL_METHOD_RESULT_GUI_OBJECT, GET_PROPERTY_GUI_OBJECT, IS_CACHED_PROP, ADD_CACHE_PROP, REMOVE_CACHE_PROP, GET_CACHE_PROP, SET_CACHE_PROP, IS_CACHE_VALID, INVALIDATE_CACHE, GET_FOCUS, SET_FOCUS, SET_NAME, GET_NAME, GET_ENABLE, SET_ENABLE, DISPATCH, FINALIZE, GET_ADJUST_DESIGN, GET_GRID_HANDLE, GET_GRID_STEP, GET_HEIGHT, GET_LEFT, GET_METRIC, GET_MODE, GET_REGISTERED_EVENTS, GET_TOP, GET_VISIBLE, GET_WIDTH, IS_ALIVE, REG_EVENT_LEFT_CLICK_DESIGN, REG_EVENT_LEFT_CLICK_RUN_MODE, REG_EVENT_MOVE_CONTROL, REG_EVENT_RIGHT_CLICK, REG_EVENT_SIZE_CONTROL, SET_ADJUST_DESIGN, SET_ALIGNMENT, SET_GRID_HANDLE, SET_GRID_STEP, SET_HEIGHT, SET_LEFT, SET_METRIC, SET_MODE, SET_POSITION, SET_REGISTERED_EVENTS, SET_TOP, SET_VISIBLE, SET_WIDTH, GET_PATH, CONTROL_REGISTER_EVENT, CONTROL_UNREGISTER_EVENT, GET_EVENT_PARAMETER, GET_REGISTERED_EVENTS_EX, GET_WINDOW_PROPERTY, INIT_CONTROL, INIT_CONTROL_WITH_HWND, REGISTER_CACHED_PROPERTY, REGISTER_CACHED_W_PROPERTY, SET_REGISTERED_EVENTS_EX, SET_WINDOW_PROPERTY, UNREGISTER_CACHED_PROPERTY, UNREGISTER_CACHED_W_PROPERTY, GET_CONTAINER_TYPE, RESIZE, GET_INNER_WIDTH, LINK, GET_LINK_INFO, GET_INNER_HEIGHT, SET_MODE_FOR_ALL, GET_DYNPRO_CONTAINER, GET_FRAME_CONTAINER, GET_CHILD, ADD_CHILD, REMOVE_CHILD, REMOVE_ALL_CHILDREN, CONSTRUCTOR.

  • Multiple scroll bars when using cl_gui_custom_container

    Hi,
    when my custom container ref to cl_gui_custom_container i'm seeing two horizontal and two vertical scroll bars.
    can anybody explain me why?
    thanks
    pratyush

    Hi,
    You might be using splitter container, that is you are logically splitting your container into parts in the program.In that case, scroll bars will be displayed.
    just check it.
    Regards,
    Sowjanya

  • In need of a pushbutton event handler for a cl_gui_custom_container

    Greetings Experts:
    Here is the situation...
    I have two cl_gui_custom_containers. Container1 has a double click event reciever that when fired displays longtext using the READ_TEXT function module displaying in Container2.  I am trying to add a pushbutton to Container2 to print contents of the screen (but not the Container1 ALV).
    It seems I am in a bit of a stand still and am in need of some advice.
    Thanks in advance.
    - Dan -

    Here is a little example program, it is not a 100% solution, but you should be able to get the idea here.  It is implemented into a docking container, so that this example is a cut/paste example.  Here we are splitting the docking container into two parts, buttom is the text editor, the top is our toolbar, notice the only button there is Print,  if you click this this will fire an event and will write out what you have typed into the text editor control.
    report zrich_0001.
    type-pools: icon.
    data:
          dock_sub_cont1   type ref to cl_gui_container,
          dock_sub_cont2   type ref to cl_gui_container,
          splitter         type ref to cl_gui_splitter_container,
          dockingleft      type ref to cl_gui_docking_container,
          text_editor      type ref to cl_gui_textedit,
          gui_tb           type ref to cl_gui_toolbar,
          repid type syrepid.
    data: itext type table of tline-tdline,
          xtext type tline-tdline.
    *       CLASS lcl_event_handler DEFINITION
    class lcl_event_handler definition.
      public section.
        class-methods:
        handle_pushbutton_click
                   for event function_selected
                           of cl_gui_toolbar importing fcode.
    endclass.
    *       CLASS lcl_event_handler IMPLEMENTATION
    class lcl_event_handler implementation.
      method  handle_pushbutton_click.
        case fcode.
          when 'PRINT'.
            call method text_editor->get_text_as_r3table
               importing
                     table              = itext
               exceptions
                     others             = 1.
            leave to list-processing.
            loop at itext into xtext.
              write:/ xtext.
            endloop.
        endcase.
      endmethod.
    endclass.
    parameters: p_check.
    at selection-screen output.
      repid = sy-repid.
      check dockingleft is initial.
      create object dockingleft
                  exporting repid     = repid
                            dynnr     = sy-dynnr
                            side      = dockingleft->dock_at_left
                            extension = 1070.
      create object splitter
                            exporting parent = dockingleft
                                      rows    = 2
                                      columns = 1.
      call method:
                      splitter->get_container
                        exporting row            = 1
                                  column         = 1
                                  receiving container = dock_sub_cont1,
                      splitter->set_row_height
                        exporting id             = 1
                                  height         = '3',
                      splitter->get_container
                        exporting row            = 2
                                  column         = 1
                                  receiving container = dock_sub_cont2.
      perform create_toolbar.
      create object text_editor
                  exporting
                       parent     = dock_sub_cont2.
      set handler:
                   lcl_event_handler=>handle_pushbutton_click for gui_tb.
    start-of-selection.
    *       FORM create_toolbar                                           *
    form create_toolbar.
      data: event type cntl_simple_event,
           events type cntl_simple_events.
    * Create the toolbar object
      create object gui_tb
        exporting
          parent             = dock_sub_cont1
        exceptions
          cntl_install_error = 1
          cntl_error         = 2
          cntb_wrong_version = 3
          others             = 4.
    * Set up events  for toolbar
      clear event. refresh events.
      event-appl_event = 'X'.
      event-eventid = gui_tb->m_id_function_selected.
      append event to events.
    * Register the events
      call method gui_tb->set_registered_events
        exporting
          events = events
        exceptions
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
    * Add Buttons to toolbar
      call method gui_tb->add_button
        exporting
          fcode            = 'PRINT'
          icon             = icon_print
          butn_type        = '0'
          text             = '  Print'
        exceptions
          cntl_error       = 1
          cntb_btype_error = 2
          cntb_error_fcode = 3
          others           = 4.
    endform.
    Regards,
    RIch Heilman

  • Use of link method in cl_gui_custom_container

    hi all experts,
    can you plz tell me the use of link method in custom container, if u have any example plz give me .
    and also tell me how can i get the documents against the methods of the classes.
    thanxs in advance
    aashi.

    Hello Ashish
    Instead of connecting a container <i>hard-wired</i> to a screen (using a custom container as screen element) you can dynamically link a container to a screen. The advantage is that you can easily re-link this container to <b>another </b>screen which is not possible in the previous case.
    The following sample report shows how a docking container is dynamically linked to screen '0100'.
    alv
    In order to test the<b> re-linking</b> simply create a second screen (e.g. '0200') and add coding in the PAI module (USER_COMMAND_0100) the following coding:
    * Link the docking container to the second screen
    IF ( gd_okcode = 'ENTER' ).
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0200'
    *      CONTAINER                   =
        EXCEPTIONS
          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.
    ENDIF.
    The docking container is now attached to the second screen.
    <b>Crucial point:</b> Linking containers instead of using hard-wired ones enhances re-usability.
    Regards
      Uwe

  • IN ALV Report 'SAVE LAYOUT' option missing

    Dear All,
                 I have created one report in ALV GRID using ABAP OBJECTS(Using class CL_GUI_CUSTOM_CONTAINER and
    CL_GUI_ALV_GRID).But in output when i click on change layout option i am not getting SAVE layout option.
    I have already passed I_SAVE parameter = 'A' while calling metod SET_TABLE_FOR_FIRST_DISPLAY. But i didnt worked.
               Please do needful.
    Regards,
    Mayank

    Hi,
    You can manage display variants by using parameters, “is_variant” and “i_save” of “set_table_for_first_display”. Here are options for variant handling. <structure_name> is the variant-defining structure of type “DISVARIANT”. The field “report” in this structure should contain the value of “sy-repid.”
    Hope this helps. Reward points if helpful.
    Thanks,
    Balaji

  • Open Adobe Print Form from ALV Int. Rprt using the XSTRING already present

    Hello Friends,
    I have a typicall issue that how to open a Adobe Print Form when a user double clicks in the ALV Report. Here when the user double clicks in the ALV Interactive Report using the unique ID I am getting the Adobe Form from a FTP location in the Form of XSTRING, now using the ABAP ADOBE PRINT FORM not using WebDynpro Application, I need to process this XSTRING and show up the Adobe Print Form.
    OR
    Is there a way to send the XSTRING to the Output Device or Printer to Display the PDF Form.
    Friends please help me in solving this issue.
    Thanks and Regards
    Pradeep Goli
    Edited by: Pradeep Goli on Mar 19, 2009 1:49 PM
    Edited by: Pradeep Goli on Mar 19, 2009 2:51 PM

    Hi Pradeep Goli,
    it is possible to show PDF in SAP GUI.
    Michal
    REPORT  ZTEST_DISPLAY_PDF.
    * You must create dynpro 500 with custom control named HTML.
    * In this custom control will be displayed PDF.
    DATA: g_pdf              TYPE xstring,
          pdf_my_container   TYPE REF TO cl_gui_custom_container,
          pdf_html_control   TYPE REF TO cl_gui_html_viewer.
    START-OF-SELECTION.
    PERFORM create_and_display.
    FORM create_and_display.
    *** Your code fo filling g_pdf
    CALL SCREEN '500'.
    ENDFORM.
    * PDF preview in HTML control
    module html_control output.
      perform pbo_html_control.
    endmodule.
    module html_control input.
      perform pai_html_control.
    endmodule.
    * PAI
    FORM pai_html_control.
      SET SCREEN '0'.
    ENDFORM.
    * Showing of PDF
    FORM pbo_html_control.
      DATA: l_pdf_alignment TYPE i,
            l_count         TYPE i,
            l_noprint       TYPE fpboolean,
            l_noarc         TYPE fpboolean,
            l_noprintarc    TYPE fpboolean.
    *  CLEAR: fcode.
      SET PF-STATUS 'VIEW_PDF'.
    * container
      IF pdf_my_container IS INITIAL.
        CREATE OBJECT pdf_my_container
          EXPORTING
            container_name = 'HTML'
          EXCEPTIONS
            OTHERS         = 1.
        IF sy-subrc <> 0.
          MESSAGE e150(FPRUNX).
          RETURN.
        ENDIF.
      ENDIF.
    * html control
      IF pdf_html_control IS INITIAL.
        CREATE OBJECT pdf_html_control
          EXPORTING
            parent = pdf_my_container
          EXCEPTIONS
            OTHERS = 1.
        IF sy-subrc <> 0.
          MESSAGE e150(FPRUNX).
          RETURN.
        ENDIF.
    *   alignment
        l_pdf_alignment = pdf_html_control->align_at_left  +
                        pdf_html_control->align_at_right +
                        pdf_html_control->align_at_top   +
                        pdf_html_control->align_at_bottom.
        CALL METHOD pdf_html_control->set_alignment
          EXPORTING
            alignment = l_pdf_alignment
          EXCEPTIONS
            OTHERS    = 1.
        IF sy-subrc <> 0.
          MESSAGE e150(FPRUNX).
          RETURN.
        ENDIF.
      ENDIF.
      PERFORM pdf_show USING g_pdf.
    ENDFORM.
    FORM pdf_show USING p_pdf_data TYPE xstring.
      STATICS: ls_url           TYPE i.
      TYPES: lt_pdf_table(1000) TYPE x.
      DATA:  l_myurl(80)        TYPE c,
             l_url(80)          TYPE c,
             l_pdf_data         TYPE STANDARD TABLE OF lt_pdf_table,
             l_pdf_size         TYPE i,
             l_pdf_line         TYPE lt_pdf_table,
             l_offset           TYPE i,
             l_len              TYPE i.
      l_pdf_size = XSTRLEN( p_pdf_data ).
      l_len = l_pdf_size.
      WHILE l_len >= 1000.
        l_pdf_line = p_pdf_data+l_offset(1000).
        APPEND l_pdf_line TO l_pdf_data.
        ADD 1000 TO l_offset.
        SUBTRACT 1000 FROM l_len.
      ENDWHILE.
      IF l_len > 0.
        l_pdf_line = p_pdf_data+l_offset(l_len).
        APPEND l_pdf_line TO l_pdf_data.
      ENDIF.
      ADD 1 TO ls_url.
      l_myurl(8) = ls_url.
      CONCATENATE l_myurl '.pdf' INTO l_myurl.
      SHIFT l_myurl LEFT DELETING LEADING space.
      CALL METHOD pdf_html_control->load_data
        EXPORTING
          url          = l_myurl
          size         = l_pdf_size
          type         = 'application'                          "#EC NOTEXT
          subtype      = 'pdf'                                  "#EC NOTEXT
        IMPORTING
          assigned_url = l_url
        CHANGING
          data_table   = l_pdf_data
        EXCEPTIONS
          OTHERS       = 1.
      IF sy-subrc <> 0.
        MESSAGE e152(FPRUNX).
        RETURN.
      ENDIF.
    * show data
      CALL METHOD pdf_html_control->show_data
        EXPORTING
          url    = l_url
        EXCEPTIONS
          OTHERS = 1.
      IF sy-subrc <> 0.
        MESSAGE e152(FPRUNX).
        RETURN.
      ENDIF.
    ENDFORM.

  • CNTL_ERROR while running a custom report program in background mode

    Hi,
    I am running a report in background on daily basis. I am using cl_gui_custom_container class here and calling the constructor of this class. I am getting a CNTL_ERROR exception at this point. But if i run the same report directly, it is not throwing any exception. The problem is if i schedule it to background. I am not able to sort it out.
    I've written the following code below:
    I did apply the logic that you'd mentioned.
    I've implemented the code as below.
    IF  gr_container IS INITIAL.
    *** Check whether the program is run in batch or foreground
        IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
    * Run in foreground
          CREATE OBJECT gr_container
            EXPORTING
              container_name = 'WORK_AREA_CONTAINER'.
          CREATE OBJECT lv_grid
            EXPORTING I_PARENT = gr_container.
        ELSE.
    * Run in background
          CREATE OBJECT lv_grid
            EXPORTING
              I_PARENT = gr_dockcontainer.
          ENDIF.
          ENDIF.
    i_parent_control = gr_dockcontainer.
            CREATE OBJECT m_base_splitter
            EXPORTING
              parent            = i_parent_control
              ROWS              = 1
              columns           = 2
            EXCEPTIONS
              cntl_error        = 1
              cntl_system_error = 2
              OTHERS            = 3.
            CALL METHOD m_base_splitter->get_container
            EXPORTING
              row       = 1
              column    = 2
              RECEIVING
              container = m_splitter_right_part
            EXCEPTIONS
              OTHERS    = 1.
    After I've implemented the above code I'm getting the following error in the batch job:
    Category               ABAP Programming Error
    Runtime Errors         OBJECTS_OBJREF_NOT_ASSIGNED
    Except.                CX_SY_REF_IS_INITIAL
    You attempted to use a 'NULL' object reference (points to 'nothing')
    access a component (variable: "M_BASE_SPLITTER").
    An object reference must point to an object (an instance of a class)
    before it can be used to access components.
    Either the reference was never set or it was set to 'NULL' using the
    CLEAR statement.
    Would you be able to help me in the above issue?
    Regards,
    Mandeep

    Hi Alexander,
    Yes I'd declared gr_dockcontainer as type ref to CL_GUI_DOCKING_CONTAINER. And I've now replaced the previous code and wwrote the below code :
    gr_container IS INITIAL.
    ***Check whether the program is run in batch or foreground
          IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
    ***Run in foreground
            CREATE OBJECT gr_container
              EXPORTING
                container_name = 'WORK_AREA_CONTAINER'.
            CREATE OBJECT lv_grid
              EXPORTING
                I_PARENT = gr_container.
          ELSE.
    ***Run in background
            CREATE OBJECT gr_dockcontainer
              EXPORTING
                NAME = 'WORK_AREA_CONTAINER'.
          ENDIF.
        ENDIF.
    = gr_dockcontainer.
        CREATE OBJECT m_base_splitter
          EXPORTING
            parent            = i_parent_control
            ROWS              = 1
            columns           = 2
          EXCEPTIONS
            cntl_error        = 1
            cntl_system_error = 2
            OTHERS            = 3.
        CALL METHOD m_base_splitter->get_container
          EXPORTING
            row       = 1
            column    = 2
          RECEIVING
            container = m_splitter_right_part
          EXCEPTIONS
            OTHERS    = 1.
    But after implementing the above code I'm facing the same issue of CTRL ERROR- " GUI cannot be reached".
    Please guide me through this.
    Regards,
    Mandeep

  • CNTL_ERROR while running a report in background mode

    Hi,
    I am running a report in background on daily basis. I am using cl_gui_custom_container class here and calling the constructor of this class. I am getting a CNTL_ERROR exception at this point. But if i run the same report directly, it is not throwing any exception. The problem is if i schedule it to background. I am not able to sort it out. So please if any body knows, answer this.
    Thanks,
    Kumar

    Hi Nithin,
    I was facing the similar issue in a custom report program. I did apply the logic that you'd mentioned.
    I've implemented the code as below.
    IF  gr_container IS INITIAL.
    *** Check whether the program is run in batch or foreground
        IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
    * Run in foreground
          CREATE OBJECT gr_container
            EXPORTING
              container_name = 'WORK_AREA_CONTAINER'.
          CREATE OBJECT lv_grid
            EXPORTING I_PARENT = gr_container.
        ELSE.
    * Run in background
          CREATE OBJECT lv_grid
            EXPORTING
              I_PARENT = gr_dockcontainer.
          ENDIF.
          ENDIF.
    i_parent_control = gr_dockcontainer.
            CREATE OBJECT m_base_splitter
            EXPORTING
              parent            = i_parent_control
              ROWS              = 1
              columns           = 2
            EXCEPTIONS
              cntl_error        = 1
              cntl_system_error = 2
              OTHERS            = 3.
            CALL METHOD m_base_splitter->get_container
            EXPORTING
              row       = 1
              column    = 2
              RECEIVING
              container = m_splitter_right_part
            EXCEPTIONS
              OTHERS    = 1.
    After I've implemented the above code I'm getting the following error in the batch job:
    Category               ABAP Programming Error
    Runtime Errors         OBJECTS_OBJREF_NOT_ASSIGNED
    Except.                CX_SY_REF_IS_INITIAL
    You attempted to use a 'NULL' object reference (points to 'nothing')
    access a component (variable: "M_BASE_SPLITTER").
    An object reference must point to an object (an instance of a class)
    before it can be used to access components.
    Either the reference was never set or it was set to 'NULL' using the
    CLEAR statement.
    Would you be able to help me in the above issue?

  • How to populate data in dynamic internal table

    Hi Expert,
    fyi. My dynamic internal table field is created base on data selected. Eg. select table qpcd has 5 records.  These 5 recods will become fieldname to my dynamic internal table. My dynamic internal table will be
    ...itab
          01
          02
          03
          04
          05
    The 5 records from qpcd is populated in another table call viqmel.  I need to find the occurance of each code in viqmel and populate the number of occurance in itab in each of column.  The final dynamic itab will be like this
    table itab
    01       02     03    04     05   -
    > field name
    2         0        1     0       1    -
    > data
    my source code like below
    Report ZPLYGRND2.
    TABLES: mara, makt.
    TYPE-POOLS: slis, sydes.
    DATA:it_fcat TYPE slis_t_fieldcat_alv,
         is_fcat LIKE LINE OF it_fcat,
         ls_layout TYPE slis_layout_alv.
    DATA: it_fieldcat TYPE lvc_t_fcat,
          is_fieldcat LIKE LINE OF it_fieldcat.
    DATA: new_table TYPE REF TO data,
          new_line TYPE REF TO data,
          ob_cont_alv TYPE REF TO cl_gui_custom_container,
          ob_alv TYPE REF TO cl_gui_alv_grid,
          vg_campos(255) TYPE c,
          i_campos LIKE TABLE OF vg_campos,
          vg_campo(30) TYPE c,
          vg_tables(60) TYPE c.
    types : begin of t_qpcd,
             codegruppe like qpcd-codegruppe,
             code like qpcd-code,
            end of t_qpcd.
    data:wa_qpcd type t_qpcd,
         i_qpcd type standard table of t_qpcd initial size 0.
    FIELD-SYMBOLS: <l_table> TYPE table,
                   <l_line> TYPE ANY,
                   <l_field> TYPE ANY.
    select * into corresponding fields of wa_qpcd from qpcd
    where katalogart = 'D'
    and   codegruppe = 'OOT01'.
    append wa_qpcd to i_qpcd.
    endselect.
    loop at i_qpcd into wa_qpcd.
      is_fcat-fieldname = wa_qpcd-code.
      APPEND is_fcat TO it_fcat.
    endloop.
    LOOP AT it_fcat INTO is_fcat.
        is_fieldcat-fieldname = is_fcat-fieldname.
        is_fieldcat-ref_field = is_fcat-ref_fieldname.
        is_fieldcat-ref_table = is_fcat-ref_tabname.
        APPEND is_fieldcat TO it_fieldcat.
    ENDLOOP.
    *... Create the dynamic internal table
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
            it_fieldcatalog = it_fieldcat
        IMPORTING
            ep_table = new_table.
    if sy-subrc = 0.
    endif.
    *... Create a new line
    ASSIGN new_table->* TO <l_table>.
    CREATE DATA new_line LIKE LINE OF <l_table>.
    ASSIGN new_line->* TO <l_line>.
    LOOP AT <l_table> INTO <l_line>.
    ENDLOOP.

    hello dear i m giving u a code in this a dynamic table is made on the basis of table in database , and u can download this data correct it , see it, or even change it....and upload in tht table help full if u dont know the table name...in advance.
    also the code to populate data in dynamic table is in this code like:
    SELECT * FROM (MTABLE_N)
    INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
    look at the whole program .hope this solve ur problem thanks.
    REPORT ZTESTA  MESSAGE-ID ZIMM    .
    TYPES : DATA_OBJECT TYPE REF TO DATA.
    DATA : MITAB TYPE REF TO DATA .
    TYPE-POOLS : SLIS .
    DATA : IT_FIELDCAT TYPE STANDARD TABLE OF SLIS_FIELDCAT_ALV
    WITH HEADER LINE .
    DATA : IT_FIELDCATALOG TYPE LVC_T_FCAT .
    DATA : WA_FIELDCATALOG TYPE LVC_S_FCAT .
    DATA : I_STRUCTURE_NAME LIKE DD02L-TABNAME .
    DATA : I_CALLBACK_PROGRAM LIKE SY-REPID .
    DATA : DYN_LINE TYPE DATA_OBJECT .
    FIELD-SYMBOLS : <FS_ITAB> TYPE STANDARD TABLE .
    DATA : TABLE_NAME_IS_VALID TYPE C .
    DATA : DYNAMIC_IT_INSTANTIATED TYPE C .
    CONSTANTS BUTTONSELECTED TYPE C VALUE 'X' .
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_TABL.
    PARAMETERS : MTABLE_N LIKE RSRD1-TBMA_VAL
    MATCHCODE OBJECT DD_DBTB_16 OBLIGATORY .
    DATA CHECKTABLED.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_FILE.
    PARAMETERS : MFILENAM LIKE RLGRAP-FILENAME .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_DOWN.
    PARAMETERS : P_DOWNLD RADIOBUTTON GROUP GRP1
    USER-COMMAND M_UCOMM .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_CHKF.
    PARAMETERS : P_CHKFIL RADIOBUTTON GROUP GRP1 .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_UPLD.
    PARAMETERS : P_UPLOAD RADIOBUTTON GROUP GRP1 .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 5(29) T_SHOW.
    PARAMETERS : P_SHOW_T RADIOBUTTON GROUP GRP1 .
    SELECTION-SCREEN END OF LINE.
    AT SELECTION-SCREEN OUTPUT .
      PERFORM CHECK_FILENAME .
    AT SELECTION-SCREEN.
      IF SY-UCOMM = 'ONLI'.
        CHECKTABLED = MTABLE_N+0(1).
        IF CHECKTABLED NE 'Z'.
          MESSAGE I017.
          LEAVE TO SCREEN 1000.
        ENDIF.
        IF SY-UNAME NE 'KAMESH.K'.
          MESSAGE I023 WITH SY-UNAME.
          LEAVE TO SCREEN 1000.
        ENDIF.
      ENDIF.
      IF SY-UCOMM = 'PRIN'.
        CHECKTABLED = MTABLE_N+0(1).
        IF CHECKTABLED NE 'Z'.
          MESSAGE I017.
          LEAVE TO SCREEN 1000.
        ENDIF.
        IF SY-UNAME NE 'KAMESH.K'.
          MESSAGE I023 WITH SY-UNAME.
          LEAVE TO SCREEN 1000.
        ENDIF.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR MFILENAM .
      PERFORM F4_FOR_FILENAME .
    INITIALIZATION .
      T_TABL = 'Table Name' .
      T_FILE = 'File Name' .
      T_DOWN = 'Download Table' .
      T_CHKF = 'Check File to Upload' .
      T_UPLD = 'Upload File' .
      T_SHOW = 'Show Table Contents' .
    START-OF-SELECTION .
      PERFORM CHECK_TABLE_NAME_IS_VALID .
    END-OF-SELECTION .
      IF TABLE_NAME_IS_VALID EQ ' ' .
        MESSAGE I398(00) WITH 'INVALID TABLE NAME' .
      ELSE .
        PERFORM INSTANTIATE_DYNAMIC_INTERNAL_T .
        CHECK DYNAMIC_IT_INSTANTIATED = 'X' .
        CASE BUTTONSELECTED .
          WHEN P_DOWNLD .
            PERFORM SELECT_AND_DOWNLOAD .
          WHEN P_CHKFIL .
            PERFORM CHECK_FILE_TO_UPLOAD .
          WHEN P_UPLOAD .
            PERFORM UPLOAD_FROM_FILE .
          WHEN P_SHOW_T .
            PERFORM SHOW_CONTENTS .
        ENDCASE .
      ENDIF .
    FORM CHECK_TABLE_NAME_IS_VALID.
      DATA MCOUNT TYPE I .
      TABLES DD02L .
      CLEAR TABLE_NAME_IS_VALID .
      SELECT COUNT(*) INTO MCOUNT FROM TADIR
      WHERE PGMID = 'R3TR'
      AND OBJECT = 'TABL'
      AND OBJ_NAME = MTABLE_N .
      IF MCOUNT EQ 1 .
        CLEAR DD02L .
        SELECT SINGLE * FROM DD02L WHERE TABNAME = MTABLE_N .
        IF SY-SUBRC EQ 0.
          IF DD02L-TABCLASS = 'TRANSP' .
            TABLE_NAME_IS_VALID = 'X' .
          ENDIF .
        ENDIF.
      ENDIF .
    ENDFORM. " CHECK_TABLE_NAME_IS_VALID
    FORM SELECT_AND_DOWNLOAD.
      CLEAR : <FS_ITAB> .
      SELECT * FROM (MTABLE_N)
      INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
      PERFORM CHECK_FILENAME.
      CALL FUNCTION 'WS_DOWNLOAD'
           EXPORTING
                FILENAME                = MFILENAM
                FILETYPE                = 'DAT'
           TABLES
                DATA_TAB                = <FS_ITAB>
           EXCEPTIONS
                FILE_OPEN_ERROR         = 1
                FILE_WRITE_ERROR        = 2
                INVALID_FILESIZE        = 3
                INVALID_TYPE            = 4
                NO_BATCH                = 5
                UNKNOWN_ERROR           = 6
                INVALID_TABLE_WIDTH     = 7
                GUI_REFUSE_FILETRANSFER = 8
                CUSTOMER_ERROR          = 9
                OTHERS                  = 10.
      IF SY-SUBRC EQ 0.
        MESSAGE I398(00) WITH 'Table' MTABLE_N
        'successfully downloaded to '
        MFILENAM .
      ENDIF.
    ENDFORM. " SELECT_AND_DOWNLOAD
    FORM UPLOAD_FROM_FILE.
      DATA : ANS TYPE C .
      DATA : LINES_OF_ITAB TYPE I .
      DATA : MSY_SUBRC TYPE I .
      CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
           EXPORTING
                TEXTLINE1 = 'Are you sure you wish to upload'
                TEXTLINE2 = 'data from ASCII File to DB table '
                TITEL     = 'Confirmation of Data Upload'
           IMPORTING
                ANSWER    = ANS.
      IF ANS = 'J' .
        PERFORM CHECK_FILENAME.
        CLEAR MSY_SUBRC .
        CALL FUNCTION 'WS_UPLOAD'
             EXPORTING
                  FILENAME                = MFILENAM
                  FILETYPE                = 'DAT'
             TABLES
                  DATA_TAB                = <FS_ITAB>
             EXCEPTIONS
                  CONVERSION_ERROR        = 1
                  FILE_OPEN_ERROR         = 2
                  FILE_READ_ERROR         = 3
                  INVALID_TYPE            = 4
                  NO_BATCH                = 5
                  UNKNOWN_ERROR           = 6
                  INVALID_TABLE_WIDTH     = 7
                  GUI_REFUSE_FILETRANSFER = 8
                  CUSTOMER_ERROR          = 9
                  OTHERS                  = 10.
        MSY_SUBRC = MSY_SUBRC + SY-SUBRC .
        IF SY-SUBRC EQ 0.
          DESCRIBE TABLE <FS_ITAB> LINES LINES_OF_ITAB .
          IF LINES_OF_ITAB GT 0 .
            MODIFY (MTABLE_N) FROM TABLE <FS_ITAB> .
            MSY_SUBRC = MSY_SUBRC + SY-SUBRC .
          ENDIF .
        ENDIF.
        IF MSY_SUBRC EQ 0 .
          MESSAGE I398(00) WITH LINES_OF_ITAB
          'Record(s) inserted in table'
          MTABLE_N .
        ELSE .
          MESSAGE I398(00) WITH
          'Errors occurred No Records inserted in table'
          MTABLE_N .
        ENDIF .
      ENDIF .
    ENDFORM. " UPLOAD_FROM_FILE
    FORM F4_FOR_FILENAME.
      CALL FUNCTION 'WS_FILENAME_GET'
           EXPORTING
                DEF_PATH         = 'C:\'
                MASK             = ',.,..'
                MODE             = '0'
           IMPORTING
                FILENAME         = MFILENAM
           EXCEPTIONS
                INV_WINSYS       = 1
                NO_BATCH         = 2
                SELECTION_CANCEL = 3
                SELECTION_ERROR  = 4
                OTHERS           = 5.
    ENDFORM. " F4_FOR_FILENAME
    FORM CHECK_FILENAME.
      IF MFILENAM IS INITIAL
      AND NOT ( MTABLE_N IS INITIAL )
      AND P_SHOW_T NE BUTTONSELECTED.
        CONCATENATE 'C:\'
        MTABLE_N '.TXT' INTO MFILENAM.
      ENDIF .
    ENDFORM. " CHECK_FILENAME
    FORM INSTANTIATE_DYNAMIC_INTERNAL_T.
      CLEAR DYNAMIC_IT_INSTANTIATED .
      I_STRUCTURE_NAME = MTABLE_N .
      CLEAR IT_FIELDCAT[] .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_STRUCTURE_NAME       = I_STRUCTURE_NAME
           CHANGING
                CT_FIELDCAT            = IT_FIELDCAT[]
           EXCEPTIONS
                INCONSISTENT_INTERFACE = 1
                PROGRAM_ERROR          = 2
                OTHERS                 = 3.
      IF SY-SUBRC EQ 0.
        LOOP AT IT_FIELDCAT .
          CLEAR WA_FIELDCATALOG .
          MOVE-CORRESPONDING IT_FIELDCAT TO WA_FIELDCATALOG .
          WA_FIELDCATALOG-REF_FIELD = IT_FIELDCAT-FIELDNAME .
          WA_FIELDCATALOG-REF_TABLE = MTABLE_N .
          APPEND WA_FIELDCATALOG TO IT_FIELDCATALOG .
        ENDLOOP .
        CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
        IT_FIELDCATALOG = IT_FIELDCATALOG
        IMPORTING
        EP_TABLE = MITAB .
        ASSIGN MITAB->* TO <FS_ITAB> .
        DYNAMIC_IT_INSTANTIATED = 'X' .
      ENDIF.
    ENDFORM. " INSTANTIATE_DYNAMIC_INTERNAL_T
    FORM SHOW_CONTENTS.
      CLEAR : <FS_ITAB> .
      SELECT * FROM (MTABLE_N)
      INTO CORRESPONDING FIELDS OF TABLE <FS_ITAB> .
      I_CALLBACK_PROGRAM = SY-REPID .
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM = I_CALLBACK_PROGRAM
                IT_FIELDCAT        = IT_FIELDCAT[]
           TABLES
                T_OUTTAB           = <FS_ITAB>
           EXCEPTIONS
                PROGRAM_ERROR      = 1
                OTHERS             = 2.
    ENDFORM. " SHOW_CONTENTS
    FORM CHECK_FILE_TO_UPLOAD.
      PERFORM CHECK_FILENAME.
      CALL FUNCTION 'WS_UPLOAD'
           EXPORTING
                FILENAME                = MFILENAM
                FILETYPE                = 'DAT'
           TABLES
                DATA_TAB                = <FS_ITAB>
           EXCEPTIONS
                CONVERSION_ERROR        = 1
                FILE_OPEN_ERROR         = 2
                FILE_READ_ERROR         = 3
                INVALID_TYPE            = 4
                NO_BATCH                = 5
                UNKNOWN_ERROR           = 6
                INVALID_TABLE_WIDTH     = 7
                GUI_REFUSE_FILETRANSFER = 8
                CUSTOMER_ERROR          = 9
                OTHERS                  = 10.
      IF SY-SUBRC EQ 0.
        I_CALLBACK_PROGRAM = SY-REPID .
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
             EXPORTING
                  I_CALLBACK_PROGRAM = I_CALLBACK_PROGRAM
                  IT_FIELDCAT        = IT_FIELDCAT[]
             TABLES
                  T_OUTTAB           = <FS_ITAB>
             EXCEPTIONS
                  PROGRAM_ERROR      = 1
                  OTHERS             = 2.
      ENDIF .
    ENDFORM. " CHECK_FILE_TO_UPLOAD
    Message was edited by:
            SAURABH SINGH
            SENIOR EXECUTIVE
            SAMSUNG INDIA ELECTRONICS LTD.,NOIDA

  • Field catalog in abap objects

    hi friends,
                   i am using factory method to display my alv. now some of the fields in my internal table i have declared them as char fields, i want certain type of headings for these fields,so where can i give heading to these fields.
                   where exactly do we create a field catalog for factory method.
    pls advice me on this

    hi
    good
    go throgh this code
    *& Report  Z_ALV_OOPS
    REPORT  Z_ALV_OOPS.
    *Event class Definition                             "Event handler class
    class event_handle definition.
      public section.
        methods: handle_user
          for event user_command of cl_gui_alv_grid
          importing e_ucomm.
    endclass.
    *Event class Implementation
    class event_handle implementation.
      method handle_user.
        write:/ ''.
      endmethod.
    endclass.
    Data: t_alv       type ref to cl_gui_alv_grid,           "ALV control
          t_cont      type ref to cl_gui_custom_container,   "Cust Container
          t_alv2      type ref to cl_gui_alv_grid,           "ALV control
          t_cont2     type ref to cl_gui_custom_container,   "Cust Container
          t_fieldcat  type lvc_t_fcat with header line,      "Field Cat
          t_fieldcat2 type lvc_t_fcat with header line,      "Field Cat
          t_layout    type lvc_s_layo,                       "Layout
          t_event     type ref to event_handle,              "Event handler
          t_sort      type LVC_T_SORT with header line,      "Sort
          t_toolbar   type ui_functions with header line.    "Toolbar xclude
    Types: begin of g_vbak,                                 "Header Table
             vbeln like vbak-vbeln,
             auart like vbak-auart,
             vkorg like vbak-vkorg,
             vtweg like vbak-vtweg,
             spart like vbak-spart,
             kunnr like vbak-kunnr,
             bstnk like vbak-bstnk,
             seltab,
           end of g_vbak.
    Types: begin of g_vbap,                                  "Item Table
             vbeln like vbap-vbeln,
             posnr(6) type c,
            posrn like vbap-posnr,
             matnr like vbap-matnr,
             netwr like vbap-netwr,
             waerk like vbap-waerk,
           end of g_vbap.
    Data: t_vbak type g_vbak occurs 0,
          t_vbap type g_vbap occurs 0.
    Start-Of-Selection.
    *Fetch data from DB Table
    select vbeln auart vkorg vtweg spart kunnr bstnk
        from vbak into table t_vbak up to 20 rows.
    End-Of-Selection.
    *Call ALV screen
    call screen 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'ALV'.
      SET TITLEBAR 'VBAK'.
    if t_cont is initial.
      create object t_cont
        exporting
          container_name = 'ALV'.
      create object t_alv
        exporting
          i_parent = t_cont.
    *Create event handlers
      create object t_event.
      set handler t_event->handle_user for t_alv.
      perform build_fieldcatlog.
      perform build_layout.
      perform xclude_toolbar.
      CALL METHOD t_alv->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                     = t_layout
         IS_PRINT                      =
         IT_SPECIAL_GROUPS             =
          IT_TOOLBAR_EXCLUDING          = t_toolbar[]
         IT_HYPERLINK                  =
         IT_ALV_GRAPHICS               =
         IT_EXCEPT_QINFO               =
        CHANGING
          IT_OUTTAB                     = t_vbak[]
          IT_FIELDCATALOG               = t_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.
    endif.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
    Data: lt_rows type lvc_t_row,
          wa_rows type line of lvc_t_row,
          wa_vbak type g_vbak,
          l_lines type i.
    refresh: t_vbap.
    case sy-ucomm.
      when 'DET'.                                  "Item details
      Get selected rows from ALV
        call method t_alv->get_selected_rows
            importing
                et_index_rows = lt_rows.
      Fetch corresponding Item details from VBAP
        loop at lt_rows into wa_rows.
          read table t_vbak into wa_vbak index wa_rows-index transporting
                                                                    vbeln.
          select vbeln posnr matnr netwr waerk from vbap
              appending corresponding fields of table t_vbap
              where vbeln = wa_vbak-vbeln.
        endloop.
      Prepare fieldcatlog
      Display Item details in ALV
        call screen 200 starting at 8 5.
      when 'SHOW'.                                  "Display order
        call method t_alv->get_selected_rows
            importing
                et_index_rows = lt_rows.
        Describe table lt_rows lines l_lines.
        if l_lines > 1.
          message e999(z_error).
        else.
          read table lt_rows into wa_rows index 1.
          read table t_vbak into wa_vbak index wa_rows-index transporting
                                                                    vbeln.
          set parameter id 'AUN' field wa_vbak-vbeln.
          call transaction 'VA03' and skip first screen.
        endif.
    endcase.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  build_fieldcatlog
          text
    form build_fieldcatlog .
      clear t_fieldcat.
      t_fieldcat-col_pos = '1'.
      t_fieldcat-fieldname = 'VBELN'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'VBELN'.
      append t_fieldcat.
      t_fieldcat-col_pos = '2'.
      t_fieldcat-fieldname = 'AUART'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'AUART'.
      append t_fieldcat.
      t_fieldcat-col_pos = '3'.
      t_fieldcat-fieldname = 'VKORG'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'VKORG'.
      append t_fieldcat.
      t_fieldcat-col_pos = '4'.
      t_fieldcat-fieldname = 'VTWEG'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'VTWEG'.
      append t_fieldcat.
      t_fieldcat-col_pos = '5'.
      t_fieldcat-fieldname = 'SPART'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'SPART'.
      append t_fieldcat.
      t_fieldcat-col_pos = '6'.
      t_fieldcat-fieldname = 'KUNNR'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'KUNNR'.
      append t_fieldcat.
      t_fieldcat-col_pos = '7'.
      t_fieldcat-fieldname = 'BSTNK'.
      t_fieldcat-ref_table = 'VBAK'.
      t_fieldcat-ref_field = 'BSTNK'.
      append t_fieldcat.
    endform.                    " build_fieldcatlog
    *&      Module  LEAVE  INPUT
          text
    module LEAVE input.
    case sy-ucomm.
      when 'BACK' or 'EXIT' or 'CANCEL'.
        leave program.
    endcase.
    endmodule.                 " LEAVE  INPUT
    *&      Form  build_layout
          text
    -->  p1        text
    <--  p2        text
    form build_layout .
    t_layout-zebra = 'X'.
    t_layout-sel_mode = 'A'.
    t_layout-grid_title = 'Header Details'.
    endform.                    " build_layout
    *&      Form  build_fcat_vbap
          text
    form build_fcat_vbap .
      clear t_fieldcat2.
      t_fieldcat2-scrtext_m = 'Sales Doc'.
      t_fieldcat2-col_pos = 1.
      t_fieldcat2-fieldname = 'VBELN'.
      t_fieldcat2-tabname = 'T_VBAP'.
      t_fieldcat2-no_zero = 'X'.
      t_fieldcat2-ref_table = 'VBAP'.
      t_fieldcat2-ref_field = 'VBELN'.
      append t_fieldcat2.
      clear t_fieldcat2.
      t_fieldcat2-col_pos = 2.
      t_fieldcat2-scrtext_m = 'Item'.
      t_fieldcat2-fieldname = 'POSNR'.
      t_fieldcat2-tabname = 'T_VBAP'.
      t_fieldcat2-intlen = '6'.
      t_fieldcat2-inttype = 'C'.
      t_fieldcat2-no_zero = 'X'.
    t_fieldcat2-ref_table = 'VBAP'.
    t_fieldcat2-ref_field = 'POSNR'.
      append t_fieldcat2.
      clear t_fieldcat2.
      t_fieldcat2-col_pos = 3.
      t_fieldcat2-fieldname = 'MATNR'.
      t_fieldcat2-ref_table = 'VBAP'.
      t_fieldcat2-ref_field = 'MATNR'.
      append t_fieldcat2.
      clear t_fieldcat2.
      t_fieldcat2-col_pos = 4.
      t_fieldcat2-fieldname = 'NETWR'.
      t_fieldcat2-ref_table = 'VBAP'.
      t_fieldcat2-ref_field = 'NETWR'.
      t_fieldcat2-do_sum = 'X'.
      append t_fieldcat2.
      clear t_fieldcat2.
      t_fieldcat2-col_pos = 5.
      t_fieldcat2-fieldname = 'WAERK'.
      t_fieldcat2-ref_table = 'VBAP'.
      t_fieldcat2-ref_field = 'WAERK'.
      append t_fieldcat2.
    endform.                    " build_fcat_vbap
    *&      Module  STATUS_0200  OUTPUT
          text
    module STATUS_0200 output.
      SET PF-STATUS 'ITEM1'.
      SET TITLEBAR 'VBAP'.
      perform build_fcat_vbap.
      perform sort_alv2.
    if t_cont2 is initial.
      create object t_cont2
        exporting
          container_name = 'ITEM'.
      create object t_alv2
        exporting
          i_parent = t_cont2.
      t_layout-grid_title = 'Item Details'.
      CALL METHOD t_alv2->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                     = t_layout
         IS_PRINT                      =
         IT_SPECIAL_GROUPS             =
          IT_TOOLBAR_EXCLUDING          = t_toolbar[]
         IT_HYPERLINK                  =
         IT_ALV_GRAPHICS               =
         IT_EXCEPT_QINFO               =
         IR_SALV_ADAPTER               =
        CHANGING
          it_outtab                     = t_vbap[]
          IT_FIELDCATALOG               = t_fieldcat2[]
          IT_SORT                       = t_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.
    else.
      CALL METHOD t_alv2->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.
    endmodule.                 " STATUS_0200  OUTPUT
    *&      Module  USER_COMMAND_0200  INPUT
          text
    module USER_COMMAND_0200 input.
    case sy-ucomm.
      when 'GOBACK'.
        leave to screen 0.
    endcase.
    endmodule.                 " USER_COMMAND_0200  INPUT
    *&      Form  sort_alv2
          text
    -->  p1        text
    <--  p2        text
    form sort_alv2 .
    clear t_sort.
    t_sort-spos = '1'.
    t_sort-fieldname = 'VBELN'.
    t_sort-up = 'X'.
    t_sort-subtot = 'X'.
    append t_sort.
    endform.                    " sort_alv2
    *&      Form  xclude_toolbar
          text
    -->  p1        text
    <--  p2        text
    form xclude_toolbar .
    t_toolbar = '&DETAIL'.
    append t_toolbar.
    t_toolbar = '&&SEP00'.
    append t_toolbar.
    t_toolbar = '&&SEP01'.
    append t_toolbar.
    t_toolbar = '&&SEP02'.
    append t_toolbar.
    t_toolbar = '&SORT_ASC'.
    append t_toolbar.
    t_toolbar = '&SORT_DSC'.
    append t_toolbar.
    t_toolbar = '&FIND'.
    append t_toolbar.
    t_toolbar = '&MB_FILTER'.
    append t_toolbar.
    t_toolbar = '&&SEP04'.
    append t_toolbar.
    t_toolbar = '&MB_SUM'.
    append t_toolbar.
    t_toolbar = '&MB_SUB_TOTAL'.
    append t_toolbar.
    t_toolbar = '&PRINT_BACK'.
    append t_toolbar.
    t_toolbar = '&MB_VIEW'.
    append t_toolbar.
    t_toolbar = '&MB_EXPORT'.
    append t_toolbar.
    t_toolbar = '&GRAPH'.
    append t_toolbar.
    t_toolbar = '&COLO'.
    append t_toolbar.
    t_toolbar = '&&SEP06'.
    append t_toolbar.
    t_toolbar = '&&SEP07'.
    append t_toolbar.
    t_toolbar = '&INFO'.
    append t_toolbar.
    t_toolbar = '&&SEP03'.
    append t_toolbar.
    endform.                    " xclude_toolbar
    reward point if helpful.
    thanks
    mrutyun^

Maybe you are looking for

  • Epson Stylus NX430 will no longer print!

    I recently changed internet providers and purchased a new Netgear router.  Up until then, I have had no problem printing from my Macbook Air to my Epson Stylus NX430, but now when I try to print I get an Error message! I have emailed back and forth w

  • Super Drive No Longer Recongized With 10.4.8

    I just updated and my Intel Mac Mini 10.4.8 no longer reconized my Super Drive. Help me.

  • GUI_UPLOAD Function Module in 4.6C does not split into lines

    Dear All, I'm about to upload text file into SAP using the FM 'GUI_UPLOAD'. Previously I've developed a test program to upload the same file in SAP v4.7 and it returns correctly into several lines as expected. Snippet: CALL FUNCTION 'GUI_UPLOAD'    

  • Change Icon in URL Bar

    Can someone please instruct me on how to change the default icon used in the URL bar for an APEX app? Thanks, Blake

  • Opening Nat on WRT54G

    Ok, I need to open my NAT on my Xbox 360. I have a model WRT54G. My setup works like this: My modem recieves the internet, my router is hooked up to my modem and is wired to my downstairs computer. My upstairs computer recieves the internet wirelessl