‎2007 Nov 27 11:59 PM
Hello,
When i activate this code, it gives an error. The error is:
"The field "S_CHAS" is unknown, but there is a field with the similar name <LS_CHAS>.
Please take a look at the code and suggest.
-
FUNCTION YCALC_VALUE .
*"----
""Local Interface:
*" IMPORTING
*" REFERENCE(I_AREA) TYPE UPC_Y_AREA
*" REFERENCE(I_PLEVEL) TYPE UPC_Y_PLEVEL
*" REFERENCE(I_METHOD) TYPE UPC_Y_METHOD
*" REFERENCE(I_PACKAGE) TYPE UPC_Y_PACKAGE
*" REFERENCE(IT_EXITP) TYPE UPF_YT_EXITP
*" REFERENCE(ITO_CHASEL) TYPE UPC_YTO_CHASEL
*" REFERENCE(ITO_CHA) TYPE UPC_YTO_CHA
*" REFERENCE(ITO_KYF) TYPE UPC_YTO_KYF
*" EXPORTING
*" REFERENCE(ET_MESG) TYPE UPC_YT_MESG
*" CHANGING
*" REFERENCE(XTH_DATA) TYPE HASHED TABLE
*"----
FIELD-SYMBOLS: <xth_data> TYPE HASHED TABLE,
<ls_data> TYPE ANY,
<ls_chas> TYPE ANY,
<ls_kyfs> TYPE ANY,
DATA: period(3) TYPE n,
total TYPE F.
DATA: area TYPE UPC_Y_AREA value 'KMPA',
level TYPE UPC_Y_PLEVEL value 'KMPL',
package TYPE UPC_Y_PACKAGE value 'KMPP',
l_source_var TYPE upc_y_variable,
l_subrc LIKE sy-subrc,
ls_return LIKE bapiret2,
l_type LIKE upc_var-vartype,
lto_varsel_all TYPE upc_yto_charsel,
lto_varsel TYPE upc_yto_charsel,
ls_varsel TYPE upc_ys_charsel,
lto_chanm TYPE upc_yto_cha.
LOOP AT xth_data ASSIGNING <ls_data>.
ASSIGN COMPONENT 'S_CHAS' OF STRUCTURE <ls_data> TO <ls_chas>.
ASSIGN COMPONENT 'S_KYFS' OF STRUCTURE <ls_data> TO <ls_chas>.
ENDLOOP.
LOOP AT xth_data INTO <ls_data>.
IF ( s_chas-0fiscper <= '009' ).
total = total + s_kyfs-0value.
ENDIF.
ENDLOOP.
ENDFUNCTION.
-
Thank You.
‎2007 Nov 28 12:31 AM
George,
Hit the syntax check (ctrl+F2) and the cursor will go to the line where the problem is to be found. I think you'll find it is
IF ( s_chas-0fiscper <= '009' ).
Try changing
LOOP AT xth_data ASSIGNING <ls_data>.
ASSIGN COMPONENT 'S_CHAS' OF STRUCTURE <ls_data> TO <ls_chas>.
ASSIGN COMPONENT 'S_KYFS' OF STRUCTURE <ls_data> TO <ls_chas>.
ENDLOOP.
LOOP AT xth_data INTO <ls_data>.
IF ( s_chas-0fiscper <= '009' ).
total = total + s_kyfs-0value.
ENDIF.
to
LOOP AT xth_data ASSIGNING <ls_data>.
ASSIGN COMPONENT 'S_CHAS' OF STRUCTURE <ls_data> TO <ls_chas>.
ASSIGN COMPONENT 'S_KYFS' OF STRUCTURE <ls_data> TO <ls_chas>.
IF ( <ls_chas>-0fiscper <= '009' ).
total = total + <ls_chas>-0value.
ENDIF.
ENDLOOP
Regards
Gareth
Message was edited by:
Gareth Ellem
‎2007 Nov 28 12:31 AM
George,
Hit the syntax check (ctrl+F2) and the cursor will go to the line where the problem is to be found. I think you'll find it is
IF ( s_chas-0fiscper <= '009' ).
Try changing
LOOP AT xth_data ASSIGNING <ls_data>.
ASSIGN COMPONENT 'S_CHAS' OF STRUCTURE <ls_data> TO <ls_chas>.
ASSIGN COMPONENT 'S_KYFS' OF STRUCTURE <ls_data> TO <ls_chas>.
ENDLOOP.
LOOP AT xth_data INTO <ls_data>.
IF ( s_chas-0fiscper <= '009' ).
total = total + s_kyfs-0value.
ENDIF.
to
LOOP AT xth_data ASSIGNING <ls_data>.
ASSIGN COMPONENT 'S_CHAS' OF STRUCTURE <ls_data> TO <ls_chas>.
ASSIGN COMPONENT 'S_KYFS' OF STRUCTURE <ls_data> TO <ls_chas>.
IF ( <ls_chas>-0fiscper <= '009' ).
total = total + <ls_chas>-0value.
ENDIF.
ENDLOOP
Regards
Gareth
Message was edited by:
Gareth Ellem
‎2007 Nov 28 12:41 AM
Hi Gareth,
I did as you suggested. Now, i get the error:
The data object "<LS_CHAS>" has no structure and therefore no component called "0FISCPER".
Thank You.
‎2007 Nov 28 12:49 AM
Hi George,
Yep. This is due to the field symbol <ls_chas> being type any. The question is therefore what do you want it to do? In the original you were trying to reference s_chas-0fiscper. If you require the field symbol to behave in the same way then you will have to type it the same as you expected for s_chas.
To get the answer you have to work out how the source data (in xth_data) is coming in in terms of structure and this will lead you to the type required for <ls_chas> and how the assignment will work at runtime.
Regards
Gareth
‎2007 Nov 28 2:24 AM
Gareth,
Thanks. Changing the TYPE for <ls_data>, <ls_chas> and <ls_kyfs> resolved the errors.
Thank You