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: 

Issue with Field symbol

amine_lamkaissi
Active Contributor
0 Kudos

Hi experts,

I am having an issue with the field symbol <fs_pa0001> in the under-mentioned code.

In fact, i don't know how to declare it, i've tried many combination, none of them is working.

The best one that i found is to declare it like :

field-symbols: <fs_pa0001> type any.


Here's the code:

TYPES: BEGIN OF s_pa0001,

pernr TYPE pa0001-pernr,

plans TYPE pa0001-plans,

begda TYPE pa0001-begda,

endda TYPE pa0001-endda,

END OF s_pa0001.

DATA: l_s_hrms_biw_io_occupancy LIKE hrms_biw_io_occupancy.

DATA: it_pa0001 TYPE STANDARD TABLE OF s_pa0001.

DATA: lit_lead_pos TYPE STANDARD TABLE OF hrobject,

lwa_lead_pos TYPE hrobject.

DATA: var_pos TYPE hrp1001-sobid.

field-symbols: <fs_pa0001> type any.

REFRESH lit_lead_pos[].

SELECT pernr plans begda endda FROM pa0001 INTO TABLE it_pa0001

WHERE begda <= sy-datum

AND endda >= sy-datum.

IF sy-subrc EQ 0.

   SORT it_pa0001 BY pernr plans.

   DELETE ADJACENT DUPLICATES FROM it_pa0001 COMPARING ALL FIELDS.

ENDIF.

var_pos = l_s_hrms_biw_io_occupancy-plans.

CALL FUNCTION 'RH_GET_LEADING_POSITION'

   EXPORTING

     plvar             = '01'

     otype             = 'S'

     sobid             = var_pos

     date              = sy-datum

     auth              = 'X'

     buffer_mode       = ' '

     consider_vac_pos  = ' '

   TABLES

     leading_pos       = lit_lead_pos

   EXCEPTIONS

     no_lead_pos_found = 1

     OTHERS            = 2.

IF sy-subrc EQ 0.

   CLEAR: lwa_lead_pos.

   READ TABLE lit_lead_pos INTO lwa_lead_pos INDEX 1.

   READ TABLE it_pa0001 ASSIGNING <fs_pa0001> WITH KEY plans = lwa_lead_pos-objid.

   IF sy-subrc EQ 0.

     l_s_hrms_biw_io_occupancy-zzxxxxxx = <fs_pa0001>-pernr.

*      Start of code for calculating super supervisor (Raj Kumar Rai), Infosys Pune

   ELSE.   " This portion of code executes when there is no active supervior for sup pos

     v_flag = 0.

     WHILE ( v_flag = 0 ).

       CLEAR var_pos.

       CLEAR lit_lead_pos.

       var_pos = lwa_lead_pos-objid.

       CALL FUNCTION 'RH_GET_LEADING_POSITION'

         EXPORTING

           plvar             = '01'

           otype             = 'S'

           sobid             = var_pos

           date              = sy-datum

           auth              = 'X'

           buffer_mode       = ' '

           consider_vac_pos  = ' '

         TABLES

           leading_pos       = lit_lead_pos

         EXCEPTIONS

           no_lead_pos_found = 1

           OTHERS            = 2.

       IF sy-subrc EQ 0.

         CLEAR: lwa_lead_pos.

         READ TABLE lit_lead_pos INTO lwa_lead_pos INDEX 1.

         READ TABLE it_pa0001 ASSIGNING <fs_pa0001> WITH KEY plans = lwa_lead_pos-objid.

         IF sy-subrc EQ 0.

           l_s_hrms_biw_io_occupancy-zzxxxxxx = <fs_pa0001>-pernr.

           v_flag = 1" Setting flag to 1 in case there exist an active supervisor for supervisor position.

         ENDIF.

       ELSE.

         EXIT.

       ENDIF.

     ENDWHILE.

   ENDIF.

ENDIF.

Thanks.

Amine


1 ACCEPTED SOLUTION

Azeemquadri
Contributor
0 Kudos

Have you tried :

field-symbols: <fs_pa0001> like line of it_pa0001.

or

field-symbols: <fs_pa0001> type s_pa0001.

12 REPLIES 12

Azeemquadri
Contributor
0 Kudos

Have you tried :

field-symbols: <fs_pa0001> like line of it_pa0001.

or

field-symbols: <fs_pa0001> type s_pa0001.

former_member184675
Active Participant
0 Kudos

Hi,

Well you have two options:

1) Either declare the FS of type s_pa0001.

field-symbols: <fs_pa0001> type s_pa0001.

In this case the field symbol has the structure of the type you have defined locally.

2) Either use an additional FS for field:

In this case your field symbol won't have any structure before runtime, and you'll have the use another FS to get the field value.

field-symbols: <fs_pa0001> type any. 

field-symbols: <field> type any.

READ TABLE it_pa0001 ASSIGNING <fs_pa0001> WITH KEY plans = lwa_lead_pos-objid. 

IF sy-subrc EQ 0.   

assign component 'PERNR' OF STRUCTURE <FS_PA0001> TO <FIELD>.

l_s_hrms_biw_io_occupancy-zzxxxxxx = <FIELD>.

Br,

Andrei



vigneshyeram
Active Participant
0 Kudos

Dear Amine,

There are two ways:-

1) field-symbols <fs_pa0001> type any. "which is used only if you want use that field symbol to use it further for other purposes or while reading another table of different structure it is used in dynamic programming where reusability is followed.

after your read statement.

field-symbols <fs_pa0001> type any,

                            <fs_field> type any.


  1. READ TABLE it_pa0001 ASSIGNING <fs_pa0001> WITH KEY plans = lwa_lead_pos-objid. 
  2.    IF <fs_pa0001> is assigned.
  3. assign component 'PERNR' OF STRUCTURE <FS_PA0001> TO <FIELD>.
  4.      l_s_hrms_biw_io_occupancy-zzxxxxxx = <FIELD>. 
  5.    endif.

please note when you field-symbol while reading internal table you are assigning it so please done check sy-subrc eq 0 it is incorrect will not work or sometime it gives dump. You should check IF <fs_pa0001> is assigned.

2) This simple by defining:-

      

field-symbols: <fs_pa0001> type s_pa0001 or <fs_pa0001> like line of it_pa0001.

  • READ TABLE it_pa0001 ASSIGNING <fs_pa0001> WITH KEY plans = lwa_lead_pos-objid. 
  •    IF <fs_pa0001> is assigned.
  •      l_s_hrms_biw_io_occupancy-zzxxxxxx<fs_pa0001>-PERNR.
  •    endif.

Hope it helps you.

Kindly let me know your feedback.

Thanks & Regards,

Vignesh Yeram                         

0 Kudos

A quick and friendly observation on your example Vignesh.

I believe the field symbol that you wanted to use in your example was <fs_field> and not <field>.

Keep up the good work!

Best regards,

Andrei

0 Kudos

Thanks bit typing error.

Note: please note in above post  its a typing error <field> should be <fs_field>.

Regards,

Vignesh Yeram

Former Member
0 Kudos

Hi Amine,

You did not declared the structure ANY in your program, but you are referring this structure to the fieldsymbols so thats why you are getting this problem.

So, declare one structure with the required fields you want.

Thanks.

Pavan.

amine_lamkaissi
Active Contributor
0 Kudos

Thanks guys for your contributions,

I have an issue now with field v_flag.

What do you think about this declaration?

flag    TYPE n VALUE IS INITIAL

As you can notice from the code, only 2 possible values 0 or 1.

Thanks.

Amine

0 Kudos

Dear Amine,

Please check with data: lv_flag type i.

Regards,

Vignesh Yeram

0 Kudos

Hi,

The declaration is kinda ok. You don't have to implicitly specify "value is initial" as by default the initial value is 0.

I think there's a problem with the logic of your program. What do you expect to happen on the second iteration of WHILE..ENDWHILE. I might be wrong, but at first glance it seems that it does the same thing over and over again.

-

Andrei

0 Kudos

Hi Amine,

Types: flag type flag

would do.

Regards,

Vamshi.

Former Member
0 Kudos

Hi,

Since you have not assigned anything to the field symbol that is why it is not recognizing the component pernr and Hence, throwing an error.

Try the following code:

Field-symbols type s_pa0001.

Hope it solves your problem

Thanks,

Nitin

amine_lamkaissi
Active Contributor
0 Kudos

Thanks guys for your contibutions.

Amine