Application Development and Automation 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: 
Read only

loop at Field symbol

Former Member
0 Likes
76,647

Hi,

I'm new to ABAP and need some urgent help.

I have a FS which is assigned to a table, i now need to access values in that table and delete a few entries.

Im doing the following for the same.

*<fs_alv_histd> is already assigned to a table and has values

FIELD-SYMBOLS: <fs_wa> type ANY.

loop at <fs_alv_histd> assigning <fs_wa>.

if <fs_wa>-OIL_DISP= 0 .

  • code for delete

endif.

endloop.

However im getting an error sayinf <fs_wa> has no structure and therefore no component named OIL_DISP.Can anyone help please.

1 ACCEPTED SOLUTION
Read only

Former Member
23,940

Hi,

Please refer to the below code:



  FIELD-SYMBOLS:  <pos_data> TYPE ANY,
                               <gt_pos_data>  TYPE table.

  DATA : lt_csks LIKE gt_csks WITH HEADER LINE.


 LOOP AT <gt_pos_data> ASSIGNING <pos_data>.

    MOVE-CORRESPONDING <pos_data> TO lt_csks.
    
    if lt_csks-oi_disp NE 0.
       APPEND lt_csks.
      CLEAR  lt_csks.
   endif.

  ENDLOOP.

In your lt_cks you will have only data which does not have oil_disp not equal to zero.

Thanks,

Sriram Ponna.

Hi,

I'm new to ABAP and need some urgent help.

I have a FS which is assigned to a table, i now need to access values in that table and delete a few entries.

Im doing the following for the same.

*<fs_alv_histd> is already assigned to a table and has values

FIELD-SYMBOLS: <fs_wa> type ANY.

loop at <fs_alv_histd> assigning <fs_wa>.

if <fs_wa>-OIL_DISP= 0 .

  • code for delete

endif.

endloop.

However im getting an error sayinf <fs_wa> has no structure and therefore no component named OIL_DISP.Can anyone help please.

8 REPLIES 8
Read only

Former Member
0 Likes
23,940

Hi you defined field symbol work area as generic type, declare like this and check it out...

<fs_alv_histd> is your intenal table.

FILED-SYMBOLS: <fs_wa> LIKE LINE OF <fs_alv_histd>.

LOOP AT <fs_alv_histd> INTO <fs_wa>.

your code...

ENDLOOP.

Reward pts if it helps....

Read only

JozsefSzikszai
Active Contributor
23,940

hi Rahul,

you have to assign the field as well to another field symbol:

DATA : <fs_field> TYPE ANY.

loop at <fs_alv_histd> assigning <fs_wa>.

ASSIGN COMPONENT 'OIL_DISP' OF STRUCTURE <fs_wa> TO <fs_field>.

if <fs_field> = 0 .

==> code for delete

...

hope this helps

ec

Read only

Former Member
23,941

Hi,

Please refer to the below code:



  FIELD-SYMBOLS:  <pos_data> TYPE ANY,
                               <gt_pos_data>  TYPE table.

  DATA : lt_csks LIKE gt_csks WITH HEADER LINE.


 LOOP AT <gt_pos_data> ASSIGNING <pos_data>.

    MOVE-CORRESPONDING <pos_data> TO lt_csks.
    
    if lt_csks-oi_disp NE 0.
       APPEND lt_csks.
      CLEAR  lt_csks.
   endif.

  ENDLOOP.

In your lt_cks you will have only data which does not have oil_disp not equal to zero.

Thanks,

Sriram Ponna.

Read only

0 Likes
23,940

This is the Best Answer

Thanks for sharing the important and awesome information.

Read only

Former Member
0 Likes
23,940

FIELD-SYMBOLS: <fs_dyn_table> TYPE STANDARD TABLE.

DATA gf_line LIKE LINE OF <fs_dyn_table>.

Use the above one in ur loop.

Read only

Former Member
23,940

Hi

you have to assign each field to another field symble then you can handle the value. Try it

ASSIGN COMPONENT <field name> OF STRUCTURE <fs_wa> TO <fs_field>.

IF <fs_field> EQ 'Give value here'.

Write code here

ENDIF.

L.Velu

Read only

former_member940664
Discoverer
0 Likes
23,940

Example field-symbol at exit & get value from other exit.

DATA: it_vbpa LIKE vbpa.
FIELD-SYMBOLS: <fs> TYPE any,
<fs_data> TYPE table.
ASSIGN ('(SAPMV56A)XVBPA[]') to <fs_data>.
LOOP AT <fs_data> ASSIGNING <fs>.
MOVE-CORRESPONDING <fs> to it_vbpa.
IF it_vbpa-vbeln = i_xvttk-tknum.
.......
ENDIF.
ENDLOOP.

Read only

subossselvam
Explorer
0 Likes
23,940

Can we set watchpoint over the field symbols? while using in loop statement? IF yes means what is the syntax