Passing dynamic internal table into ALV

I have made one ALV report where i had created one button 'GENERATE'.  ON CLICKING THIS BUTTON the data in the ALV report is downloaded to excel file.
i have used this:-
CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
      window_title         = l_title
      default_extension    = 'XLS'
      initial_directory    = 'C:\'
    CHANGING
      filename             = filename
      path                 = path
      fullpath             = fullpath
      user_action          = user_action
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      not_supported_by_gui = 3
      OTHERS               = 4.
  IF sy-subrc <> 0.
    EXIT.
  ENDIF.
Check which button is pressed
  IF user_action <> cl_gui_frontend_services=>action_ok.
    EXIT.
  ENDIF.
Download error data collected from the internal table
  CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      filename                = fullpath
      filetype                = 'ASC'
      write_field_separator   = '#'
     codepage                = '4103'
     write_bom               = c_true
    CHANGING
      data_tab                = gi_final
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      not_supported_by_gui    = 22
      error_no_gui            = 23
      OTHERS                  = 24.
If selection is successful
  IF sy-subrc EQ 0.
    MESSAGE s004 . " File  created successfully
  ELSE.
    MESSAGE i005 . " File is not created successfully
  ENDIF.
In the table i have passed the internal table . this is working fine.
<b>But,
The problem is if i want to display the data in diferent layout based on selection screen criteria the data downloaded are same as default layout.
how to pass a dynamic internal table in the
CALL METHOD cl_gui_frontend_services=>gui_download</b>

Hi    ,
here is the Program for  Download  
REPORT yrs_download_transport_request.
PARAMETERS:
  p_reqest TYPE trkorr OBLIGATORY,
  p_folder(255) TYPE c LOWER CASE, p_sepr OBLIGATORY.
DATA:
  folder TYPE string,
  retval LIKE TABLE OF ddshretval WITH HEADER LINE,
  fldvalue LIKE help_info-fldvalue,
  transdir TYPE text255,
  filename(255),
  trfile(20) TYPE c,
  datatab TYPE TABLE OF text8192 WITH HEADER LINE,
  len TYPE i,
  flen TYPE i.
TYPE-POOLS: sabc, stms, trwbo.
INITIALIZATION.
  CONCATENATE sy-sysid 'K*' INTO p_reqest.
  IF sy-opsys = 'Windows NT'.
    p_sepr = ''.
  ELSE.
    p_sepr = '/'.
  ENDIF.
*  CALL FUNCTION 'WSAF_BUILD_SEPARATOR'
*       IMPORTING
*            separator                  = p_sepr
*       EXCEPTIONS
*            separator_not_maintained   = 1
*            wrong_call                 = 2
*            wsaf_config_not_maintained = 3
*            OTHERS                     = 4.
*  IF sy-subrc NE 0.
*    MESSAGE s001(00)
*      WITH
*      'Unable to find out the separator symbol for the system.'(011).
*  ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_reqest.
  DATA:
    tt_system TYPE TABLE OF tmscsys WITH HEADER LINE,
    es_selected_request TYPE trwbo_request_header,
    es_selected_task TYPE trwbo_request_header,
    iv_organizer_type TYPE trwbo_calling_organizer,
    is_selection TYPE trwbo_selection.
  iv_organizer_type = 'W'. is_selection-reqstatus = 'R'.
  CALL FUNCTION 'TR_PRESENT_REQUESTS_SEL_POPUP'
    EXPORTING
      iv_organizer_type   = iv_organizer_type
      is_selection        = is_selection
    IMPORTING
      es_selected_request = es_selected_request
      es_selected_task    = es_selected_task.
  p_reqest = es_selected_request-trkorr.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder.
  DATA: title TYPE string.
  title = 'Select target folder'(005).
  CALL METHOD cl_gui_frontend_services=>directory_browse
    EXPORTING
      window_title    = title
    CHANGING
      selected_folder = folder
    EXCEPTIONS
      cntl_error      = 1
      error_no_gui    = 2
      OTHERS          = 3.
  CALL FUNCTION 'CONTROL_FLUSH'
    EXCEPTIONS
      cntl_system_error = 1
      cntl_error        = 2
      OTHERS            = 3.
  p_folder = folder.
AT SELECTION-SCREEN ON p_reqest.
  DATA: request_info TYPE stms_wbo_request,
        request_infos TYPE stms_wbo_requests.
  REFRESH request_infos.
  CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST'
    EXPORTING
      iv_request                 = p_reqest
      iv_header_only             = 'X'
    IMPORTING
      et_request_infos           = request_infos
    EXCEPTIONS
      read_config_failed         = 1
      table_of_requests_is_empty = 2
      system_not_available       = 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.
  CLEAR request_info.
  READ TABLE request_infos INTO request_info INDEX 1.
  IF sy-subrc NE 0
  OR request_info-e070-trkorr IS INITIAL.
    MESSAGE e398(00) WITH 'Request'(006) p_reqest 'not found'(007).
  ELSEIF request_info-e070-trstatus NE 'R'.
    MESSAGE e398(00)
    WITH 'You must release request'(008)
         request_info-e070-trkorr
         'before downloading'(009).
  ENDIF.
START-OF-SELECTION.
  folder = p_folder.
  CONCATENATE p_reqest+3(7) '.' p_reqest(3) INTO trfile.
  CALL FUNCTION 'RSPO_R_SAPGPARAM'
    EXPORTING
      name   = 'DIR_TRANS'
    IMPORTING
      value  = transdir
    EXCEPTIONS
      error  = 0
      OTHERS = 0.
  PERFORM copy_file USING 'cofiles' trfile.
  trfile(1) = 'R'.
  PERFORM copy_file USING 'data' trfile.
  trfile(1) = 'D'.
  PERFORM copy_file USING 'data' trfile.
* FORM copy_file *
* --> SUBDIR * * --> FNAME *
FORM copy_file USING subdir fname.
  DATA:
    auth_filename TYPE authb-filename,
    gui_filename TYPE string.
  CONCATENATE transdir subdir fname
    INTO filename
    SEPARATED BY p_sepr.
  REFRESH datatab.
  CLEAR flen.
  auth_filename = filename.
  CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
    EXPORTING
      activity         = sabc_act_read
      filename         = auth_filename
    EXCEPTIONS
      no_authority     = 1
      activity_unknown = 2
      OTHERS           = 3.
  IF sy-subrc <> 0.
    FORMAT COLOR COL_NEGATIVE.
    WRITE: / 'Read access denied. File'(001),
              filename.
    FORMAT COLOR OFF. EXIT.
  ENDIF.
  OPEN DATASET filename FOR INPUT IN BINARY MODE.
  IF sy-subrc NE 0.
    FORMAT COLOR COL_TOTAL.
    WRITE: / 'File open error'(010), filename.
    FORMAT COLOR OFF. EXIT.
  ENDIF.
  DO.
    CLEAR len.
    READ DATASET filename INTO datatab LENGTH len.
    flen = flen + len.
    IF len > 0. APPEND datatab. ENDIF.
    IF sy-subrc NE 0.
      EXIT.
    ENDIF.
  ENDDO.
  CLOSE DATASET filename.
  CONCATENATE p_folder '' fname INTO gui_filename.
  CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      bin_filesize            = flen
      filename                = gui_filename
      filetype                = 'BIN'
    CHANGING
      data_tab                = datatab[]
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      OTHERS                  = 24.
  IF sy-subrc = 0.
    WRITE: / 'File'(002), filename, 'downloaded. Length'(003), flen.
  ELSE.
    FORMAT COLOR COL_NEGATIVE.
    WRITE: / 'File download error. Filename:'(004), filename.
    FORMAT COLOR OFF.
  ENDIF.
ENDFORM. "copy_file
Reward  points if it is usefull....
Girish

Similar Messages

  • Passing Dynamic Internal Tables to Memory

    I have a bit of a conundrum right now that I can't seem to correct. I am working on adding an ALV report to an existing report program. I was able to write a simple helper program that builds a custom object that I defined that translates my raw data into two seperate dynamic tables, and then builds an ALV grid and outputs it. The reason I wrote this in a simple helper program was so that I could use SUBMIT ... EXPORTING LIST TO MEMORY from my primary report program and capture the input so I can later write it out under our company's standard ABAP list format as if I were using WRITE statements.
    The output of the report itself is working beautifully. We have included functionality to automatically take the output, produce an HTML file from it, and then FTP it directly to a webserver so our clients can get easy access to it. What I want to be able to do though is give the clients two tab-delimited files that contain the raw data that was used to build the report. We have an interface in place to do that, but I somehow need to be able to pass these two dynamic internal tables which I have field-symbols to reference back to my calling program.
    Here is what I am trying to do:
    CALL METHOD OBJ_ALV_MR_EST_REASONS->PRODUCE_ESTIMATION_REPORT
        IMPORTING
          RPT_DATA_BY_REASON   = ref_it_estreason
          RPT_DATA_BY_DISTRICT = ref_it_district.
    *   Assign the field symbols
      ASSIGN ref_it_estreason->* TO <it_estreason>.
      ASSIGN ref_it_district->* TO <it_district>.
    * Export the two internal tables to memory so they can be
    * retrieved by the calling program
      EXPORT reason = <it_estreason>[]
             district = <it_district>[]
      TO MEMORY ID 'ZCR_ESTIMATION_REASON_RPT'.
    As you can see, my method returns two references to dynamic internal tables. I have used the memory debugger to see that these tables are being correctly written to the ABAP memory.
    However, back in my parent program when I try to do the following,
    CREATE DATA ref_it_estreason TYPE REF TO DATA.
          CREATE DATA ref_it_district TYPE REF TO DATA.
          ASSIGN ref_it_estreason->* TO <it_estreason>.
          ASSIGN ref_it_district->* TO <it_district>.
          IMPORT reason = <it_estreason>
                 district = <it_district>
          FROM MEMORY ID 'ZCR_ESTIMATION_REASON_RPT'.
    I get the REFS_NOT_SUPPORTED_YET exception which says that "For the statement Export/Import ..." object references, interface references, and data references are currently not supported".
    I have tried multiple other ways of defining my field-symbols or my reference pointers but they all result in exceptions of some sort. Is there any way for me to get this data passed back? It seems like there must be a way to get the data from memory since I know it's being correctly stored there.
    Thanks in advance.

    Shortly after posting this, I had an idea which I was able to implement to actually get this to work.
    I decided that I would simply pass the FIELDCAT tables for each of my dynamic tables into the same memory ID as the tables themselves.
      EXPORT reason_fcat = it_estreason_fcat
             district_fcat = it_district_fcat
             reason = <it_estreason>[]
             district = <it_district>[]
      TO MEMORY ID 'ZCR_ESTIMATION_REASON_RPT'.
    Then, back in my calling program I execute the following code. This retrieves the FIELDCAT tables, builds two empty dynamic table type reference variables and then lets me create field-symbols to reference those components.
    *     Retrieve the fieldcat internal tables first
          IMPORT reason_fcat = it_estreason_fcat
                 district_fcat = it_district_fcat
          FROM MEMORY ID 'ZCR_ESTIMATION_REASON_RPT'.
    *     Generate an internal table type assigned to each
    *     reference variable based on the fieldcat listings we
    *     retrieve
          CALL METHOD cl_alv_table_create=>create_dynamic_table
            EXPORTING
              it_fieldcatalog = it_estreason_fcat
            IMPORTING
              ep_table        = ref_it_estreason.
          CALL METHOD cl_alv_table_create=>create_dynamic_table
            EXPORTING
              it_fieldcatalog = it_district_fcat
            IMPORTING
              ep_table        = ref_it_district.
    *     Assign the field symbols
          ASSIGN ref_it_estreason->* TO <it_estreason>.
          ASSIGN ref_it_district->* TO <it_district>.
          CREATE DATA ref_wa_estreason LIKE LINE OF <it_estreason>.
          CREATE DATA ref_wa_district LIKE LINE OF <it_district>.
          ASSIGN ref_wa_estreason->* TO <wa_estreason>.
          ASSIGN ref_wa_district->* TO <wa_district>.
    *     Finally, we can retrieve the data from memory and assign
    *     to the internal tables referenced by our field-symbols
          IMPORT reason = <it_estreason>[]
                 district = <it_district>[]
          FROM MEMORY ID 'ZCR_ESTIMATION_REASON_RPT'.
    This worked beautifully and saved me from having to do a major redesign. I don't know how helpful it would be for ABAP Objects to be passed to memory (I believe some type of serialization would need to be in order there), but for dynamically typed internal tables it worked like a dream with little overhead.

  • Passing Dynamic Internal Table values to another program

    Hi,
    I have a program ZSAPNEW.
    In this I have created a Dynamic internal table <fs_emp>. The number of fields differ for each run. The values are passed into <fs_emp> in this program.  Now I need to submit thsi program from a main program ZHEAD and then display the values got from ZHEAD. For this I need to access the values retrieved from ZSAPNEW in <fs_emp> in ZHEAD. I cant figure out how to do this. I tried IMPORT ing the reference of teh field symbol too/ But its not allowing references in IMPORT/EXPORT. And since the table is of type ANY( as structure varies) I cant assign it to an internal table and then pass. Can some one suggest a solution please.
    Suzie

    Hi
    You need to know how the strcture of your table is generated In both programm:
    - Calling program:
    DATA: LR_VALUE_DESCR  TYPE REF TO CL_ABAP_ELEMDESCR,
          COMPONENT       TYPE CL_ABAP_STRUCTDESCR=>COMPONENT,
          LT_COMPONENTS   TYPE CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE.
    DATA: LT_STRUC        TYPE REF TO CL_ABAP_STRUCTDESCR,
          LT_TAB          TYPE REF TO CL_ABAP_TABLEDESCR.
    DATA: L_INDEX TYPE C.
    DATA: W_LINE          TYPE REF TO DATA,
          INT_TABLE       TYPE REF TO DATA.
    FIELD-SYMBOLS: <WA>    TYPE ANY,
                   <ITAB>  TYPE TABLE,
                   <VALUE> TYPE ANY.
    DO 4 TIMES.
      CLEAR COMPONENT.
      MOVE SY-INDEX TO L_INDEX.
      CONCATENATE 'FIELD' L_INDEX INTO COMPONENT-NAME.
      MOVE CL_ABAP_ELEMDESCR=>GET_C( P_LENGTH = 4 ) TO LR_VALUE_DESCR.
      COMPONENT-TYPE = LR_VALUE_DESCR.
      INSERT COMPONENT INTO TABLE LT_COMPONENTS.
    ENDDO.
    * Workarea
    LT_STRUC = CL_ABAP_STRUCTDESCR=>CREATE( P_COMPONENTS = LT_COMPONENTS
                                                       P_STRICT     = 'X' ).
    CREATE DATA W_LINE TYPE HANDLE LT_STRUC.
    ASSIGN W_LINE->* TO <WA>.
    * Table
    LT_TAB = CL_ABAP_TABLEDESCR=>CREATE( P_LINE_TYPE = LT_STRUC ).
    CREATE DATA INT_TABLE TYPE HANDLE LT_TAB.
    ASSIGN INT_TABLE->* TO <ITAB>.
    DO 3 TIMES.
      CLEAR <WA>.
      DO 4 TIMES.
        MOVE SY-INDEX TO L_INDEX.
        CONCATENATE 'FIELD' L_INDEX INTO COMPONENT-NAME.
        ASSIGN COMPONENT COMPONENT-NAME OF STRUCTURE <WA> TO <VALUE>.
        MOVE SY-INDEX TO <VALUE>.
      ENDDO.
      APPEND <WA> TO <ITAB>.
    ENDDO.
    DATA: WA_INDX TYPE INDX.
    WA_INDX-USERA = SY-UNAME.
    WA_INDX-PGMID = 'MAXMAX'.
    EXPORT TAB = <ITAB>
      TO DATABASE INDX(XY)
      FROM WA_INDX
      CLIENT SY-MANDT
      ID 'TABLE'.
    Called program:
    DATA: LR_VALUE_DESCR  TYPE REF TO CL_ABAP_ELEMDESCR,
          COMPONENT       TYPE CL_ABAP_STRUCTDESCR=>COMPONENT,
          LT_COMPONENTS   TYPE CL_ABAP_STRUCTDESCR=>COMPONENT_TABLE.
    DATA: LT_STRUC        TYPE REF TO CL_ABAP_STRUCTDESCR,
          LT_TAB          TYPE REF TO CL_ABAP_TABLEDESCR.
    DATA: L_INDEX TYPE C.
    DATA: W_LINE          TYPE REF TO DATA,
          INT_TABLE       TYPE REF TO DATA.
    FIELD-SYMBOLS: <WA>    TYPE ANY,
                   <ITAB>  TYPE TABLE,
                   <VALUE> TYPE ANY.
    DO 4 TIMES.
      CLEAR COMPONENT.
      MOVE SY-INDEX TO L_INDEX.
      CONCATENATE 'FIELD' L_INDEX INTO COMPONENT-NAME.
      MOVE CL_ABAP_ELEMDESCR=>GET_C( P_LENGTH = 4 ) TO LR_VALUE_DESCR.
      COMPONENT-TYPE = LR_VALUE_DESCR.
      INSERT COMPONENT INTO TABLE LT_COMPONENTS.
    ENDDO.
    * Workarea
    LT_STRUC = CL_ABAP_STRUCTDESCR=>CREATE( P_COMPONENTS = LT_COMPONENTS
                                                       P_STRICT     = 'X' ).
    CREATE DATA W_LINE TYPE HANDLE LT_STRUC.
    ASSIGN W_LINE->* TO <WA>.
    * Table
    LT_TAB = CL_ABAP_TABLEDESCR=>CREATE( P_LINE_TYPE = LT_STRUC ).
    CREATE DATA INT_TABLE TYPE HANDLE LT_TAB.
    ASSIGN INT_TABLE->* TO <ITAB>.
    DATA: WA_INDX TYPE INDX.
    WA_INDX-USERA = SY-UNAME.
    WA_INDX-PGMID = 'MAXMAX'.
    IMPORT TAB = <ITAB>
      FROM DATABASE INDX(XY)
      TO WA_INDX
      CLIENT SY-MANDT
      ID 'TABLE'.
    LOOP AT <ITAB> ASSIGNING <WA>.
      WRITE: / <WA>.
    ENDLOOP.
    The sample above use IMPORT/EXPORT from database: if the called program can't know the structure of the dynaic table, you need to transfer it by the same way you transfer the data
    Max

  • Subtotals in dynamic internal table using alv grid

    hi experts i have created one dynamic table.  The requirement is to display the subtotals in the output using reuse_alv_grid.
    Dynamic itab (field-symbols) and ALV event BEFORE_LINE_OUTPUT
    the above is the thread related and could any one please provide the sample code for this task.
    can any one post the solution for that.
    rewards points will be awarded.
    khazi

    * ASSINING STRUCTURE FOR FILD CATLOGS
    DATA: DYN_TABLE    TYPE REF TO DATA,
          DYN_LINE     TYPE REF TO DATA,
          LS_FIELDCAT TYPE LVC_S_FCAT,
          LT_FIELDCAT TYPE LVC_T_FCAT.
      LOOP AT LT_DMTAB INTO LS_DMTAB.
        CLEAR LS_FIELDCAT.
        LS_FIELDCAT-FIELDNAME = LS_DMTAB-SDATE .
        LS_FIELDCAT-DATATYPE  = 'DEC'.
        LS_FIELDCAT-INTTYPE   = 'P'.
        LS_FIELDCAT-INTLEN    = '16' .
        LS_FIELDCAT-DECIMALS  = '03'.
        LS_FIELDCAT-JUST      = 'C'.
        APPEND LS_FIELDCAT TO LT_FIELDCAT.
      ENDLOOP.
    *& For grouping the table rows for Under Line
      LS_FIELDCAT-FIELDNAME = 'ULFIELD' .
      LS_FIELDCAT-DATATYPE  = 'INT'.
      LS_FIELDCAT-INTTYPE   = 'P'.
      LS_FIELDCAT-INTLEN    = '2' .
      LS_FIELDCAT-DECIMALS  = ''.
      APPEND LS_FIELDCAT TO LT_FIELDCAT.
      "* Create dynamic internal table and assign to Field-Symbol
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_FIELDCAT
        IMPORTING
          EP_TABLE        = DYN_TABLE.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      ASSIGN DYN_TABLE->* TO <LT_AREA_F>.
      "* Create dynamic work area and assign to Field Symbol
      CREATE DATA DYN_LINE LIKE LINE OF <LT_AREA_F>.
      ASSIGN DYN_LINE->* TO <LS_AREA_F>.
    You check in Field cat level you will get  Check Sub total field will exist
    Thanks and regards
    Jogu

  • Dynamic internal table for ALV output

    Hi,
    I am looking for a simple & efficient sample code for an ALV report output with dynamic columns. Can someone please help!
    Thanks,
    JS

    Here is a small example. This is pretty old code, and it uses the FM approach.
    report zrich_0001.
    type-pools: slis.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>.
    data: it_alvfc type slis_t_fieldcat_alv,
          wa_alvfc type slis_fieldcat_alv,
          it_fldcat type lvc_t_fcat,
          wa_fldcat type lvc_s_fcat.
    selection-screen begin of block b1 with frame title text-001.
    parameters: p_flds(5) type c.
    selection-screen end of block b1.
    start-of-selection.
    * build the dynamic internal table
      perform build_dyn_itab.
    * write 5 records to the alv grid
      do 5 times.
        perform build_report.
      enddo.
    * call the alv grid.
      perform call_alv.
    *  Build_dyn_itab
    form build_dyn_itab.
    * Create the dynamic internal table
      data: new_table type ref to data,
            new_line  type ref to data.
    * Create fields .
      do p_flds times.
        clear wa_fldcat.
        wa_fldcat-fieldname = sy-index.
        wa_fldcat-datatype  = 'CHAR'.
        wa_fldcat-intlen    = 5.
        append wa_fldcat to it_fldcat .
      enddo.
    * Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = it_fldcat
                   importing
                      ep_table        = new_table.
      assign new_table->* to <dyn_table>.
    * Create dynamic work area and assign to FS
      create data new_line like line of <dyn_table>.
      assign new_line->* to <dyn_wa>.
    endform.
    Have to split this code into two postings to keep formatting.
    Regards,
    Rich Heilman
    Edited by: Rich Heilman on Jun 23, 2009 11:59 AM

  • How to create Dynamic Internal table in ALV?

    Hi all,
    I have to create a ALV report based on dynamic internal table. The requirement is that when I enter the months in my selection screen I should get the data relevant to those many months only. For eg if in selection I have given January to March, I should get an ALV output with columns from January to March only.
    Please help me with the coding part as I find it a bit confusing.
    Please reply immediately.
    Regards,
    Bhavani.

    Hi BHAVANI,
    first you have to prapare a field catalog [(see this)|http://help.sap.com/saphelp_470/helpdata/en/52/5f060de02d11d2b47d006094192fe3/frameset.htm]
    and than you can use a Method cl_alv_table_create=>create_dynamic_table
    I hope that help a little.
    Regards Bogdan

  • Smartforms - pass dynamic internal tables

    Hello experts,
    In my smartform print program, I have created a dynamic internal table using method CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE where in my dynamic internal table <DYN_TABLE> is declared as
    FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
                   <DYN_WA>.
    I am populating <DYN_TABLE> and passing it on to my smartform. Now my question is, inside my smartform, how can I declare this dynamic table <DYN_TABLE> in form interface? Please let me know. Thanks.

    This could be one of the solution.
    1. Create table type using data element EDI_SDATA (char 1000) , say ZTTDYN .
    2. Use this as importing paramter your smarform.
    3. In print program transfer the content from dynamic internal table to internal table define using ZTTDYN. You can comma seperate then fields.
    4. Pass this comma separated internal table to smartform.
    5. And finally proces this data in smartform.

  • Passing dynamic internal table to FM using RFC

    Dear All,
    Is it possible to pass a dynamic internal table to a function module using RFC?
    If it is possible than how do i achive this?

    Basically not, RFC enabled FM parameters must be defined by a LIKE or TYPE clause. so you may try to use a prededined SAP type wide enough (e.g. TAB512 ) and map the data in the FM and caller program (in Unicode try to use tools like class CL_ABAP_CONTAINER_UTILITIES to map data between actual internal table record and RFC used itab "container" type)
    For examples look at RFC enabled RFC_GET_TABLE_ENTRIES FM, and look for where-used program.
    Regards,
    Raymond

  • How to pass a internal table into Java Bean

    Hi Experts,
    I created a JSPDyn page to display Sales orders form R/3 using bapi_sales_order_getlist.
    I used JCO to establish connectivity between JSP Dynpage and R/3. I executed the bapi successfully, i want to move the sales orders retrieved from the Bapi to a Java Bean. So that i can use the bean to populate the value as a table.
    with regards,
    James.
    Valuable answers will be rewarded.....

    Hi Bala,
    If you want to pass this internal table between different methods of the same view then write the contents of this internal table to a context node of your view using BIND_TABLE. You can then read the contents of this internal table from the other method using the reference of that node & the GET_STATIC_ATTRIBUTES_TABLE method.
    However if you want to pass the internal table between methods of different views then create a context node at the COMPONENTCONTROLLER level & then do a context mapping of this node to your local views context in both your views. You can follow the same BIND_TABLE & GET_STATIC_ATTRIBUTES_TABLE methods approach.
    Regards,
    Uday

  • To pass internal table data(including subtotal) to dynamic internal table

    here i am displaying the dynamic internal table in alv grid.
    i followed like this but i am unable to get the subtotal form the internal table.
    LOOP AT ITAB1. " assigning <fs_itab1>.
        ASSIGN COMPONENT 'RACCT' OF STRUCTURE <DYN_WA> TO <DYN_FIELD>.
        <DYN_FIELD> = ITAB1-RACCT.
        ASSIGN COMPONENT 'ERGSL' OF STRUCTURE <DYN_WA> TO <DYN_FIELD>.
        <DYN_FIELD> = ITAB1-ERGSL.
        ASSIGN COMPONENT 'TEXT' OF STRUCTURE <DYN_WA> TO <DYN_FIELD>.
        <DYN_FIELD> = ITAB1-TEXT.
        I = 4.
        CLEAR COMP_ITAB.
        LOOP AT COMP_ITAB.
          ASSIGN COMPONENT I OF STRUCTURE <DYN_WA> TO <DYN_FIELD>.
         LOOP AT ITAB WHERE RACCT = ITAB1-RACCT.
           IF ITAB-RBUKRS EQ COMP_ITAB-RBUKRS.
          IF ITAB1-RBUKRS EQ COMP_ITAB-RBUKRS.
            <DYN_FIELD> = ITAB1-REPVAL.
            SUB_TOT = ITAB1-REPVAL.
          ELSE.
            <DYN_FIELD> = 0.
            SUB_TOT = 0.
          ENDIF.
         ENDLOOP.
          I = I + 1.
          TOTAL = TOTAL + SUB_TOT.
        ENDLOOP.
        ASSIGN COMPONENT I OF STRUCTURE <DYN_WA> TO <DYN_FIELD>.
        <DYN_FIELD> = TOTAL.
        APPEND <DYN_WA> TO <DYN_TABLE>.
        CLEAR <DYN_WA>.
        TOTAL = 0.
      ENDLOOP.
    Thanks,
    sridhar.

    Hi Rakesh,
    We pass internal tables for the smartform are shown in bold in below code,
    CALL FUNCTION LF_FM_NAME
        EXPORTING
          ARCHIVE_INDEX      = TOA_DARA
          ARCHIVE_PARAMETERS = ARC_PARAMS
          CONTROL_PARAMETERS = LS_CONTROL_PARAM
          MAIL_RECIPIENT     = LS_RECIPIENT
          MAIL_SENDER        = LS_SENDER
          OUTPUT_OPTIONS     = LS_COMPOSER_PARAM
          USER_SETTINGS      = ' '               
          ZXEKKO             = L_DOC-XEKKO
          ZXPEKKO            = L_DOC-XPEKKO
          ZNAST              = NAST
        IMPORTING
          DOCUMENT_OUTPUT_INFO = IT_DOCUMENT
          JOB_OUTPUT_INFO      = IT_OUTPUT_INFO
          JOB_OUTPUT_OPTIONS   = IT_JOB_OUTPUT
        <b>TABLES
          L_XEKPO            = L_DOC-XEKPO[]
          L_XEKPA            = L_DOC-XEKPA[]
          L_XPEKPO           = L_DOC-XPEKPO[]
          L_XEKET            = L_DOC-XEKET[]
          L_XTKOMV           = L_DOC-XTKOMV[]
          L_XEKKN            = L_DOC-XEKKN[]
          L_XEKEK            = L_DOC-XEKEK[]
          L_XKOMK            = L_XKOMK</b>  
    EXCEPTIONS
          FORMATTING_ERROR   = 1
          INTERNAL_ERROR     = 2
          SEND_ERROR         = 3
          USER_CANCELED      = 4
          OTHERS             = 5.
    Regards,
    Azaz Ali.

  • How to do parallel processing with dynamic internal table

    Hi All,
    I need to implement parallel processing that involves dynamically created internal tables. I tried doing so using RFC function modules (using starting new task and other such methods) but didn't get success this requires RFC enabled function modules and at the same time RFC enabled function modules do not allow generic data type (STANDARD TABLE) which is needed for passing dynamic internal tables. My exact requirement is as follows:
    1. I've large chunk of data in two internal tables, one of them is formed dynamically and hence it's structure is not known at the time of coding.
    2. This data has to be processed together to generate another internal table, whose structure is pre-defined. But this data processing is taking very long time as the number of records are close to a million.
    3. I need to divide the dynamic internal table into (say) 1000 records each and pass to a function module and submit it to run in another task. Many such tasks will be executed in parallel.
    4. The function module running in parallel can insert the processed data into a database table and the main program can access it from there.
    Unfortunately, due to the limitation of not allowing generic data types in RFC, I'm unable to do this. Does anyone has any idea how to implement parallel processing using dynamic internal tables in these type of conditions.
    Any help will be highly appreciated.
    Thanks and regards,
    Ashin

    try the below code...
      DATA: w_subrc TYPE sy-subrc.
      DATA: w_infty(5) TYPE  c.
      data: w_string type string.
      FIELD-SYMBOLS: <f1> TYPE table.
      FIELD-SYMBOLS: <f1_wa> TYPE ANY.
      DATA: ref_tab TYPE REF TO data.
      CONCATENATE 'P' infty INTO w_infty.
      CREATE DATA ref_tab TYPE STANDARD TABLE OF (w_infty).
      ASSIGN ref_tab->* TO <f1>.
    * Create dynamic work area
      CREATE DATA ref_tab TYPE (w_infty).
      ASSIGN ref_tab->* TO <f1_wa>.
      IF begda IS INITIAL.
        begda = '18000101'.
      ENDIF.
      IF endda IS INITIAL.
        endda = '99991231'.
      ENDIF.
      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr           = pernr
          infty           = infty
          begda           = '18000101'
          endda           = '99991231'
        IMPORTING
          subrc           = w_subrc
        TABLES
          infty_tab       = <f1>
        EXCEPTIONS
          infty_not_found = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
        subrc = w_subrc.
      ELSE.
      ENDIF.

  • Logic for retreiving the values from a dynamic internal table

    Hi all,
    I have an issue with the logic to fetch data from a dynamic internal table into fields. let me give you guys an example the sy-tfill = 9 (subject to vary). I need to populate the fields.
    Regards,
    Sukumar

    Hi,
    this is for printing out the info in a dynamic table,
    it will work likewise to insert data.
    PARAMETERS:
      p_tabnam TYPE tabname DEFAULT 'DB_TABLE_NAME'.
    DATA:
      lv_dref TYPE REF TO data,
      ls_dd03l LIKE dd03l,
      lt_fieldname TYPE TABLE OF fieldname,
      ls_fieldname TYPE fieldname.
    FIELD-SYMBOLS:
      <fs> TYPE STANDARD TABLE,
      <wa_comp> TYPE fieldname,
      <wa_data> TYPE ANY,
      <wa_field> TYPE ANY.
    REFRESH lt_fieldname.
    SELECT * FROM dd03l INTO ls_dd03l
                       WHERE as4local = 'A'
                         AND as4vers  = '0000'
                         AND tabname  = p_tabnam
                       ORDER BY position.
      ls_fieldname = ls_dd03l-fieldname.
      APPEND ls_fieldname TO lt_fieldname.
    ENDSELECT.
    IF NOT ( lt_fieldname[] IS INITIAL ).
      CREATE DATA lv_dref TYPE TABLE OF (p_tabnam).
      ASSIGN lv_dref->* TO <fs>.
      SELECT * FROM (p_tabnam) INTO TABLE <fs>.
      WRITE:
        / 'CONTENTS OF TABLE', p_tabnam.
      LOOP AT <fs> ASSIGNING <wa_data>.
        SKIP.
        WRITE:
          / 'LINE', sy-tabix.
        ULINE.
        LOOP AT lt_fieldname ASSIGNING <wa_comp>.
          ASSIGN COMPONENT sy-tabix OF STRUCTURE <wa_data> TO <wa_field>.
          WRITE:
            / <wa_comp>, <wa_field>.
        ENDLOOP.
      ENDLOOP.
    ENDIF.
    grtz
    Koen

  • Dynamic internal table in Subroutines

    Can we pass Dynamic internal table in subroutine.
    I tried doing this. but it is not working
    perform xyz tables <DYN_tab>.
    form xyz tables <DYN_tab> type standard table
    endform
    Kindly provide me some solution for this.
    Moderator Message: Read the F1 documentation on USING & CHANGING additions and figure it out yourself
    Edited by: Suhas Saha on Nov 7, 2011 5:11 PM

    Hi
    Don't use TABLE, but USING:
    form xyz USING P_ITAB TYPE TABLE
    endform .
    PERFORM XYZ USING <DYN_TAB>.
    Max

  • Display ALV GRID Using Dynamic Internal Table

    Hi all,
    I try to display ALV Grid using Dynamic Internal Table, but when i activate my program, i get an error message "DYN_TABLE" is not type-compatible with formal parameter "IT_OUTTAB". ( DYN_TABLE is my Dynamic Itab).
    Anybody can help me how to passing Dynamic Itab into ALV Grid ?? Of ALV Grid only accept static Itab ??
    Thanks,

    Hi Vijay,
    It's doesn't work, and make new error "Formal parameter "IT_OUTTAB[]" does not exist. However, the parameter "IT_OUTTAB" has a similar name."
    Because the method is:
    CALL METHOD <ref. var. to CL_GUI_ALV_GRID>->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE = <any type (ANY)>
    I_STRUCTURE_NAME = <string of type DD02L-TABNAME>
    IS_VARIANT = <structure of type DISVARIANT>
    I_SAVE = <var. of type CHAR01>
    I_DEFAULT = <var. of type CHAR01>
    IS_LAYOUT = <structure of type LVC_S_LAYO>
    IS_PRINT = <structure of type LVC_S_PRNT>
    IT_SPECIAL_GROUPS = <internal table of type LVC_T_SGRP>
    IT_TOOLBAR_EXCLUDING = <internal table of type UI_FUNCTIONS>
    IT_HYPERLINK = <internal table of type LVC_T_HYPE>
    IT_ALV_GRAPHICS = <internal table of type DTC_T_TC>
    CHANGING
    IT_OUTTAB = <internal table>
    IT_FIELDCATALOG = <internal table of type LVC_T_FCAT>
    IT_SORT = <internal table of type LVC_T_SORT>
    IT_FILTER = <internal table of type LVC_T_FILT>
    Thanks,

  • How to populate field catalogue fields in ALV using  dynamic internal table

    Hi All,
    Please let me know how to populate field catalogue fields in ALV using  dynamic internal table.
    I have created <dyn_table> using code below.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
                     EXPORTING
                       it_fieldcatalog = g_t_ifc
                        it_fieldcatalog = g_t_fieldcat
                     IMPORTING
                        ep_table        = dy_table.
      ASSIGN dy_table->* TO <dyn_table>.
    Create dynamic work area and assign to FS
      CREATE DATA dy_line LIKE LINE OF <dyn_table>.
      ASSIGN dy_line->* TO <dyn_wa>.
    Now this  <dyn_table>  has fields like idoc no.,creation date ,
    segment field 1, segment field 2 etc..Now idoc no.,creation date  are static fields from table EDIDC. And segment field 1, segment field 2 etc are dynamic fields from table EDSAPPL.
    In my  ALV report I am getting the final layout properly but I am unable to move values to corresponding fields in the final layout shown.Please let me know how to populate these fields from different tables.
    I tried this way but its not working.
    SORT g_t_edid4 BY docnum.
      LOOP AT g_t_edidc INTO g_r_edidc.
        READ TABLE g_t_edid4 into g_r_edid4
                         WITH KEY docnum = g_r_edidc-docnum
                                        BINARY SEARCH.
        IF sy-subrc = 0.
          <dyn_wa> =  g_r_edid4-sdata.
         MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
       CLEAR g_r_edid4.
        ENDIF.
    MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
    APPEND <dyn_wa> TO <dyn_table>.

    You have to assign each field to field symbol and then assign the value to that field symbol and asssign that field symbol to workarea field symbol.
    LOOP AT g_t_edidc INTO g_r_edidc.
    READ TABLE g_t_edid4 into g_r_edid4
    WITH KEY docnum = g_r_edidc-docnum
    BINARY SEARCH.
    IF sy-subrc = 0.
    ASSIGN COMPONENT 'SDATA' OF STRUCTURE <DYN_WA> TO <DYN_FLD>.
    <DYN_FLD> = g_r_edid4-sdata.
    " <dyn_wa> = g_r_edid4-sdata.
    " Assign each fields like this.
    " MOVE-CORRESPONDING g_r_edid4 to <dyn_wa>.
    CLEAR g_r_edid4.
    ENDIF.
    " MOVE-CORRESPONDING g_r_edidc to <dyn_wa>.
    APPEND <dyn_wa> TO <dyn_table>.
    Regards,
    Naimesh Patel

Maybe you are looking for