on 02-19-2014 12:48 PM
Hi ALL,
i have to write some formula ta transformation level but is not working. i am facing always syntax errors.
please look at the data
sample data
Type | Category | units | Max Units | Fixed Charge (Rs/HP/Month) | Demand Charge (Rs/kVA/Month) | Energy Charge (Rs/unit) |
LT | LT1 | Slab 1 (0-50) | 50 | 1.45 | ||
LT | LT1 | Slab 2 (51-100) | 100 | 2.8 | ||
LT | LT1 | Slab 3 (101-200) | 200 | 3.05 | ||
LT | LT1 | Slab 4 (201-300) | 300 | 4.75 | ||
LT | LT1 | Slab 5 (>300) | 301 | 5.5 | ||
LT | LT2 | Slab 1 (0-50) | 50 | 3.85 | ||
LT | LT2 | Slab 2 (51-100) | 100 | 6.2 | ||
LT | LT2 | Slab 3 (>100) | 101 | 6.5 |
here consumer type have only LT and category have different (LT1,LT2,LT3) and different slabs (0-50, 51-100, 101-200,201-300, above 300)
my requirement is
if type is LT and if category is LT1 and slab is ( 0-50) = charge 1.45
if type is LT and if category is LT1 and slab is ( 51- 100) = charge 2.8
if i write the formula or routine is best performance please suggest.
Thanks,
Phani.
According to me writing this logic in end routine would be more performance oriented as your data will be processed in packages whereas in field level routine it will be done record by record and same will be the case with Formula.
Logic should be something like that:
loop at RESULT_PACKAGE ASSIGNING <RESULT_FIELDS> .
if <RESULT_FIELDS>-A EQ 'LT'
and <RESULT_FIELDS>-B EQ 'LT1'
and <RESULT_FIELDS>-C EQ '( 0-50)'
Charge = '1.45'.
Other conditions also you can write in Elseif part in similar way.
ENDIF.
<RESULT_FIELDS>-Charge = Charge.
ENDLOOP.
Hope this helps.
Regards,
AL
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey pani has suggested you to write in end routine due to performance reasons still you wrote in field level.
According to me writing this logic in end routine would be more performance oriented as your data will be processed in packages whereas in field level routine it will be done record by record and same will be the case with Formula.
so please write the peice of code in end routine which anshu has already given in his reply still if you come across any errors or difficulty please revert we are pleased to assist you
Cheers,
Harish
hey you can try below logic for field level hope it'll suits your requirement!!!!.
IF SOURCE_FIELDS-TYPE EQ 'LT' AND SOURCE_FIELDS-CATEGORY EQ 'LT1' AND SOURCE_FIELDS-SLABS BETWEEN '0' AND '50'
RESULT = SOURCE_FEILDS- FIXEDCHARGE.
ELSE
IF SOURCE_FIELDS-TYPE EQ 'LT' AND SOURCE_FIELDS-CATEGORY EQ 'LT2' AND SOURCE_FIELDS-SLABS BETWEEN '51' AND '100'
RESULT = SOURCE_FEILDS- FIXEDCHARGE.
ENDIF.
Regards,
Harish
Hi anshnu,
after applying the code getting some syntax errors help me i am doing wrong at LOOP.
IF RESULT_PACKAGE is not INITIAL.
SELECT
/BIC/ZMAX_UNIT
/BIC/ZSLABUNIT
/BIC/ZCAT_TEXT
FROM /BIC/AZD_TRATE00 INTO CORRESPONDING FIELDS OF TABLE
IT_ZD_TRATE FOR ALL ENTRIES IN RESULT_PACKAGE
WHERE /BIC/ZMAX_UNIT = RESULT_PACKAGE-/BIC/ZMAX_UNIT AND
/BIC/ZSLABUNIT = RESULT_PACKAGE-/BIC/ZSLABUNIT.
LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
IF <RESULT_FIELDS>-/BIC/ZTYPE_MD = 'LT'
AND <RESULT_FIELDS>-/BIC/ZCAT_TEXT = 'LT1'
AND <RESULT_FIELDS>-/BIC/ZSLABUNIT = ( 0-50)
/BIC/ZLTBVAL= '1.45'.
ENDIF.
<RESULT_FIELDS> = /BIC/ZLTBVAL.
ENDLOOP.
Thanks,
Phani.
see if the fields which you are using for comparison are already available in the DSO then you do not have to select them.
LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
IF <RESULT_FIELDS>-/BIC/ZTYPE_MD EQ 'LT'
AND <RESULT_FIELDS>-/BIC/ZCAT_TEXT EQ 'LT1'
AND <RESULT_FIELDS>-/BIC/ZSLABUNIT EQ '( 0-50)'
/BIC/ZLTBVAL= '1.45'.
ENDIF.
<RESULT_FIELDS>-/BIC/ZLTBVAL = /BIC/ZLTBVAL.
ENDLOOP.
Please check the above code and share the syntax error if you get any so that i can understand the issue.
Regards,
Al
Hi anshnu,
After applying these code getting syntax error.
E:Unknown column name "/BIC/ZLTBVAL not determined until runtime, you
cannot specify a field list.
IF RESULT_PACKAGE IS NOT INITIAL.
SELECT
/BIC/ZMAX_UNIT
/BIC/ZSLABUNIT
/BIC/ZCAT_TEXT
/BIC/ZLTBVAL
FROM /BIC/AZD_TRATE00 INTO CORRESPONDING FIELDS OF TABLE
IT_ZD_TRATE FOR ALL ENTRIES IN RESULT_PACKAGE
WHERE /BIC/ZMAX_UNIT = RESULT_PACKAGE-/BIC/ZMAX_UNIT AND
/BIC/ZSLABUNIT = RESULT_PACKAGE-/BIC/ZSLABUNIT.
LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
IF <RESULT_FIELDS>-/BIC/ZTYPE_MD = 'LT'
AND <RESULT_FIELDS>-/BIC/ZCAT_TEXT = 'LT1'
AND <RESULT_FIELDS>-/BIC/ZSLABUNIT = '0-50'
/BIC/ZLTBVAL= '1.45'.
ENDIF.
<RESULT_FIELDS> = /BIC/ZLTBVAL = /BIC/ZLTBVAL.
ENDLOOP.
Thanks,
Phani.
This message was moderated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.