cancel
Showing results for 
Search instead for 
Did you mean: 

Transformation formula getting error

KodandaPani_KV
Active Contributor
0 Kudos

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

TypeCategoryunitsMax UnitsFixed Charge  (Rs/HP/Month)Demand Charge (Rs/kVA/Month)Energy Charge (Rs/unit)
LTLT1Slab 1 (0-50)501.45
LTLT1Slab 2 (51-100)1002.8
LTLT1Slab 3 (101-200)2003.05
LTLT1Slab 4 (201-300)3004.75
LTLT1Slab 5 (>300)3015.5
LTLT2Slab 1 (0-50)503.85
LTLT2Slab 2 (51-100)1006.2
LTLT2Slab 3 (>100)1016.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.

Accepted Solutions (1)

Accepted Solutions (1)

anshu_lilhori
Active Contributor
0 Kudos

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

KodandaPani_KV
Active Contributor
0 Kudos

Thanks Anshnu replay for this,

i tried in formula and field level am greeting syntax errors and i will try and come back to you.

Thanks,

Phani.

former_member184884
Active Participant
0 Kudos

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

KodandaPani_KV
Active Contributor
0 Kudos

Hi Anshnu,

here i am not look uping form DSO, i want read record wise only please suggest the field level routine if possible.

target filed is Billed value (charge)

Thanks,

Phani.

anshu_lilhori
Active Contributor
0 Kudos

You can write in end routine itself if you have all the fields which you require are in the structure of DSO itself.

Please proceed the way i mentioned it will work..If you have issues with syntax error then please share the screenshot.I shall help you with it.

Regards,

AL

former_member184884
Active Participant
0 Kudos

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

KodandaPani_KV
Active Contributor
0 Kudos

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.

anshu_lilhori
Active Contributor
0 Kudos

Is this a different DSO table /BIC/AZD_TRATE00 than in which you are loading ?

Please confirm on this.

KodandaPani_KV
Active Contributor
0 Kudos

only one table /BIC/AZD_TRATE00 and out put i want how much units consumed and based on the unit it will charge.

please look at the raw data.


Thanks,

Phani.

anshu_lilhori
Active Contributor
0 Kudos

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

KodandaPani_KV
Active Contributor
0 Kudos

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.

anshu_lilhori
Active Contributor
0 Kudos

Just copy paste the above code given by me.You do not require to do a select as you are reading the data of the same dso only and not other dso.

Please understand that.

Regards,

AL

Former Member
0 Kudos

HI Phani,

Can you also paste the internal table declaration for table IT_ZD_TRATE from your code. Also, please check if you have the field /BIC/ZLTBVAL defined correctly in your code.

Regards,

Satyam

Answers (1)

Answers (1)

Former Member
0 Kudos

This message was moderated.