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

Table Control Processing - Order of Processing

Former Member
0 Likes
766

Hi,

i am calculating some values in Table control based on rows( it is basically table maintenance generator )

it is like below.

B 222

B 333

C 444

D 999

now formula is D = B + C in above case it is working, however if it is like

B 222

D ???

C 444

B 333

now D is not calculated as because if some thing is changed say C to 555. it cannot be captured, because table control goes line by line sequentially when it come across D row it does know what is changed in C, so not able to capture the value.

any solutions please suggest

6 REPLIES 6
Read only

Former Member
0 Likes
730

Hi,

I'm not sure I well understood...

I think you have to add a new module in your PAI, after the LOOP over table control, to update your D cell.

Something like:


*&SPWIZARD: PAI FLOW LOGIC FOR TABLECONTROL 'TCMAIN'
  LOOP AT gt_tc.
"...
  ENDLOOP.
  MODULE update_d.


MODULE update_d INPUT.
  DATA: l_idx TYPE sytabix.
  FIELD-SYMBOLS: <tc> TYPE ty_tc.

  CLEAR: sum_b, sum_c, sum_d.

  LOOP AT gt_tc ASSIGNING <tc>.
    CASE <tc>-fld1.
      WHEN 'B'. sum_b = sum_b + <tc>-fld2.
      WHEN 'C'. sum_c = sum_c + <tc>-fld2.
      WHEN 'D'. l_idx = sy-tabix.
      WHEN OTHERS.
    ENDCASE.
  ENDLOOP.

  IF l_idx IS NOT INITIAL.                        "Update D field
    READ TABLE gt_tc INDEX l_idx ASSIGNING <tc>.
    <tc>-fld2 = sum_b + sum_c.
  ENDIF.
ENDMODULE.                

Well, hope it helps,

Kr,

m.

Read only

0 Likes
730

Hi,

i did write this logic after loop and endloop and calcuating the values and showing the same in PBO as we cannot show in the PAI as we are out of loop.

the problem with this approach is values updated will be shown to user as soon as he presses enter however when i save the values they are updating old values only, for that i am again using 'After Save' table event to update the table not sure if this is the correct way.

Thanks,

Kranthi.

Read only

0 Likes
730

Hi,

I don't really get your point, you say:

the problem with this approach is values updated will be shown to user as soon as he presses enter however when i save the values they are updating old values only

If you place the update module before your user-command module, correct values will always be used, even if the user press SAVE without pressing ENTER... ?

Kr,

m.

Read only

0 Likes
730

Hi,

i thought of this 'Calculating module' putting in PAI however i encountered following problems, below is actual siutaiton i am in

1. this module program is actually a table maintenace generator program here i have 'EXTRACT' internal table in the module pool which is of line type c(512) so it does not have line type of actual table for which this maintenance generator is generated

2. in both PBO and PAI this is the internal table ( EXTRACT ) which is being looped.

3. what i am doing is creating another internal table ( ITAB ) which of my ztable type ( ZTEST ) and moving ( using globally available work area ) all the entries of table control to my internal table and then doing calculations in PAI on this internal table ITAB

Now if i want to modify my 'EXTRACT' using my internal table ( ITAB ) values, is't possible as because both are not unicode-convertible.

so i am using the work area( which is avaiable while looping 'EXTRACT' in PBO ) to show my updated values from ITAB and using 'EVENTS' for table maintanance generator 'AFTER_SAVE' where i am using my internal table to update the database table as my internal table will have updated values.

conclusion is:

1. Internal table ITAB will have calculations, however i cannot use this table to update 'EXTRACT' so that standard program considers these updated values whenever i press enter or save.

2. so I am using PBO to show updated values using my internal table 'ITAB' and 'after_save' event to actually update database table with correct values.

above explanation may be difficult to understand, i tired my best to put in proper way. i guess this is the common problem whenver we are using program of table maintenance generator, not sure if there is better way!!

Thanks,

Kranthi.

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
730

I think yoiu can create a new module with addition of ON REQUEST OR CHAIN REQUEST it will be trigger if some value changes.

thanks

Nabhete

Read only

sarang_gujrati2
Explorer
0 Likes
730

Hi,

you can write code in your user command. at the enter command loop on to your internal table and calculate the value.

regards,

Sarang