Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

help in field symbols

Former Member
0 Kudos

Hi,

i do dynamic select and i wont use dynamic work area

that i can update table how i can do that?

i try like this but i have error .

Regards

e.g.

FIELD-SYMBOLS: <l_act> TYPE ANY.



SELECT (field_selection)
  FROM datab
  INTO TABLE <dyn_actual>
  AND dim0calmonth IN g_months_act.

   IF  a_flag = 'X'.
    CREATE DATA dy_line LIKE LINE OF  it_acl.
    ASSIGN dy_line->* TO <l_act>.
  ELSE.
    CREATE DATA dy_line LIKE LINE OF a_type.
    ASSIGN dy_line->* TO <l_act>.
  ENDIF.


  LOOP AT <dyn_actual> ASSIGNING <l_act>.

    <l_act>-change_fld =  ( <l_act>-kyf0hdcnt_last02 / <l_act>-kyf0hdcnt_last02 ) * 100.
  ENDLOOP.

the erorr i get :

The data object "<L_ACT>" has no structure and therefore no component called "KYF0HDCNT_LAST02". called "KYF0HDCNT_LAST02".

i have field KYF0HDCNT_LAST02 in <dyn_actual> .

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

You want to update the internal table <dyn_actual> with the calculated amount..right??

Field-symbols.
  FIELD-SYMBOLS: <fs_data1> TYPE any,
                              <fs_data2> TYPE any,
                              <fs_data3> TYPE any.
 
  LOOP AT <dyn_actual> ASSIGNING <l_act>.
 
   ASSIGN COMPONENT 'CHANGE_FLD' OF STRUCTURE <l_act> TO <fs_data1>.
 
    CHECK sy-subrc = 0.

   ASSIGN COMPONENT 'KYF0HDCNT_LAST02' OF STRUCTURE <l_act> TO <fs_data2>.
 
    CHECK sy-subrc = 0.

   ASSIGN COMPONENT 'KYF0HDCNT_LAST03' OF STRUCTURE <l_act> TO <fs_data3>.
 
    CHECK sy-subrc = 0. 
 
      <fs_data1> =  ( <fs_data2> / <fs_data3> ) * 100.
 
 
ENDLOOP.

Thanks

Naren

8 REPLIES 8

Former Member
0 Kudos

Hi,

Try this..

* Field-symbols.
  FIELD-SYMBOLS: <fs_data> TYPE any.

  LOOP AT <dyn_actual> ASSIGNING <l_act>.

   ASSIGN COMPONENT 'CHANGE_FLD' OF STRUCTURE <l_act> TO <fs_data>.

    IF SY-SUBRC = 0.
 
      <fs_data> =  ( <l_act>-kyf0hdcnt_last02 / <l_act>-kyf0hdcnt_last02 ) * 100.

    ENDIF.
  
ENDLOOP.

Do the same for the other fields in the structure..

Thanks

Naren

0 Kudos

Hi Narendran ,

thanks ,i try like u tell but i have the same error :

LOOP AT <dyn_actual> ASSIGNING <l_act>.
      ASSIGN COMPONENT:  'CHANGE_FLD' OF STRUCTURE <l_act> TO <fs_data>,
                         'KYFOHDCNT_LAST02' OF STRUCTURE <l_act> TO <fs_data>,
                         'KYFOHDCNT_LAST03' OF STRUCTURE <l_act> TO <fs_data>.
      <fs_data> =  ( <fs_data>-kyf0hdcnt_last02 / <fs_data>-kyf0hdcnt_last03 ) * 100.
    ENDLOOP.
  ENDIF.

Regards

naimesh_patel
Active Contributor
0 Kudos

You need to assign the required field (which you want to access) to the field-symbol and than use that field symbol to process data.

Like:


LOOP AT <dyn_actual> ASSIGNING <l_act>.
  assign component 'CHNAGE_FLD' of strcuture <l_act> to <lf_chage>.
  assign component 'KYFOHDCNT_LAST02' of strcuture <l_act> to <lf_hdcnt>.
  assign component 'KYFOHDCNT_LAST03' of strcuture <l_act> to <lf_hdcnt3>.

  <lf_change> = ( <lf_hdcnt> / <lf_hdcnt3> ) * 100.

ENDLOOP.

Regards,

Naimesh Patel

0 Kudos

hi Naimesh,

thanks but what i wont is to modify table <dyn_actual> with the result,

it is fits?

Regards

0 Kudos

Once you move data to the field-symbols of the fields, it will automatically update the current workarea field symbol and internal table. You don't have to explicitally MODIFY it.

Regards,

Naimesh Patel

Former Member
0 Kudos

Hi,

You need to define a structure for the field symbol.


DATA : i_fcat         TYPE STANDARD TABLE OF lvc_s_fcat.
DATA: i_table_data1  TYPE REF TO data.

FIELD-SYMBOLS: <f_table_data1>     TYPE STANDARD TABLE.

  CLEAR   i_fcat.
  REFRESH i_fcat.

  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
            i_structure_name = 'BKPF'         "Structure to refer
       CHANGING
            ct_fieldcat      = i_fcat
       EXCEPTIONS
            OTHERS           = 1.

  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = i_fcat
    IMPORTING
      ep_table        = i_table_data1.
  IF sy-subrc = 0.
    ASSIGN i_table_data1->* TO <f_table_data1>.
  ELSE.
    WRITE: 'Error creating internal table'.
  ENDIF.

*Get DATA
SELECT * FROM bkpf INTO corresponding fields of TABLE <f_table_data1>.

Regards,

Subramanian

Former Member
0 Kudos

Naimesh's way is the correct way. As far as i know dynamically created objects and their assignments to fields symbols, have no control over the field names. So you have to use ASSIGN COMPONENT statement in this case

A

Former Member
0 Kudos

Hi,

You want to update the internal table <dyn_actual> with the calculated amount..right??

Field-symbols.
  FIELD-SYMBOLS: <fs_data1> TYPE any,
                              <fs_data2> TYPE any,
                              <fs_data3> TYPE any.
 
  LOOP AT <dyn_actual> ASSIGNING <l_act>.
 
   ASSIGN COMPONENT 'CHANGE_FLD' OF STRUCTURE <l_act> TO <fs_data1>.
 
    CHECK sy-subrc = 0.

   ASSIGN COMPONENT 'KYF0HDCNT_LAST02' OF STRUCTURE <l_act> TO <fs_data2>.
 
    CHECK sy-subrc = 0.

   ASSIGN COMPONENT 'KYF0HDCNT_LAST03' OF STRUCTURE <l_act> TO <fs_data3>.
 
    CHECK sy-subrc = 0. 
 
      <fs_data1> =  ( <fs_data2> / <fs_data3> ) * 100.
 
 
ENDLOOP.

Thanks

Naren