Dynamic access to work area fields

Hi
I've got a DataBase table with 20 fields with different names.
field1
field2
field3.
field20
I'm using a work area to read values and i wanna read an specific field of this work area.
The problem is the following:
I don't know the name of the field i need to access, instead, i have it in a field symbol.
Is there any way i can get the value of this field???

Hi,
Try the following example
  DATA: i_TAB           LIKE PA0001 OCCURS 0 WITH HEADER LINE,
        l_field(50)     TYPE C,
        l_fieldname(50) TYPE C VALUE 'UNAME'.
  FIELD-SYMBOLS: <fieldxx> TYPE ANY,
                 <valxx>   TYPE ANY.
  ASSIGN l_fieldname TO <fieldxx>.
  SELECT * FROM PA0001 INTO TABLE I_TAB.
  LOOP AT I_TAB.
    CONCATENATE 'I_TAB-' <fieldxx> INTO l_field.
    ASSIGN (l_field) TO <valxx>.
    WRITE <valxx>.
  ENDLOOP.

Similar Messages

  • Dynamic Work Area - fields

    HI SDN COMMUNITY..!!
    I HAVE TO USE THE WA_SEKPO-FIELDNAME DYNAMICALLY..
    DATA: BEGIN OF WA_SEKPO,
          EBELN TYPE EBELN,
          BRTWR TYPE BRTWR,
          EFFWR TYPE EFFWR,
          MENGE TYPE MENGE,
          END OF WA_SEKPO.
    DATA: SEKPO LIKE TABLE OF WA_SEKPO.
    DATA: VAR_FNAME TYPE STRING.
    FIELD-SYMBOLS: <FS> TYPE ANY.
    STRUCTURE OF <b>EDITPOS</b>(INTERNAL TABLE)
    |OBJECTID   |TABNAME|FNAME  |   F_NEW    |    F_OLD
    |4500016340 |EKPO   |BRTWR  |       26   |    11
    |4500016340 |EKPO   |EFFWR  |       25   |    12
    |4500016340 |EKPO   |MENGE  |       22   |    13
    INTERNAL TABLE :
    <b>EDITPOS</b> CONTAINS VALUES FOR : BRTWR
                                  EFFWR 
                                  MENGE
    IT MAY CONTAIN VALUES FOR MORE FIELDS.
    NOW PROBLEM IS
    I HAVE TO UPDATE MY INTERNAL TABLE : SEKPO
    FOR FIELDNAMES : BRTWR
                     EFFWR
                     MENGE
    BUT I DONT HAVE TO HARD CODE IT FOR EACH FIELD.
    PLEASE CHECK, HOW THIS CAN BE ACHIVED?
    WA_SEKPO-BRTWR = WA_EDITPOS-F_NEW.
    PLEASE UPDATE THE CODE:
    LOOP AT EDITPOS INTO WA_EDITPOS.
               ASSIGN WA_EDITPOS-FNAME TO <FS>.
               CONCATENATE 'WA_SEKPO-' <FS> INTO VAR_FNAME.
               WA_SEKPO-(<FS>)  = WA_EDITPOS-F_NEW.
    *       MODIFY TABLE SEKPO FROM WA_SEKPO
    *          TRANSPORTING <FS>.
    ENDLOOP.
    HELP WILL BE APPRICIATED
    THANKS IN ADVANCE
    VIJAY RAHEJA

    HI
    STRUCTURE OF EDITPOS(INTERNAL TABLE)
    |OBJECTID |TABNAME|FNAME | F_NEW | F_OLD
    |4500016340 |EKPO |BRTWR | 26 | 11
    |4500016340 |EKPO |EFFWR | 25 | 12
    |4500016340 |EKPO |MENGE | 22 | 13
    LOOP AT EDITPOS INTO WA_EDITPOS.
    IF WA_EDITPOS = 'BRTWR'.
      WA_SEKPO-BRTWR = WA_EDITPOS-F_NEW.
      MODIFY TABLE SEKPO FROM WA_SEKPO
      TRANSPORTING BRTWR.
    ELSEIF WA_EDITPOS = 'EFFWR'.
      WA_SEKPO-EFFWR = WA_EDITPOS-F_NEW.
      MODIFY TABLE SEKPO FROM WA_SEKPO
      TRANSPORTING EFFWR.
    ELSEIF WA_EDITPOS = 'MENGE'.
      WA_SEKPO-EFFWR = WA_EDITPOS-F_NEW.
      MODIFY TABLE SEKPO FROM WA_SEKPO
      TRANSPORTING MENGE.
    ENDIF.
    ENDLOOP.
    I AM TRYING TO ACHIEVE THE ABOVE FUNCTIONALITY DYNAMICALLY,
    AS I AM UNAWARE OF ENTRIES IN Internal Table: EDITPOS.
    It contains values:  BRTWR/EFFWR/MENGE
    But it may contain more,SO i cannot straight away HARD code it for modifying entries in SEKPO.
    for which i have written the code:
    LOOP AT EDITPOS INTO WA_EDITPOS.
    ASSIGN WA_EDITPOS-FNAME TO <FS>.
    CONCATENATE 'WA_SEKPO-' <FS> INTO VAR_FNAME.
    WA_SEKPO-<FS> = WA_EDITPOS-F_NEW.
    MODIFY TABLE SEKPO FROM WA_SEKPO
    TRANSPORTING <FS>.
    ENDLOOP.
    But there it shown Error before Activating the code: that <fs> is not a component of work area wa_sekpo
    WA_SEKPO-<FS>
    that is the problem,How to assign fieldname to a work area Dynamically.
    Regards,
    Vijay Raheja

  • Work area field value not getting populated in table control grid.

    Hi all,
    I am currently facing an issue where I have declared a variable and have fetched the workarea field name in it. To be exact, the variable contains the workarea name whose value I am finally populating to the table control. Now although the workarea name when manually copied and pasted in field name in debugging mode exhibits the value of the it, Im unable to fetch the same value in the variable as I have only the work area name in it. I need the value of the workarea-field to be in the variable.Please provide your valuable suggestions for this issue...
    Regards,
    Edited by: Vishwanath Sreedharen on Jan 2, 2012 3:25 PM

    Hi Nabheet,
    Please consider the below example...
    DATA: l_var(30) TYPE C.
    CONCATENATE 'wa' '-' I_FIELD2-NAME INTO l_var.
    The i_field2-name contains the name of a custom table field CP_CUSTOM_GRP. So now the l_var contains wa_cp_custom_grp.
    Now consider the wa_cp_custom_grp has a value 'BA'.
    Now my issue is the l_var contains wa_cp_custom_grp but not its value(too obvious)... Would like to know whether is there a way through which the value of this wa_cp_custom_grp  'BA' could be populated to the variable l_var...

  • Code to equate table value to work area field name

    Hello Experts,
    How to match a certain value fetched from table to the internal table field.
    For instance: transparent table has a column containing values as
    AMOUNT
    QUANTITY
    there is another work area structure associated with different internal table consisting of amount and quantity fields.
    Now depending on whether the record from transparent table has fetched AMOUNT or QUANTITY, i have to read either the amount or quantity value from the work area.
    Can any one please suggest a technique to do it?
    Thanks,
    Pankaj

    Hi
    Try This:
    suppose you have zitab table as trans. Table and another table itab1 with work area wa.
    First you need to select values from Zitab to an internal table say itab.
    sort itab by <field name>
    loop at itab.
    read table itab1 into wa with key quantity = itab-quantity
                                      amount = itab-amount.
    endloop.
    This will read table itab1 where quantity and amount from itab table matches.
    hope this will work for you.
    thanks
    Lalit Gupta

  • Dynamic read from work area

    Hello, me again ...
    I have a work area declared like this:
    data: begin of wa,
              fld1  type c,
              fld2  type c,
              fld3  type c,
            end of wa.
    I want to check a different field's value at each iteration, meaning somthing like this:
    concatenate 'fld' sy-tabix into var.
    if wa-var eq ......
    I know it's possible by using field-symbols, does anyone can write me the specific syntax pls ?
    Thanks in advance,
    Rebeka.

    field-symbols: <fs>.
    data: var(20) type c.
    data: tabix(4) type c.
    tabix = sy-tabix.
       concatenate 'FLD' tabix into var.
       condense var no-gaps.
    assign component var of structure wa to <fs>.
    if <fs> = 'X'.
    endif.
    Regards,
    Rich Heilman

  • Dynamic Work Area Field name Assignment.

    hi Guru,
      data: it_SFLIGHT type TABLE OF SFLIGHT,
              wa_SFLIGHT TYPE SFLIGHT,
              lv_field TYPE string.
      lv_field =     'CARRID'.   " Field name
        wa_SFLIGHT-<lv_field> = 'vivek'.  " Assigning Value to workarea.
    When i try this i am getting the error.
    Regards.
    Vivekananthan.S

    Hi,
    assign (p_tc_name) to <tc>.
    TYPES:
      BEGIN OF st_mytable,
        name1 TYPE string,
        name2 TYPE string,
        age TYPE i,
      END OF st_mytable.
    DATA:
      gi_mytable TYPE STANDARD TABLE OF st_mytable,
      g_mytable  TYPE st_mytable.
    * Define field symbols
    FIELD-SYMBOLS:
      <myfield1> TYPE ANY,
      <myfield2> TYPE ANY,
      <myfield3> TYPE ANY,
      <myline>  TYPE ANY.
    * Fill table with data
    g_mytable-name1 = 'John'.
    g_mytable-name2 = 'Johnson'.
    g_mytable-age   = 25.
    APPEND g_mytable TO gi_mytable.
    g_mytable-name1 = 'Claudio'.
    g_mytable-name2 = 'Jensen'.
    g_mytable-age   =  45.
    APPEND g_mytable TO gi_mytable.
    * The normal way to do it
    LOOP AT gi_mytable INTO g_mytable.
      WRITE: / g_mytable-name1, g_mytable-name2 ,g_mytable-age.
    ENDLOOP.
    SKIP 2.
    * Do it with field symbols
    LOOP AT gi_mytable ASSIGNING <myline>.
      ASSIGN COMPONENT 1 OF STRUCTURE <myline> TO <myfield1>.
      ASSIGN COMPONENT 2 OF STRUCTURE <myline> TO <myfield2>.
      ASSIGN component 3 OF STRUCTURE <myline> TO <myfield3>.
      WRITE: / <myfield1>,<myfield2>,<myfield3>.
    ENDLOOP.
    * Unassign field symbols
    UNASSIGN <myfield1>.
    UNASSIGN <myfield2>.
    UNASSIGN <myfield3>.
    UNASSIGN <myline>.
    Regards,
    Prabhudas

  • How to fill Dynamic work area or field symbol?

    HI All,
    I have created dynamic work area(field symbol) by using following code. Now I want to fill the work area with values which are there in other internal table.
    * Create dynamic internal table/structure
      call method cl_alv_table_create=>create_dynamic_table
        exporting
          it_fieldcatalog = it_fieldcat
        importing
          ep_table        = dyn_table.
      assign dyn_table->* to <fs_table>.
    * Create dynamic work area and assign to Field Symbol
      create data dyn_line like line of <fs_table>.
      assign dyn_line->* to <fs_wa>.
    My <FS_WA> contains:
    ROW1
    ROW2
    ROW3
    ROW4 as fields in it without having any data.
    I have other internal table.. where I have FIELDS and Data like following:
    FIELD1  FIELD2   FIELD3
    ID1 ROW1 A1
    ID1 ROW2 A2
    ID1 ROW3 A3
    ID1 ROW4 A4
    ID2 ROW1 B1
    ID2 ROW2 B2
    ID2 ROW3 B3
    ID3 ROW1 C4
    Important thing that I have to share with you is... Source table of my Internal table and Source structure to create my dynamic table are same.
    This dynamic table has fields... with "FIELD2" values.
    Thanks,
    Naveen.I

    Create a dynamic internal table
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = lt_fcat
        IMPORTING
          ep_table        = lt_dy_table.
    Create dynamic work area and assign to FS
      ASSIGN lt_dy_table->* TO <fs_dyn_table>.
      CREATE DATA lt_dy_line LIKE LINE OF <fs_dyn_table>.
      ASSIGN lt_dy_line->* TO <fs_dyn_wa>.
    Define WA
      CREATE DATA dref TYPE (iv_struc_name).
      ASSIGN dref->* TO <fs_final>.
    Populate dynamic table from the file
      OPEN DATASET iv_path FOR INPUT IN TEXT MODE ENCODING DEFAULT.
      IF sy-subrc = 0.
        DO.
          READ DATASET iv_path INTO ls_str.
          IF sy-subrc <> 0.
            ev_failed = abap_true.
            EXIT.
          ENDIF.
          SPLIT ls_str AT ';' INTO TABLE lt_dyn_tab.  " columns
          LOOP AT lt_dyn_tab INTO ls_dyn_tab.
            READ TABLE lt_struc_fld INTO ls_struc_fld INDEX sy-tabix.
            IF sy-subrc EQ 0.
              MOVE ls_struc_fld-fieldname TO ls_fieldname.
              ASSIGN COMPONENT ls_fieldname OF STRUCTURE <fs_dyn_wa> TO <fs_val>.
              IF sy-subrc = 0.
                <fs_val> = ls_dyn_tab.
              ENDIF.
              ASSIGN COMPONENT ls_fieldname OF STRUCTURE <fs_final> TO <fs_val>.
              IF sy-subrc = 0.
                <fs_val> = ls_dyn_tab.
              ENDIF.
            ENDIF.
          ENDLOOP.
          APPEND <fs_dyn_wa> TO <fs_dyn_table>.
          APPEND <fs_final> TO et_table.
          UNASSIGN: <fs_val>.
        ENDDO.
      ENDIF.
      CLOSE DATASET iv_path.

  • How to read data from dynamic work area.

    Hi guys,
                I have created dynamic table and work area for report.
    i have populated few values in dynamic work area.
    Now i want to read that data from work area again for calculation.
    i can not use local varialbes to store those values as i dont know how many such variables i need to read.
    that will be known only at run time.
    So as per my knowledge i have only 1 option...to read those all values from work area.
    Kindly help me .... how can i read data which is stored in dynamic work area.

    Hi Kiran,
    Following is not exact code, but exact solution to your problem:
      LOOP AT <dyn_table> ASSIGNING <dyn_wa>.
          l_tabix = sy-tabix.
          ASSIGN COMPONENT 'KOTAB' OF STRUCTURE <dyn_wa> TO <l_kotab>.
          IF <l_kotab> IS ASSIGNED AND <l_kotab> IS INITIAL.
            <l_kotab> = gt_tabs-kotab.
            MODIFY <dyn_table> FROM <dyn_wa> INDEX l_tabix.
          ENDIF.
        ENDLOOP.
    I am hardcoding KOTAB as I was sure about that being in the dynamic structure.
    You can loop on the field catalogue, which you used to create dyamic table,  to use the FIELDNAME to read all the fields of the work area (structure) of your dynamic table.
    thanks,
    Aabhas
    Edited by: Aabhas K Vishnoi on Sep 24, 2009 8:12 PM

  • Dynamic Type assignment to a Field symbol

    Hi All,
    I am using the below statement in one of my programs.
    ASSIGN COMPONENT 1 OF STRUCTURE <lfs_dyn_colwa> TO <lfs_dyn_field>.
    It works fine, but if the first field of structure <lfs_dyn_colwa> is a very large character field, only 29 characters are assigned to <lfs_dyn_field>. am I doing something wrong here.
    <lfs_dyn_field> is not assigned previously. The table <lfs_dyn_colwa> is a dynamic table with field names known only at run time.
    I tried a lot but could not find any solution.
    Any help is appreciated.
    Thanks,
    Mz

    Hi Rahul, Keshav
    Sorry if i didnt mention before. But i am using type any for both of my field symbols.
    In the middle of processing, i am creating a structure for <lfs_dyn_colwa> dynamically as a work area.
    I want to assign the first field of the work area to my second field symbol <lfs_dyn_field>.
    If first field of the work area is having a character size of more than 30, only the first 29 are getting copied to the field symbol <lfs_dyn_field>.
    First field of the table <lfs_dyn_colwa> is of type c10.
    second field of the table <lfs_dyn_colwa> is c160.
    the first field is copied alright.
    the second field is copied only upto the 29th character.
    Thanks for the prompt response.
    Mz

  • Internal table & Work area

    Hi Experts,
    I am a novice to ABAP. Can anyone tell me whats the difference b/w internal table and work area. In writing function modules how these will be utilized and in what way.
    Regards
    ss

    HI,
    Internal tables are a standard data type object which exists only during the runtime of the program. They are used to perform table calculations on subsets of database tables and for re-organising the contents of database tables according to users need.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb35de358411d1829f0000e829fbfe/content.htm
    Difference between Work Area and Header Line
    While adding or retrieving records to / from internal table we have to keep the record temporarily.
    The area where this record is kept is called as work area for the internal table.  The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
    Header line is a implicit work area for the internal table.  It depends on how the internal table is declared that the itab will have the header line or not.
    e.g.
    data: begin of itab occurs 10,
               ab type c,
               cd type i,
            end of itab.  " this table will have the header line.
    data: wa_itab like itab. " explicit work area for itab
    data: itab1 like itab occurs 10. " table is without header line.
    The header line is a field string with the same structure as a row of the body, but it can only hold a single row.
    It is a buffer used to hold each record before it is added or each record as it is retrieved from the internal table.  It is the default work area for the internal table
    1) The difference between
    whih header line and with out heater line of internal table.
    ex:-
    a) Data : itab like mara occurs 0 with header line.
    b) Data: itab like mara occurs 0.
    -While adding or retrieving records to / from internal table we have to keep the record temporarily.
    -The area where this record is kept is called as work area for the internal table.
    -The area must have the same structure as that of internal table. An internal table consists of a body and an optional header line.
    -Header line is a implicit work area for the internal table. It depends on how the internal table is declared that the itab will have the header line or not.
    a) Data : itab like mara occurs 0 with header line.
    table is with header line
    b) Data: itab like mara occurs 0.
    table is without header line
    2)work area / field string and internal table
    which one is prefarable for good performance any why ?
    -The header line is a field string with the same structure as a row of the body, but it can only hold a single row , whereas internal table can have more than one record.
    In short u can define a workarea of an internal table which means that area must have the same structure as that of internal table and can have one record only.
    Example code:
    data: begin of itab occurs 10,
    ab type c,
    cd type i,
    end of itab. " this table will have the header line.
    data: wa_itab like itab. " explicit work area for itab
    data: itab1 like itab occurs 10. " table is without header line.
    http://www.allsaplinks.com/faq_abap_internaltables.html
    Do reward if it helps,
    Regards,
    Laxmi

  • Work Area - Discussion not displayed in cFolders

    Hi All,
    We are creating Bid Invitationa and in that we have created Cfolder.
    we are facing issue with language specific cFolder access as discribe below;
    When we create Bid Invitation with EN language then he could able to see work area - Discussion ( This is we think custom work area called though RCF) but when we create this Bid Invitaion in Spanis language (ES) then we are not able to see this work area in cFolder screen.
    Any idea how to maintain access to work area for language specific. Also I am interested to know how these custom work areas been called thorugh RFC- can we check in some Badi or any FM?
    Please provide valuable inputs,
    Thanks

    not yet resolved

  • Read dynamic field symbol Work Area before append to dynamic table

    Hi experts:
    I have a dynamic work area but before doing an append to the dynamic table, I need to do some validation on some fields of the work area in order to decide to append it or not, but I don't know how...
    More or less this is the example
    loop at so_kschl.
        field = so_kschl-low.
        if <t_dyntable>-field = 0. "if the value of this field in dinamic table is 0.
    don't append
        else.
           APPEND <fs_dyntable> TO <t_dyntable>.  
        endif.
    endloop.
    Thank you very much for your help.
    Miriam

    Check this example, you read the component of the dynamic work area and assign it to a field-symbols. In this case, I validate that the entry is always 'a'.
    DATA: i_lvc TYPE lvc_t_fcat WITH HEADER LINE,
          i_table TYPE REF TO data,
          l_style TYPE lvc_fname,
          l_warea TYPE REF TO data,
          l_name(7) VALUE 'VARCHAR'..
    FIELD-SYMBOLS: <fs> TYPE table,
                  <fs2> TYPE ANY,
                  <fs3> TYPE ANY.
    PARAMETERS p_char TYPE c LOWER CASE.
    START-OF-SELECTION.
      i_lvc-fieldname = 'Varchar'.
      i_lvc-inttype = 'C'.
      i_lvc-intlen = 1.
      APPEND i_lvc.
      CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
      it_fieldcatalog = i_lvc[]
      IMPORTING
      ep_table = i_table
      e_style_fname = l_style.
      ASSIGN i_table->* TO <fs>.
      CREATE DATA l_warea LIKE LINE OF <fs>.
      ASSIGN l_warea->* TO <fs2>.
      <fs2> = p_char.
      ASSIGN COMPONENT l_name OF STRUCTURE <fs2> TO <fs3>.
      IF <fs3> = 'a'.
        WRITE: 'Component VARCHAR is a'.
    *  APPEND <fs2> TO <fs>.
      ELSE.
        WRITE: 'Component VARCHAR is not a'.
      ENDIF.

  • Dynamic Work Area and field symbol

    Hi All,
    I'm have a big internal table like this
    data: begin of data occurs 0,
    Field01,
    Field02,
    Field03,
    *bucket 1
    Field04,
    Field05,
    Field06,
    *bucket 2
    Field04,
    Field05,
    Field06,
    *bucket 3
    Field04,
    Field05,
    Field06,
    Field 1, 2 3 will be the same for pernr, first last name.
    Field 4, 5, 6 are the same format but different numbers (or values ) in different buckets.
    Each bucket can be shown (or not) based on the condition of a person, for example if that person live in 2 states, it will show 2 bucket with 2 address info inside each.
    I will run this under get pernr to sort out each person who have many address or not.
    Can I use dynamic work area and field symbol here? if I can, how?
    Really appreciate your help with points...

    You can use the ASSIGN COMPONENT ... and than APPEND the work area to the table.
    Check out this sample program:
    REPORT  ZTEST_NP.
    DATA: BEGIN OF ITAB OCCURS 0,
          F1    TYPE I,
          F2    TYPE I,
          F3    TYPE I,
          END   OF ITAB.
    DATA: WA_ITAB LIKE ITAB.
    DATA: L_CNT TYPE I.
    FIELD-SYMBOLS: <F_FLD> TYPE ANY.
    DO 10 TIMES.    " I want 10 reocrds
      CLEAR L_CNT.
      DO 3 TIMES.   " I have 3 fields
        L_CNT = L_CNT + 1.
        ASSIGN COMPONENT L_CNT OF STRUCTURE WA_ITAB TO <F_FLD>.
        <F_FLD> = L_CNT.
      ENDDO.
      APPEND WA_ITAB TO ITAB.
      CLEAR  ITAB.
    ENDDO.
    LOOP AT ITAB INTO WA_ITAB.
      WRITE: / WA_ITAB-F1,
               WA_ITAB-F2,
               WA_ITAB-F3.
    ENDLOOP.
    Regards,
    Naimesh Patel

  • Dynamic field modification in Work Area.

    Hi,
    I want to insert 1 record in a transparent table. (But for time being, let us assume the table is MARA)
    The columns and table name to which data is to be inserted are stored in another transparent table say (z1354_inv_rec_dt).
    The data to be inserted is specified in a text file.
    The value for MATNR, let us assume is hard coded as 1252.
    The value for fields ERSDA, ERNAM, LAEDA and AENAM will be specified in input text file.
    Also the table z1354_inv_rec_dt, will have rows with values ERSDA, ERNAM, LAEDA and AENAM.
    How do I do this, the code specified in form comparedata is not correct one, but just a starting point for code.
    <b>So how do I specify the column of work area at run time and assign value to it.</b>
    Then I have to append value from work area to internal table.
    And from internal table, I will insert to database.
    REPORT ZDYN_INS_MARA.
    TYPE-POOLS : abap.
    DATA:
      lit_z1354_inv_rec_dt  TYPE TABLE OF z1354_inv_rec_dt,
    * table z1354_inv_rec_dt contains 2 columns column_name and table_name
    * values for column_name are ERSDA, ERNAM, LAEDA and AENAM
    * value for table_name is MARA.
      lwa_invoice LIKE  z1354_inv_rec_dt,
      lit_mara TYPE TABLE OF mara,
      lwa_mara LIKE mara.
    * To get column names
    DATA :
      it_details TYPE abap_compdescr_tab,
      wa_details TYPE abap_compdescr,
      ref_descr TYPE REF TO cl_abap_structdescr.
    FIELD-SYMBOLS : <fs_mara> TYPE mara.
    FIELD-SYMBOLS : <fs_wa_mara> LIKE LINE OF lit_mara.
    FIELD-SYMBOLS : <dyn_field>.
    DATA: int_tabname(30).
    int_tabname = 'MARA'.
    *Populate internal table with columns to be added to Database
    PERFORM populaterecdt.
    ref_descr ?= cl_abap_typedescr=>describe_by_name( int_tabname ).
    *Get the column names from the Database tables
    it_details[] = ref_descr->components[].
    PERFORM comparedata.
    *&      Form  PopulateRecDt
    FORM populaterecdt .
      SELECT column_name table_name FROM z1354_inv_rec_dt
      INTO CORRESPONDING FIELDS OF TABLE lit_z1354_inv_rec_dt
      WHERE table_name = 'MARA' .
    ENDFORM.                    " PopulateRecDt
    *&      Form  CompareData
    FORM comparedata .
    *loop through the DB table which holds the column names to be added
    LOOP AT lit_z1354_inv_rec_dt INTO lwa_invoice.
    *Loop throught table which holds the column names
      ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_wa_mara> TO <dyn_field>.
      <dyn_field> = '1252'   .
      LOOP AT it_details INTO wa_details.
        IF wa_details-name = lwa_invoice-column_name.
    * Assign value to column of work area from text file.
          ASSIGN component lwa_invoice-column_name of structure                   <fs_wa_mara> to <dyn_field>.
    *Get value for <dyn_field> from text file
            <dyn_field> = 'XYZ212'.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
    *append work area t to lit_mara.
    *Append work area to internal table.
    *insert the internal table to DB
    ENDFORM.                    " CompareData
    Here in this loop, I want to assign to the work area for Mara based on the column values, How do I do it.
    Regards,
    Vikas

    Hi,
    This problem has been resolved.
    DATA:
        lit_MARA TYPE TABLE OF MARA,
        lit2_MARA TYPE TABLE OF MARA,
        lwa_MARA LIKE MARA,
        lit_inv TYPE TABLE OF z1354_inv_rec_dt,
        wa_inv  LIKE z1354_inv_rec_dt,
        sctemp(100) TYPE c,
        ifs type i,
         p_gs_s_rec_line TYPE string.
      FIELD-SYMBOLS:
        <fs_MARA> TYPE table,
        <ld_column>   TYPE ANY,
        <fs_wa_MARA> LIKE LINE OF lit_MARA.
    *Populate Invoice table
      SELECT * FROM  z1354_inv_rec_dt INTO CORRESPONDING FIELDS OF TABLE
      lit_inv WHERE recordtype = 'S' AND table_name = 'MARA' AND
      column_seq > 0.
      p_gs_rec_line = '1234567890000001'.
      lwa_MARA-laufi = '123e'.
      FREE lit_MARA.
      APPEND  lwa_MARA TO lit_MARA.
      ASSIGN lit_MARA[] TO <fs_MARA>.
      UNASSIGN: <fs_wa_MARA>.
    * free lit_MARA[] .
    * LOOP AT <fs> ASSIGNING <fs1>.
    LOOP AT lit_MARA ASSIGNING <fs_wa_MARA>.
      ifs = sy-tabix.
      write: / ifs.
        LOOP AT lit_inv INTO wa_inv.
          WRITE
          p_gs_s_rec_line+wa_inv-start_pos_extrac(wa_inv-chars_to_extract)
          TO sctemp.
          UNASSIGN: <ld_column>.
          ASSIGN COMPONENT wa_inv-column_name OF STRUCTURE <fs_wa_MARA>
          TO <ld_column>.
          <ld_column> =  sctemp.
          IF ( <ld_column> IS ASSIGNED ).
            WRITE: / '.' .
          ENDIF.
          CLEAR wa_inv.
        ENDLOOP.
        MOVE  <fs_wa_MARA> TO lwa_MARA.
        APPEND lwa_MARA TO lit2_MARA.
       CLEAR <fs_wa_MARA>.
      ENDLOOP.
    loop at lit2_MARA into lwa_MARA.
      write: / lwa_MARA-filename.
      clear lwa_MARA.
    endloop.
    insert MARA from table lit2_MARA.
    if sy-subrc <> 0.
      write: / ' Insert  :-( '.
    endif.

  • How to create dynamic strcture and accepting runtime value in work area

    Hi,
    I am using RFC_READ_TABLE for  joining more than table  and written select query but  into clause work area value is passed but it is short dump is displaying with too few many fields  in into clause .work area WA need some casting type conversion which accepts the some run time value  and should have some structure  for it.how to create dynamic structure?

    hi
    good
    go through this and use in your report accordingly.
    If you are trying to read some information from SAP and you can't find the right BAPI then RFC_READ_TABLE can do the job for you.
    RFC_READ_TABLE is powerful RFC it gives you the access to all tables and views in SAP. I basically used RFC_READ_TABLE for Material Master Search application on the Intranet.
    Now you may say there are lots of BAPI for this functionality. You are right but I had to work around the BAPI to get Prices (Moving Average Price) and it just did not work very well. Because of the nature of the application I had to use RFC_READ_TABLE because then I can use powerful SQL expression for searching. RFC_READ_TABLE give you the ability to code the where clause which is quite enough.
    I have included part of the code use in asp page to read ENT1027 for Mgroup and M description & number but without object creation. The other part of the code reads MBEW for price & quantity.
    Code
    lt;%
    '#######################Diming the Structures
    Call BAPIRFC.DimAs("Rfc_Read_Table", "FIELDS", MaterialSelection_RS)
    Call BAPIRFC.DimAs("Rfc_Read_Table", "OPTIONS", Selection_RS)
    '########################Search Type########################
    ' C contanis
    ' S Start with
    ' E Ends with
    if searchtype = "C" then
    FormatedSearch_Keyword = "%" & Search_Keyword & "%"
    elseif searchtype = "S" then
    FormatedSearch_Keyword = Search_Keyword & "%"
    else searchtype = "E" then
    FormatedSearch_Keyword = "%" & Search_Keyword
    end if
    '################# Flaged for deletion Materials #####################
    if showdeleted = "No"  then
    Selection_RS.AddNew Array("TEXT"),Array("LVORM <> 'X' AND")
    end if
    '############## users can search three material group ################
    '############## GROUPS: OFFICESUP TECOMHARD TECOMSOFT ###############
    '##USER STILL CAN NAROW THEIR SEARCH BY SELECTING ON OF THREE#########
    if MGroup = "ALL"  then
    Selection_RS.AddNew Array("TEXT"),Array("MATKL IN ('OFFICESUP','TECOMHARD','TECOMSOFT')")
    else
    Selection_RS.AddNew Array("TEXT"),Array("MATKL = '"& MGroup &"' and ")
    end if
    '#######################ADDING SEARCH KEYWORD TO STRUCTURE##############
    if not  Search_Keyword = "" then
    Selection_RS.AddNew Array("TEXT"),Array(" MAKTG LIKE '" & FormatedSearch_Keyword &  "'")
    end if
    Selection_RS.Update
    '#######################ADD RETURNED FIELDS#########################
    MaterialSelection_RS.AddNew array("FIELDNAME","OFFSET","LENGTH","TYPE","FIELDTEXT"),array("MATNR","000000","000000" ,"","")
    MaterialSelection_RS.AddNew array("FIELDNAME","OFFSET","LENGTH","TYPE","FIELDTEXT"),array("MATKL","000000","000000" ,"","")
    MaterialSelection_RS.AddNew array("FIELDNAME","OFFSET","LENGTH","TYPE","FIELDTEXT"),array("MAKTG","000000","000000" ,"","")
    MaterialSelection_RS.Update
    call BAPIRFC.Rfc_Read_Table("ENT1027", Material_RS, MaterialSelection_RS, Selection_RS, "~", "", "0", "0")
    If Err.Number > 0 then
                   Response.Write "Error:" & "<BR>"
                   Response.Write "   Err.number...... " & Err.Number & "<BR>"
                   Response.Write "   Err.Description. " & Err.Description & "<BR>"
    end if
    '###########LOOP THROUGH RECORDSET
    if not Material_RS is nothing then
    do while not Material_RS.eof
    loop
    end if
    %>
    thanks
    mrutyun^

Maybe you are looking for

  • OUTPUT..URGENT

    Hi frnds,       i have modified a standard report to 'z' report.the output comes as like standard abap list. when i execute the report in foreground and saves the output in spreadsheet its fine but when i execute it in background the output is messed

  • Mercury GPU acceleration worse then software acceleration :(

    I have to date the latest Premiere, and the latest Nvidia drivers.. Two GTX 580 cards and a Intel i7 4930k. The timeline I'm having uses loads of warp stabelizers, AVCHD footage and heavy speedgrade looks with masks and five primarys. The gtx cards w

  • Decrease the GAP

    Hello Guru's, I'm new to adobe form design, So I couldn't catch the solution to decrease the GAP between two fields. Like I have to fields side by side, with first field lenth 40 and second field 10. If the first field field is not in full lenth, it

  • No Voicemail But Missed Call Text Alert

    Hi EE, I'm new to EE, previously I've been on Vodafone and O2.  With them I always had a feature where I revieved missed call text alerts when ever my phone was unavailable with no signals either in Underground Tube, Indoors or if the phone was swith

  • Video screen Capturing compatible with FCP!!!

    Hello, I recently captured a lot of footage using Snapz Pro X to create a tutorial for a website. After importing it into FCP, it wants to render everything, all the time, for every small change. These render take hours and hours for the smallest cha