Dynamic Internal table data

Hi All,
I was created program to generate Dynamic field catalog and internal table, here is confusion how to display below mentioned internal table data to final dynamic internal table based on document type headings
This is Statsic internal table Data
1 0000123  GBP  DA  S  6265.45
2 0000123  GBP  DA  H  240.51
3 0000123  GBP  DA  S  35.82
4 0000123  GBP  D1  H  281.85
5 0000123  GBP  D1  S  23.41
6 0000123  GBP  D1  S  34.23
7 0000123  GBP  RV  H  97.02
8 0000123  GBP  RV  S  52.90
9 0000123  GBP  RV  S  148.31
Can anybody suggest me how to populate the amount based on Document type and posting (credit or debit)
For Example
CUST DAC       DAD         D1C       D1D     RVC     RVD
123                  6265.45   240.51
                        35.82
Thanks in Advance
Sekhar
Moderator message: please do not open multiple threads for the same or similar issue.
Edited by: Thomas Zloch on Dec 9, 2011 4:17 PM

Hi All,
I was created program to generate Dynamic field catalog and internal table, here is confusion how to display below mentioned internal table data to final dynamic internal table based on document type headings
This is Statsic internal table Data
1 0000123  GBP  DA  S  6265.45
2 0000123  GBP  DA  H  240.51
3 0000123  GBP  DA  S  35.82
4 0000123  GBP  D1  H  281.85
5 0000123  GBP  D1  S  23.41
6 0000123  GBP  D1  S  34.23
7 0000123  GBP  RV  H  97.02
8 0000123  GBP  RV  S  52.90
9 0000123  GBP  RV  S  148.31
Can anybody suggest me how to populate the amount based on Document type and posting (credit or debit)
For Example
CUST DAC       DAD         D1C       D1D     RVC     RVD
123                  6265.45   240.51
                        35.82
Thanks in Advance
Sekhar
Moderator message: please do not open multiple threads for the same or similar issue.
Edited by: Thomas Zloch on Dec 9, 2011 4:17 PM

Similar Messages

  • Dynamic Internal Table - data type changed automatically

    Dear All,
    I have a requirement of craetion of dynamic inetrnal table which I have created referring to a custom table .
    In that custom table there is field ZDC002 of type DEC(16,7) which is converted to data type P(9,7) .
    Now it works fine if 2 digit and 7 decimals  value passed like 12.1234567 but it gives overflow error when passing more than 2 digit value .
    Please help me as I have no control to SAP standard functinality while creation of data-type . My piece of code :
    ref_table_des ?=
          cl_abap_typedescr=>describe_by_name( 'ZBW_EE_DCONTR' ).
          idetails[] = ref_table_des->components[].
    In this idetails[] table filedname data type changed from DEC16,7 to data type P(9,7). => Total Length of Packed Data Type is 9 which allows to contain only 2 numericdigits and 7 decimals => puts overflow error if more than 2 numeric data passed.
    Any suggestions will be appreciated.
    Thanks,
    Sachin

    Did you try to view the code on the Data Source view and cube that it is reflecting the correct data type on both places? if not you can change there and save it.
    prajwal kumar potula

  • How to Copy data from field symbol to Dynamic Internal Table

    Hi,
    I want to copy the data between two dynamic Internal tables . Following is the code were I have data in the field symbol wanted to transfer it to the other Internal table :
    REPORT  ztest.
    DATA:
           gd_dref          TYPE REF TO data,
           gd_dref1          TYPE REF TO data.
    FIELD-SYMBOLS:  <fs1>   TYPE any,
                               <fs_wa> TYPE any,
                                <field>    TYPE any,                  
                                <fs_wa1> TYPE ANY TABLE.  * Contains data from p_src
    *Copy data from p_src to p_dest*
    PARAMETERS: p_src LIKE dd02l-tabname .    * Name of Dynamic Internal table *
                             p_dest LIKE dd02l-tabname .  * Name of Dynamic Internal table*
    *DATA : lt_csks LIKE p_dest WITH HEADER LINE.
    START-OF-SELECTION.
      CREATE DATA gd_dref TYPE (p_src).
      CREATE DATA gd_dref1 TYPE TABLE OF (p_src).
       ASSIGN gd_dref->* TO <fs_wa>.
       ASSIGN gd_dref1->* TO <fs_wa1>.
       SELECT * FROM (p_src) INTO TABLE <fs_wa1>.
    *Write out data from FIELD SYMBOLS TO Table.
       loop at <fs_wa1> into <fs_wa>.
         do.
           assign component  sy-index
              of structure <fs_wa> to <field>.
           if sy-subrc <> 0.
           exit.
           endif.
           if sy-index = 1.
             write:/ <field>.
           else.
           write: / <field>.
           endif.
         enddo.
       endloop.
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    *p_dest is a table having a similar structure to table p_src .
    *Need Logic To Copy the Data to p_dest table from <fs_wa1>.
    EXIT.
    Thanks in Advance.

    try this...
    I have extended your source code and just used vbak/vbap as an example as they have some common fields like vbeln/erdat etc which corresponds with your requirement of 'similar structure' i.e. shared/common fields in both.
    Cheers...
    report  ztest.
    data:
      gd_dref type ref to data,
      gd_dref1 type ref to data,
      gd_dref_str type ref to data,
      gd_dref_tab type ref to data.
    field-symbols:
      <fs1> type any,
      <fs_wa> type any,
      <fs1_dest_str> type any,
      <fs_dest_tab> type any table,
      <field> type any,
      <fs_wa1> type any table.
    * contains data from p_src
    *Copy data from p_src to p_dest*
    parameters: p_src like dd02l-tabname default 'vbak',
    * name of dynamic internal table *
                p_dest like dd02l-tabname default 'vbap'.
    * name of dynamic internal table*
    *data : lt_csks like p_dest with header line.
    start-of-selection.
      create data gd_dref type (p_src).
      create data gd_dref1 type table of (p_src).
      assign gd_dref->* to <fs_wa>.
      assign gd_dref1->* to <fs_wa1>.
      select * from (p_src) into corresponding fields of table <fs_wa1>
      up to 3 rows
      where vbeln ne space.
      create data gd_dref_str type (p_dest).
      create data gd_dref_tab type standard table of (p_dest).
      assign gd_dref_str->* to <fs1_dest_str>.
      assign gd_dref_tab->* to <fs_dest_tab>.
    *write out data from field symbols to table.
      loop at <fs_wa1> into <fs_wa>.
        " break-point here - can see vbeln/waers/create date/ etc move over to new structure
        " the 'common' fields of your structures - the same will happen. if they not the same name you will have to do an
        " explicit move i.e. if fieldname = xyz ....move fieldxyz to new field123....after the move-corre
        break-point.
        move-corresponding <fs_wa> to <fs1_dest_str>.
        insert <fs1_dest_str> into table <fs_dest_tab>.
    **    do.
    **      assign component  sy-index
    **         of structure <fs_wa> to <field>.
    **      if sy-subrc <> 0.
    **        exit.
    **      endif.
    **      if sy-index = 1.
    **        write:/ <field>.
    **      else.
    **        write: / <field>.
    **      endif.
    **    enddo.
      endloop.
      " write out some dest data from the dest table build from previous loop
      loop at <fs_dest_tab> assigning <fs1_dest_str>.
        do.
          assign component sy-index of structure <fs_wa> to <field>.
          if sy-subrc <> 0.
            exit.
          endif.
          if sy-index = 1.
            write:/ <field>.
          else.
            write: / <field>.
          endif.
        enddo.
      endloop.

  • Need information on Dynamic internal table

    Hi All,
    I need some information on dynamic internal table.
    I want what are the field names and the values in dynamic internal table.
    Is there any function module, which tells us the field names and values of corresponding fields from a dynamic internal table ?
    Thank you very much in advance.

    Hi,
    Program to display/edit database tables dynamically.
    REPORT  zdyn_table_display.
    PARAMETERS: p_table TYPE tabname OBLIGATORY,
                p_rows  TYPE I.
    * Creation of dynamic internal table
    DATA: lv_dref             TYPE REF TO data.
    FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE.
    DATA: lv_table  TYPE  string.
    START-OF-SELECTION.
    * Dynamic internal table.
      CREATE DATA lv_dref       TYPE TABLE OF (p_table).
      ASSIGN lv_dref->* TO <fs_table>.
      IF sy-subrc  EQ 0.
    *    EXIT.
      ENDIF.
    data i type i.
    * Get the data
      SELECT  *
            FROM (p_table)
            UP TO p_rows ROWS
            INTO TABLE <fs_table>.
      CONCATENATE 'Table contents : ' p_table INTO lv_table.
    * display the table control.
      CALL FUNCTION 'STC1_FULLSCREEN_TABLE_CONTROL'
        EXPORTING
          header            = lv_table
          tabname           = p_table
          no_button         = space
        TABLES
          table             = <fs_table>
        EXCEPTIONS
          no_more_tables    = 1
          too_many_fields   = 2
          nametab_not_valid = 3
          handle_not_valid  = 4
          OTHERS            = 5.
      IF sy-subrc  EQ 0.
        EXIT.
      ENDIF.
    Getting internal table definition 
    Try this...
    DATA : l_descr_ref TYPE REF TO cl_abap_structdescr.
    l_descr_ref ?= cl_abap_typedescr=>describe_by_data( itab ).
    Now l_descr_ref->components holds the entire list of fields in itab.
    Thanks & Regards,
    ShreeMohan

  • Dynamic Internal table values read and assign it back

    Hi All,
            I want to get the internal table field name dynamically and fetch its value and do some calculation and asign the new value to the same field name.
           CONCATENATE '<WA_PIPE>-ZW' v_index INTO v_fld.
            CONDENSE v_fld NO-GAPS.
            FIELD-SYMBOLS <fs> TYPE ANY.
            ASSIGN (v_fld) TO <fs>.
            v_fld1 = <fs> * <wa_pipe>-zrate.
    Now i've the internal table field name as <WA_PIPE>-ZW1 in v_fld and v_fld1 is having the value of the same field.
    How to assign it to the internal table field.
    Thanks.
    Ashok

    *& Report  YY_TEST1
    REPORT  YY_TEST1.
    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.
    *Form build_report
    form build_report.
    *Fill some values into the dynamic internal table
    data: fieldname(20) type c.
    data: fieldvalue(5) type c.
    data: index(3) type c.
    field-symbols: <fs1>.
    do p_flds times.
    index = sy-index.
    *Set up fieldvalue
    concatenate 'FLD' index into
    fieldvalue.
    condense fieldvalue no-gaps.
    assign component index of structure <dyn_wa> to <fs1>.
    <fs1> = fieldvalue.
    enddo.
    *Append to the dynamic internal table
    append <dyn_wa> to <dyn_table>.
    endform.
    *CALL_ALV
    form call_alv.
    *Build FC for ALV
    loop at it_fldcat into wa_fldcat.
    wa_alvfc-fieldname = wa_fldcat-fieldname.
    wa_alvfc-seltext_s = sy-tabix.
    wa_alvfc-outputlen = wa_fldcat-intlen.
    append wa_alvfc to it_alvfc.
    endloop.
    *Call ABAP List Viewer (ALV)
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    it_fieldcat = it_alvfc
    tables
    t_outtab = <dyn_table>.
    endform.

  • How to add new field into dynamic internal table

    Hello Expert.
    how to add new field into dynamic internal table.
    PARAMETERS: P_TABLE(30).    "table name
    DATA: I_TAB TYPE REF TO DATA.
    FIELD-SYMBOLS: <TAB> TYPE standard TABLE.
    *Create dynamic FS
    create DATA I_TAB TYPE TABLE OF (p_table).
      ASSIGN I_TAB->* TO <TAB>.
    SELECT * FROM (p_table) INTO TABLE <TAB>.
       here i want to add one more field into <TAB> at LAST position and my 
       Field name  =  field_stype     and
       Field type    =  'LVC_T_STYL'
    could you please helpme out .

    Hi,
    Please find the code below.You can add the field acc to your requirement.
    Creating Dynamic internal table
    TYPE-POOLS: slis.
    FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE,  u201C Dynamic internal table name
                   <fs_dyntable>,                     u201C Field symbol to create work area
                   <fs_fldval> type any.              u201C Field symbol to assign values 
    PARAMETERS: p_cols(5) TYPE c.                     u201C Input number of columns
    DATA:   t_newtable TYPE REF TO data,
            t_newline  TYPE REF TO data,
            t_fldcat   TYPE slis_t_fldcat_alv,
            t_fldcat   TYPE lvc_t_fcat,
            wa_it_fldcat TYPE lvc_s_fcat,
            wa_colno(2) TYPE n,
            wa_flname(5) TYPE c. 
    Create fields .
      DO p_cols TIMES.
        CLEAR wa_it_fldcat.
        move sy-index to wa_colno.
        concatenate 'COL'
                    wa_colno
               into wa_flname.
        wa_it_fldcat-fieldname = wa_flname.
        wa_it_fldcat-datatype = 'CHAR'.
        wa_it_fldcat-intlen = 10.
        APPEND wa_it_fldcat TO t_fldcat.
      ENDDO. 
    Create dynamic internal table and assign to FS
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = t_fldcat
        IMPORTING
          ep_table        = t_newtable. 
      ASSIGN t_newtable->* TO <t_dyntable>. 
    Create dynamic work area and assign to FS
      CREATE DATA t_newline LIKE LINE OF <t_dyntable>.
      ASSIGN t_newline->* TO <fs_dyntable>.
    Populating Dynamic internal table 
      DATA: fieldname(20) TYPE c.
      DATA: fieldvalue(10) TYPE c.
      DATA: index(3) TYPE c. 
      DO p_cols TIMES. 
        index = sy-index.
        MOVE sy-index TO wa_colno.
        CONCATENATE 'COL'
                    wa_colno
               INTO wa_flname. 
    Set up fieldvalue
        CONCATENATE 'VALUE' index INTO
                    fieldvalue.
        CONDENSE    fieldvalue NO-GAPS. 
        ASSIGN COMPONENT  wa_flname
            OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
        <fs_fldval> =  fieldvalue. 
      ENDDO. 
    Append to the dynamic internal table
      APPEND <fs_dyntable> TO <t_dyntable>.
    Displaying dynamic internal table using Grid. 
    DATA: wa_cat LIKE LINE OF fs_fldcat. 
      DO p_cols TIMES.
        CLEAR wa_cat.
        MOVE sy-index TO wa_colno.
        CONCATENATE 'COL'
                    wa_colno
               INTO wa_flname. 
        wa_cat-fieldname = wa_flname.
        wa_cat-seltext_s = wa_flname.
        wa_cat-outputlen = '10'.
        APPEND wa_cat TO fs_fldcat.
      ENDDO. 
    Call ABAP List Viewer (ALV)
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          it_fieldcat = fs_fldcat
        TABLES
          t_outtab    = <t_dyntable>.

  • 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 populate data in dynamic internal table

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

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

  • How to delete data from dynamic internal table

    Hi,
    I have dynamic internal table and I have some slection screen fields , using these selection screen fields
    (select -options), I have to filter the data? assigning will work with READ , but I have select options not the parametre,
    and also delete will not work for dynamic table..
    as we cannot use assigning with delete..
    So how to do this?
    and one more thing is , I cannot filter the data while selection( in select, I cannot filter the data-> as it's not coming directly from table, it's coming from buffer),
    so now after selection of data, I need to filter the data from dynamic table.
    Is there any way to do this?
    Regards,
    Mrunal

    Hi matt,
    I tried with below code as  you said. But I am getting dump. can you help?
    here is my piece of code.
    FIELD-SYMBOLS: <LS_DATA> type any,
                               <LT_DATA> TYPE table,
                                <L_FIELD> type any.
        ASSIGN <l_buffer_entry>-dataptr->* TO <LS_DATA>.
        ASSIGN <l_buffer_entry>-dataptr->* TO <LT_DATA>.
    LOOP AT <LT_DATA> ASSIGNING <LS_DATA>.
    ASSIGN COMPONENT 'BUKRS' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
    IF <L_FIELD> NOT IN SO_BUKRS.
    DELETE <LT_DATA>.
    ENDIF.
    UNASSIGN <L_FIELD>.
    ASSIGN COMPONENT 'BELNR' OF STRUCTURE <LS_DATA> TO <L_FIELD>.
    IF <L_FIELD> NOT IN SO_BELNR.
    DELETE <LT_DATA>.
    ENDIF.
    UNASSIGN <L_FIELD>.
    ENDLOOP.
    and here is the description of my dump:->>>
    You attempted to access an unassigned field symbol
    (data segment 32772).
    This error may occur for any of the following reasons:
    - You address a typed field symbol before it is set using ASSIGN
    - You address a field symbol that points to a line in an internal table
      that has been deleted
    - You address a field symbol that had previously been reset using
      UNASSIGN, or that pointed to a local field that no longer exists
    - You address a global function interface parameter, even
      though the relevant function module is not active,
      that is it is not in the list of active calls. You can get the list
      of active calls from the this short dump.

  • How to transfer data from a dynamic internal table

    Hi All
    I want to transfer data from a dynamic internal table<dyn_table>
    to a non dynamic internal table itab which should have the same structure as <dyn_table>.
    How can this be done?
    Regards,
    Harshit Rungta

    As stated earlier this can be done only through field symbols...
    You cannot create an non dynamic internal table with ANY structure...using DATA statement
    If the strucutre is defined well and good...you can create an non-dynamic internal table...
    If you do not know the structure then the internal table has to be dynamic...and to be generated using field symbols
    DATA: lv_ref TYPE REF TO data.
    FIELD-SYMBOLS: <fs_dyn_table> TYPE STANDARD TABLE.
    * You create a dynamic internal table...
    CREATE DATA lv_ref LIKE (your_dynamic_internal_table).
    ASSIGN lv_ref->* TO <fs_dyn_table>.
    Now...do the transfer.
    <fs_dyn_table> = "your_dynamic_internal_Table
    Hope it helps!

  • How to populate dynamic internal table fields with data??

    Hi Folks,
    How to assign a particular internal table field to a dynamically assigned internal table?
    I have an excel sheet, and i upload the excel sheet data into an internal IT_EXLOAD table using FM ALSM_EXCEL_TO_INTERNAL_TABLE
    Now i created a dynamic internal table which has the same column as in my DB table.
    I have to fill the dynamically created Internal table with the IT_EXLOAD data dynamically.
    Suppose in future if i add some field in DB table and for that field if i add some column in excel sheet there is no need to change in the program.
    Looking for reply...
    Best Regards,
    Sayak

    hi,
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
           EXPORTING
                filename                = p_path
                i_begin_col             = '1'
                i_begin_row             = '2'
                i_end_col               = '2'
                i_end_row               = '1000'
           TABLES
                intern                  = intern
           EXCEPTIONS
                inconsistent_parameters = 1
                upload_ole              = 2
                OTHERS                  = 3.
    *declare intern_tmp as internal table tb_data in wich you want the data
    *and declare a field symbol <fs_123>
    LOOP AT intern.
        ASSIGN COMPONENT intern-col OF STRUCTURE
        intern_tmp TO <fs_123>.
        IF NOT <fs_123> IS ASSIGNED.
          CLEAR intern.
          CLEAR intern_tmp.
          CONTINUE.
        ENDIF.
        <fs_123> = intern-value.
        AT END OF row.
          CLEAR tb_data.
          MOVE-CORRESPONDING: intern_tmp TO tb_data.
          APPEND tb_data.
          CLEAR intern_tmp.
        ENDAT.
        CLEAR intern.
      ENDLOOP.
    **paste this code and you can see the data in ur tables dynamically.
    Thanks
    Nitin Sachdeva

  • To populate data in a dynamic internal table

    Hi,
    I have an internal table <FS_1> which I have created dynamically. Now i need to populate the columns (7th column onwards) in the internal table with my data in GT_REQMT which is an internal table.
    Data: L_IDX type I.
    L_IDX = 6.
    Loop at <FS_1> assigning <FS_2>.
      If sy-tabix = 1.
        Loop at GT_REQMT.
         Add 1 to L_IDX.
    *****I need to populate GT_REQMT-DATA to column 7 then 8 etc depending on the number of loops.
         Modify <FS_1> from <FS_2>.
        Endloop.
      Else.
    **do other things here**
      Endif.
    Endloop.
    I have search through the forums and weblogs but the solutions are catered to populating the internal tables from SAP database using SQL statements.
    I couldn't find anything on populating own data in dynamic table by looping it. Please help. THANKS!!
    Cheers,
    Chelsea

    Hi!
    I have used classes for dynamic internal table, SO i here give you my sample code for your help.
    DATA : new_table TYPE REF TO data,
           new_line  TYPE REF TO data.
    FIELD-SYMBOLS : <TAB1> type standard table,
                    <l_table> TYPE ANY TABLE,
                    <l_line>  TYPE ANY,
                    <l_field> TYPE ANY.
        count = count + 1.
        clear wa_fieldcat.
        wa_fieldcat-col_pos   = count.
        wa_fieldcat-fieldname = 'CONDITION'.
        wa_fieldcat-coltext   = 'Condition Value'.
        wa_fieldcat-ref_field = 'KWERT'.
        wa_fieldcat-ref_table = 'KONV'.
        wa_fieldcat-outputlen = 13.
        append wa_fieldcat to it_fieldcat.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
       EXPORTING
         it_fieldcatalog = it_fieldcat
       IMPORTING
         ep_table        = new_table.
    ASSIGN new_table->* TO <l_table>.
    CREATE DATA new_line LIKE LINE OF <l_table>.
    ASSIGN new_line->* TO <l_line>.
    ASSIGN COMPONENT KWERT OF STRUCTURE <l_line> TO <l_field>.
    <l_field> = t_kschlkonv-vtext.
    NOw u append internal table
    IF its helps you then dont forget to rewards points.
    Regards From
    Priyank

  • How to pass data from dynamic internal table to standard internal table

    hi experts,
    below is the piece of code which i have used in my requirement but the data is not moved.
    LOOP AT <tab> ASSIGNING <tab1>.
      MOVE-CORRESPONDING <tab1> TO wa.
      append wa TO  gt_outtab.
    ENDLOOP.
    here
    <tab> - dynamic internal table.
    <tab1>-dynamic internal table work area.
    gt_outtab - standard internal table.
    wa- standard internal table work area.
    i am not getting what additional thing i have to write.
    pls help me in this regard.
    thankx in advance.
    soham.p.

    Hello soham p ,
    I am also using the same logic but in my program it is working fine so you declare the fieldsymols like this and try and also check the dynamic internal contain the data or not.
    FIELD-SYMBOLS : <y_i_table>  TYPE STANDARD TABLE,
                                 <y_wa_table> TYPE ANY.
      LOOP AT <y_i_table> ASSIGNING <y_wa_table>.
        MOVE-CORRESPONDING <y_wa_table> TO y_wa_vfscaid.
        APPEND y_wa_vfscaid TO y_i_vfscaid.
        CLEAR y_wa_vfscaid.
      ENDLOOP.

  • 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

  • How to upload data with dynamic internal table

    Hi,
    I have to upload the basic , sales, purchasing view data by using bapi depend on check box selected for views.
    i have filled fieldcatalog for selected views and pass the field catalog structure to dynamic int table and
    import it into the field symbol <fs_data>. this field symbol assigned to <fs_1>.
    then callED the 'GUI_UPLOAD '  and  when i pass field symbo for function module i am getting first 10 rows 0f the file .
    flat file has basic data,sales ,purchase fields data
    ex: i was selected basicview and purchase view and execute i am getting basic,sales view data.
    how can i get only basic and purchase data.

    hi ,
    please find code.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog           = lt_fieldcatalog
        IMPORTING
          ep_table                  = <fs_data>
        EXCEPTIONS
          generate_subpool_dir_full = 1
          OTHERS                    = 2.
      IF sy-subrc <> 0.                                         "#EC NEEDED
      ENDIF.
    So <FS_1> now points to our dynamic internal table.
      ASSIGN <fs_data>->* TO <fs_1>.
    Next step is to create a work area for our dynamic internal table.
      CREATE DATA new_line LIKE LINE OF <fs_1>.
    A field-symbol to access that work area
      ASSIGN new_line->*  TO <fs_2>.
      ASSIGN new_line->*  TO <fs_3>.
    CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = p_f
          filetype                = 'DAT'
        TABLES
          data_tab                = <fs_1>
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

Maybe you are looking for

  • PLEASE   CAN SOMEOME HELP ME INSTALL THIS PROGRAM????

    PLease  can someone help me install this program??  I am not computer literate.

  • Problem in merging two files using BPM

    Hello Frens, I am doing a scenario for merging of two files N:1 using BPMu2026 I have to merge two files into one file. The two input files are as below : File1 : Id, Name, Age, Place File2 : ID, Street, Adrress And output File is : ID, Name, Age,pla

  • Uix BC4J: create a link download to download my resultsets

    Greetings, The case: - i've created my flows using the amazing uix bc4j technology; - end users can manipulate their data (view and update) - Now i'd like to create a link which will point over the query result and download the data with csv or xls f

  • OBE: Portal 10.1.2 Building Portlets Declaratively - web service errors

    Note: I found a similiar post from mid-2006 which had no solution reported. I hope my question gets a response more quickly. "Creating a Portlet Using a Web Service as a Data Source" Step 9: WSDL URL: http://webservices.oracle.com/ws/emp/oracle.ws.sc

  • Publishing website with flash - size

    hello, I would like to know how I can publish my wesbite with a bit of flash in on a host without the flv files, hence with only the swf files. for some reason when I put my flv files external to my website folder, the videos dont play anymore in dre