11-28-2007 11:08 AM
Hello,
In one of my function modules, I have the code as shown below. I got an error after executing this code. The error is:
In LOOP .... WHERE... the line type of the table must be statically defined.
<b>This error is for the highlighted LOOP statement.</b> Could someone please help me with the code.
<b>Objective of the function module:</b> I have a hashed table with some records.
Eg: CCTR FISCPER VERSION AMOUNT
100 06/2007 10 100
100 06/2007 20 0
100 07/2007 10 45
I want to update the amount for version '20' (for same costcenter and same period as of version 10) by doing some calculations.
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 /1SEM/_YT_DATA_100KMPA,
<l_chavl> TYPE ANY,
field symbols for fields of <ls_data>
<ls_chas> TYPE /1SEM/_YT_CHAS_100KMPA,
<ls_nchas> TYPE /1SEM/_YT_CHAS_100KMPA,
<ls_kyfs> TYPE /1SEM/_YT_KYFS_100KMPA,
<ls_nkyfs> TYPE /1SEM/_YT_KYFS_100KMPA,
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_kyfs>.
......There are some calculations................................
ENDLOOP.
LOOP AT xth_data INTO <ls_data>.
ASSIGN COMPONENT 'S_CHAS' OF STRUCTURE <ls_data> TO <ls_nchas>.
ASSIGN COMPONENT 'S_KYFS' OF STRUCTURE <ls_data> TO <ls_nkyfs>.
IF ( <ls_data>-S_CHAS-0fiscper = '006' ) AND (<ls_data>-S_CHAS-0version='10' ).
tempcctr = <ls_data>-S_CHAS-0costctr.
tempperiod = <ls_data>-S_CHAS-0fiscper.
tempamount = <ls_data>-S_KYFS-0amount.
<b> LOOP AT XTH_DATA INTO <ls_nchas>
WHERE 0costctr = tempcostctr
AND 0fiscper = tempperiod
AND 0version = '20'.</b>
<ls_nchas>-S_KYFS-0amount = ( tempamount * 100 ) + 500.
MODIFY xth_data FROM <ls_nchas>.
ENDLOOP.
ENDFUNCTION.
Thank You.
Message was edited by:
George Smith
Message was edited by:
George Smith
11-28-2007 11:11 AM
LOOP AT xth_data INTO <ls_data>.
LOOP AT XTH_DATA INTO <ls_nchas>
Change INTO to Assigning. I think the problem will solve.
11-28-2007 11:11 AM
LOOP AT xth_data INTO <ls_data>.
LOOP AT XTH_DATA INTO <ls_nchas>
Change INTO to Assigning. I think the problem will solve.
11-28-2007 11:18 AM
Hello Amit,
Even after replacing 'INTO' with 'ASSIGNING', I am still getting the same error.
Thank You.
null
11-28-2007 11:35 AM
11-28-2007 11:46 AM
Hi George..
Declare the Field symbol with the Same line type of the Internal table which is passed to the FM.
Eg:
<b>Field-symbols : <ls_data> like Line of XTH_Data.
Loop at XTH_Data ASSIGNING <LS_DATA>.</b>
Then it should work...