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.

Similar Messages

  • 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

  • How to pass dynamic name to a field-symbol?

    Hi All,
    I have a requirement like I need to create dynamic internal table with dynamic name. Say like,
    Create a new Table
       CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
         it_fieldcatalog = it_fieldcat_fin[]
        IMPORTING
         ep_table        = new_table.
        IF sy-subrc EQ 0.
    Create a new Line with the same structure of the table.
         ASSIGN new_table->* to <b>(<fs_table>)</b>.
    In the above code, (<fs_table>) is a variable. Actually it is in the loop, so that first time it comes, it has to create an internal table with name as <fs_01>, next time <fs_02> and so on. Hope I am clear.
    Please help me. I am sure that i will mark the helpful answers.

    DATA: DREF TYPE REF TO DATA,WA_REF TYPE REF TO DATA.
    FIELD-SYMBOLS: <TEMP_TAB> TYPE TABLE, <TEMP_WA> TYPE ANY.
    *&      Form  DYNAMIC_TABLE
          text
    -->  p1        text
    <--  p2        text
    FORM DYNAMIC_TABLE.
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG = LT_LVCFIELDCAT
        IMPORTING
          EP_TABLE        = DREF.
      ASSIGN dref->*  TO <TEMP_TAB>.
    ENDFORM.                    " DYNAMIC_TABLE
    the above is the procedure to create dynamic internal tables.
    now <TEMP_TAB> points to the contents of the table table in DREF.
    field symbol it self is meant for dynamic.
    then y r u using (<fs_table>).
    when everytime the same fieldsymbol is pointing to new contents, y u need new name everytime?
    i mean as the data is not static, so what is the use of naming a field symbol every time?.
    if u want to store the data in an internal table with a name,
    then u can do like below,
    data: tabname type string, i type i.
    concatenate '<fs_' i into tabname.
    "let i be the variable which stores the internal tables count
    "MOVE <temp_tab> to tabname.

  • 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

  • How to move a dynamic variable to a FIELD-SYMBOL

    Hello:
    i would like to ask a favor i have been trying to move a dynamic variable to a FIELD-SYMBOL but, when i compile the programm it send a error message that say 'error with assign'.
    The FS is declared like this
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE, <dyn_wa>.
    and then there is a PERFORM that send a dynamic varible and then this variable is asigned to the <dyn_table> and after of this one variable is created like this CREATE DATA wa_dynamic LIKE LINE OF <dyn_table>.
    and finalilly there is a sentences where i trying to send the wa_dynamic to the <dyn_wa>.
    here is where the error appear.
    if you have any tips for this problem i will appreciate.
    thanks a lot
    Definition of FS
    FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE, <dyn_wa>.
    PERFORM
    Create dynamic internal table and Assign it to Field Symbol
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
          it_fieldcatalog = it_fldcat
        IMPORTING
          ep_table        = it_dynamic.
      ASSIGN it_dynamic->* TO <dyn_table>.
    Create dynamic work area and assign to FS
    CREATE DATA wa_dynamic LIKE LINE OF <dyn_table>.
    ASSIGN wa_dynamic->* TO <dyn_wa>. "HERE IS THE PROBLEM

    How is wa_dynamic defined?
    data: wa_dynamic type ref to data.
    Regards,
    Rich Heilman

  • How to copy the structure of a Field Symbol?

    Hi,
              I have a requirement where in a dynamic Internal table is supposed to be created. I have created that dynamic table using the class method cl_alv_table_create=>create_dynamic_table. Here I have a structure in the field symbol. My requirement is how do I create a internal table with the structure that is there in the field symbol?...
    and i'm unable to refer to the field that is dynamically created in the field symbol.
    Like,
    <gfs_tab>-pernr = itab-pernr.
    in the above stmt the field pernr is created in the field symbol dynamically.
    Thanks,
    Deepak.

    Hi Matt,
                my objective is to create an internal table with structure that i have obtained in <gfs_tab> .
    other than the pernr, there are many fields dynamically generated.
    say if I have generated the following structure in <gfs_tab> :
    pernr            ename1            day1             day2                 day3
    then I want to create an internal table with the above structure so that my internal table will have fields:
    1) pernr
    2) ename1
    3) day1
    4) day2
    5) day3
    for each execution of the report there will be different structure generated in <gfs_tab> depending upon the inputs that I give.
    Thanks,
    Deepak.

  • Create Dynamic Structure based on Field-Symbol

    Hi Experts!!
    I need to create a structure with dynamic structure included within.
    I have a parameter on sel. screen in which we provide table name.
    PARAMETERS: p_table TYPE tabname.
    FIELD-SYMBOLS: <gt_data> TYPE ANY TABLE.
    CREATE DATA gr_data TYPE TABLE OF (p_table).
    ASSIGN gr_data-* TO <gt_data>.
    Now I need a structure like below:
    TYPES: BEGIN OF type_test,
    struct TYPE <gt_data>, " dynamic structure based on table name entered on sel. screen
    fld1 TYPE c,
    fld2 TYPE n,
    END OF type_test.
    Can somebody suggest how to achieve this?
    Your help is highly appreciated. Thanks a lot

    You can view this thread where our friend Marcin rocks .. Dynamically create a type
    FIELD-SYMBOLS: <gt_data> TYPE ANY TABLE.
    FIELD-SYMBOLS: <gs_wa> TYPE ANY.
    data:wf_ref type ref to data.
    DATA:i_comp TYPE cl_abap_structdescr=>component_table,
         i_tot_comp TYPE cl_abap_structdescr=>component_table.
    CREATE DATA gr_data TYPE TABLE OF (p_table).
    ASSIGN gr_data-* TO <gt_data>.
    create data wf_ref like line of <gt_data>.
    assign wf_ref->* to <gs_wa>.
    *--Getting Compoents from existing type
      lf_struct ?= cl_abap_typedescr=>describe_by_name( '<GS_WA>' ).
      i_comp = lf_struct->get_components( ).
      APPEND LINES OF i_comp TO i_tot_comp.
    The idea is Get all the field details available it to i_tot_comp, then append individual fields manually to
    i_tot_comp as explained in the link and create a dynamic structure and table.

  • How to assign ranges ( select-option)to field symbol

    Hi ,
    I have following scenario
    ranges : r_test1 for agr_1251,
                 r_test2 for agr_1251.
    In runtime i am getting which range i have to populate in a field v_rname.for now let it me v_rname  = 'r_test2'
    i want to assign (v_rname ) to <field -symbol> ie is range to field symbol.
    and i want to update the <field -symbol>-sign ='I'
                                        <field -symbol>-LOW ='some value'
                                        append <field -symbol>.
    This is the logic i want to follow,  for this how should i have to declare the field symbol ? I couldn't assign a range to field symbol . Please help me.
    thanks
    Murali

    Try this
    FIELD-SYMBOLS : <field_symbol>  TYPE ANY TABLE.
    ASSIGN (v_rname) to <field_symbol>.
    <field -symbol>-sign ='I'
    <field -symbol>-LOW ='some value'
    append <field -symbol>.
    This should work because your range is a table.
    Hope this helps you.

  • Populate data into the dynamic table ie using field symbols

    Dear All,
    I need to convert the XML data into internal table. I did this using the guidelines in the forum. Using all those i can get my data
    in the format of
    Cname Cvalue
    id          1
    name    XX
    id          2
    name    YY
    But i need the values in the format of int_tab like,
    ID      Name
    1       XX
    2       YY
    I used the below code to create the dynamic table strucure.
    call method cl_alv_table_create=>create_dynamic_table
                   exporting
                      it_fieldcatalog = ifc
                   importing
                      ep_table        = dy_table.
    assign dy_table->* to <itab>.
    * Create dynamic work area and assign to FS
      create data dy_line like line of <itab>.
      assign dy_line->* to <wa>.
    So now my strucure will be like ID Name.
    I strucked in the place of populating the data into this like 1,XX,2,YY into the dynamic table.
    If you come across with this scenario, can anyone suggest me on this.
    Regards,
    Anita Vizhi Arasi B

    Hi Anita,
    Try to understand below given code. It works same as you want. But I used Function module not any method.
    TYPES: BEGIN OF ty_xml,
              raw(255) TYPE x,
             END OF ty_xml.
      DATA: lv_file_name TYPE                   rlgrap-filename,
            lit_hdr      TYPE TABLE OF          ty_hdr,
            ls_hdr       TYPE                   ty_hdr,
            lv_file      TYPE                   string,
            wa_xml       TYPE                   ty_xml,
            lit_xml      TYPE STANDARD TABLE OF ty_xml,
            lv_filename  TYPE                   string ,
            ls_xmldata   TYPE                   xstring ,
            lit_result   TYPE STANDARD TABLE OF smum_xmltb,
            ls_result    TYPE                   smum_xmltb,
            lit_return   TYPE STANDARD TABLE OF bapiret2,
            lv_size      TYPE                   i,
            lv_count     TYPE                   i.
      CONSTANTS: line_size TYPE i VALUE 255.
      REFRESH lit_hdr.
    *~ File selected from Local System
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        EXPORTING
          program_name  = syst-repid
          dynpro_number = syst-dynnr
        CHANGING
          file_name     = lv_file_name
        EXCEPTIONS
          mask_too_long = 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.
      lv_file = lv_file_name.
    *~ Upload for Data Provider
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename            = lv_file
          filetype            = 'BIN'
          has_field_separator = ' '
          header_length       = 0
        IMPORTING
          filelength          = lv_size
        TABLES
          data_tab            = lit_xml
        EXCEPTIONS
          OTHERS              = 1.
    *~ Convert from Binary to String
      CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
        EXPORTING
          input_length = lv_size
        IMPORTING
          buffer       = ls_xmldata
        TABLES
          binary_tab   = lit_xml
        EXCEPTIONS
          failed       = 1
          OTHERS       = 2.
    *~ Parse XML docment into a table structure
      CALL FUNCTION 'SMUM_XML_PARSE'
        EXPORTING
          xml_input = ls_xmldata                  " Buffered data
        TABLES
          xml_table = lit_result                  " final internal table which contain records
          return    = lit_return.
      LOOP AT lit_result INTO ls_result.
        IF ls_result-hier = '3'.
          IF ls_result-type = 'V'.
            CASE ls_result-cname.
              WHEN 'intno'.                       "Internal Number
                ls_hdr-intno = ls_result-cvalue.
              WHEN 'acode'.                       "Article Code
                ls_hdr-matnr = ls_result-cvalue.
              WHEN 'adesc'.                       "Article Description
                ls_hdr-maktx = ls_result-cvalue.
              WHEN 'idesc'.                       "Item Description
                ls_hdr-itmds = ls_result-cvalue.
              WHEN 'sdesc'.                       "Standard Description
                ls_hdr-stdds = ls_result-cvalue.
              WHEN 'at'.                          "Article Type
                ls_hdr-mtart = ls_result-cvalue.
              WHEN 'mc'.                          "Merchandise Category
                ls_hdr-matkl = ls_result-cvalue.
              WHEN 'cp'.                          "Characteristic Profile
                ls_hdr-charp = ls_result-cvalue.
                CONDENSE ls_hdr-charp.
              WHEN 'c1'.
                ls_hdr-col01 = ls_result-cvalue.
              WHEN 'c2'.
                ls_hdr-col02 = ls_result-cvalue.
              WHEN 'c3'.
                ls_hdr-col03 = ls_result-cvalue.
              WHEN 'c4'.
                ls_hdr-col04 = ls_result-cvalue.
              WHEN 'c5'.
                ls_hdr-col05 = ls_result-cvalue.
              WHEN 'c6'.
                ls_hdr-col06 = ls_result-cvalue.
              WHEN 'tc'.                          "Tax Classification
                ls_hdr-taklv = ls_result-cvalue.
              WHEN 's'.                           "Season
                ls_hdr-saiso = ls_result-cvalue.
              WHEN 'sy'.                          "Season Year
                ls_hdr-saisj = ls_result-cvalue.
              WHEN 'fg'.                          "Fashion Grade
                ls_hdr-fashg = ls_result-cvalue.
              WHEN 'rm'.                          "Reference Material
                ls_hdr-rfmat = ls_result-cvalue.
              WHEN 'fcv'.                         "Free Character Value
                ls_hdr-frecv = ls_result-cvalue.
              WHEN 'uom'.                         "Unit of Measure
                ls_hdr-uom = ls_result-cvalue.
              WHEN 'pou'.                         "PO Unit
                ls_hdr-pount = ls_result-cvalue.
              WHEN 'v'.                           "Vendor
                ls_hdr-lifnr = ls_result-cvalue.
              WHEN 'b'.                           "Vendor
                ls_hdr-brand = ls_result-cvalue.
              WHEN 'pg'.                          "Purchasing Group
                ls_hdr-wekgr = ls_result-cvalue.
              WHEN 'rv'.                          "Regular Vendor
                ls_hdr-rlifn = ls_result-cvalue.
              WHEN 'pp'.                          "Pricing Profile
                ls_hdr-sprof = ls_result-cvalue.
              WHEN 'sp'.                          "Sales Price
                ls_hdr-spric = ls_result-cvalue.
              WHEN 'm'.                           "Margin
                ls_hdr-margn = ls_result-cvalue.
              WHEN 'c'.                           "Calculate
                ls_hdr-pcalc = ls_result-cvalue.
              WHEN 'purp'.                        "Purchase Price
                ls_hdr-ppric = ls_result-cvalue.
              WHEN 'a'.                            "Assortment
                ls_hdr-asort = ls_result-cvalue.
              WHEN 'bm'.                           "Batch Management
                ls_hdr-batch = ls_result-cvalue.
              WHEN 'mrl'.                          "Min. Remaining Life
                ls_hdr-minrl = ls_result-cvalue.
              WHEN 'aag'.                          "Account Assignment Group
                ls_hdr-acass = ls_result-cvalue.
              WHEN 'vc'.                           "Valuation Class
                ls_hdr-valcl = ls_result-cvalue.
              WHEN 'eancat'.                       "EAN Category
                ls_hdr-eanct = ls_result-cvalue.
              WHEN 'ean11'.
                ls_hdr-ean11 = ls_result-cvalue.
            ENDCASE.
            AT END OF hier.
              APPEND ls_hdr TO lit_hdr.
            ENDAT.
          ENDIF.
        ENDIF.
      ENDLOOP.
      APPEND LINES OF lit_hdr TO git_hdr.
      DELETE git_hdr  WHERE maktx IS INITIAL            "Article Description
                          AND mtart IS INITIAL          "Article Type
                          AND matkl IS INITIAL          "Merchandise Category
                          AND charp IS INITIAL          "Characteristic Profile
                          AND taklv IS INITIAL          "Tax Classification
                          AND uom   IS INITIAL          "Unit of Measure
                          AND pount IS INITIAL          "PO Unit
                          AND lifnr IS INITIAL          "Vendor
                          AND brand IS INITIAL          "Brand
                          AND wekgr IS INITIAL          "Purchasing Group
                          AND ppric IS INITIAL          "Purchasing Price
                          AND spric IS INITIAL          "Sales Price
                          AND acass IS INITIAL          "A/c Assign. Grp.
                          AND valcl IS INITIAL          "Valuation Class
                          AND saiso IS INITIAL          "Season
                          AND saisj IS INITIAL.         "Season Year
      IF git_hdr[] IS NOT INITIAL.
        CLEAR: lv_count.
        LOOP AT git_hdr INTO ls_hdr.
          lv_count  = lv_count + 1.
          ls_hdr-intno = lv_count.
          MODIFY git_hdr FROM ls_hdr TRANSPORTING intno.
          CLEAR: ls_hdr.
        ENDLOOP.
      ENDIF.
    Code written is part of my program. Try to understand it. I hope it will help you out.
    Regards,
    Narendra

  • Creating dynamic internal table(Not field symbol table)

    Hi Experts,
    I am facing problem creating Intarnal table
    I have fieldcatalog, I want create dynamic internal table(Not field symbol table).
    I have written----
      CALL METHOD cl_alv_table_create=>create_dynamic_table
        EXPORTING
       i_style_table             =
         it_fieldcatalog           = it_fldcat
          it_fieldcatalog           = me->gt_fieldcat
       i_length_in_byte          =
        IMPORTING
          ep_table                  = lt_new_table
       e_style_fname             =
        EXCEPTIONS
         generate_subpool_dir_full = 1
         OTHERS                    = 2.
        ASSIGN lt_new_table->* TO <gt_dyn_repdata>.
        CREATE DATA ls_new_line LIKE LINE OF <gt_dyn_repdata>.
        ASSIGN ls_new_line->* TO <gs_dyn_repdata>.
    above logic creating dynamic field symbol table.... But I want create normal internal table.
    Thanks,
    Rajasekhar

    Hi
    What do you mean?
    It needs to use the field-symbol, this is the price to pay if it wants a dynamic object
    Max

  • How to check data type of the field symbol at run time

    Hi,
    My code is as following:
          LOOP AT <fs> ASSIGNING <wa_covp_ext>.
            ASSIGN COMPONENT 86 OF STRUCTURE <wa_covp_ext> TO <f_zzname>.
            IF sy-subrc = 0.
              ASSIGN COMPONENT 158 OF STRUCTURE <wa_covp_ext> TO <f_pernr>.
              IF sy-subrc = 0.
                  SELECT SINGLE sname INTO <f_zzname> FROM pa0001
                                WHERE pernr = <f_pernr>
                                AND endda GE sy-datum
                                AND begda LE sy-datum.
             ENDIF.
          ENDIF.
        ENDLOOP.
    This query is giving dump when <f_zzname> is type P length 8 and decimals 2, because it tries to put PA0001-sname into it which is type C length 30. So I want to check the type of <f_zzname> before the select statement. If it is character 30, then I will write the select statement else not.
    How to check data type of the field symbol at run time? If it's not possible, then can somebody suggest a workaround? Thanks.

    check this ...
    write describe statement  ...
    field-symbols : <f_zzname> .
    data : sname like pa0001-sname,
           typ(10).
    assign sname to  <f_zzname>.
    describe  field <f_zzname> type typ.
    write : typ. <-- typ contains character type in this case ..
    U can check if typ is of character(C) if so .. write the select statement ...

  • 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

  • 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 more values in one field (JSP / HTMLX)

    When I want to fill one value in a field on a JSP page, I enter:
    value="<%=someClass.getSomeValue() %>"
    How should I enter more values (e.g. street, city, postal code, country) in one field?
    I tried to put those fields together, so I do one getAddress() call, but the output is (initial screen - supposed to be empty) null null null null
    When I enter a customer, the field works ok (no null values).
    TIA,
    Mylene

    JSP:
    <hbj:inputField     
    id="CustomerAddressInputField"     
    type="STRING"     
    maxlength="10"     
    value="<%=quotationHeader.getCustomer().getAddress().getAddress() %>"
    design="STANDARD"
    ... %>"
    getAddress():
    @return String (complete address / positioning
    pCode unsure!)
    public final String getAddress()
    return (street + " " + pCode + " " + city + " " + cCode);
    This is what returns null null null null
    What I want (if possible) is to change the getAddress() in the JSP in subsequent getStreet() - add space - getPCode() - add space - getCity() - add space - getCCode()
    That will not result in null values - I hope.
    But just putting those calls in the string between the
    value ="<%= and the %>" tags doesn't seem to work!
    TIA,
    Mylene

  • How to fill empty business area in posted documents?

    Hi SAP Team,
    My Client need to fill the field "business area" for documents already posted. However, today all posted documents, have a rule + validation or substitution for this field.- fill business area to be filled in. For year 2013, my client want to re-assign business area at balance sheet accounts but the problem is how to that at customers, vendors account that are reconciliation accounts. Do you have any sugestion?
    For balance accounts, for eg:, if my total in a gl bank account is in debit (no business area at this gl account level), my client idea is to credit that bank account without business area and debit it again but filling the business area. For Customers/Vendors, is not that easy because that gl account does not allow directed posting.
    Do you have suggestion to handle this?
    Thanks a lot,
    Kind regards
    Antónia Farias

    For vendor / customer postings you have to create reconiliation account wise dummy sub ledgers.
    E.g. 1.You have 3 recon. a/c's for customers then you cretae 3 dummy customer codes.
           2. Post a consolidated entry using this dummy accounts(one line item with B.A and the second
               line ietm without B.A)
           3. So at any point of time these subledgers should have zero balance.
           4.  Please block these sub-ledgers once your postings have been finished.
    Rgds
    MBN.

Maybe you are looking for