03-07-2013 5:06 PM
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
03-07-2013 5:18 PM
field-symbols: <fs_pa0001> like line of it_pa0001.
or
field-symbols: <fs_pa0001> type s_pa0001.
03-07-2013 5:18 PM
field-symbols: <fs_pa0001> like line of it_pa0001.
or
field-symbols: <fs_pa0001> type s_pa0001.
03-07-2013 5:32 PM
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
03-07-2013 6:48 PM
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.
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.
Hope it helps you.
Kindly let me know your feedback.
Thanks & Regards,
Vignesh Yeram
03-07-2013 10:19 PM
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
03-08-2013 8:56 AM
03-08-2013 4:54 AM
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.
03-08-2013 10:02 AM
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
03-08-2013 11:08 AM
Dear Amine,
Please check with data: lv_flag type i.
Regards,
Vignesh Yeram
03-08-2013 11:16 AM
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
03-08-2013 11:29 AM
03-08-2013 11:36 AM
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
03-08-2013 10:15 PM