Dynamic typeing of a type any structure at runtime.

Hello Gurus,
i have in my Method a TYPE ANY structure as import parameter declared, the structure has in the calling program a dictionary structure type.
Can i change (or assign) the new dictionary structure TYPE to the import parameter like for example as below in the third line ??
  l_rcl_struc ?= cl_abap_typedescr=>describe_by_data( i_str_applparam ).
  l_var_ddic_header = l_rcl_struc->get_ddic_header( ).
?? data: i_str_applparam type (l_var_ddic_header-tabname). ??
Greetings,
Ioan Constantin.

Hello,
the structure has in the calling program a dictionary structure type.
This is pretty basic then
DATA: DREF TYPE REF TO DATA.
FIELD-SYMBOL: <STRUC> TYPE ANY.
CREATE DATA DREF TYPE (l_var_ddic_header-tabname).
ASSIGN DREF->* TO <STRUC>.
BR,
Suhas

Similar Messages

  • Here's how to use DYNAMIC tables for almost any structure (4.6C onwards)

    Hi guys
    I'm describing a  feature  here that has been around since 4.6C that is not really well known but can really simplfy programming where you need to get data into some sort of internal table and then display it either as a classical list or as al ALV grid.
    This feature is RTTI which allows you to retrieve your structure, build a dynamic FCAT (Field catalog) and a Dynamic table.
    Here's a really quick little program which reads 200 entries from VAPMA into a dynamic table. Any structure will work if you use the code sample shown.
    To pass it to an ALV GRID  is then really simple as you've already got the Field Catalog, Table and Data.
    The method I'm showing below will work for almost ANY structure you care to name whether or not the fields are in the data dictionary.
    I create a dynamic FCAT and dynamic table based on the FCAT and then populate it.
    You can create field catalogs dynamically quite simply by using the new RTTI facility available from 4.6C onwards.
    (From here it's only a small step to dynamic tables and EASY ALV grid displays)
    Example to create dynamic FCAT and table and populate it with 200 entries from VAPMA
    PROGRAM ZZ_BUILD_FLDCATALOG.
    tables: vapma.
    Define any structure
    types: begin of s_elements,
    vbeln type vapma-vbeln,
    posnr type vapma-posnr,
    matnr type vapma-matnr,
    kunnr type vapma-kunnr,
    werks type vapma-werks,
    vkorg type vapma-vkorg,
    vkbur type vapma-vkbur,
    status type c,
    end of s_elements.
    end of your structure
    data lr_rtti_struc type ref to cl_abap_structdescr .
    data:
    zog like line of lr_rtti_struc->components .
    data:
    zogt like table of zog,
    wa_it_fldcat type lvc_s_fcat,
    it_fldcat type lvc_t_fcat ,
    dy_line type ref to data,
    dy_table type ref to data.
    data: dref type ref to data.
    field-symbols: <fs> type any,
    <dyn_table> type standard table,
    <dyn_wa>.
    *now I want to build a field catalog
    *First get your data structure into a field symbol
    create data dref type s_elements.
    assign dref->* to <fs>.
    lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( <fs> ).
    zogt[] = lr_rtti_struc->components.
    Now build the field catalog.  zogt has the structure in it from RTTI.
    loop at zogt into zog.
    clear wa_it_fldcat.
    wa_it_fldcat-fieldname = zog-name .
    wa_it_fldcat-datatype = zog-type_kind.
    wa_it_fldcat-inttype = zog-type_kind.
    wa_it_fldcat-intlen = zog-length.
    wa_it_fldcat-decimals = zog-decimals.
    wa_it_fldcat-coltext = zog-name.
    wa_it_fldcat-lowercase = 'X'.
    append wa_it_fldcat to it_fldcat .
    endloop.
    Let's create a dynamic table and populate it
    call method cl_alv_table_create=>create_dynamic_table
    exporting
    it_fieldcatalog = it_fldcat
    importing
    ep_table = dy_table.
    assign dy_table->* to <dyn_table>.
    create data dy_line like line of <dyn_table>.
    assign dy_line->* to <dyn_wa>.
    select vbeln posnr matnr kunnr werks vkorg vkbur
    up to 200 rows
    from vapma
    into corresponding fields of table <dyn_table>.
    from here you can pass your table to a GRID for display etc etc.
    Cheers
    Jimbo

    Thanks for the info.
    I went to their web site and also Googled.
    I found a great review on their photographer's books on nikonians.org
    They use an HP/Indigo Ultrastream 3000 digital offset press for all hardcover books, which is GREAT!
    I did sign up and requested the 45 day trial "photographer" account.
    I am curious if Shared Ink offers a size that matches the ONLY current book size from Aperture, the odd 8.5x11.
    In the above review, I saw that Shared Ink offers a 12x12 book.. very nice! Except you will need to design that one in CS2
    So then, all that Apple really needs to do is simply add the ability to select/create custom book sizes. Then we don't need a printing service from Apple, as there are plenty of options out there, and more arriving on the market each month!

  • Create dynamic data type in structure

    Hi Experts,
    I am new to ABAP.
    In my scenario data type is varying for the field. for that I need to create dynamic data type in structure, this structure I am using for  internal table for OVS search input.
    Please suggest the solution for this.
    Advance thanks,
    Regards,
    BBC

    Thanks for your quick reply,
    I used your logic like this.
    data:
    ls_component type abap_componentdescr,
    lt_component type abap_component_tab.
    *... (1) define structure components :
    clear ls_component.
    ls_component-name = 'NVALUE'.
    ls_component-type ?= cl_abap_typedescr=>describe_by_name( <fs_seg_v>-fieldname ).
    insert ls_component into table lt_component.
    *... (2) create structure
    data lr_strucdescr type ref to cl_abap_structdescr.
    data lr_data_struc type ref to data.
    lr_strucdescr = cl_abap_structdescr=>create( lt_component ).
    create data lr_data_struc type handle lr_strucdescr.
    field-symbols <fs> TYPE any.
    assign lr_data_struc->* to <fs>.
    your logic is working fine.
    here I am getting feild name (<fs_seg_v>-fieldname) from internal table.
    But I need to assign same field name structure to query parameter.
    FIELD-SYMBOLS: <ls_query_params> TYPE lty_stru_input.
    Please can you suggest how I can refer the field name structure?
    Regards,
    BBC

  • Dynamic Type creation: structure

    Hey,
    I made a dynamic table and now I want to loop this table.
    But I can't seem to make a structure to use in the loop.
    I get the error 'data object has no structure'.
    This is what I already have.
    data: linetype   type ref to cl_abap_structdescr,
            tabletype  type ref to cl_abap_tabledescr,
            lt_comp    type cl_abap_structdescr=>component_table,
            lr_table type ref to data,
            lr_line type ref to data.
    field-symbols: <lt_data> type table,
                         <ls_data> type any.
    ...first I fill lt_comp ...
    linetype = cl_abap_structdescr=>create( lt_comp ).
    tabletype = cl_abap_tabledescr=>create( p_line_type = linetype p_table_kind = 'S' ).
    create data lr_table type handle tabletype.
    assign lr_table->* to <lt_data> casting type handle tabletype.
    create data lr_line like line of <lt_data>.
    assign lr_line->* to <ls_data> casting type handle linetype.
    ... filling the table <lt_data> ....
    loop at lt_data assigning <ls_data>.
      ... when I try to access a field of <ls_data>, I get the error '<ls_data> is no structure'.
    endloop.

    Hello Steven
    If you are going for dynamic programming then you have to use "the full monty" meaning field-symbols for:
    - itab
    - structure    AND
    - fields
    FIELD-SYMBOLS:
      <ld_fld>    TYPE any.
      LOOP AT <lt_data> ASSIGNING <ls_data>.
        UNASSIGN <ld_fld>.
        ASSIGN COMPONENT '<name of field  OR sy-index>' OF STRUCTURE <ls_data>
                                                                                    TO <ld_fld>.
       IF ( <ld_fld> IS ASSIGNED ).
    "   do something...
       ENDIF.
      ENDLOOP.
    Regards,
        Uwe

  • Table with type ANY in function module

    Hi all
    I want to use a function module in different programs. I want to pass always a table and in a string the name of the structure, so that I can access the data with ASSIGN and the passed structure name.
    For a structure I can use the type ANY, but if I want to use a table in a function module, I need to define a table type.
    Is there a way to define a tabletype with the type ANY? A Workaround would be fine too.
    Thanks and best regards!
    Christian

    Hi Christian,
    ANY TABLE is used to type a parameter, or field symbol, that can be a table of any type or structure.
    ANY is used to type a parameter, or field symbol, that can be any type. You can't, however, use any table operations on a parameter/field-symbol typed as ANY. For that, you have to use ANY TABLE.
    The same applies to ANY. You can pass to the method a data object, without specifying its type (i.e, in dynamic programs).
    Suppose that I need to split a line into a table, but I don't know the structure of this line:
    I have a method:
    codeMETHOD split_line_in_table IMPORTING im_line TYPE ANY
    EXPORTING ex_table TYPE ANY TABLE.
    [/code]
    codeMETHOD split_line_in_table.
    SPLIT im_line AT separator INTO TABLE ex_table.
    ENDMETHOD.[/code]
    Now, i can pass this method a line of ANY structure and get a table without specifying its structure.
    cheers,
    Hema.

  • Create Dynamic Structure at Runtime via ALV-Methods!

    Hi Experts,
    i try to create at the ABAP Runtime a new Structure.
    FOR EXAMPLE: I have a internal Table "database" and i dont know their Structure or Typ.
    MY Question: How can i get the structuretype for this internal Table "database" ??
                                    I thought that it is possible with ALV-Methods, but i dont find the right way.
    First Step:       I must get the structure of this internal Table.
    Second Step: I must create a workarea/ line of this internal Table, that i can work row for row with the table.
    Have someone an code example for me, because iám very confused about this Problem.
    With kind regards.
    Ersin Tosun

    Hello,
    For this specific requirement, SAP has provided RTTI class.
    Below is a code snippet for your ready reference. In this example we're trying to get the structure of the dynamic table <ITAB> whose structure is not defined till run-time.
    TYPE-POOLS: abap.
    PARAMETERS: p_table TYPE tabname.
    DATA: dref TYPE REF TO data.
    FIELD-SYMBOLS <itab> TYPE STANDARD TABLE.
    CREATE DATA dref TYPE STANDARD TABLE OF (p_table).
    ASSIGN dref->* TO <itab>.
    DATA: go_tab_descr TYPE REF TO cl_abap_tabledescr,
          go_struc_descr TYPE REF TO cl_abap_structdescr,
          wa_comp TYPE abap_compdescr.
    go_tab_descr ?= cl_abap_tabledescr=>describe_by_data( <itab> ).
    CHECK sy-subrc = 0.
    go_struc_descr ?= go_tab_descr->get_table_line_type( ).
    LOOP AT go_struc_descr->components INTO wa_comp.
      WRITE: / wa_comp-name.
    ENDLOOP.
    I must create a workarea/ line of this internal Table, that i can work row for row with the table.
    Sorry i missed the Step 2:
    FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
                   <wa> TYPE ANY,
                   <val> TYPE ANY.
    LOOP AT <itab> ASSIGNING <wa>.
      LOOP AT go_struc_descr->components INTO wa_comp.
    *   To access the components of the structure dynamically
        ASSIGN COMPONENT wa_comp-name OF STRUCTURE <wa> TO <val>.
      ENDLOOP.
    ENDLOOP.
    BR,
    Suhas
    Edited by: Suhas Saha on Nov 18, 2010 7:26 PM

  • Dynamic assignment of field in a Structure

    Hello there,
    i'm looking for a solution of the following Problem:
    I have a structure STRUC with several fields e.g. Name, Street, City
    In my program i get dynamically the fieldname and the corresponding value.
    With these information i like to do the following assignment:
    STRUC-<fieldname> = 'Hello world'. (which is not working in ABAP)
    How can i do an assignment like this? I only found a way to read colums dynamically from a structure but not the oppside way.
    ASSIGN COMPONENT <fieldname> of structure <STRUC> to <fieldvalue>.
    I need something like this
    ASSIGN <fieldvalue> to COMPONENT <comp> of structure <STRUC>.
    Does anybody has an idea?
    Many thanks in advance!
    Josef

    Hello together,
    the problem is solved here is the example coding:
    data: lv_value(80) type c,
            fieldname(20) type c.
    field-symbols: <value> type any.
    fieldname = 'TEXT'.
    concatenate 'STRUC-' fieldname into lv_value.
    assign (lv_value) to <value>
    if sy-subrc = 0.
      <value> = 'Hello world'.
    endif.
    unassign <value>
    result: struc-text = 'Hello World'.

  • BADI that has a parameter of type ANY

    How do I work with a parameter of type ANY?  I need it to be typed to a structure.  How can I do that and ensure that it is coming in correctly?
    Regards,
    Davis

    How do I work with a parameter of type ANY?  I need it to be typed to a structure.  How can I do that and ensure that it is coming in correctly?
    Regards,
    Davis

  • Dynamic typing error

    Hi *,
    I'm trying to build a generic application to check values into any table.
    But I'm facing the following problem:
    FIELD-SYMBOLS: <fstable> TYPE table,
                   <fscond> TYPE table,
                   <fs_line> TYPE ANY,
                   <dyn_wa> TYPE any,
                   <dyn_field> TYPE any.
    data: tipo(20) TYPE c VALUE '/FRE/SUBST_ASSMT'.
    data:       dy_line  type ref to data.
    ASSIGN it_data TO <fstable> CASTING TYPE (tipo).
      create data dy_line TYPE (tipo)."like line of <fstable>.
      assign dy_line->* to <dyn_wa> CASTING TYPE (tipo).
    LOOP at <fstable> INTO <dyn_wa>.
    --->  if <dyn_wa>-subst_c = '0'.
    -->    endif.
        do.
         assign component  sy-index of structure <dyn_wa> to <dyn_field>.
          if sy-subrc <> 0.
          exit.
          endif.
        enddo.
    ENDLOOP.
    It's clear that since the variable is untyped I can not perform this check. SE80 says that there is no structure, therefore no component.
    Let's say, I've got a table, MARA and I want to check if a field is 0, and then later on I have to check if MARC has field 'X' to 0... I want to reuse the code.
    Any ideas how can achieve that?
    Any help will be apprecitad,
    Isidoro!

    Hi,
    Your solution is not bad, actually I like it, but I solved the problem in a different way. Have a look at:
    FIELD-SYMBOLS: <fstable> TYPE table,
                   <fscond> TYPE table,
                   <fs_line> TYPE ANY,
                   <dyn_wa> TYPE any,
                   <dyn_field> TYPE any.
    data:  lt_wheres         TYPE rsds_twhere,
           lrt_cond          TYPE STANDARD TABLE OF rsds_range,
           lrs_cond          LIKE LINE OF lrt_cond.
    data:  dy_line  type ref to data.
    DATA: lr_rtti_struc TYPE REF TO cl_abap_structdescr.
    DATA: lt_comp TYPE cl_abap_structdescr=>component_table.
    DATA: ls_comp LIKE LINE OF lt_comp.
    data: campos type DDFIELDS,
          ls_campos LIKE LINE OF campos.
    DATA: index TYPE i VALUE '1'.
    *Assign the dynamic structures.
    ASSIGN it_data TO <fstable>.
    create data dy_line like line of <fstable>.
    assign dy_line->* to <dyn_wa>.
    *get the description of the elements from DDIC
    lr_rtti_struc ?= cl_abap_structdescr=>DESCRIBE_BY_DATA_REF( dy_line ).
    lr_rtti_struc->GET_DDIC_FIELD_LIST( EXPORTING P_INCLUDING_SUBSTRUCTRES = 'X'
                                        RECEIVING P_FIELD_LIST = campos ).
    LOOP at campos INTO ls_campos.
        if ls_campos-fieldname = 'SUBST_CTRL'.
          index = sy-tabix.
        endif.
    ENDLOOP.
    LOOP at <fstable> INTO <dyn_wa>.
        do.
         assign component  sy-index of structure <dyn_wa> to <dyn_field>.
          if sy-subrc <> 0.
          exit.
          endif.
    if sy-index = index.
    if  <dyn_field> = '3'.
      WRITE / 'OK!

  • FM Table TYPE ANY

    Hi,
    is it possible to give an FM a table with the type ANY? The table type is dynamic.
    Regards,
    Sinan

    TABLES parameters are table parameters. Table parameters are obsolete CHANGING parameters that are typed as internal standard tables with a header line. If an internal table without a header line or a table body is passed as an actual parameter to such a formal parameter, an empty header line is generated in the function module. If an internal table with a header line is used as an actual parameter, both the table body and the header line are passed to the function module. In the case of formal parameters defined with TABLES, no value transmission is possible.
    Formal parameters defined with TABLES can be replaced by formal parameters defined with CHANGING. A local work area can be created in the function module  for the internal table using the addition LIKE LINE OF itab of the DATA statement in the function module.
    So you cant use the Tables type any option.....
    Message was edited by:
            Muthurajan Ramkumar

  • Is it possible to create attribute in Z Class of type any

    Hi Friends,
    I am working on a requirement to fine tune the code. for this i need to store the values retreived from a remote FM call in a global internal table. I am trying to check whether is it possible to create a global attribute of type any. This  would help me to use the same internal table for down processing also. other wise i need to create several gloabl internal tables with the required structures.
    any pointers on this would be very helpful.
    Thanks,
    udaya

    These generic types can only be used for field symbols and import / export parameters of methods and function modules. Here is a thought though: You can create some sort of container in which you can store all kinds of internal tables from your function module.
    1. Create a global type in DDIC, or a local type in your class.
    Code for local type:
    TYPES: BEGIN OF ty_container,
             name        TYPE char30,
             container   TYPE REF TO data,
           END OF ty_container.
    TYPES: tty_container TYPE SORTED TABLE OF ty_container WITH UNIQUE KEY name.
    2. Create a private / protected attribute when using local type or any attribute you like when using a global type (set step 1).
    3. Create a method (let's call it ADD_DATA) which imports the name of the structure the internal table from your FM is based on and the actual internal table. The import parameter for this internal table is typed TABLE (generic).
    4. Coding in method:
      DATA: ls_itab TYPE ty_container.
      DATA: lv_data_ref       TYPE REF TO data.
      FIELD-SYMBOLS: <lt_value> TYPE table.
      CREATE DATA lv_data_ref LIKE ipt_itab.
      ASSIGN lv_data_ref->* TO <lt_value>.
      <lt_value> = ipt_itab[].
      ls_itab-name = itabname.
      ls_itab-container = lv_data_ref.
      INSERT ls_itab INTO TABLE gt_container.
    Now the global attribute gt_container can hold any kind of internal table you add to it. It can be read using the NAME column field.
    Hope this makes any sense to you, if not let me know.
    BTW: Doesn't look like an ABAP Performance and Tuning issue (other forum).

  • Assigning part of a string dynamically to a component of a structure

    Hello,
    I want to take part of a string
    example: value = string+10(7)
    and assign this value to a structure. But I only have the fieldnames of the structure. I need something like the following
    Assign value TO COMPONENT (fieldname) of structure
    Thanks.
    Regards, Lars.

    do you have a set structure name you're dealing with or is that dynamic?
    If it's the first scenario and, say, you were dealing with mara and field matnr you could do this:
    data l_string.
    field-symbols <field> type any.
    l_string = in_string+10(18).
    assign l_string to <field> casting type matnr.
    (or assign l_string to <field> casting like mara-matnr).
    now <field> is a 'matnr' type field.
    If it's more complex please give some more info as I'm sure what you want can be done.

  • Mean "TYPE any"

    Hello abapers,
    I don´t understand the meaning of "TYPE any"
    Is the same that  ANY TABLE?
    Is advisable to use it?
    I´m confused.
    For example in this code:
    Cordial greetings.

    The mean is that you can pass to the method a table without specifying the structure -> ANY TABLE.
    The same applies to ANY. You can pass to the method a data object, without specifying its type (i.e, in dynamic programs).
    Suppose that I need to split a line into a table, but I don't know the structure of this line:
    I have a method:
    METHOD split_line_in_table IMPORTING im_line TYPE ANY
    EXPORTING ex_table TYPE ANY TABLE.
    METHOD split_line_in_table.
    SPLIT im_line AT separator INTO TABLE ex_table.
    ENDMETHOD.
    Now, i can pass this method a line of ANY structure and get a table without specifying its structure.
    Hope this helps,
    R.

  • Assigning a value to a field-symbol (workarea of type any)

    Dear forumers,
    I'm having a bit of difficulty in assigning a value to a field-symbol (it should be treated as a workarea of type any), but I'm given a syntax error instead:-
    The data object "<LFS_WORKAREA>" has no structure and therefore no component called "LFMON".
    What could have gone wrong and how may I resolve this (I must have missed something out)? I will still need <LFS_WORKAREA> to be defined as TYPE ANY.
    Please help. I'd appreciate any inputs at all. Thanks.
    *&      Form  FORMAT_POST_PERIOD
    *       Subroutine to format the posting period data
    *      --> PI_MBEW     Material valuation data (internal table)
    FORM format_post_period  CHANGING    pi_mbew TYPE ANY TABLE.
    " Create local field symbols
      FIELD-SYMBOLS:
      <lfs_workarea> TYPE ANY,
      <lfs_lfmon>    TYPE ckmlcr-poper.
    " Create local variables
      DATA: lv_index TYPE sy-tabix.
      DATA: lv_lfmon TYPE ckmlcr-poper.
    " Format posting periods
      LOOP AT pi_mbew ASSIGNING <lfs_workarea>.
        lv_index = sy-tabix.
        ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
        PERFORM convert_lfmon USING    <lfs_lfmon>
                              CHANGING lv_lfmon.
        MOVE lv_lfmon TO <lfs_workarea>-lfmon.   " the syntax error occurs here  :(
        MODIFY pi_mbew FROM <lfs_workarea>
          INDEX lv_index
          TRANSPORTING lfmon.
        CLEAR: <lfs_workarea>,
               <lfs_lfmon>
               lv_lfmon,
               lv_index.
      ENDLOOP.
    ENDFORM.                    " FORMAT_POST_PERIOD

    Most of us aren't in it for the points in any case...
    For your solution you've redundant code:
    *&      Form  FORMAT_POST_PERIOD
    *       Subroutine to format the posting period data
    *      --> PI_MBEW     Material valuation data (internal table)
    FORM format_post_period  CHANGING    pi_mbew TYPE ANY TABLE.
      FIELD-SYMBOLS:
      <lfs_workarea> TYPE ANY,
      <lfs_lfmon>    TYPE ckmlcr-poper.
      DATA: lv_lfmon TYPE ckmlcr-poper.
    *  DATA: lo_workarea TYPE REF TO data.   "<--Not needed, because the LOOP AT ASSIGNING below does the work
    *  CREATE DATA lo_workarea LIKE LINE OF pi_mbew.
    *  ASSIGN lo_workarea->* TO <lfs_workarea>.
      LOOP AT pi_mbew ASSIGNING <lfs_workarea>.
        ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
        PERFORM convert_lfmon USING    <lfs_lfmon>
                              CHANGING lv_lfmon.
        <lfs_lfmon> = lv_lfmon.
        CLEAR lv_lfmon.
      ENDLOOP.
    ENDFORM.                    " FORMAT_POST_PERIOD
    Here's a couple of more efficient solutions, using LOOP AT INTO.
    FORM format_post_period  CHANGING    pi_mbew TYPE INDEX TABLE. " <-- Table type a little more specific
                                                                   "<--now you can use index operations
      FIELD-SYMBOLS:
      <lfs_workarea> TYPE ANY,
      <lfs_lfmon>    TYPE ckmlcr-poper.
      DATA: lv_lfmon TYPE ckmlcr-poper,
            lv_index TYPE sytabix.
      DATA: lo_workarea TYPE REF TO data.
      CREATE DATA lo_workarea LIKE LINE OF pi_mbew.
      ASSIGN lo_workarea->* TO <lfs_workarea>.
    ASSIGN COMPONENT 'LFMON' OF STRUCTURE <lfs_workarea> TO <lfs_lfmon>.
      LOOP AT pi_mbew INTO <lfs_workarea>.
        lv_index = sy-tabix.    
        PERFORM convert_lfmon USING    <lfs_lfmon>
                              CHANGING lv_lfmon.
        <lfs_lfmon> = lv_lfmon.
        MODIFY pi_mbew FROM <lfs_workarea>
           INDEX lv_index. " <--INDEX TABLE, so this is permitted.
        CLEAR lv_lfmon.
      ENDLOOP.
    ENDFORM.                    " FORMAT_POST_PERIOD

  • Dynamic table with field type table

    Hi,
    I´m using "cl_alv_table_create=>create_dynamic_table" to create a dynamic table for ALV Grid.
    But...I need to use colors in ALV, then I need to declare a field type LVC_S_SCOL in dynamic table from "cl_alv_table_create=>create_dynamic_table".
    How can I declare this in fieldcat?
    The code:
    Creating dynamic table
    DATA: table_agrup TYPE REF TO data,
            line_agrup  TYPE REF TO data.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = t_fieldcat
        IMPORTING
          ep_table                  = table_agrup
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
        ASSIGN table_agrup->* TO .
    Printing ALV
      CALL METHOD obj_grid->set_table_for_first_display
        EXPORTING
          is_variant                    = w_variant
          i_save                        = 'A'
          is_layout                     = w_layout
        CHANGING
          it_outtab                     =
          it_fieldcatalog               = t_fieldcat
          it_sort                       = t_sort
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
    Thanks.

    It is not possible with the  METHOD cl_alv_table_create=>create_dynamic_table to include another table inside that newly generated table.
    I have tried to do it with the code and I got the dynamic table created after at the end of the program.
    In the code,
    <DYN_TABLE> has same effect as your <table> variable
    <DYN_WA> has same effect as your <HEADER>
    REPORT  ZTEST_NP_DYNAMIC.
    DATA: DY_TABLE TYPE REF TO DATA,
          DY_LINE  TYPE REF TO DATA.
    FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
                   <DYN_WA>,
                   <DYN_FIELD>.
    FIELD-SYMBOLS: <FS> TYPE ANY.
    * To generate the Dyanmic table with the COLOR
    DATA: LS_SOURCE TYPE STRING.
    DATA: LT_SOURCE LIKE STANDARD TABLE OF LS_SOURCE WITH HEADER LINE.
    DATA: L_NAME LIKE SY-REPID.
    DATA: L_MESSAGE(240) TYPE C,
          L_LINE TYPE I,
          L_WORD(72) TYPE C.
    DATA: L_FORM(30) TYPE C VALUE 'TABLE_CREATE'.
    LT_SOURCE = 'REPORT ZTEST_SUBROUTINE_POOL.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'FORM  TABLE_CREATE USING I_FS TYPE ANY.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: BEGIN OF LT_GENTAB OCCURS 0.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: BUKRS TYPE BUKRS. '.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: BKTXT TYPE BKTXT. '.
    APPEND LT_SOURCE.
    * you can add your fields here.....
    LT_SOURCE = 'DATA: COLOR TYPE lvc_t_scol. '.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: END OF LT_GENTAB.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'DATA: POINTER TYPE REF TO DATA.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'CREATE DATA POINTER LIKE STANDARD TABLE OF LT_GENTAB.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'I_FS = POINTER.'.
    APPEND LT_SOURCE.
    LT_SOURCE = 'ENDFORM. '.
    APPEND LT_SOURCE.
    L_NAME = 'ZTEST_SUBROUTINE_POOL'.
    CATCH SYSTEM-EXCEPTIONS GENERATE_SUBPOOL_DIR_FULL = 9.
      GENERATE SUBROUTINE POOL LT_SOURCE NAME L_NAME
               MESSAGE L_MESSAGE LINE L_LINE WORD L_WORD.  "#EC CI_GENERATE
    ENDCATCH.
    IF NOT L_MESSAGE IS INITIAL.
      MESSAGE E000(0K) WITH L_MESSAGE L_LINE L_WORD.
    ENDIF.
    ASSIGN DY_TABLE TO <FS>.
    PERFORM (L_FORM) IN PROGRAM (L_NAME) USING <FS>.
    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>.
    Write: 'bye'.
    Regards,
    Naimesh Patel

Maybe you are looking for

  • Default versions are not working on BPEL 10.1.3.3

    Hi All, We are on Oracle SOA 10.1.3.3 We have multiple processes with multiple versions deployed and all of them are activated. But when we call a BPEL process from another BPEL then version being called is changing from one instance to another insta

  • ITuns keeps opening itself

    Hi guys! my problem is just as the subject says! Itunes keeps opening itself I tried everything but can't get around this. NOTE: didn't have ituneshelpper to open at login in the first place. First i tried deleting itunes preference files - didn't wo

  • Copy Price from Purchase Order to Invoice

    HI, I have a urgent issue. I have created a STO purchase order and i have done delivery. The problem is i want to call the same value in the invoice. Please let me know is there any way out. Regards, AKASH

  • .bqy file location or export

    Hello everyone, I have a IR report in workspace and i would like to export it. Can you please let me know how i can export this .bqy file or else any physical location where the .bqy file is getting saved. I tried doing LCM but i dont know under whic

  • Sybase 5.5 Migration to Oracle

    Hoping for some input... What is the best option for migrating application data only (will not be migrating the application and thus don't need the procedures, triggers, etc) into Oracle? We're on Sybase SQL Anywhere 5.5 with read-only privileges so