Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Code correction

former_member381412
Participant
0 Likes
981
Hello Guru,
I want to insert to condition in my report please help.
if amount less than 110 then add 25 Rupees and show the final out value 135
if amount grater than 110 than not add 25 rupees and show the final value only 110
Please check my code:
--------------------------------------------------------------------------
GIT_HFINAL-DMBTR1 = GIT_HFINAL-HPPC3.  
if
      GIT_HFINAL-DMBTR1 < 110.                                                               
      GIT_HFINAL-DMBTR1 =  GIT_HFINAL-DMBTR1 + 25.
else.
      GIT_HFINAL-DMBTR1 =   GIT_HFINAL-HPPC3.
endif.
--------------------------------------------------------------------------------------
IF grater than 110 then working this condition
         GIT_HFINAL-DMBTR2 =  GIT_HFINAL-HPPC3    .                              
          LV_RATE = GIT_HFINAL-DMBTR2  * '0.25' .
          GIT_HFINAL-DMBTR2 = GIT_HFINAL-DMBTR2 + LV_RATE + 4.
This code is working only debugging condition. after debugging condition is not working. Please help me.
Regards
Richa
10 REPLIES 10
Read only

Former Member
0 Likes
900

Paste your whole code. May be then we can help.

Read only

Former Member
0 Likes
900

Hi Richa,

I am not clear with this.

if amount is less than 110 then add 25.

if amount is greater than 110 dont change.

is this correct ?

and what if the amount is exactly 110 ?

please clarify.

Regards,

Bhaskar

Read only

Arun_Prabhu_K
Active Contributor
0 Likes
900

Hello Richa.

     Guess the calculated values from header are not passed on to internal table's body.

     You have to use MODIFY statement to pass internal table HEADER data to its BODY.

     For instance,

     MODIFY GIT_HFINAL TRANSPORTING DMBTR1.

Regards.

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
900

Check if your internal table is getting modified aftyer it

Read only

0 Likes
900

Dear All,

Thanks for the Response.

Please check my code

GIT_HFINAL-DMBTR1 = GIT_HFINAL-HPPC3.

if

      GIT_HFINAL-DMBTR1 < 110.                                                                 " Less then 110 then add 25 Rupess.

      GIT_HFINAL-DMBTR1 =  GIT_HFINAL-DMBTR1 + dmbtr14.

else.

      GIT_HFINAL-DMBTR1 =   GIT_HFINAL-HPPC3.

endif.

         GIT_HFINAL-DMBTR2 =  GIT_HFINAL-HPPC3    .                              

         LV_RATE = GIT_HFINAL-DMBTR2  * '0.25' .

         GIT_HFINAL-DMBTR2 = GIT_HFINAL-DMBTR2 + LV_RATE + 4.

         GIT_HFINAL-DMBTR4   =  ( ( GIT_HFINAL-DMBTR2 )  *   '9.08' ) / 100 .                

         GIT_HFINAL-DMBTR3   =  GIT_HFINAL-DMBTR4 + GIT_HFINAL-DMBTR2.                       

         GIT_HFINAL-DMBTR3   =  ( (  GIT_HFINAL-DMBTR3  ) *   '4.15' ) / 100..

         GIT_HFINAL-DMBTR5   =    GIT_HFINAL-DMBTR2 + GIT_HFINAL-DMBTR4 + GIT_HFINAL-DMBTR3 .

         GIT_HFINAL-DMBTR5  = CEIL( GIT_HFINAL-DMBTR5  ).

         GIT_HFINAL-PRICE  =  ( ( GIT_HFINAL-DMBTR5 )  *   '8' ) / 100 .

         GIT_HFINAL-PRICE1   =  ( (  GIT_HFINAL-DMBTR5  ) *   '4' ) / 100.

We have declare two condition 1: is if less then 110 then add 25 Rupees.

2: if grate then 110 then work GIT_HFINAL-DMBTR2 condition.

Read only

0 Likes
900

Yoour loop is on which tables..GIT_HFINAL if yes where are you modifying it with the values calculated before end of loop?

How are you displaying data ALV/Classical?

Nabheet

Read only

VijayaKrishnaG
Active Contributor
0 Likes
900

Hi Richa,

Either you are not appending the values into table or overwriting the same variable in the loop or somewhere after this code.

GIT_HFINAL-DMBTR1 = GIT_HFINAL-HPPC3. 
if
      GIT_HFINAL-DMBTR1 < 110.                                                              
      GIT_HFINAL-DMBTR1 =  GIT_HFINAL-DMBTR1 + 25.
else.
      GIT_HFINAL-DMBTR1 =   GIT_HFINAL-HPPC3.             if you want to be 110 as it is > 110 why need to assign new value to DMBTR1?
endif.


It will be better if you post complete code.


Thanks & Regards,

-Vijay

Read only

Former Member
0 Likes
900

Hi,

I hope you got the answer. You just need to use modify statement. Modify the internal table using work area.

Regards

Read only

Former Member
0 Likes
900

Dear Richa,

As the gurus already have explained, when you loop an internal table into work area only the entries from internal table are copied into work area, any change in the work area will not get updated in the internal table automatically. There are 2 ways to do that,

  • Use modify table statement using index to modify the internal table with changed value.
  • Instead of using work area use field symbols.

Considering that you have already finished a bigger chunk of coding, in my opinion the easier way to do that will be using modify table statement.

Please find the help on using the modify statement at:

https://help.sap.com/saphelp_45b/helpdata/en/34/8e72f96df74873e10000009b38f9b8/content.htm

Best Regards,

Imran

Read only

Former Member
0 Likes
900

Hi Richa,

How you are displaying the report! If it working in debugging and not working in dispaly. check the below things.

- your local variables

- How you are passing the calculated values to internal table or modifying the table

- displaying the value in the final output