Create Table Control using Dynamic Internal Table.

Hi,
   I have requirement in which I will create a Dynamic Internal Table and then I need to create a Table Control Using that Internal Table. Now this can't be done using Screen Editor as it requires a pre-defined internal table or a DDIC Object.
  Please Help.

This should be correct answer(I am not author of code below):
REPORT ztablemaintace NO STANDARD PAGE HEADING.
TYPE-POOLS: rsds.
DATA: is_x030l TYPE x030l,
it_dfies TYPE TABLE OF dfies,
is_dfies TYPE dfies,
it_fdiff TYPE TABLE OF field_dif,
is_fdiff TYPE field_dif.
DATA: w_selid TYPE rsdynsel-selid,
it_tables TYPE TABLE OF rsdstabs,
is_tables TYPE rsdstabs,
it_fields TYPE TABLE OF rsdsfields,
it_expr TYPE rsds_texpr,
it_ranges TYPE rsds_trange,
it_where TYPE rsds_twhere,
is_where TYPE rsds_where,
w_active TYPE i.
DATA: it_content TYPE REF TO data,
it_modif TYPE REF TO data,
it_fcat TYPE lvc_t_fcat.
DATA: w_okcode TYPE sy-ucomm.
FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
<ntab> TYPE STANDARD TABLE.
* Macros
DEFINE table_error.
  message e398(00) with 'Table' p_table &1.
END-OF-DEFINITION.
DEFINE fixed_val.
  is_fdiff-fieldname = is_dfies-fieldname.
  is_fdiff-fixed_val = &1.
  is_fdiff-no_input = 'X'.
  append is_fdiff to it_fdiff.
END-OF-DEFINITION.
* Selection screen
SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME.
PARAMETERS: p_table TYPE tabname OBLIGATORY "table
MEMORY ID dtb
MATCHCODE OBJECT dd_dbtb_16.
SELECTION-SCREEN: BEGIN OF LINE,
PUSHBUTTON 33(20) selopt USER-COMMAND sel,
COMMENT 55(15) selcnt,
END OF LINE.
SELECTION-SCREEN: SKIP.
PARAMETERS: p_rows TYPE i. "rows
SELECTION-SCREEN: END OF BLOCK b01,
SKIP,
BEGIN OF BLOCK b02 WITH FRAME.
PARAMETERS: p_displ TYPE c AS CHECKBOX. "display
SELECTION-SCREEN: END OF BLOCK b02.
* Initialization
INITIALIZATION.
  MOVE '@4G@ Filter records' TO selopt.
* PBO
AT SELECTION-SCREEN OUTPUT.
  IF w_active IS INITIAL.
    CLEAR: selcnt.
  ELSE.
    WRITE w_active TO selcnt LEFT-JUSTIFIED.
  ENDIF.
* PAI
AT SELECTION-SCREEN.
  IF p_table NE is_x030l-tabname.
    CALL FUNCTION 'DDIF_NAMETAB_GET'
      EXPORTING
        tabname   = p_table
      IMPORTING
        x030l_wa  = is_x030l
      TABLES
        dfies_tab = it_dfies
      EXCEPTIONS
        OTHERS    = 1.
    IF is_x030l IS INITIAL.
      table_error 'does not exist or is not active'.
    ELSEIF is_x030l-tabtype NE 'T'.
      table_error 'is not selectable'.
*    ELSEIF is_x030l-align NE 0.
*      table_error 'has alignment - cannot continue'.
    ENDIF.
* Default values for system fields
    REFRESH: it_fdiff.
    is_fdiff-tabname = p_table.
    LOOP AT it_dfies INTO is_dfies.
      IF is_dfies-datatype = 'CLNT'.
        fixed_val sy-mandt.
      ELSEIF is_dfies-rollname = 'ERDAT'
      OR is_dfies-rollname = 'ERSDA'
      OR is_dfies-rollname = 'AEDAT'
      OR is_dfies-rollname = 'LAEDA'.
        fixed_val sy-datum.
      ELSEIF is_dfies-rollname = 'ERTIM'
      OR is_dfies-rollname = 'AETIM'.
        fixed_val sy-uzeit.
      ELSEIF is_dfies-rollname = 'ERNAM'
      OR is_dfies-rollname = 'AENAM'.
        fixed_val sy-uname.
      ENDIF.
      CALL FUNCTION '/SAPDMC/DATAELEMENT_GET_TEXTS'
        EXPORTING
          name        = is_dfies-rollname
        IMPORTING
          text_middle = is_dfies-reptext
        EXCEPTIONS
          not_found   = 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.
      MODIFY it_dfies FROM is_dfies.
  ENDLOOP.
* Prepare free selection on table
  REFRESH it_tables.
  is_tables-prim_tab = p_table.
  APPEND is_tables TO it_tables.
  CLEAR: w_selid.
ENDIF.
IF sy-ucomm = 'SEL'.
  IF w_selid IS INITIAL.
* Init free selection dialog
    CALL FUNCTION 'FREE_SELECTIONS_INIT'
      EXPORTING
        expressions  = it_expr
      IMPORTING
        selection_id = w_selid
        expressions  = it_expr
      TABLES
        tables_tab   = it_tables
      EXCEPTIONS
        OTHERS       = 1.
  ENDIF.
* Display free selection dialog
  CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
    EXPORTING
      selection_id            = w_selid
      title                   = 'Selection'
      status                  = 1
      as_window               = 'X'
    IMPORTING
      expressions             = it_expr
      field_ranges            = it_ranges
      number_of_active_fields = w_active
    TABLES
      fields_tab              = it_fields
    EXCEPTIONS
      OTHERS                  = 1.
ENDIF.
* Start of processing
START-OF-SELECTION.
  PERFORM f_create_table USING p_table.
  PERFORM f_select_table.
  PERFORM f_display_table.
* FORM f_create_table *
FORM f_create_table USING in_tabname.
  FIELD-SYMBOLS: <fcat> TYPE lvc_s_fcat.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name = in_tabname
    CHANGING
      ct_fieldcat      = it_fcat
    EXCEPTIONS
      OTHERS           = 1.
  IF sy-subrc = 0.
*   Complete field catalog
    LOOP AT it_fcat ASSIGNING <fcat>.
      <fcat>-tabname = in_tabname.
    ENDLOOP.
    CALL FUNCTION 'LVC_FIELDCAT_COMPLETE'
      CHANGING
        ct_fieldcat = it_fcat
      EXCEPTIONS
        OTHERS      = 1.
  ELSE.
    WRITE: 'Error building field catalog'.
    STOP.
  ENDIF.
* Create dynamic table for data
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = it_fcat
    IMPORTING
      ep_table        = it_content.
  IF sy-subrc = 0.
    ASSIGN it_content->* TO <itab>.
  ELSE.
    WRITE: 'Error creating internal table'.
    STOP.
  ENDIF.
* Create dynamic table for modif
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = it_fcat
    IMPORTING
      ep_table        = it_modif.
  IF sy-subrc = 0.
    ASSIGN it_modif->* TO <ntab>.
  ELSE.
    WRITE: 'Error creating internal table'.
    STOP.
  ENDIF.
ENDFORM.                    "f_create_table
* FORM f_select_table *
FORM f_select_table.
  IF w_active = 0.
    SELECT * FROM (p_table)
    INTO CORRESPONDING FIELDS OF TABLE <itab>
    UP TO p_rows ROWS.
  ELSE.
* Selection with parameters
    CALL FUNCTION 'FREE_SELECTIONS_RANGE_2_WHERE'
      EXPORTING
        field_ranges  = it_ranges
      IMPORTING
        where_clauses = it_where.
    READ TABLE it_where INTO is_where WITH KEY tablename = p_table.
    SELECT * FROM (p_table)
    INTO CORRESPONDING FIELDS OF TABLE <itab>
    UP TO p_rows ROWS
    WHERE (is_where-where_tab).
  ENDIF.
  IF sy-dbcnt = 0.
    WRITE: 'No record selected'.
    STOP.
  ENDIF.
ENDFORM.                    "f_select_table
* FORM f_display_table *
FORM f_display_table.
  DATA: l_answer TYPE c,
  l_eflag TYPE c.
  CLEAR: w_okcode.
  REFRESH: <ntab>.
* Display table contents
  CALL FUNCTION 'STC1_FULLSCREEN_TABLE_CONTROL'
    EXPORTING
      header       = p_table
      tabname      = p_table
      display_only = p_displ
      endless      = 'X'
      no_button    = space
    IMPORTING
      okcode       = w_okcode
    TABLES
*      nametab      = it_dfies
      table        = <itab>
*      fielddif     = it_fdiff
      modif_table  = <ntab>
    EXCEPTIONS
      OTHERS       = 1.
  IF sy-subrc = 0.
    IF p_displ IS INITIAL AND w_okcode = 'SAVE'.
* Confirm update
      CALL FUNCTION 'POPUP_TO_CONFIRM'
        EXPORTING
          titlebar              = p_table
          text_question         = 'Do you want to update table ?'
          default_button        = '2'
          display_cancel_button = ' '
        IMPORTING
          answer                = l_answer
        EXCEPTIONS
          OTHERS                = 1.
      IF l_answer = '1'.
* Apply modifications
        IF NOT <ntab>[] IS INITIAL.
          PERFORM f_add_system USING space.
          MODIFY (p_table) FROM TABLE <ntab>.
          IF sy-subrc NE 0.
            l_eflag = 'X'.
          ENDIF.
        ENDIF.
* Apply deletions
        IF l_eflag IS INITIAL.
          REFRESH: <ntab>.
          CALL FUNCTION 'STC1_GET_DATA'
            TABLES
              deleted_data = <ntab>
            EXCEPTIONS
              OTHERS       = 1.
          IF NOT <ntab>[] IS INITIAL.
            DELETE (p_table) FROM TABLE <ntab>.
            IF sy-subrc NE 0.
              ROLLBACK WORK.
              l_eflag = 'X'.
            ENDIF.
          ENDIF.
        ENDIF.
* Apply creations
        IF l_eflag IS INITIAL.
          REFRESH: <ntab>.
          CALL FUNCTION 'STC1_GET_DATA'
            TABLES
              new_data = <ntab>
            EXCEPTIONS
              OTHERS   = 1.
          IF NOT <ntab>[] IS INITIAL.
            PERFORM f_add_system USING 'X'.
            INSERT (p_table) FROM TABLE <ntab>.
            IF sy-subrc NE 0.
              ROLLBACK WORK.
              l_eflag = 'X'.
            ENDIF.
          ENDIF.
        ENDIF.
        IF l_eflag IS INITIAL.
          COMMIT WORK.
          MESSAGE s261(53).
        ELSE.
          MESSAGE s075(3i).
          PERFORM f_select_table.
        ENDIF.
      ENDIF.
* Display table again
      PERFORM f_display_table.
    ENDIF.
  ENDIF.
ENDFORM.                    "f_display_table
* FORM f_add_system *
FORM f_add_system USING new TYPE c.
  FIELD-SYMBOLS: <irec> TYPE ANY,
  <upd> TYPE ANY.
  LOOP AT it_fdiff INTO is_fdiff.
    READ TABLE it_dfies INTO is_dfies
    WITH KEY fieldname = is_fdiff-fieldname.
    LOOP AT <ntab> ASSIGNING <irec>.
      ASSIGN COMPONENT is_fdiff-fieldname OF STRUCTURE <irec> TO <upd>.
      IF is_dfies-datatype = 'CLNT'.
        <upd> = sy-mandt.
      ELSE.
        CASE is_dfies-rollname.
          WHEN 'AENAM'.
            <upd> = sy-uname.
          WHEN 'AEDAT' OR 'LAEDA'.
            <upd> = sy-datum.
          WHEN 'AETIM'.
            <upd> = sy-uzeit.
          WHEN OTHERS.
        ENDCASE.
      ENDIF.
    ENDLOOP.
  ENDLOOP.
ENDFORM.                    "f_add_system

Similar Messages

  • 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

  • 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,

  • No column text displayed in alv when i use dynamic internal table

    Hi friends,
    when I use dynamic internal table to display the fields in ALV formant, field column text was not displaying ,
    total row of column text was blank.
    can u sujjest me in this...
    with regards,
    prasad.

    Hi
    That depends on how you've filled the catalog table, here u need to insert the description for the labels (short, medium and long) and the description for the layout variant management.
    So u make sure to fill the fields like
    SCRTEXT_L
    SCRTEXT_M
    SCRTEXT_S
    REPTEXT
    Max

  • Problem disalying alv using dynamic internal table

    Hi All,
        I have 4 radiobutton for each radiobutton there is one internaltable to be displayed in alv.
    My requirement is intead of calling the function module reuse_alv_grid_display everytime for
    each of the internal table I want to create a dynamic internal tble for the function module.
       My question is how to create a dynamic internal table which will hold the fields & data of
    different interna table when diffrent radiobuttons are checked.
       Areciate your time to help.
       Thank you very much.

    Hi follow following logic:
    field-symbols: <i_table> type standard table.
    when rb1 is checked.
    assign itab1 to <i_table>.
    perform alv_disp using <i_table>
    when rb2 is checked.
    assign itab2 to <i_table>.
    perform alv_disp using <i_table>
    when rb3 is checked.
    assign itab3 to <i_table>.
    perform alv_disp using <i_table>
    when rb4 is checked.
    assign itab4 to <i_table>.
    perform alv_disp using <i_table>
    <<<<<<<<<<form alv_disp
    form alv_disp  using p_i_table type standard table.
    perform create fieldcatelog changing i_fc
    call the fm and pass the table p_i_table and i_fc
    <<<<<<<<<< form create fieldcaelog
    here create field catelog ..either by fm reuse_alv_fieldcatelog_merge ...in this just pass the structure name based on the radiobutton
    hope its useful

  • Alv grid using dynamic internal table

    hi i have an internal table
    begin of itab
    equipno like equi-equnr,
    reading like imrg-readg
    uom like imrg-uom
    date like imrg-date
    end of itab.
    and many more fields  in this table the reading, date, uom are dynamic its not fixed there can be five readings and 6 reading etc
    if i get all the data populated into final table  itab. how to display it throgh the alv grid
    i can use fieldsymbols i have seen some documents i want to know how to populate the fieldname s of the dynamic internal table to the field catalog and the values of the dynamic internal table .its a alv grid display pls guide

    Hi,
    Before displaying the records in ALV, you integrate all the fields (Fixed fields as well as variable fields) into one table. To do so you need create one dynamic table. If you already created this dynamic table then in the same way (same sequence) you need to populate the field catalog and use normal FM REUSE_ALV_GRID_DISPLAY to display it.
    If you not aware of how to create this dynamic internal table, please check the below way.
    1. Populate the fixed field into one field catalog(NB. this to create dyn table not ALV).
    *--- Cons Unit
      wa_lvc_cat-fieldname = c_cons.       
      wa_lvc_cat-ref_field = c_rbunit.      
      wa_lvc_cat-ref_table = c_ecmca.   
      append wa_lvc_cat to it_lvc_cat.    
    *--- account description
      wa_lvc_cat-fieldname = c_acctd.
      wa_lvc_cat-ref_field = c_txtmi.
      wa_lvc_cat-ref_table = c_tf101.
      append wa_lvc_cat to it_lvc_cat.
    2. For variable fields you have your own logic based on which you need to display the output. (like loop at one table and make each field as one column). Here one thing need to make sure every time field name should be different. You know in one structure there are 2 fields with same name is not allowed.
    3. next use the below method to create the internal table
    Create a new Table
      call method cl_alv_table_create=>create_dynamic_table
        exporting
          it_fieldcatalog = it_lvc_cat
        importing
          ep_table        = it_new_table.
    Create a new Line with the same structure of the table.
      assign it_new_table->* to <l_table>. " internal table
      create data wa_new_line like line of <l_table>.
      assign wa_new_line->* to <l_line>.  " Work area
    4. To populate the field catalog for ALV use the same sequence. Better while you populated it_lvc_cat for dynamic table also create one lookup table with three fields. (fieldname, Text, col_pos). Here loop into this look up table and populate the ALV field catalog.
    5. Display it using REUSE_ALV_GRID_DISPLAY
    call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program      = c_rep_name
          i_callback_user_command = 'F_USER_DOUBLE_CLICK'       "SD0K963313
          is_layout               = l_wa_layout
          it_fieldcat             = it_fieldcat
          it_sort                 = it_sort
          i_save                  = l_save
          is_variant              = wa_variant1
          it_events               = it_events
        tables
          t_outtab                = <l_table>
        exceptions
          program_error           = 1
          others                  = 2.
    Thanks
    Subhankar

  • How to use dynamic internal table when using gui_upload?

    Hi Experts,
    my scenario is like i have header data, item data and serial numbers.
    so with respect to the  quantity in unit of measure ,there will be number of serial numbers..
    i have declared the dynamic internal table,but i am not getting the logic to change the structure accordingly with respect to the flat file entries..
    is it possible to do or its not possible....any suggestion!!!!i have declared like this....
    TYPES: BEGIN OF ty_final,
          bldat TYPE string,      "Document Date
          budat TYPE string,      "Psting Date
          bktxt TYPE string,      "Document Header Text
          werks TYPE string,      "Plant
          lgort TYPE string,      "Storage Location
          matnr TYPE string,      "Material Number
          erfmg TYPE string,      "Quantity in Unit Of Entry
          anln1 TYPE string,      "Asset Number
          anln2 TYPE string,      "Asset Subnumber
          sernr TYPE string,      "serial Number
    END OF ty_final.
    DATA : it_final TYPE TABLE OF ty_final,
           wa_final TYPE ty_final.
    FIELD-SYMBOLS : <fs_final> TYPE table.
    ASSIGN it_final TO <fs_final>.
    after this i called gui upload and passed internal table it_final..
    but i have to change the internal table structure dynamically before the upload function.so that it will match with the flat file...
    Regards
    Karthick

    There are at least two approaches you can use to change/generate new dynamic-structured table. Either with [RTTI + RTTS|https://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI] or using [CL_ALV_TABLE_CREATE|http://www.sdn.sap.com/irj/scn/advancedsearch?query=cl_alv_table_create] . In this one just determine fieldcatalog of current table and change it accordingly, then regenarate table.
    There are plenty of examples in SCN for this. You should not face difficulties applying this.
    Regards
    Marcin

  • How to use dynamic internal table in interactive report syntax

    pls let me know

    Hi Aarif,
    Go through the below code for better understanding:
    *& Report  ZDYN_INT_TABLE_02                                           *
    REPORT  ZDYN_INT_TABLE_02.
    TYPE-POOLS: slis.                      " ALV Global types
    SELECTION-SCREEN BEGIN OF BLOCK b1.
    PARAMETERS : p_max(3) TYPE n OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK b1.
    TYPES: BEGIN OF wa_gt_data,
              matnr TYPE mara-matnr,
           END OF wa_gt_data.
    DATA gt_data TYPE STANDARD TABLE OF wa_gt_data WITH HEADER LINE.
    *INITIALIZATION.
    v_1 = 'Maximum of records to read'.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_display_data.
         Form  f_read_data
    FORM f_read_data.
      SELECT matnr INTO TABLE gt_data
               FROM mara
                 UP TO p_max ROWS.
    ENDFORM.                               " F_READ_DATA
         Form  F_DISPLAY_DATA
    FORM f_display_data.
      DATA:
        l_column    TYPE sy-tabix,
        lp_struct   TYPE REF TO data,
        lp_table    TYPE REF TO data,      " Pointer to dynamic table
        ls_lvc_cat  TYPE lvc_s_fcat,
        lt_lvc_cat  TYPE lvc_t_fcat,       " Field catalog
        lt_fcat     TYPE slis_t_fieldcat_alv,  " Field catalog
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv,  " Field catalog
        ls_layout   TYPE slis_layout_alv.
      FIELD-SYMBOLS :
        <header>       TYPE ANY,
        <field_header> TYPE ANY,
        <field_mara>  TYPE ANY,
        <lt_data>      TYPE table.         " Data to display
      ls_lvc_cat-fieldname = 'COLUMNTEXT'.
      ls_lvc_cat-ref_table = 'LVC_S_DETA'.
      APPEND ls_lvc_cat TO lt_lvc_cat.
      ls_fieldcat-fieldname = 'COLUMNTEXT'.
      ls_fieldcat-ref_tabname = 'LVC_S_DETA'.
      ls_fieldcat-key  = 'X'.
      APPEND ls_fieldcat TO lt_fieldcat.
      DO p_max TIMES.
      For each line, a column 'VALUEx' is created in the fieldcatalog
      Build Fieldcatalog
       WRITE sy-index TO ls_lvc_cat-fieldname LEFT-JUSTIFIED.
        CONCATENATE 'VALUE' ls_lvc_cat-fieldname
               INTO ls_lvc_cat-fieldname.
        ls_lvc_cat-ref_field = 'VALUE'.
        ls_lvc_cat-ref_table = 'LVC_S_DETA'.
        APPEND ls_lvc_cat TO lt_lvc_cat.
      Build Fieldcatalog
        CLEAR ls_fieldcat.
        ls_fieldcat-fieldname = ls_lvc_cat-fieldname.
        ls_fieldcat-ref_fieldname = 'VALUE'.
        ls_fieldcat-ref_tabname = 'LVC_S_DETA'.
        APPEND ls_fieldcat TO lt_fieldcat.
      ENDDO.
    Create internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = lt_lvc_cat
        IMPORTING
          ep_table        = lp_table.
      ASSIGN lp_table->* TO <lt_data>.
    Create structure = structure of the internal table
      CREATE DATA lp_struct LIKE LINE OF <lt_data>.
      ASSIGN lp_struct->* TO <header>.
    Create field catalog from dictionary structure
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name       = 'MARA'
        CHANGING
          ct_fieldcat            = lt_fcat
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      LOOP AT lt_fcat INTO ls_fieldcat WHERE fieldname = 'MATNR'.
        ASSIGN COMPONENT 1 OF STRUCTURE <header> TO <field_header>.
        IF sy-subrc NE 0. EXIT .ENDIF.
        READ TABLE lt_fcat INTO ls_fieldcat INDEX sy-index.
        <field_header> = ls_fieldcat-seltext_m.
        IF <field_header> IS INITIAL.
          <field_header> = ls_fieldcat-fieldname.
        ENDIF.
        LOOP AT gt_data.
          l_column = sy-tabix + 1.
          ASSIGN COMPONENT 1 OF STRUCTURE gt_data TO <field_mara>.
          IF sy-subrc NE 0. EXIT .ENDIF.
          ASSIGN COMPONENT l_column OF STRUCTURE <header> TO <field_header>.
          IF sy-subrc NE 0. EXIT .ENDIF.
          WRITE <field_mara> TO <field_header> LEFT-JUSTIFIED.
        ENDLOOP.
        APPEND <header> TO <lt_data>.
      ENDLOOP.
      ls_layout-colwidth_optimize = 'X'.
      ls_layout-no_colhead = 'X'.
      ls_layout-zebra = 'X'.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          is_layout   = ls_layout
          it_fieldcat = lt_fieldcat
        TABLES
          t_outtab    = <lt_data>.
    ENDFORM.                               " F_DISPLAY_DATA
    END OF PROGRAM Z_ALV_LIST_TRANSPOSED *********************
    *Always reward point for helpful answers
    Regards,
    Amit

  • How to use dynamic internal table with FOR ALL ENTRIES

    Hello SDNers,
    I am having a dynamic internal table & want to use FOR ALL ENTRIES(FAE) using this dyn. table.
    This works fine for me:
    IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
            SELECT field1 field2
              FROM TABLE ztable
              INTO TABLE itab "Itab is a static table
              FOR ALL ENTRIES IN <lt_tmp>
              WHERE (lv_dynwhere). "lv_dynwhere -> dynamic where clause
          ENDIF.
    SAP documentation says:
    "The logical expression sql_cond of the WHERE condition can be comprised of several logical expressions using AND and OR. However, if FOR ALL ENTRIES is specified, there must be at least one comparison with a column of the internal table itab that can be specified statically or dynamically. "
    How do we specify the column of the internal table dynamically ? Can we do something like this:
    IF <lt_tmp> IS NOT INITIAL. "<lt_tmp> is my dyn. internal table
            SELECT field1 field2
              FROM TABLE
              INTO TABLE itab "Itab is a static table
              FOR ALL ENTRIES IN <lt_tmp>
              WHERE key_field1 = (dynamic token for column1 of <lt_tmp>)
                           key_field2 = (dynamic token for column2 of <lt_tmp>)
          ENDIF.
          ENDIF.
    Let me know if i am not clear about my requirement.
    BR,
    Suhas

    Hello Thomas,
    What i meant was something like this:
    WHERE key_field1 = ('<LT_TMP-COL1>') AND
          key_field2 = ('<LT_TMP-COL2>')
    I am confused by what SAP means with "dynamic representation of internal table columns" in FAE ?
    @Rob: I was referring to SAPNW 7.0 documentation & the phrase (release 6.40 & higher) is missing. Anyways fyi i am on ECC5.0 ABAP release 6.40.
    @Subhankar: This is what Marcin had proposed in For all entries and dynamic table.
    Thanks,
    Suhas
    Edited by: Suhas Saha on Apr 6, 2010 11:53 AM

  • Create object/structure like dynamic internal table

    Hi,
    We have created dynamic internal table with some fields.
    for the above how to create structure or internal table like dynamic internal table structure .
    Scenario: internal table itab1 ( with header line) have 5 fields.
    Based on some of the conditions in layout of the report.
    we have to create dynamic internal table.
    field-symbols: <FS> type standard table.
    we are able to create dynamic internal table with 3 fields
    with assignment <fs> = itab1[]
    the columns are not appearing but data appearing in next column.
    how to solve this one
    Thanks
    Ramesh

    Hi Ramesh,
      I hope this code works...
    report  yup_alv_datbase                         .
    *-Display Database table contents in ALV Grid Format
    >********************************************************************
    This report displays data from SAP tables, views (like SE16)        *
    FM : REUSE_ALV_GRID_DISPLAY                                         *
    tables:
      dd02l,                               " SAP tables
      dd03l.                               " Table Fields
    type-pools: slis.                      " ALV Global Types
    selection-screen :
    begin of line, comment 1(35) v_1 for field p_table.         "#EC NEEDED
    parameters p_table like dd03l-tabname obligatory memory id dtb.
    selection-screen end of line.
    selection-screen :
    begin of line, comment 1(35) v_2 for field p_max.           "#EC NEEDED
    parameters p_max(2) type n default '20' obligatory.
    selection-screen end of line.
    at selection-screen.
      select single * from dd02l where tabname  = p_table
                                   and as4local = 'A'
                                   and as4vers  = '0000'.
      if sy-subrc ne 0.
      Table & is not active in the Dictionary
        message e402(mo) with p_table.
      elseif dd02l-tabclass = 'INTTAB'.
      & is a structure, not a table
        message e403(mo) with p_table.
      endif.
    initialization.
      v_1 = 'Table'.
      v_2 = 'Maximum of records'.
    start-of-selection.
      perform f_display_data.
         Form  F_DISPLAY_DATA
    form f_display_data.
    Macro definition
      define m_sort.
        add 1 to ls_sort-spos.
        ls_sort-fieldname = &1.
        ls_sort-up = 'X'.
        append ls_sort to lt_sort.
      end-of-definition.
      data:
        l_long type i,
        lp_struct   type ref to data,
        lp_table    type ref to data,      " Pointer to dynamic table
        of_sdescr   type ref to cl_abap_structdescr,
        ls_lvc_cat  type lvc_s_fcat,
        lt_lvc_cat  type lvc_t_fcat,       " Field catalog
        ls_fieldcat type slis_fieldcat_alv,
        lt_fieldcat type slis_t_fieldcat_alv,  " Field catalog
        ls_layout   type slis_layout_alv,
        lt_sort     type slis_t_sortinfo_alv,  " Sort table
        ls_sort     type slis_sortinfo_alv.
      field-symbols :
        <fieldcat>   type slis_fieldcat_alv,
        <lt_data>    type table,           " Data to display
        <fs>         type any,
        <components> type abap_compdescr.
    Dynamic creation of a structure
      create data lp_struct type (p_table).
      assign lp_struct->* to <fs>.
    Fields Structure
      of_sdescr ?= cl_abap_typedescr=>describe_by_data( <fs> ).
      loop at of_sdescr->components assigning <components>.
      Field MANDT not displayed
        if sy-tabix = 1 and <components>-name = 'MANDT'.
          continue.                        " Next loop
        endif.
      Build Fieldcatalog
        ls_lvc_cat-fieldname = <components>-name.
        ls_lvc_cat-ref_table = p_table.
        append ls_lvc_cat to lt_lvc_cat.
      Build Fieldcatalog
        ls_fieldcat-fieldname = <components>-name.
        ls_fieldcat-ref_tabname = p_table.
        append ls_fieldcat to lt_fieldcat.
      endloop.
    Create internal table
      call method cl_alv_table_create=>create_dynamic_table
        exporting it_fieldcatalog = lt_lvc_cat
        importing ep_table = lp_table.
      assign lp_table->* to <lt_data>.
    Read data
      select * from (p_table) up to p_max rows
        into corresponding fields of table <lt_data>
       order by primary key.
      if <lt_data>[] is initial.
      No table entries found for specified key
        message i429(mo).
        exit.
      endif.
    Read key field to Build Sort Table
      select * from dd03l where tabname  = p_table
                            and fieldname <> '.INCLUDE'
                            and as4vers  = '0000'
                            and as4local = 'A'
                          order by position.
        read table lt_fieldcat assigning <fieldcat>
                                with key fieldname = dd03l-fieldname.
        check sy-subrc eq 0.
        add dd03l-leng to l_long.
        if dd03l-keyflag = 'X'.
        Build Sort Table
          m_sort dd03l-fieldname.
          <fieldcat>-key = 'X'.
        elseif l_long > 150.
          <fieldcat>-tech = 'X'.
        endif.
      endselect.
      ls_layout-zebra = 'X'.
      ls_layout-colwidth_optimize = 'X'.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                is_layout   = ls_layout
                it_fieldcat = lt_fieldcat
                it_sort     = lt_sort
           tables
                t_outtab    = <lt_data>.
    endform.                               " F_DISPLAY_DATA
    END OF PROGRAM Z_ALV_DYNAMIC_DATA *********************
    Regards,
    Sampath

  • How to use Dynamic Internal table

    Hello,
    I have a requirement where I need to pick a field from final internal table and display that field as ALV columns and I have to pick another field in the same INternal table to display it as a corresponding value for each header DYNAMICALLY.
    lw_fieldcat-col_pos = 1.
      lw_fieldcat-tabname = 'T_FINAL'.
      lw_fieldcat-fieldname = 'ATTR20A'.
      lw_fieldcat-seltext_m = 'SUBSTANCE ID'.
      lw_fieldcat-outputlen = '21'.
      lw_fieldcat-fix_column = 'X'.
      lw_fieldcat-key = 'X'.
      APPEND lw_fieldcat TO lt_fieldcat.
      CLEAR LW_FIELDCAT.
      lw_fieldcat-col_pos = 2.
      lw_fieldcat-tabname = 'T_FINAL'.
      lw_fieldcat-fieldname = 'PRVSY'.
      lw_fieldcat-seltext_m = 'R3 MAT NBR'.
      lw_fieldcat-outputlen = '14'.
      lw_fieldcat-FIX_COLUMN = 'X'.
      lw_fieldcat-key = 'X'.
      APPEND lw_fieldcat TO lt_fieldcat.
      CLEAR LW_FIELDCAT.
    These 2 fields are constant, now i need to display fields dynamically from the field STCTS (for dynamic header) CCNGN (for the value in each header)
    In the below code the logic is working to pick appropriate value for each header.
    DATA : Y_I_FCAT  TYPE LVC_T_FCAT,
          Y_WA_FCAT LIKE LINE OF Y_I_FCAT.
    DATA : T_NEWFINAL TYPE STANDARD TABLE OF TY_FINAL,
           WA_NEWFINAL TYPE TY_FINAL.
    LOOP AT T_FINAL INTO WA_FINAL
                  WHERE STCTS IS NOT INITIAL
    CONCATENATE 'SUBID CLASSIFICATION-' WA_FINAL-STCTS
                       INTO Y_WA_FCAT-FIELDNAME.
                       INTO Y_WA_FCAT-SCRTEXT_M.
      APPEND Y_WA_FCAT TO Y_I_FCAT. "Header of column appear as
                                    'SUBID SUBID CLASSIFICATION-AR-HTS'
      CLEAR Y_WA_FCAT.
    MOVE WA_FINAL-CCNGN TO WA_NEWFINAL-CCNGN.  "HERE IT WILL PICK THE VALUE FOR THE ABOVE                                             " HEADER EX : '2345'
    *&THIS STATEMENT WILL MOVE THE KEY FIELD TO
    *&WA_NEWFINAL.
    MOVE WA_FINAL-GUID_PR TO WA_NEWFINAL-GUID_PR.
      APPEND WA_NEWFINAL TO T_NEWFINAL.
      CLEAR : WA_FINAL,
              WA_NEWFINAL.
    ENDLOOP.
    How should i pass it to the dynamic interanl table and then to the ALV grid filed catlog.
    Below is my code for refernce :
    **DATA : Y_I_FCAT  TYPE LVC_T_FCAT,
          Y_WA_FCAT LIKE LINE OF Y_I_FCAT.
          Y_WA_FCAT TYPE LVC_S_FCAT.
    **DATA : T_NEWFINAL TYPE STANDARD TABLE OF TY_FINAL,
          WA_NEWFINAL TYPE TY_FINAL.
    *DATA : W_STRING TYPE STRING.
    DATA : WA_FLNAME(32) TYPE C.
    *LOOP AT T_FINAL INTO WA_FINAL
                 WHERE STCTS IS NOT INITIAL
                   AND CCNGN IS NOT INITIAL.
    *ADD 1 TO COUNTER.
    *ENDLOOP.
    *DO COUNTER TIMES.
    LOOP AT T_FINAL INTO WA_FINAL
                  WHERE STCTS IS NOT INITIAL
                    AND CCNGN IS NOT INITIAL.
    CONCATENATE 'SUBID CLASSIFICATION-' WA_FINAL-STCTS
                      INTO Y_WA_FCAT-FIELDNAME.
                       INTO Y_WA_FCAT-SCRTEXT_M.
                        INTO WA_FLNAME.
       Y_WA_FCAT-FIELDNAME = WA_FLNAME.
       Y_WA_FCAT-SELTEXT = WA_FLNAME.
      APPEND Y_WA_FCAT TO Y_I_FCAT.
      CLEAR Y_WA_FCAT.
    MOVE WA_FINAL-CCNGN TO W_STRING.
    MOVE WA_FINAL-CCNGN TO WA_NEWFINAL-CCNGN.
    *&THIS STATEMENT WILL MOVE THE KEY FIELD TO
    *&WA_NEWFINAL.
    MOVE WA_FINAL-GUID_PR TO WA_NEWFINAL-GUID_PR.
      APPEND WA_NEWFINAL TO T_NEWFINAL.
      CLEAR : WA_FINAL,
              WA_NEWFINAL.
    ENDIF.
    *ENDDO.
    ENDLOOP.
    PERFORM CREATE_DYNAMIC_ITAB.
    LOOP AT Y_I_FCAT INTO Y_WA_FCAT. "IT_FIELDCAT INTO LW_FIELDCAT.
    MOVE :  Y_WA_FCAT-SCRTEXT_M TO LW_FIELDCAT-SELTEXT_M,
            Y_WA_FCAT-FIELDNAME TO LW_FIELDCAT-FIELDNAME,
           Y_WA_FCAT-TABNAME   TO LW_FIELDCAT-TABNAME,
           Y_WA_FCAT-COL_POS   TO LW_FIELDCAT-COL_POS,
            Y_WA_FCAT-SCRTEXT_M TO LW_FIELDCAT-SELTEXT_M.
           Y_WA_FCAT-DATATYPE  TO LW_FIELDCAT-DATATYPE,
           Y_WA_FCAT-INTLEN    TO LW_FIELDCAT-INTLEN.
    APPEND LW_FIELDCAT TO LT_FIELDCAT.
    ENDLOOP.
    ENDFORM.                    " DYNAMIC
    *&      Form  CREATE_DYNAMIC_ITAB
          text
    -->  p1        text
    <--  p2        text
    FORM CREATE_DYNAMIC_ITAB .
    *DATA : DY_TABLE TYPE REF TO DATA,
          DY_LINE TYPE REF TO DATA.
    DATA : Y_LV_COMP TYPE STRING.
    *FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
                  <DYN_WA>,
                  <DYN_FIELD>.
    *FIELD-SYMBOLS : <y_fld> TYPE ANY.
    CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
      EXPORTING
        IT_FIELDCATALOG           = Y_I_FCAT
      IMPORTING
        EP_TABLE                  = DY_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 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>.
    LOOP AT T_FINAL INTO WA_FINAL.
      Y_LV_COMP = 'ATTR20A'.
      ASSIGN COMPONENT Y_LV_COMP OF STRUCTURE <DYN_WA> TO <Y_FLD>.
       <Y_FLD> = WA_FINAL-ATTR20A.
       Y_LV_COMP = 'PRVSY'.
       ASSIGN COMPONENT Y_LV_COMP OF STRUCTURE <DYN_WA> TO <Y_FLD>.
       <Y_FLD> = WA_FINAL-PRVSY.
       Y_LV_COMP = 'PRTXT'.
       ASSIGN COMPONENT Y_LV_COMP OF STRUCTURE <DYN_WA> TO <Y_FLD>.
       <Y_FLD> = WA_FINAL-PRVSY.
       Y_LV_COMP = 'GRVSY'.
       ASSIGN COMPONENT Y_LV_COMP OF STRUCTURE <DYN_WA> TO <Y_FLD>.
       <Y_FLD> = WA_FINAL-GRVSY.
    LOOP AT T_NEWFINAL INTO WA_NEWFINAL
          WHERE GUID_PR = WA_FINAL-GUID_PR.
    CONCATENATE 'SUBID Classification-'
                  WA_FINAL-STCTS
                   INTO Y_LV_COMP.
      ASSIGN COMPONENT Y_LV_COMP OF STRUCTURE <DYN_WA> TO <Y_FLD>.
          <Y_FLD> = WA_NEWFINAL-CCNGN.
    ENDLOOP.
    APPEND <DYN_WA> TO <DYN_TABLE>.
    FREE : <DYN_WA>, <Y_FLD>.
    ENDLOOP.
    ENDFORM.                    " CREATE_DYNAMIC_ITA
    ANy suggestion would be apprecaited.
    Regards,
    Kittu

    I think I need to put it in more descriptive way...
    I am closing this thread

  • Creating XML transformation using multiple internal tables

    <b>Hi everyone,</b><br />
    <br />
    <b>I'm trying to transforme 3 internal tables (from customer master data) into a single XML document.</b><br />
    <p />
    DATA:   BEGIN OF wtab OCCURS 0 ,<br />
            kunnr LIKE kna1-kunnr, "Customer ID<br />
            ktokd LIKE kna1-ktokd, <br />
            land1 LIKE kna1-land1, <br />
            name1 LIKE kna1-name1, <br />
            ort01 LIKE kna1-ort01, <br />
            pstlz LIKE kna1-pstlz, <br />
            spras_iso LIKE kna1-spras, <br />
            smtp_addr LIKE adr6-smtp_addr, <br />
            stras LIKE kna1-stras, <br />
              END OF wtab.<br />
    <br />
    DATA:   BEGIN OF wtab_o OCCURS 0 ,<br />
            kunnr LIKE knvv-kunnr, "Customer ID<br />
            vkorg LIKE knvv-vkorg, "Sales organisation<br />
            waers LIKE knvv-waers, <br />
            END OF wtab_o.<br />
    <br />
    DATA:   BEGIN OF wtab_p OCCURS 0 ,<br />
            kunnr LIKE knvp-kunnr, "Customer ID<br />
            vkorg LIKE knvp-vkorg, "Sales organisation<br />
            parvw LIKE knvp-parvw, <br />
            kunn2 LIKE knvp-kunnr,<br />
              END OF wtab_p.<br />
    <p />
    <b>The internal tables are related to each other as follows:*</b><br />
    <br />
    wtab-kunnr = wtab_o-kunnr<br />
    <br />
    AND<br />
    <br />
    wtab_o-vkorg = wtab_p-vkorg<br />
    wtab_o-kunnr = wtab_p-kunnr<br />
    <br />
    <b>I couldn't figure out how to declare this relationship when calling the transformation. Is it possible?</b><br />
    <p />
    ABAP<br />
    <br />
    <br />
    REFRESH : gt_source_itab.<br />
    CLEAR : g_rxml.<br />
    <br />
      GET REFERENCE OF wtab INTO gs_source_wa-value.<br />
      gs_source_wa-name = 'DEBMAS04'.<br />
      APPEND gs_source_wa TO gt_source_itab.<br />
    <br />
      GET REFERENCE OF wtab_o INTO gs_source_wa-value.<br />
      gs_source_wa-name = 'E1KNVVM'.<br />
      APPEND gs_source_wa TO gt_source_itab.<br />
    <br />
    GET REFERENCE OF wtab_p INTO gs_source_wa-value.<br />
      gs_source_wa-name = 'E1KNVPM'.<br />
      APPEND gs_source_wa TO gt_source_itab.<br />
    <br />
      TRY.<br />
          CALL TRANSFORMATION Z_XSLT_CLIENT<br />
          SOURCE (gt_source_itab)<br />
          RESULT XML g_rxml<br />
          OPTIONS xml_header = 'without_encoding'.<br />
    CATCH cx_root INTO gs_rif_ex.<br />
    <br />
          gs_var_text = gs_rif_ex-&gt;get_text( ).<br />
          MESSAGE gs_var_text TYPE 'E'.<br />
        ENDTRY.<br />
    <br />
    <br />
    Transformation Z_XSLT_CLIENT:<br />
    <br />
    <br />
    &lt;xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   xmlns:sap="http://www.sap.com/sapxsl"&gt;<br />
    &lt;xsl:output indent="yes" encoding="UTF-16" method="xml" version="1.0"/&gt;<br />
    &lt;xsl:strip-space elements="*"/&gt;<br />
    &lt;xsl:template match="/"&gt;<br />
    &lt;DEBMAS04&gt;<br />
    &lt;xsl:apply-templates select="//DEBMAS04/item"/&gt;<br />
    &lt;/DEBMAS04&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;xsl:template match="DEBMAS04/item"&gt;<br />
         &lt;IDOC&gt;<br />
           &lt;xsl:attribute name="BEGIN"&gt;1&lt;/xsl:attribute&gt;<br />
           &lt;E1KNA1M&gt;<br />
            &lt;xsl:attribute name="SEGMENT"&gt;1&lt;/xsl:attribute&gt;<br />
            &lt;KUNNR&gt;<br />
               &lt;xsl:value-of select="KUNNR"/&gt;<br />
            &lt;/KUNNR&gt;<br />
            &lt;KTOKD&gt;<br />
               &lt;xsl:value-of select="KTOKD"/&gt;<br />
            &lt;/KTOKD&gt;<br />
            &lt;LAND1&gt;<br />
               &lt;xsl:value-of select="LAND1"/&gt;<br />
            &lt;/LAND1&gt;<br />
            &lt;NAME1&gt;<br />
               &lt;xsl:value-of select="NAME1"/&gt;<br />
            &lt;/NAME1&gt;<br />
            &lt;ORT01&gt;<br />
               &lt;xsl:value-of select="ORT01"/&gt;<br />
            &lt;/ORT01&gt;<br />
            &lt;PSTLZ&gt;<br />
               &lt;xsl:value-of select="PSTLZ"/&gt;<br />
            &lt;/PSTLZ&gt;<br />
            &lt;SPRAS_ISO&gt;<br />
               &lt;xsl:value-of select="SPRAS_ISO"/&gt;<br />
            &lt;/SPRAS_ISO&gt;<br />
            &lt;SMTP_ADDR&gt;<br />
               &lt;xsl:value-of select="SMTP_ADDR"/&gt;<br />
            &lt;/SMTP_ADDR&gt;<br />
            &lt;STRAS&gt;<br />
               &lt;xsl:value-of select="STRAS"/&gt;<br />
            &lt;/STRAS&gt;<br />
             &lt;xsl:apply-templates select="//E1KNVVM/item"/&gt;<br />
           &lt;/E1KNA1M&gt;<br />
      &lt;/IDOC&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;xsl:template match="E1KNVVM/item"&gt;<br />
       &lt;E1KNVVM&gt;<br />
             &lt;xsl:attribute name="SEGMENT"&gt;1&lt;/xsl:attribute&gt;<br />
             &lt;VKORG&gt;<br />
               &lt;xsl:value-of select="VKORG"/&gt;<br />
             &lt;/VKORG&gt;<br />
             &lt;WAERS&gt;<br />
               &lt;xsl:value-of select="WAERS"/&gt;<br />
             &lt;/WAERS&gt;<br />
           &lt;xsl:apply-templates select="//E1KNVPM/item"/&gt;<br />
       &lt;/E1KNVVM&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;xsl:template match="E1KNVPM/item"&gt;<br />
       &lt;E1KNVPM&gt;<br />
             &lt;xsl:attribute name="SEGMENT"&gt;1&lt;/xsl:attribute&gt;<br />
             &lt;PARVW&gt;<br />
               &lt;xsl:value-of select="PARVW"/&gt;<br />
             &lt;/PARVW&gt;<br />
             &lt;KUNN2&gt;<br />
               &lt;xsl:value-of select="KUNN2"/&gt;<br />
             &lt;/KUNN2&gt;<br />
       &lt;/E1KNVPM&gt;<br />
    &lt;/xsl:template&gt;<br />
    &lt;/xsl:transform&gt;<br />
    <br />
    <b>The way the call transformation is now, for each line in table wtab (DEBMAS04) I'm getting all the lines in table wtab_o (E1KNVVM) and table wtab_p (E1KNVPM)</b><br />
    <p />
    <br />
    Thank you for your help,<br />
    <br />
    Giselle<br />
    <p />

    Hi Giselle,
    I think it's possible (using xsl:if for instance), but an easier way is to nest your internal tables declarations (wtab_o inside wtab, kunnr becomes useless, and wtab_p inside wtab_o), and use the SAP standard "ID" transformation (no need for a custom XSL transformation). You'll get a slightly different result, but I don't think you want something very sophisticated.
    Sandra

  • Reading data from table control in an internal table

    Hello All,
    I want to read the data entered in the screen in an internal table,screen has header segment fields of an idoc and two item segment fields with multiple occurance in form of  two table control,have to read both the table control and have to pass it to idoc inbound function based on postion(posnr) of the order. can anyone provide me with the sample code for the same .
    Thanks and Regards,
    Gunjan

    hi gunjan
    refer to the folllowing code. it will work for u
    Creation of an IDoc generation program
    The following code extract contains everything needed to generate an IDoc from data contained in a table.
    FORM F_110_SEND_IDOC.
    CONSTANTS:
      C_MESTYP TYPE EDIDC-MESTYP VALUE 'ZVISTAPM',"message type
      C_DOCTYP TYPE EDIDC-IDOCTP VALUE 'ZVISTAPM01',"idoc type
      C_SEGNAM TYPE EDIDD-SEGNAM VALUE 'Z1VISTAPM'."segment name
    DATA:
      I_ZVISTA_PM TYPE ZVISTA_PM_T OCCURS 6000,
      I_EDIDC TYPE EDIDC OCCURS 0,
      I_EDIDD TYPE EDIDD OCCURS 0,
      WA_ZVISTA_PM TYPE ZVISTA_PM_T,
      WA_EDIDC TYPE EDIDC,
      WA_EDIDD TYPE EDIDD,
      WA_Z1VISTAPM TYPE Z1VISTAPM,
      V_OCCMAX TYPE IDOCSYN-OCCMAX,
      V_NBSEG TYPE I.
    CLEAR WA_ZVISTA_PM.
    CLEAR WA_EDIDC.
    * Save the message type and the basic IDoc type
    * in the control segment
    MOVE C_MESTYP TO WA_EDIDC-MESTYP.
    MOVE C_DOCTYP TO WA_EDIDC-IDOCTP.
    * Retrieve the maximum number of segments in the basic IDoc
    * type
    SELECT MIN( OCCMAX )
      FROM IDOCSYN
      INTO V_OCCMAX
      WHERE IDOCTYP EQ C_DOCTYP AND SEGTYP EQ C_SEGNAM.
    * Save the whole ZVISTA_PM_T table content
    * in the I_ZVISTA_PM internal table.
    SELECT *
    FROM ZVISTA_PM_T
    INTO CORRESPONDING FIELDS OF TABLE I_ZVISTA_PM.
    * Create a data segment for each line of I_ZVISTA_PM
    LOOP AT I_ZVISTA_PM INTO WA_ZVISTA_PM.
      MOVE-CORRESPONDING WA_ZVISTA_PM TO WA_Z1VISTAPM.
      CLEAR WA_EDIDD.
      MOVE C_SEGNAM TO WA_EDIDD-SEGNAM.
      MOVE WA_Z1VISTAPM TO WA_EDIDD-SDATA.
      APPEND WA_EDIDD TO I_EDIDD.
      CLEAR WA_ZVISTA_PM.
      CLEAR WA_Z1VISTAPM.
    ENDLOOP.
    * Count the number of data segments
    DESCRIBE TABLE I_EDIDD LINES V_NBSEG.
    * If the number of data segments exceeds the maximum
    * allowed number, then edit a message in the spool,
    * then display an error message (quit the program)
    IF V_NBSEG GT V_OCCMAX.
      WRITE:/ TEXT-003, V_OCCMAX.
      MESSAGE E751.
    ENDIF.
    * Call the IDoc creation function
    CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
      EXPORTING
        MASTER_IDOC_CONTROL = WA_EDIDC
      TABLES
        COMMUNICATION_IDOC_CONTROL = I_EDIDC
        MASTER_IDOC_DATA = I_EDIDD
      EXCEPTIONS
        ERROR_IN_IDOC_CONTROL = 1
        ERROR_WRITING_IDOC_STATUS = 2
        ERROR_IN_IDOC_DATA = 3
        SENDING_LOGICAL_SYSTEM_UNKNOWN = 4
        OTHERS = 5.
    * If there was an error, display a message (quit the
    * program)
    IF SY-SUBRC NE 0.
      MESSAGE E746.
    ENDIF.
    ENDFORM.
    regards
    ravish
    <b>plz dont forget to reward points if useful</b>

  • 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.

  • Populate data in dynamic internal table

    Hi ppl,
    I have a requirement where I need to display certain fields in the report output.
    The output contains 8 fixed fields (common for all rows in output) and some dynamic fields (number of column varies with rows) which will be determined at runtime.
    I am able to create the dunamic internal table....and at runtime I see the fields created in the internal table correctly.
    Now my requirement is to fill this table with the data from 2 internal tables.
    The values for the 8 common fields comes from the internal table t_output and the values for dynamic fields come from t_dynamic.
    Please let me know the logic to merge these 2 internal tables into the dynamic internal table <dyn_table>.
    Regards.

    Hello David,
    This has been discussed many times before in this forum. Since the table structure is dynamic the fields are determined at runtime.
    To assign data to this table you have to use [ASSIGN COMPONENT ... |http://help.sap.com/abapdocu_70/en/ABAPASSIGN_MEM_AREA_DYNAMIC_DOBJ.htm#!ABAP_ALTERNATIVE_4@4@] variant.
    Please refer to the example provided in the documentation for details.
    BR,
    Suhas

Maybe you are looking for

  • Macbook Pro vs iMac for video production

    Hello - I need to invest in a new system for production of HD videos, typically music videos less than 4-mins, which make heavy use of Premier Pro and Effects. The priority is real-time editing and fast rendering. I had more or less settled on the fo

  • Jdbc url for yahoo finance

    Hey guys, Can anyone please help me find out what is the JDBC url for Yahoo Finance Database that stores the values of the historical stock quotes . I desperately need it for my java application in which I require to access the database in order to g

  • IMac Sleep Disorder

    My wife's iMac (fully updated and running 10.7.4) has two problems that just started yesterday.. 1.  After going to sleep, normally I would simply press any key on the keyboard to get to the login screen, but now pressing keyboard keys, moving the mo

  • Purchase order reject function

    Hi all, I need to reject a PO with abap code. Since i didn't found any function module for that, i tried to create a BDC with ME29N but it doesn't seem to work. Any other ideas? Thanks, Luis Cruz

  • Need to reinstall Snow Leopard on Mini.

    I have a Mac Mini that is too old for Lion.  I need to reinstall Snow Leopard, but I think the DVD drive is broken.  How can I connect the Mini to a MacBook so it appears as a hard disk where I can then use the MacBook DVD drive to reinstall the OS o